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.SourceCompletionProposalT;
26 
27 public  import gdkpixbuf.Pixbuf;
28 public  import gio.Icon;
29 public  import gio.IconIF;
30 public  import glib.Str;
31 public  import gobject.ObjectG;
32 public  import gobject.Signals;
33 public  import gsvc.gsv;
34 public  import gsvc.gsvtypes;
35 public  import gtkc.gdktypes;
36 
37 
38 /** */
39 public template SourceCompletionProposalT(TStruct)
40 {
41 	/** Get the main Gtk struct */
42 	public GtkSourceCompletionProposal* getSourceCompletionProposalStruct()
43 	{
44 		return cast(GtkSourceCompletionProposal*)getStruct();
45 	}
46 
47 
48 	/**
49 	 * Emits the "changed" signal on @proposal. This should be called by
50 	 * implementations whenever the name, icon or info of the proposal has
51 	 * changed.
52 	 */
53 	public void changed()
54 	{
55 		gtk_source_completion_proposal_changed(getSourceCompletionProposalStruct());
56 	}
57 
58 	/**
59 	 * Get whether two proposal objects are the same.  This is used to (together
60 	 * with gtk_source_completion_proposal_hash()) to match proposals in the
61 	 * completion model. By default, it uses direct equality (g_direct_equal()).
62 	 *
63 	 * Params:
64 	 *     other = a #GtkSourceCompletionProposal.
65 	 *
66 	 * Return: %TRUE if @proposal and @object are the same proposal
67 	 */
68 	public bool equal(SourceCompletionProposalIF other)
69 	{
70 		return gtk_source_completion_proposal_equal(getSourceCompletionProposalStruct(), (other is null) ? null : other.getSourceCompletionProposalStruct()) != 0;
71 	}
72 
73 	/**
74 	 * Gets the #GIcon for the icon of @proposal.
75 	 *
76 	 * Return: A #GIcon with the icon of @proposal.
77 	 *
78 	 * Since: 3.18
79 	 */
80 	public IconIF getGicon()
81 	{
82 		auto p = gtk_source_completion_proposal_get_gicon(getSourceCompletionProposalStruct());
83 		
84 		if(p is null)
85 		{
86 			return null;
87 		}
88 		
89 		return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p);
90 	}
91 
92 	/**
93 	 * Gets the #GdkPixbuf for the icon of @proposal.
94 	 *
95 	 * Return: A #GdkPixbuf with the icon of @proposal.
96 	 */
97 	public Pixbuf getIcon()
98 	{
99 		auto p = gtk_source_completion_proposal_get_icon(getSourceCompletionProposalStruct());
100 		
101 		if(p is null)
102 		{
103 			return null;
104 		}
105 		
106 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
107 	}
108 
109 	/**
110 	 * Gets the icon name of @proposal.
111 	 *
112 	 * Return: The icon name of @proposal.
113 	 *
114 	 * Since: 3.18
115 	 */
116 	public string getIconName()
117 	{
118 		return Str.toString(gtk_source_completion_proposal_get_icon_name(getSourceCompletionProposalStruct()));
119 	}
120 
121 	/**
122 	 * Gets extra information associated to the proposal. This information will be
123 	 * used to present the user with extra, detailed information about the
124 	 * selected proposal. The returned string must be freed with g_free().
125 	 *
126 	 * Return: a newly-allocated string containing
127 	 *     extra information of @proposal or %NULL if no extra information is associated
128 	 *     to @proposal.
129 	 */
130 	public string getInfo()
131 	{
132 		auto retStr = gtk_source_completion_proposal_get_info(getSourceCompletionProposalStruct());
133 		
134 		scope(exit) Str.freeString(retStr);
135 		return Str.toString(retStr);
136 	}
137 
138 	/**
139 	 * Gets the label of @proposal. The label is shown in the list of proposals as
140 	 * plain text. If you need any markup (such as bold or italic text), you have
141 	 * to implement gtk_source_completion_proposal_get_markup(). The returned string
142 	 * must be freed with g_free().
143 	 *
144 	 * Return: a new string containing the label of @proposal.
145 	 */
146 	public string getLabel()
147 	{
148 		auto retStr = gtk_source_completion_proposal_get_label(getSourceCompletionProposalStruct());
149 		
150 		scope(exit) Str.freeString(retStr);
151 		return Str.toString(retStr);
152 	}
153 
154 	/**
155 	 * Gets the label of @proposal with markup. The label is shown in the list of
156 	 * proposals and may contain markup. This will be used instead of
157 	 * gtk_source_completion_proposal_get_label() if implemented. The returned string
158 	 * must be freed with g_free().
159 	 *
160 	 * Return: a new string containing the label of @proposal with markup.
161 	 */
162 	public string getMarkup()
163 	{
164 		auto retStr = gtk_source_completion_proposal_get_markup(getSourceCompletionProposalStruct());
165 		
166 		scope(exit) Str.freeString(retStr);
167 		return Str.toString(retStr);
168 	}
169 
170 	/**
171 	 * Gets the text of @proposal. The text that is inserted into
172 	 * the text buffer when the proposal is activated by the default activation.
173 	 * You are free to implement a custom activation handler in the provider and
174 	 * not implement this function. For more information, see
175 	 * gtk_source_completion_provider_activate_proposal(). The returned string must
176 	 * be freed with g_free().
177 	 *
178 	 * Return: a new string containing the text of @proposal.
179 	 */
180 	public string getText()
181 	{
182 		auto retStr = gtk_source_completion_proposal_get_text(getSourceCompletionProposalStruct());
183 		
184 		scope(exit) Str.freeString(retStr);
185 		return Str.toString(retStr);
186 	}
187 
188 	/**
189 	 * Get the hash value of @proposal. This is used to (together with
190 	 * gtk_source_completion_proposal_equal()) to match proposals in the completion
191 	 * model. By default, it uses a direct hash (g_direct_hash()).
192 	 *
193 	 * Return: The hash value of @proposal.
194 	 */
195 	public uint hash()
196 	{
197 		return gtk_source_completion_proposal_hash(getSourceCompletionProposalStruct());
198 	}
199 
200 	int[string] connectedSignals;
201 
202 	void delegate(SourceCompletionProposalIF)[] _onChangedListeners;
203 	@property void delegate(SourceCompletionProposalIF)[] onChangedListeners()
204 	{
205 		return _onChangedListeners;
206 	}
207 	/**
208 	 * Emitted when the proposal has changed. The completion popup
209 	 * will react to this by updating the shown information.
210 	 */
211 	void addOnChanged(void delegate(SourceCompletionProposalIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
212 	{
213 		if ( "changed" !in connectedSignals )
214 		{
215 			Signals.connectData(
216 				this,
217 				"changed",
218 				cast(GCallback)&callBackChanged,
219 				cast(void*)cast(SourceCompletionProposalIF)this,
220 				null,
221 				connectFlags);
222 			connectedSignals["changed"] = 1;
223 		}
224 		_onChangedListeners ~= dlg;
225 	}
226 	extern(C) static void callBackChanged(GtkSourceCompletionProposal* sourcecompletionproposalStruct, SourceCompletionProposalIF _sourcecompletionproposal)
227 	{
228 		foreach ( void delegate(SourceCompletionProposalIF) dlg; _sourcecompletionproposal.onChangedListeners )
229 		{
230 			dlg(_sourcecompletionproposal);
231 		}
232 	}
233 }