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  * Conversion parameters:
26  * inFile  = GtkSourceCompletionContext.html
27  * outPack = gsv
28  * outFile = SourceCompletionContext
29  * strct   = GtkSourceCompletionContext
30  * realStrct=
31  * ctorStrct=
32  * clss    = SourceCompletionContext
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_source_completion_context_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * 	- gtk_source_completion_context_add_proposals
45  * omit signals:
46  * imports:
47  * 	- glib.ListG
48  * 	- gsv.SourceCompletionProviderIF
49  * 	- gtk.TextIter
50  * structWrap:
51  * 	- GList* -> ListG
52  * 	- GtkSourceCompletionProvider* -> SourceCompletionProviderIF
53  * 	- GtkTextIter* -> TextIter
54  * module aliases:
55  * local aliases:
56  * overrides:
57  */
58 
59 module gsv.SourceCompletionContext;
60 
61 public  import gsvc.gsvtypes;
62 
63 private import gsvc.gsv;
64 private import glib.ConstructionException;
65 private import gobject.ObjectG;
66 
67 private import gobject.Signals;
68 public  import gtkc.gdktypes;
69 private import glib.ListG;
70 private import gsv.SourceCompletionProviderIF;
71 private import gtk.TextIter;
72 
73 
74 private import gobject.ObjectG;
75 
76 /**
77  * Initially, the completion window is hidden. For a completion to occur, it has
78  * to be activated. The different possible activations are listed in
79  * GtkSourceCompletionActivation. When an activation occurs, a
80  * GtkSourceCompletionContext object is created, and the eligible providers are
81  * asked to add proposals with gtk_source_completion_context_add_proposals().
82  *
83  * If no proposals are added, the completion window remains hidden, and the
84  * context is destroyed.
85  *
86  * On the other hand, if proposals are added, the completion window becomes
87  * visible, and the user can choose a proposal. If the user is not happy with
88  * the shown proposals, he or she can insert or delete characters, to modify the
89  * completion context and therefore hoping to see the proposal he or she wants.
90  * This means that when an insertion or deletion occurs in the GtkTextBuffer
91  * when the completion window is visible, the eligible providers are again asked
92  * to add proposals. The "activation" remains the
93  * same in this case.
94  *
95  * When the completion window is hidden, the interactive completion is triggered
96  * only on insertion in the buffer, not on deletion. Once the completion window
97  * is visible, then on each insertion or deletion, there is a new population and
98  * the providers are asked to add proposals. If there are no more proposals, the
99  * completion window disappears. So if you want to keep the completion window
100  * visible, but there are no proposals, you can insert a dummy proposal named
101  * "No proposals". For example, the user types progressively the name of
102  * a function, and some proposals appear. The user types a bad character and
103  * there are no proposals anymore. What the user wants is to delete the last
104  * character, and see the previous proposals. If the completion window
105  * disappears, the previous proposals will not reappear on the character
106  * deletion.
107  *
108  * A GtkTextIter is associated with the context, this is where the completion
109  * takes place. With this GtkTextIter, you can get the associated
110  * GtkTextBuffer with gtk_text_iter_get_buffer().
111  */
112 public class SourceCompletionContext : ObjectG
113 {
114 	
115 	/** the main Gtk struct */
116 	protected GtkSourceCompletionContext* gtkSourceCompletionContext;
117 	
118 	
119 	/** Get the main Gtk struct */
120 	public GtkSourceCompletionContext* getSourceCompletionContextStruct()
121 	{
122 		return gtkSourceCompletionContext;
123 	}
124 	
125 	
126 	/** the main Gtk struct as a void* */
127 	protected override void* getStruct()
128 	{
129 		return cast(void*)gtkSourceCompletionContext;
130 	}
131 	
132 	/**
133 	 * Sets our main struct and passes it to the parent class
134 	 */
135 	public this (GtkSourceCompletionContext* gtkSourceCompletionContext)
136 	{
137 		super(cast(GObject*)gtkSourceCompletionContext);
138 		this.gtkSourceCompletionContext = gtkSourceCompletionContext;
139 	}
140 	
141 	protected override void setStruct(GObject* obj)
142 	{
143 		super.setStruct(obj);
144 		gtkSourceCompletionContext = cast(GtkSourceCompletionContext*)obj;
145 	}
146 	
147 	/**
148 	 * Providers can use this function to add proposals to the completion. They
149 	 * can do so asynchronously by means of the finished argument. Providers must
150 	 * ensure that they always call this function with finished set to TRUE
151 	 * once each population (even if no proposals need to be added).
152 	 * Params:
153 	 * provider = A GtkSourceCompletionProvider
154 	 * proposals = The list of proposals to add
155 	 * finished = Whether the provider is finished adding proposals
156 	 */
157 	public void addProposals(SourceCompletionProviderIF provider, ListG proposals, int finished)
158 	{
159 		// void gtk_source_completion_context_add_proposals  (GtkSourceCompletionContext *context,  struct _GtkSourceCompletionProvider *provider,  GList *proposals,  gboolean finished);
160 		gtk_source_completion_context_add_proposals(gtkSourceCompletionContext, (provider is null) ? null : provider.getSourceCompletionProviderTStruct(), (proposals is null) ? null : proposals.getListGStruct(), finished);
161 	}
162 	
163 	/**
164 	 */
165 	int[string] connectedSignals;
166 	
167 	void delegate(SourceCompletionContext)[] onCancelledListeners;
168 	/**
169 	 * Emitted when the current population of proposals has been cancelled.
170 	 * Providers adding proposals asynchronously should connect to this signal
171 	 * to know when to cancel running proposal queries.
172 	 */
173 	void addOnCancelled(void delegate(SourceCompletionContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
174 	{
175 		if ( !("cancelled" in connectedSignals) )
176 		{
177 			Signals.connectData(
178 			getStruct(),
179 			"cancelled",
180 			cast(GCallback)&callBackCancelled,
181 			cast(void*)this,
182 			null,
183 			connectFlags);
184 			connectedSignals["cancelled"] = 1;
185 		}
186 		onCancelledListeners ~= dlg;
187 	}
188 	extern(C) static void callBackCancelled(GtkSourceCompletionContext* arg0Struct, SourceCompletionContext _sourceCompletionContext)
189 	{
190 		foreach ( void delegate(SourceCompletionContext) dlg ; _sourceCompletionContext.onCancelledListeners )
191 		{
192 			dlg(_sourceCompletionContext);
193 		}
194 	}
195 	
196 	
197 	/**
198 	 * Get the iter at which the completion was invoked. Providers can use this
199 	 * to determine how and if to match proposals.
200 	 * Params:
201 	 * iter = a GtkTextIter. [out]
202 	 */
203 	public void getIter(TextIter iter)
204 	{
205 		// void gtk_source_completion_context_get_iter  (GtkSourceCompletionContext *context,  GtkTextIter *iter);
206 		gtk_source_completion_context_get_iter(gtkSourceCompletionContext, (iter is null) ? null : iter.getTextIterStruct());
207 	}
208 	
209 	/**
210 	 * Get the context activation.
211 	 * Returns: The context activation.
212 	 */
213 	public GtkSourceCompletionActivation getActivation()
214 	{
215 		// GtkSourceCompletionActivation gtk_source_completion_context_get_activation  (GtkSourceCompletionContext *context);
216 		return gtk_source_completion_context_get_activation(gtkSourceCompletionContext);
217 	}
218 }