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