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