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
27 * outFile = EntryCompletion
28 * strct = GtkEntryCompletion
31 * clss = EntryCompletion
39 * - gtk_entry_completion_
49 * - GtkTreeModel* -> TreeModel
50 * - GtkWidget* -> Widget
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
;
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
) )
134 cast(GCallback
)&callBackActionActivated
,
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
);
154 gboolean
delegate(char[], EntryCompletion
)[] onInsertPrefixListeners
;
155 void addOnInsertPrefix(gboolean
delegate(char[], EntryCompletion
) dlg
)
157 if ( !("insert-prefix" in connectedSignals
) )
162 cast(GCallback
)&callBackInsertPrefix
,
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
);
182 gboolean
delegate(TreeModel
, GtkTreeIter
*, EntryCompletion
)[] onMatchSelectedListeners
;
183 void addOnMatchSelected(gboolean
delegate(TreeModel
, GtkTreeIter
*, EntryCompletion
) dlg
)
185 if ( !("match-selected" in connectedSignals
) )
190 cast(GCallback
)&callBackMatchSelected
,
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
);
214 * Creates a new GtkEntryCompletion object.
216 * A newly created GtkEntryCompletion object.
221 // GtkEntryCompletion* gtk_entry_completion_new (void);
222 this(cast(GtkEntryCompletion
*)gtk_entry_completion_new() );
226 * Gets the entry completion has been attached to.
228 * A GtkEntryCompletion.
230 * The entry completion has been attached to.
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.
244 * A GtkEntryCompletion.
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.
259 * A GtkEntryCompletion.
261 * A GtkTreeModel, or NULL if none is currently being used.
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
275 * A GtkEntryCompletion.
277 * The GtkEntryCompletionMatchFunc to use.
279 * The user data for func.
281 * Destroy notifier for func_data.
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).
296 * A GtkEntryCompletion.
298 * The minimum length of the key in order to start completing.
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.
310 * A GtkEntryCompletion.
312 * The currently used minimum key length.
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.
326 * A GtkEntryCompletion.
329 public void complete()
331 // void gtk_entry_completion_complete (GtkEntryCompletion *completion);
332 gtk_entry_completion_complete(gtkEntryCompletion
);
336 * Requests a prefix insertion.
338 * a GtkEntryCompletion
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().
352 * A GtkEntryCompletion.
354 * The index of the item to insert.
356 * Text of the item to insert.
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.
369 * A GtkEntryCompletion.
371 * The index of the item to insert.
373 * Markup of the item to insert.
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.
385 * A GtkEntryCompletion.
387 * The index of the item to Delete.
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.
405 * A GtkEntryCompletion.
407 * The column in the model of completion to get strings from.
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.
419 * a GtkEntryCompletion
421 * the column containing the strings
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.
434 * a GtkEntryCompletion
436 * TRUE to do inline completion
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.
449 * a GtkEntryCompletion
451 * TRUE if inline completion is turned on
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.
463 * a GtkEntryCompletion
465 * TRUE to do popup completion
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.
477 * a GtkEntryCompletion
479 * TRUE if popup completion is turned on
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.
492 * a GtkEntryCompletion
494 * TRUE to make the width of the popup the same as the entry
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.
507 * a GtkEntryCompletion
509 * TRUE if the popup window will be resized to the width of
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
525 * a GtkEntryCompletion
526 * popup_single_match:
527 * TRUE if the popup should appear even for a single
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.
541 * a GtkEntryCompletion
543 * TRUE if the popup window will appear regardless of the
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
553 * Default value: FALSE
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
);