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