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.SourceCompletionContext;
26 
27 private import glib.ListG;
28 private import glib.MemorySlice;
29 private import gobject.ObjectG;
30 private import gobject.Signals;
31 private import gsv.SourceCompletionProposalIF;
32 private import gsv.SourceCompletionProviderIF;
33 private import gsv.c.functions;
34 public  import gsv.c.types;
35 public  import gsvc.gsvtypes;
36 private import gtk.TextIter;
37 private import std.algorithm;
38 
39 
40 /** */
41 public class SourceCompletionContext : ObjectG
42 {
43 	/** the main Gtk struct */
44 	protected GtkSourceCompletionContext* gtkSourceCompletionContext;
45 
46 	/** Get the main Gtk struct */
47 	public GtkSourceCompletionContext* getSourceCompletionContextStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gtkSourceCompletionContext;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected override void* getStruct()
56 	{
57 		return cast(void*)gtkSourceCompletionContext;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GtkSourceCompletionContext* gtkSourceCompletionContext, bool ownedRef = false)
64 	{
65 		this.gtkSourceCompletionContext = gtkSourceCompletionContext;
66 		super(cast(GObject*)gtkSourceCompletionContext, ownedRef);
67 	}
68 
69 
70 	/** */
71 	public static GType getType()
72 	{
73 		return gtk_source_completion_context_get_type();
74 	}
75 
76 	/**
77 	 * Providers can use this function to add proposals to the completion. They
78 	 * can do so asynchronously by means of the @finished argument. Providers must
79 	 * ensure that they always call this function with @finished set to %TRUE
80 	 * once each population (even if no proposals need to be added).
81 	 * Population occurs when the gtk_source_completion_provider_populate()
82 	 * function is called.
83 	 *
84 	 * Params:
85 	 *     provider = a #GtkSourceCompletionProvider.
86 	 *     proposals = The list of proposals to add.
87 	 *     finished = Whether the provider is finished adding proposals.
88 	 */
89 	public void addProposals(SourceCompletionProviderIF provider, ListG proposals, bool finished)
90 	{
91 		gtk_source_completion_context_add_proposals(gtkSourceCompletionContext, (provider is null) ? null : provider.getSourceCompletionProviderStruct(), (proposals is null) ? null : proposals.getListGStruct(), finished);
92 	}
93 
94 	/**
95 	 * Get the context activation.
96 	 *
97 	 * Returns: The context activation.
98 	 */
99 	public GtkSourceCompletionActivation getActivation()
100 	{
101 		return gtk_source_completion_context_get_activation(gtkSourceCompletionContext);
102 	}
103 
104 	/**
105 	 * Get the iter at which the completion was invoked. Providers can use this
106 	 * to determine how and if to match proposals.
107 	 *
108 	 * Params:
109 	 *     iter = a #GtkTextIter.
110 	 *
111 	 * Returns: %TRUE if @iter is correctly set, %FALSE otherwise.
112 	 */
113 	public bool getIter(out TextIter iter)
114 	{
115 		GtkTextIter* outiter = sliceNew!GtkTextIter();
116 
117 		auto p = gtk_source_completion_context_get_iter(gtkSourceCompletionContext, outiter) != 0;
118 
119 		iter = ObjectG.getDObject!(TextIter)(outiter, true);
120 
121 		return p;
122 	}
123 
124 	/**
125 	 * Emitted when the current population of proposals has been cancelled.
126 	 * Providers adding proposals asynchronously should connect to this signal
127 	 * to know when to cancel running proposal queries.
128 	 */
129 	gulong addOnCancelled(void delegate(SourceCompletionContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
130 	{
131 		return Signals.connect(this, "cancelled", dlg, connectFlags ^ ConnectFlags.SWAPPED);
132 	}
133 }