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.SourceCompletionProviderT;
26 
27 public  import gdkpixbuf.Pixbuf;
28 public  import gio.IconIF;
29 public  import glib.Str;
30 public  import gobject.ObjectG;
31 public  import gsv.SourceCompletionContext;
32 public  import gsv.SourceCompletionInfo;
33 public  import gsv.SourceCompletionProposalIF;
34 public  import gsv.c.functions;
35 public  import gsv.c.types;
36 public  import gsvc.gsvtypes;
37 public  import gtk.TextIter;
38 public  import gtk.Widget;
39 
40 
41 /** */
42 public template SourceCompletionProviderT(TStruct)
43 {
44 	/** Get the main Gtk struct */
45 	public GtkSourceCompletionProvider* getSourceCompletionProviderStruct(bool transferOwnership = false)
46 	{
47 		if (transferOwnership)
48 			ownedRef = false;
49 		return cast(GtkSourceCompletionProvider*)getStruct();
50 	}
51 
52 
53 	/**
54 	 * Activate @proposal at @iter. When this functions returns %FALSE, the default
55 	 * activation of @proposal will take place which replaces the word at @iter
56 	 * with the text of @proposal (see gtk_source_completion_proposal_get_text()).
57 	 *
58 	 * Here is how the default activation selects the boundaries of the word to
59 	 * replace. The end of the word is @iter. For the start of the word, it depends
60 	 * on whether a start iter is defined for @proposal (see
61 	 * gtk_source_completion_provider_get_start_iter()). If a start iter is defined,
62 	 * the start of the word is the start iter. Else, the word (as long as possible)
63 	 * will contain only alphanumerical and the "_" characters.
64 	 *
65 	 * Params:
66 	 *     proposal = a #GtkSourceCompletionProposal.
67 	 *     iter = a #GtkTextIter.
68 	 *
69 	 * Returns: %TRUE to indicate that the proposal activation has been handled,
70 	 *     %FALSE otherwise.
71 	 */
72 	public bool activateProposal(SourceCompletionProposalIF proposal, TextIter iter)
73 	{
74 		return gtk_source_completion_provider_activate_proposal(getSourceCompletionProviderStruct(), (proposal is null) ? null : proposal.getSourceCompletionProposalStruct(), (iter is null) ? null : iter.getTextIterStruct()) != 0;
75 	}
76 
77 	/**
78 	 * Get with what kind of activation the provider should be activated.
79 	 *
80 	 * Returns: a combination of #GtkSourceCompletionActivation.
81 	 */
82 	public GtkSourceCompletionActivation getActivation()
83 	{
84 		return gtk_source_completion_provider_get_activation(getSourceCompletionProviderStruct());
85 	}
86 
87 	/**
88 	 * Gets the #GIcon for the icon of @provider.
89 	 *
90 	 * Returns: The icon to be used for the provider,
91 	 *     or %NULL if the provider does not have a special icon.
92 	 *
93 	 * Since: 3.18
94 	 */
95 	public IconIF getGicon()
96 	{
97 		auto p = gtk_source_completion_provider_get_gicon(getSourceCompletionProviderStruct());
98 
99 		if(p is null)
100 		{
101 			return null;
102 		}
103 
104 		return ObjectG.getDObject!(IconIF)(cast(GIcon*) p);
105 	}
106 
107 	/**
108 	 * Get the #GdkPixbuf for the icon of the @provider.
109 	 *
110 	 * Returns: The icon to be used for the provider,
111 	 *     or %NULL if the provider does not have a special icon.
112 	 */
113 	public Pixbuf getIcon()
114 	{
115 		auto p = gtk_source_completion_provider_get_icon(getSourceCompletionProviderStruct());
116 
117 		if(p is null)
118 		{
119 			return null;
120 		}
121 
122 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
123 	}
124 
125 	/**
126 	 * Gets the icon name of @provider.
127 	 *
128 	 * Returns: The icon name to be used for the provider,
129 	 *     or %NULL if the provider does not have a special icon.
130 	 *
131 	 * Since: 3.18
132 	 */
133 	public string getIconName()
134 	{
135 		return Str.toString(gtk_source_completion_provider_get_icon_name(getSourceCompletionProviderStruct()));
136 	}
137 
138 	/**
139 	 * Get a customized info widget to show extra information of a proposal.
140 	 * This allows for customized widgets on a proposal basis, although in general
141 	 * providers will have the same custom widget for all their proposals and
142 	 * @proposal can be ignored. The implementation of this function is optional.
143 	 *
144 	 * If this function is not implemented, the default widget is a #GtkLabel. The
145 	 * return value of gtk_source_completion_proposal_get_info() is used as the
146 	 * content of the #GtkLabel.
147 	 *
148 	 * <note>
149 	 * <para>
150 	 * If implemented, gtk_source_completion_provider_update_info()
151 	 * <emphasis>must</emphasis> also be implemented.
152 	 * </para>
153 	 * </note>
154 	 *
155 	 * Params:
156 	 *     proposal = a currently selected #GtkSourceCompletionProposal.
157 	 *
158 	 * Returns: a custom #GtkWidget to show extra
159 	 *     information about @proposal, or %NULL if the provider does not have a special
160 	 *     info widget.
161 	 */
162 	public Widget getInfoWidget(SourceCompletionProposalIF proposal)
163 	{
164 		auto p = gtk_source_completion_provider_get_info_widget(getSourceCompletionProviderStruct(), (proposal is null) ? null : proposal.getSourceCompletionProposalStruct());
165 
166 		if(p is null)
167 		{
168 			return null;
169 		}
170 
171 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
172 	}
173 
174 	/**
175 	 * Get the delay in milliseconds before starting interactive completion for
176 	 * this provider. A value of -1 indicates to use the default value as set
177 	 * by the #GtkSourceCompletion:auto-complete-delay property.
178 	 *
179 	 * Returns: the interactive delay in milliseconds.
180 	 */
181 	public int getInteractiveDelay()
182 	{
183 		return gtk_source_completion_provider_get_interactive_delay(getSourceCompletionProviderStruct());
184 	}
185 
186 	/**
187 	 * Get the name of the provider. This should be a translatable name for
188 	 * display to the user. For example: _("Document word completion provider"). The
189 	 * returned string must be freed with g_free().
190 	 *
191 	 * Returns: a new string containing the name of the provider.
192 	 */
193 	public string getName()
194 	{
195 		auto retStr = gtk_source_completion_provider_get_name(getSourceCompletionProviderStruct());
196 
197 		scope(exit) Str.freeString(retStr);
198 		return Str.toString(retStr);
199 	}
200 
201 	/**
202 	 * Get the provider priority. The priority determines the order in which
203 	 * proposals appear in the completion popup. Higher priorities are sorted
204 	 * before lower priorities. The default priority is 0.
205 	 *
206 	 * Returns: the provider priority.
207 	 */
208 	public int getPriority()
209 	{
210 		return gtk_source_completion_provider_get_priority(getSourceCompletionProviderStruct());
211 	}
212 
213 	/**
214 	 * Get the #GtkTextIter at which the completion for @proposal starts. When
215 	 * implemented, this information is used to position the completion window
216 	 * accordingly when a proposal is selected in the completion window. The
217 	 * @proposal text inside the completion window is aligned on @iter.
218 	 *
219 	 * If this function is not implemented, the word boundary is taken to position
220 	 * the completion window. See gtk_source_completion_provider_activate_proposal()
221 	 * for an explanation on the word boundaries.
222 	 *
223 	 * When the @proposal is activated, the default handler uses @iter as the start
224 	 * of the word to replace. See
225 	 * gtk_source_completion_provider_activate_proposal() for more information.
226 	 *
227 	 * Params:
228 	 *     context = a #GtkSourceCompletionContext.
229 	 *     proposal = a #GtkSourceCompletionProposal.
230 	 *     iter = a #GtkTextIter.
231 	 *
232 	 * Returns: %TRUE if @iter was set for @proposal, %FALSE otherwise.
233 	 */
234 	public bool getStartIter(SourceCompletionContext context, SourceCompletionProposalIF proposal, out TextIter iter)
235 	{
236 		GtkTextIter* outiter = gMalloc!GtkTextIter();
237 
238 		auto p = gtk_source_completion_provider_get_start_iter(getSourceCompletionProviderStruct(), (context is null) ? null : context.getSourceCompletionContextStruct(), (proposal is null) ? null : proposal.getSourceCompletionProposalStruct(), outiter) != 0;
239 
240 		iter = ObjectG.getDObject!(TextIter)(outiter, true);
241 
242 		return p;
243 	}
244 
245 	/**
246 	 * Get whether the provider match the context of completion detailed in
247 	 * @context.
248 	 *
249 	 * Params:
250 	 *     context = a #GtkSourceCompletionContext.
251 	 *
252 	 * Returns: %TRUE if @provider matches the completion context, %FALSE otherwise.
253 	 */
254 	public bool match(SourceCompletionContext context)
255 	{
256 		return gtk_source_completion_provider_match(getSourceCompletionProviderStruct(), (context is null) ? null : context.getSourceCompletionContextStruct()) != 0;
257 	}
258 
259 	/**
260 	 * Populate @context with proposals from @provider added with the
261 	 * gtk_source_completion_context_add_proposals() function.
262 	 *
263 	 * Params:
264 	 *     context = a #GtkSourceCompletionContext.
265 	 */
266 	public void populate(SourceCompletionContext context)
267 	{
268 		gtk_source_completion_provider_populate(getSourceCompletionProviderStruct(), (context is null) ? null : context.getSourceCompletionContextStruct());
269 	}
270 
271 	/**
272 	 * Update extra information shown in @info for @proposal.
273 	 *
274 	 * <note>
275 	 * <para>
276 	 * This function <emphasis>must</emphasis> be implemented when
277 	 * gtk_source_completion_provider_get_info_widget() is implemented.
278 	 * </para>
279 	 * </note>
280 	 *
281 	 * Params:
282 	 *     proposal = a #GtkSourceCompletionProposal.
283 	 *     info = a #GtkSourceCompletionInfo.
284 	 */
285 	public void updateInfo(SourceCompletionProposalIF proposal, SourceCompletionInfo info)
286 	{
287 		gtk_source_completion_provider_update_info(getSourceCompletionProviderStruct(), (proposal is null) ? null : proposal.getSourceCompletionProposalStruct(), (info is null) ? null : info.getSourceCompletionInfoStruct());
288 	}
289 }