1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gsv.SourceCompletionInfo;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gobject.Signals;
30 private import gsvc.gsv;
31 public  import gsvc.gsvtypes;
32 private import gtk.BuildableIF;
33 private import gtk.BuildableT;
34 private import gtk.TextIter;
35 private import gtk.TextView;
36 private import gtk.Widget;
37 private import gtk.Window;
38 private import std.algorithm;
39 
40 
41 /** */
42 public class SourceCompletionInfo : Window
43 {
44 	/** the main Gtk struct */
45 	protected GtkSourceCompletionInfo* gtkSourceCompletionInfo;
46 
47 	/** Get the main Gtk struct */
48 	public GtkSourceCompletionInfo* getSourceCompletionInfoStruct(bool transferOwnership = false)
49 	{
50 		if (transferOwnership)
51 			ownedRef = false;
52 		return gtkSourceCompletionInfo;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected override void* getStruct()
57 	{
58 		return cast(void*)gtkSourceCompletionInfo;
59 	}
60 
61 	protected override void setStruct(GObject* obj)
62 	{
63 		gtkSourceCompletionInfo = cast(GtkSourceCompletionInfo*)obj;
64 		super.setStruct(obj);
65 	}
66 
67 	/**
68 	 * Sets our main struct and passes it to the parent class.
69 	 */
70 	public this (GtkSourceCompletionInfo* gtkSourceCompletionInfo, bool ownedRef = false)
71 	{
72 		this.gtkSourceCompletionInfo = gtkSourceCompletionInfo;
73 		super(cast(GtkWindow*)gtkSourceCompletionInfo, ownedRef);
74 	}
75 
76 
77 	/** */
78 	public static GType getType()
79 	{
80 		return gtk_source_completion_info_get_type();
81 	}
82 
83 	/**
84 	 * Returns: a new GtkSourceCompletionInfo.
85 	 *
86 	 * Throws: ConstructionException GTK+ fails to create the object.
87 	 */
88 	public this()
89 	{
90 		auto p = gtk_source_completion_info_new();
91 		
92 		if(p is null)
93 		{
94 			throw new ConstructionException("null returned by new");
95 		}
96 		
97 		this(cast(GtkSourceCompletionInfo*) p);
98 	}
99 
100 	/**
101 	 * Get the current content widget.
102 	 *
103 	 * Deprecated: Use gtk_bin_get_child() instead.
104 	 *
105 	 * Returns: The current content widget.
106 	 */
107 	public Widget getWidget()
108 	{
109 		auto p = gtk_source_completion_info_get_widget(gtkSourceCompletionInfo);
110 		
111 		if(p is null)
112 		{
113 			return null;
114 		}
115 		
116 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
117 	}
118 
119 	/**
120 	 * Moves the #GtkSourceCompletionInfo to @iter. If @iter is %NULL @info is
121 	 * moved to the cursor position. Moving will respect the #GdkGravity setting
122 	 * of the info window and will ensure the line at @iter is not occluded by
123 	 * the window.
124 	 *
125 	 * Params:
126 	 *     view = a #GtkTextView on which the info window should be positioned.
127 	 *     iter = a #GtkTextIter.
128 	 */
129 	public void moveToIter(TextView view, TextIter iter)
130 	{
131 		gtk_source_completion_info_move_to_iter(gtkSourceCompletionInfo, (view is null) ? null : view.getTextViewStruct(), (iter is null) ? null : iter.getTextIterStruct());
132 	}
133 
134 	/**
135 	 * Sets the content widget of the info window. See that the previous widget will
136 	 * lose a reference and it can be destroyed, so if you do not want this to
137 	 * happen you must use g_object_ref() before calling this method.
138 	 *
139 	 * Deprecated: Use gtk_container_add() instead. If there is already a child
140 	 * widget, remove it with gtk_container_remove().
141 	 *
142 	 * Params:
143 	 *     widget = a #GtkWidget.
144 	 */
145 	public void setWidget(Widget widget)
146 	{
147 		gtk_source_completion_info_set_widget(gtkSourceCompletionInfo, (widget is null) ? null : widget.getWidgetStruct());
148 	}
149 
150 	protected class OnBeforeShowDelegateWrapper
151 	{
152 		static OnBeforeShowDelegateWrapper[] listeners;
153 		void delegate(SourceCompletionInfo) dlg;
154 		gulong handlerId;
155 		
156 		this(void delegate(SourceCompletionInfo) dlg)
157 		{
158 			this.dlg = dlg;
159 			this.listeners ~= this;
160 		}
161 		
162 		void remove(OnBeforeShowDelegateWrapper source)
163 		{
164 			foreach(index, wrapper; listeners)
165 			{
166 				if (wrapper.handlerId == source.handlerId)
167 				{
168 					listeners[index] = null;
169 					listeners = std.algorithm.remove(listeners, index);
170 					break;
171 				}
172 			}
173 		}
174 	}
175 
176 	/**
177 	 * This signal is emitted before any "show" management. You can connect
178 	 * to this signal if you want to change some properties or position
179 	 * before the real "show".
180 	 *
181 	 * Deprecated: This signal should not be used.
182 	 */
183 	gulong addOnBeforeShow(void delegate(SourceCompletionInfo) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
184 	{
185 		auto wrapper = new OnBeforeShowDelegateWrapper(dlg);
186 		wrapper.handlerId = Signals.connectData(
187 			this,
188 			"before-show",
189 			cast(GCallback)&callBackBeforeShow,
190 			cast(void*)wrapper,
191 			cast(GClosureNotify)&callBackBeforeShowDestroy,
192 			connectFlags);
193 		return wrapper.handlerId;
194 	}
195 	
196 	extern(C) static void callBackBeforeShow(GtkSourceCompletionInfo* sourcecompletioninfoStruct, OnBeforeShowDelegateWrapper wrapper)
197 	{
198 		wrapper.dlg(wrapper.outer);
199 	}
200 	
201 	extern(C) static void callBackBeforeShowDestroy(OnBeforeShowDelegateWrapper wrapper, GClosure* closure)
202 	{
203 		wrapper.remove(wrapper);
204 	}
205 }