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 gsv.c.functions;
31 public  import gsv.c.types;
32 public  import gsvc.gsvtypes;
33 private import gtk.BuildableIF;
34 private import gtk.BuildableT;
35 private import gtk.TextIter;
36 private import gtk.TextView;
37 private import gtk.Widget;
38 private import gtk.Window;
39 private import std.algorithm;
40 
41 
42 /** */
43 public class SourceCompletionInfo : Window
44 {
45 	/** the main Gtk struct */
46 	protected GtkSourceCompletionInfo* gtkSourceCompletionInfo;
47 
48 	/** Get the main Gtk struct */
49 	public GtkSourceCompletionInfo* getSourceCompletionInfoStruct(bool transferOwnership = false)
50 	{
51 		if (transferOwnership)
52 			ownedRef = false;
53 		return gtkSourceCompletionInfo;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected override void* getStruct()
58 	{
59 		return cast(void*)gtkSourceCompletionInfo;
60 	}
61 
62 	protected override void setStruct(GObject* obj)
63 	{
64 		gtkSourceCompletionInfo = cast(GtkSourceCompletionInfo*)obj;
65 		super.setStruct(obj);
66 	}
67 
68 	/**
69 	 * Sets our main struct and passes it to the parent class.
70 	 */
71 	public this (GtkSourceCompletionInfo* gtkSourceCompletionInfo, bool ownedRef = false)
72 	{
73 		this.gtkSourceCompletionInfo = gtkSourceCompletionInfo;
74 		super(cast(GtkWindow*)gtkSourceCompletionInfo, ownedRef);
75 	}
76 
77 
78 	/** */
79 	public static GType getType()
80 	{
81 		return gtk_source_completion_info_get_type();
82 	}
83 
84 	/**
85 	 * Returns: a new GtkSourceCompletionInfo.
86 	 *
87 	 * Throws: ConstructionException GTK+ fails to create the object.
88 	 */
89 	public this()
90 	{
91 		auto p = gtk_source_completion_info_new();
92 
93 		if(p is null)
94 		{
95 			throw new ConstructionException("null returned by new");
96 		}
97 
98 		this(cast(GtkSourceCompletionInfo*) p);
99 	}
100 
101 	/**
102 	 * Get the current content widget.
103 	 *
104 	 * Deprecated: Use gtk_bin_get_child() instead.
105 	 *
106 	 * Returns: The current content widget.
107 	 */
108 	public Widget getWidget()
109 	{
110 		auto p = gtk_source_completion_info_get_widget(gtkSourceCompletionInfo);
111 
112 		if(p is null)
113 		{
114 			return null;
115 		}
116 
117 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
118 	}
119 
120 	/**
121 	 * Moves the #GtkSourceCompletionInfo to @iter. If @iter is %NULL @info is
122 	 * moved to the cursor position. Moving will respect the #GdkGravity setting
123 	 * of the info window and will ensure the line at @iter is not occluded by
124 	 * the window.
125 	 *
126 	 * Params:
127 	 *     view = a #GtkTextView on which the info window should be positioned.
128 	 *     iter = a #GtkTextIter.
129 	 */
130 	public void moveToIter(TextView view, TextIter iter)
131 	{
132 		gtk_source_completion_info_move_to_iter(gtkSourceCompletionInfo, (view is null) ? null : view.getTextViewStruct(), (iter is null) ? null : iter.getTextIterStruct());
133 	}
134 
135 	/**
136 	 * Sets the content widget of the info window. See that the previous widget will
137 	 * lose a reference and it can be destroyed, so if you do not want this to
138 	 * happen you must use g_object_ref() before calling this method.
139 	 *
140 	 * Deprecated: Use gtk_container_add() instead. If there is already a child
141 	 * widget, remove it with gtk_container_remove().
142 	 *
143 	 * Params:
144 	 *     widget = a #GtkWidget.
145 	 */
146 	public void setWidget(Widget widget)
147 	{
148 		gtk_source_completion_info_set_widget(gtkSourceCompletionInfo, (widget is null) ? null : widget.getWidgetStruct());
149 	}
150 
151 	protected class OnBeforeShowDelegateWrapper
152 	{
153 		void delegate(SourceCompletionInfo) dlg;
154 		gulong handlerId;
155 
156 		this(void delegate(SourceCompletionInfo) dlg)
157 		{
158 			this.dlg = dlg;
159 			onBeforeShowListeners ~= this;
160 		}
161 
162 		void remove(OnBeforeShowDelegateWrapper source)
163 		{
164 			foreach(index, wrapper; onBeforeShowListeners)
165 			{
166 				if (wrapper.handlerId == source.handlerId)
167 				{
168 					onBeforeShowListeners[index] = null;
169 					onBeforeShowListeners = std.algorithm.remove(onBeforeShowListeners, index);
170 					break;
171 				}
172 			}
173 		}
174 	}
175 	OnBeforeShowDelegateWrapper[] onBeforeShowListeners;
176 
177 	/**
178 	 * This signal is emitted before any "show" management. You can connect
179 	 * to this signal if you want to change some properties or position
180 	 * before the real "show".
181 	 *
182 	 * Deprecated: This signal should not be used.
183 	 */
184 	gulong addOnBeforeShow(void delegate(SourceCompletionInfo) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
185 	{
186 		auto wrapper = new OnBeforeShowDelegateWrapper(dlg);
187 		wrapper.handlerId = Signals.connectData(
188 			this,
189 			"before-show",
190 			cast(GCallback)&callBackBeforeShow,
191 			cast(void*)wrapper,
192 			cast(GClosureNotify)&callBackBeforeShowDestroy,
193 			connectFlags);
194 		return wrapper.handlerId;
195 	}
196 
197 	extern(C) static void callBackBeforeShow(GtkSourceCompletionInfo* sourcecompletioninfoStruct, OnBeforeShowDelegateWrapper wrapper)
198 	{
199 		wrapper.dlg(wrapper.outer);
200 	}
201 
202 	extern(C) static void callBackBeforeShowDestroy(OnBeforeShowDelegateWrapper wrapper, GClosure* closure)
203 	{
204 		wrapper.remove(wrapper);
205 	}
206 }