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 public class SourceCompletionContext : ObjectG
39 {
40 	/** the main Gtk struct */
41 	protected GtkSourceCompletionContext* gtkSourceCompletionContext;
42 
43 	/** Get the main Gtk struct */
44 	public GtkSourceCompletionContext* getSourceCompletionContextStruct()
45 	{
46 		return gtkSourceCompletionContext;
47 	}
48 
49 	/** the main Gtk struct as a void* */
50 	protected override void* getStruct()
51 	{
52 		return cast(void*)gtkSourceCompletionContext;
53 	}
54 
55 	protected override void setStruct(GObject* obj)
56 	{
57 		gtkSourceCompletionContext = cast(GtkSourceCompletionContext*)obj;
58 		super.setStruct(obj);
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (GtkSourceCompletionContext* gtkSourceCompletionContext, bool ownedRef = false)
65 	{
66 		this.gtkSourceCompletionContext = gtkSourceCompletionContext;
67 		super(cast(GObject*)gtkSourceCompletionContext, ownedRef);
68 	}
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 	public void getIter(out TextIter iter)
114 	{
115 		GtkTextIter* outiter = new GtkTextIter;
116 		
117 		gtk_source_completion_context_get_iter(gtkSourceCompletionContext, outiter);
118 		
119 		iter = ObjectG.getDObject!(TextIter)(outiter);
120 	}
121 
122 	int[string] connectedSignals;
123 
124 	void delegate(SourceCompletionContext)[] onCancelledListeners;
125 	/**
126 	 * Emitted when the current population of proposals has been cancelled.
127 	 * Providers adding proposals asynchronously should connect to this signal
128 	 * to know when to cancel running proposal queries.
129 	 */
130 	void addOnCancelled(void delegate(SourceCompletionContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
131 	{
132 		if ( "cancelled" !in connectedSignals )
133 		{
134 			Signals.connectData(
135 				this,
136 				"cancelled",
137 				cast(GCallback)&callBackCancelled,
138 				cast(void*)this,
139 				null,
140 				connectFlags);
141 			connectedSignals["cancelled"] = 1;
142 		}
143 		onCancelledListeners ~= dlg;
144 	}
145 	extern(C) static void callBackCancelled(GtkSourceCompletionContext* sourcecompletioncontextStruct, SourceCompletionContext _sourcecompletioncontext)
146 	{
147 		foreach ( void delegate(SourceCompletionContext) dlg; _sourcecompletioncontext.onCancelledListeners )
148 		{
149 			dlg(_sourcecompletioncontext);
150 		}
151 	}
152 }