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