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