alternative to assert
[gtkD.git] / src / gtk / EntryCompletion.d
blobbd7cdad8426f6aa7d7334fda53e12a7305415e18
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkEntryCompletion.html
26 * outPack = gtk
27 * outFile = EntryCompletion
28 * strct = GtkEntryCompletion
29 * realStrct=
30 * ctorStrct=
31 * clss = EntryCompletion
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_entry_completion_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - gtk.Widget
47 * - gtk.TreeModel
48 * structWrap:
49 * - GtkTreeModel* -> TreeModel
50 * - GtkWidget* -> Widget
51 * local aliases:
54 module gtk.EntryCompletion;
56 private import gtk.gtktypes;
58 private import lib.gtk;
60 private import glib.Str;
61 private import gtk.Widget;
62 private import gtk.TreeModel;
64 /**
65 * Description
66 * GtkEntryCompletion is an auxiliary object to be used in conjunction with
67 * GtkEntry to provide the completion functionality. It implements the
68 * GtkCellLayout interface, to allow the user to add extra cells to the
69 * GtkTreeView with completion matches.
70 * "Completion functionality" means that when the user modifies the text
71 * in the entry, GtkEntryCompletion checks which rows in the model match
72 * the current content of the entry, and displays a list of matches.
73 * By default, the matching is done by comparing the entry text
74 * case-insensitively against the text column of the model (see
75 * gtk_entry_completion_set_text_column()), but this can be overridden with
76 * a custom match function (see gtk_entry_completion_set_match_func()).
77 * When the user selects a completion, the content of the entry is updated.
78 * By default, the content of the entry is replaced by the text column of the
79 * model, but this can be overridden by connecting to the ::match-selected signal
80 * and updating the entry in the signal handler. Note that you should return
81 * TRUE from the signal handler to suppress the default behaviour.
82 * To add completion functionality to an entry, use gtk_entry_set_completion().
83 * In addition to regular completion matches, which will be inserted into the
84 * entry when they are selected, GtkEntryCompletion also allows to display
85 * "actions" in the popup window. Their appearance is similar to menuitems,
86 * to differentiate them clearly from completion strings. When an action is
87 * selected, the ::action-activated signal is emitted.
89 private import gobject.ObjectG;
90 public class EntryCompletion : ObjectG
93 /** the main Gtk struct */
94 protected GtkEntryCompletion* gtkEntryCompletion;
97 public GtkEntryCompletion* getEntryCompletionStruct()
99 return gtkEntryCompletion;
103 /** the main Gtk struct as a void* */
104 protected void* getStruct()
106 return cast(void*)gtkEntryCompletion;
110 * Sets our main struct and passes it to the parent class
112 public this (GtkEntryCompletion* gtkEntryCompletion)
114 super(cast(GObject*)gtkEntryCompletion);
115 this.gtkEntryCompletion = gtkEntryCompletion;
121 // imports for the signal processing
122 private import gobject.Signals;
123 private import gdk.gdktypes;
124 int[char[]] connectedSignals;
126 void delegate(gint, EntryCompletion)[] onActionActivatedListeners;
127 void addOnActionActivated(void delegate(gint, EntryCompletion) dlg)
129 if ( !("action-activated" in connectedSignals) )
131 Signals.connectData(
132 getStruct(),
133 "action-activated",
134 cast(GCallback)&callBackActionActivated,
135 this,
136 null,
137 cast(ConnectFlags)0);
138 connectedSignals["action-activated"] = 1;
140 onActionActivatedListeners ~= dlg;
142 extern(C) static void callBackActionActivated(GtkEntryCompletion* widgetStruct, gint index, EntryCompletion entryCompletion)
144 bit consumed = false;
146 foreach ( void delegate(gint, EntryCompletion) dlg ; entryCompletion.onActionActivatedListeners )
148 dlg(index, entryCompletion);
151 return consumed;
154 gboolean delegate(char[], EntryCompletion)[] onInsertPrefixListeners;
155 void addOnInsertPrefix(gboolean delegate(char[], EntryCompletion) dlg)
157 if ( !("insert-prefix" in connectedSignals) )
159 Signals.connectData(
160 getStruct(),
161 "insert-prefix",
162 cast(GCallback)&callBackInsertPrefix,
163 this,
164 null,
165 cast(ConnectFlags)0);
166 connectedSignals["insert-prefix"] = 1;
168 onInsertPrefixListeners ~= dlg;
170 extern(C) static void callBackInsertPrefix(GtkEntryCompletion* widgetStruct, gchar* prefix, EntryCompletion entryCompletion)
172 bit consumed = false;
174 foreach ( gboolean delegate(char[], EntryCompletion) dlg ; entryCompletion.onInsertPrefixListeners )
176 dlg(Str.toString(prefix), entryCompletion);
179 return consumed;
182 gboolean delegate(TreeModel, GtkTreeIter*, EntryCompletion)[] onMatchSelectedListeners;
183 void addOnMatchSelected(gboolean delegate(TreeModel, GtkTreeIter*, EntryCompletion) dlg)
185 if ( !("match-selected" in connectedSignals) )
187 Signals.connectData(
188 getStruct(),
189 "match-selected",
190 cast(GCallback)&callBackMatchSelected,
191 this,
192 null,
193 cast(ConnectFlags)0);
194 connectedSignals["match-selected"] = 1;
196 onMatchSelectedListeners ~= dlg;
198 extern(C) static void callBackMatchSelected(GtkEntryCompletion* widgetStruct, GtkTreeModel* model, GtkTreeIter* iter, EntryCompletion entryCompletion)
200 bit consumed = false;
202 foreach ( gboolean delegate(TreeModel, GtkTreeIter*, EntryCompletion) dlg ; entryCompletion.onMatchSelectedListeners )
204 dlg(new TreeModel(model), iter, entryCompletion);
207 return consumed;
214 * Creates a new GtkEntryCompletion object.
215 * Returns:
216 * A newly created GtkEntryCompletion object.
217 * Since 2.4
219 public this ()
221 // GtkEntryCompletion* gtk_entry_completion_new (void);
222 this(cast(GtkEntryCompletion*)gtk_entry_completion_new() );
226 * Gets the entry completion has been attached to.
227 * completion:
228 * A GtkEntryCompletion.
229 * Returns:
230 * The entry completion has been attached to.
231 * Since 2.4
233 public Widget getEntry()
235 // GtkWidget* gtk_entry_completion_get_entry (GtkEntryCompletion *completion);
236 return new Widget( gtk_entry_completion_get_entry(gtkEntryCompletion) );
240 * Sets the model for a GtkEntryCompletion. If completion already has
241 * a model set, it will remove it before setting the new model.
242 * If model is NULL, then it will unset the model.
243 * completion:
244 * A GtkEntryCompletion.
245 * model:
246 * The GtkTreeModel.
247 * Since 2.4
249 public void setModel(TreeModel model)
251 // void gtk_entry_completion_set_model (GtkEntryCompletion *completion, GtkTreeModel *model);
252 gtk_entry_completion_set_model(gtkEntryCompletion, (model is null) ? null : model.getTreeModelStruct());
256 * Returns the model the GtkEntryCompletion is using as data source.
257 * Returns NULL if the model is unset.
258 * completion:
259 * A GtkEntryCompletion.
260 * Returns:
261 * A GtkTreeModel, or NULL if none is currently being used.
262 * Since 2.4
264 public TreeModel getModel()
266 // GtkTreeModel* gtk_entry_completion_get_model (GtkEntryCompletion *completion);
267 return new TreeModel( gtk_entry_completion_get_model(gtkEntryCompletion) );
271 * Sets the match function for completion to be func. The match function
272 * is used to determine if a row should or should not be in the completion
273 * list.
274 * completion:
275 * A GtkEntryCompletion.
276 * func:
277 * The GtkEntryCompletionMatchFunc to use.
278 * func_data:
279 * The user data for func.
280 * func_notify:
281 * Destroy notifier for func_data.
282 * Since 2.4
284 public void setMatchFunc(GtkEntryCompletionMatchFunc func, void* funcData, GDestroyNotify funcNotify)
286 // void gtk_entry_completion_set_match_func (GtkEntryCompletion *completion, GtkEntryCompletionMatchFunc func, gpointer func_data, GDestroyNotify func_notify);
287 gtk_entry_completion_set_match_func(gtkEntryCompletion, func, funcData, funcNotify);
291 * Requires the length of the search key for completion to be at least
292 * length. This is useful for long lists, where completing using a small
293 * key takes a lot of time and will come up with meaningless results anyway
294 * (ie, a too large dataset).
295 * completion:
296 * A GtkEntryCompletion.
297 * length:
298 * The minimum length of the key in order to start completing.
299 * Since 2.4
301 public void setMinimumKeyLength(int length)
303 // void gtk_entry_completion_set_minimum_key_length (GtkEntryCompletion *completion, gint length);
304 gtk_entry_completion_set_minimum_key_length(gtkEntryCompletion, length);
308 * Returns the minimum key length as set for completion.
309 * completion:
310 * A GtkEntryCompletion.
311 * Returns:
312 * The currently used minimum key length.
313 * Since 2.4
315 public int getMinimumKeyLength()
317 // gint gtk_entry_completion_get_minimum_key_length (GtkEntryCompletion *completion);
318 return gtk_entry_completion_get_minimum_key_length(gtkEntryCompletion);
322 * Requests a completion operation, or in other words a refiltering of the
323 * current list with completions, using the current key. The completion list
324 * view will be updated accordingly.
325 * completion:
326 * A GtkEntryCompletion.
327 * Since 2.4
329 public void complete()
331 // void gtk_entry_completion_complete (GtkEntryCompletion *completion);
332 gtk_entry_completion_complete(gtkEntryCompletion);
336 * Requests a prefix insertion.
337 * completion:
338 * a GtkEntryCompletion
339 * Since 2.6
341 public void insertPrefix()
343 // void gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion);
344 gtk_entry_completion_insert_prefix(gtkEntryCompletion);
348 * Inserts an action in completion's action item list at position index_
349 * with text text. If you want the action item to have markup, use
350 * gtk_entry_completion_insert_action_markup().
351 * completion:
352 * A GtkEntryCompletion.
353 * index_:
354 * The index of the item to insert.
355 * text:
356 * Text of the item to insert.
357 * Since 2.4
359 public void insertActionText(int index, char[] text)
361 // void gtk_entry_completion_insert_action_text (GtkEntryCompletion *completion, gint index_, const gchar *text);
362 gtk_entry_completion_insert_action_text(gtkEntryCompletion, index, Str.toStringz(text));
366 * Inserts an action in completion's action item list at position index_
367 * with markup markup.
368 * completion:
369 * A GtkEntryCompletion.
370 * index_:
371 * The index of the item to insert.
372 * markup:
373 * Markup of the item to insert.
374 * Since 2.4
376 public void insertActionMarkup(int index, char[] markup)
378 // void gtk_entry_completion_insert_action_markup (GtkEntryCompletion *completion, gint index_, const gchar *markup);
379 gtk_entry_completion_insert_action_markup(gtkEntryCompletion, index, Str.toStringz(markup));
383 * Deletes the action at index_ from completion's action list.
384 * completion:
385 * A GtkEntryCompletion.
386 * index_:
387 * The index of the item to Delete.
388 * Since 2.4
390 public void deleteAction(int index)
392 // void gtk_entry_completion_delete_action (GtkEntryCompletion *completion, gint index_);
393 gtk_entry_completion_delete_action(gtkEntryCompletion, index);
397 * Convenience function for setting up the most used case of this code: a
398 * completion list with just strings. This function will set up completion
399 * to have a list displaying all (and just) strings in the completion list,
400 * and to get those strings from column in the model of completion.
401 * This functions creates and adds a GtkCellRendererText for the selected
402 * column. If you need to set the text column, but don't want the cell
403 * renderer, use g_object_set() to set the ::text_column property directly.
404 * completion:
405 * A GtkEntryCompletion.
406 * column:
407 * The column in the model of completion to get strings from.
408 * Since 2.4
410 public void setTextColumn(int column)
412 // void gtk_entry_completion_set_text_column (GtkEntryCompletion *completion, gint column);
413 gtk_entry_completion_set_text_column(gtkEntryCompletion, column);
417 * Returns the column in the model of completion to get strings from.
418 * completion:
419 * a GtkEntryCompletion
420 * Returns:
421 * the column containing the strings
422 * Since 2.6
424 public int getTextColumn()
426 // gint gtk_entry_completion_get_text_column (GtkEntryCompletion *completion);
427 return gtk_entry_completion_get_text_column(gtkEntryCompletion);
431 * Sets whether the common prefix of the possible completions should
432 * be automatically inserted in the entry.
433 * completion:
434 * a GtkEntryCompletion
435 * inline_completion:
436 * TRUE to do inline completion
437 * Since 2.6
439 public void setInlineCompletion(int inlineCompletion)
441 // void gtk_entry_completion_set_inline_completion (GtkEntryCompletion *completion, gboolean inline_completion);
442 gtk_entry_completion_set_inline_completion(gtkEntryCompletion, inlineCompletion);
446 * Returns whether the common prefix of the possible completions should
447 * be automatically inserted in the entry.
448 * completion:
449 * a GtkEntryCompletion
450 * Returns:
451 * TRUE if inline completion is turned on
452 * Since 2.6
454 public int getInlineCompletion()
456 // gboolean gtk_entry_completion_get_inline_completion (GtkEntryCompletion *completion);
457 return gtk_entry_completion_get_inline_completion(gtkEntryCompletion);
461 * Sets whether the completions should be presented in a popup window.
462 * completion:
463 * a GtkEntryCompletion
464 * popup_completion:
465 * TRUE to do popup completion
466 * Since 2.6
468 public void setPopupCompletion(int popupCompletion)
470 // void gtk_entry_completion_set_popup_completion (GtkEntryCompletion *completion, gboolean popup_completion);
471 gtk_entry_completion_set_popup_completion(gtkEntryCompletion, popupCompletion);
475 * Returns whether the completions should be presented in a popup window.
476 * completion:
477 * a GtkEntryCompletion
478 * Returns:
479 * TRUE if popup completion is turned on
480 * Since 2.6
482 public int getPopupCompletion()
484 // gboolean gtk_entry_completion_get_popup_completion (GtkEntryCompletion *completion);
485 return gtk_entry_completion_get_popup_completion(gtkEntryCompletion);
489 * Sets whether the completion popup window will be resized to be the same
490 * width as the entry.
491 * completion:
492 * a GtkEntryCompletion
493 * popup_set_width:
494 * TRUE to make the width of the popup the same as the entry
495 * Since 2.8
497 public void setPopupSetWidth(int popupSetWidth)
499 // void gtk_entry_completion_set_popup_set_width (GtkEntryCompletion *completion, gboolean popup_set_width);
500 gtk_entry_completion_set_popup_set_width(gtkEntryCompletion, popupSetWidth);
504 * Returns whether the completion popup window will be resized to the
505 * width of the entry.
506 * completion:
507 * a GtkEntryCompletion
508 * Returns:
509 * TRUE if the popup window will be resized to the width of
510 * the entry
511 * Since 2.8
513 public int getPopupSetWidth()
515 // gboolean gtk_entry_completion_get_popup_set_width (GtkEntryCompletion *completion);
516 return gtk_entry_completion_get_popup_set_width(gtkEntryCompletion);
520 * Sets whether the completion popup window will appear even if there is
521 * only a single match. You may want to set this to FALSE if you
522 * are using inline
523 * completion.
524 * completion:
525 * a GtkEntryCompletion
526 * popup_single_match:
527 * TRUE if the popup should appear even for a single
528 * match
529 * Since 2.8
531 public void setPopupSingleMatch(int popupSingleMatch)
533 // void gtk_entry_completion_set_popup_single_match (GtkEntryCompletion *completion, gboolean popup_single_match);
534 gtk_entry_completion_set_popup_single_match(gtkEntryCompletion, popupSingleMatch);
538 * Returns whether the completion popup window will appear even if there is
539 * only a single match.
540 * completion:
541 * a GtkEntryCompletion
542 * Returns:
543 * TRUE if the popup window will appear regardless of the
544 * number of matches.
545 * Since 2.8
546 * Property Details
547 * The "inline-completion" property
548 * "inline-completion" gboolean : Read / Write
549 * Determines whether the common prefix of the possible completions
550 * should be inserted automatically in the entry. Note that this
551 * requires text-column to be set, even if you are using a custom
552 * match function.
553 * Default value: FALSE
554 * Since 2.6
556 public int getPopupSingleMatch()
558 // gboolean gtk_entry_completion_get_popup_single_match (GtkEntryCompletion *completion);
559 return gtk_entry_completion_get_popup_single_match(gtkEntryCompletion);