2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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
55 module gtk
.EntryCompletion
;
61 import tango
.io
.Stdout
; // use the tango loging?
65 private import gtkc
.gtktypes
;
67 private import gtkc
.gtk
;
70 private import glib
.Str
;
71 private import gtk
.Widget
;
72 private import gtk
.TreeModel
;
79 * GtkEntryCompletion is an auxiliary object to be used in conjunction with
80 * GtkEntry to provide the completion functionality. It implements the
81 * GtkCellLayout interface, to allow the user to add extra cells to the
82 * GtkTreeView with completion matches.
83 * "Completion functionality" means that when the user modifies the text
84 * in the entry, GtkEntryCompletion checks which rows in the model match
85 * the current content of the entry, and displays a list of matches.
86 * By default, the matching is done by comparing the entry text
87 * case-insensitively against the text column of the model (see
88 * gtk_entry_completion_set_text_column()), but this can be overridden with
89 * a custom match function (see gtk_entry_completion_set_match_func()).
90 * When the user selects a completion, the content of the entry is updated.
91 * By default, the content of the entry is replaced by the text column of the
92 * model, but this can be overridden by connecting to the ::match-selected signal
93 * and updating the entry in the signal handler. Note that you should return
94 * TRUE from the signal handler to suppress the default behaviour.
95 * To add completion functionality to an entry, use gtk_entry_set_completion().
96 * In addition to regular completion matches, which will be inserted into the
97 * entry when they are selected, GtkEntryCompletion also allows to display
98 * "actions" in the popup window. Their appearance is similar to menuitems,
99 * to differentiate them clearly from completion strings. When an action is
100 * selected, the ::action-activated signal is emitted.
102 private import gobject
.ObjectG
;
103 public class EntryCompletion
: ObjectG
106 /** the main Gtk struct */
107 protected GtkEntryCompletion
* gtkEntryCompletion
;
110 public GtkEntryCompletion
* getEntryCompletionStruct()
112 return gtkEntryCompletion
;
116 /** the main Gtk struct as a void* */
117 protected void* getStruct()
119 return cast(void*)gtkEntryCompletion
;
123 * Sets our main struct and passes it to the parent class
125 public this (GtkEntryCompletion
* gtkEntryCompletion
)
129 if ( gtkEntryCompletion
is null )
134 Stdout("struct gtkEntryCompletion is null on constructor").newline
;
138 printf("struct gtkEntryCompletion is null on constructor");
145 assert(gtkEntryCompletion
!is null, "struct gtkEntryCompletion is null on constructor");
147 super(cast(GObject
*)gtkEntryCompletion
);
148 this.gtkEntryCompletion
= gtkEntryCompletion
;
154 // imports for the signal processing
155 private import gobject
.Signals
;
156 private import gtkc
.gdktypes
;
157 int[char[]] connectedSignals
;
159 void delegate(gint
, EntryCompletion
)[] onActionActivatedListeners
;
160 void addOnActionActivated(void delegate(gint
, EntryCompletion
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
162 if ( !("action-activated" in connectedSignals
) )
167 cast(GCallback
)&callBackActionActivated
,
171 connectedSignals
["action-activated"] = 1;
173 onActionActivatedListeners
~= dlg
;
175 extern(C
) static void callBackActionActivated(GtkEntryCompletion
* widgetStruct
, gint index
, EntryCompletion entryCompletion
)
177 bool consumed
= false;
179 foreach ( void delegate(gint
, EntryCompletion
) dlg
; entryCompletion
.onActionActivatedListeners
)
181 dlg(index
, entryCompletion
);
187 gboolean
delegate(char[], EntryCompletion
)[] onInsertPrefixListeners
;
188 void addOnInsertPrefix(gboolean
delegate(char[], EntryCompletion
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
190 if ( !("insert-prefix" in connectedSignals
) )
195 cast(GCallback
)&callBackInsertPrefix
,
199 connectedSignals
["insert-prefix"] = 1;
201 onInsertPrefixListeners
~= dlg
;
203 extern(C
) static void callBackInsertPrefix(GtkEntryCompletion
* widgetStruct
, gchar
* prefix
, EntryCompletion entryCompletion
)
205 bool consumed
= false;
207 foreach ( gboolean
delegate(char[], EntryCompletion
) dlg
; entryCompletion
.onInsertPrefixListeners
)
209 dlg(Str
.toString(prefix
), entryCompletion
);
215 gboolean
delegate(TreeModel
, GtkTreeIter
*, EntryCompletion
)[] onMatchSelectedListeners
;
216 void addOnMatchSelected(gboolean
delegate(TreeModel
, GtkTreeIter
*, EntryCompletion
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
218 if ( !("match-selected" in connectedSignals
) )
223 cast(GCallback
)&callBackMatchSelected
,
227 connectedSignals
["match-selected"] = 1;
229 onMatchSelectedListeners
~= dlg
;
231 extern(C
) static void callBackMatchSelected(GtkEntryCompletion
* widgetStruct
, GtkTreeModel
* model
, GtkTreeIter
* iter
, EntryCompletion entryCompletion
)
233 bool consumed
= false;
235 foreach ( gboolean
delegate(TreeModel
, GtkTreeIter
*, EntryCompletion
) dlg
; entryCompletion
.onMatchSelectedListeners
)
237 dlg(new TreeModel(model
), iter
, entryCompletion
);
247 * Creates a new GtkEntryCompletion object.
249 * A newly created GtkEntryCompletion object.
254 // GtkEntryCompletion* gtk_entry_completion_new (void);
255 this(cast(GtkEntryCompletion
*)gtk_entry_completion_new() );
259 * Gets the entry completion has been attached to.
261 * A GtkEntryCompletion.
263 * The entry completion has been attached to.
266 public Widget
getEntry()
268 // GtkWidget* gtk_entry_completion_get_entry (GtkEntryCompletion *completion);
269 return new Widget( gtk_entry_completion_get_entry(gtkEntryCompletion
) );
273 * Sets the model for a GtkEntryCompletion. If completion already has
274 * a model set, it will remove it before setting the new model.
275 * If model is NULL, then it will unset the model.
277 * A GtkEntryCompletion.
282 public void setModel(TreeModel model
)
284 // void gtk_entry_completion_set_model (GtkEntryCompletion *completion, GtkTreeModel *model);
285 gtk_entry_completion_set_model(gtkEntryCompletion
, (model
is null) ?
null : model
.getTreeModelStruct());
289 * Returns the model the GtkEntryCompletion is using as data source.
290 * Returns NULL if the model is unset.
292 * A GtkEntryCompletion.
294 * A GtkTreeModel, or NULL if none is currently being used.
297 public TreeModel
getModel()
299 // GtkTreeModel* gtk_entry_completion_get_model (GtkEntryCompletion *completion);
300 return new TreeModel( gtk_entry_completion_get_model(gtkEntryCompletion
) );
304 * Sets the match function for completion to be func. The match function
305 * is used to determine if a row should or should not be in the completion
308 * A GtkEntryCompletion.
310 * The GtkEntryCompletionMatchFunc to use.
312 * The user data for func.
314 * Destroy notifier for func_data.
317 public void setMatchFunc(GtkEntryCompletionMatchFunc func
, void* funcData
, GDestroyNotify funcNotify
)
319 // void gtk_entry_completion_set_match_func (GtkEntryCompletion *completion, GtkEntryCompletionMatchFunc func, gpointer func_data, GDestroyNotify func_notify);
320 gtk_entry_completion_set_match_func(gtkEntryCompletion
, func
, funcData
, funcNotify
);
324 * Requires the length of the search key for completion to be at least
325 * length. This is useful for long lists, where completing using a small
326 * key takes a lot of time and will come up with meaningless results anyway
327 * (ie, a too large dataset).
329 * A GtkEntryCompletion.
331 * The minimum length of the key in order to start completing.
334 public void setMinimumKeyLength(int length
)
336 // void gtk_entry_completion_set_minimum_key_length (GtkEntryCompletion *completion, gint length);
337 gtk_entry_completion_set_minimum_key_length(gtkEntryCompletion
, length
);
341 * Returns the minimum key length as set for completion.
343 * A GtkEntryCompletion.
345 * The currently used minimum key length.
348 public int getMinimumKeyLength()
350 // gint gtk_entry_completion_get_minimum_key_length (GtkEntryCompletion *completion);
351 return gtk_entry_completion_get_minimum_key_length(gtkEntryCompletion
);
355 * Requests a completion operation, or in other words a refiltering of the
356 * current list with completions, using the current key. The completion list
357 * view will be updated accordingly.
359 * A GtkEntryCompletion.
362 public void complete()
364 // void gtk_entry_completion_complete (GtkEntryCompletion *completion);
365 gtk_entry_completion_complete(gtkEntryCompletion
);
369 * Requests a prefix insertion.
371 * a GtkEntryCompletion
374 public void insertPrefix()
376 // void gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion);
377 gtk_entry_completion_insert_prefix(gtkEntryCompletion
);
381 * Inserts an action in completion's action item list at position index_
382 * with text text. If you want the action item to have markup, use
383 * gtk_entry_completion_insert_action_markup().
385 * A GtkEntryCompletion.
387 * The index of the item to insert.
389 * Text of the item to insert.
392 public void insertActionText(int index
, char[] text
)
394 // void gtk_entry_completion_insert_action_text (GtkEntryCompletion *completion, gint index_, const gchar *text);
395 gtk_entry_completion_insert_action_text(gtkEntryCompletion
, index
, Str
.toStringz(text
));
399 * Inserts an action in completion's action item list at position index_
400 * with markup markup.
402 * A GtkEntryCompletion.
404 * The index of the item to insert.
406 * Markup of the item to insert.
409 public void insertActionMarkup(int index
, char[] markup
)
411 // void gtk_entry_completion_insert_action_markup (GtkEntryCompletion *completion, gint index_, const gchar *markup);
412 gtk_entry_completion_insert_action_markup(gtkEntryCompletion
, index
, Str
.toStringz(markup
));
416 * Deletes the action at index_ from completion's action list.
418 * A GtkEntryCompletion.
420 * The index of the item to Delete.
423 public void deleteAction(int index
)
425 // void gtk_entry_completion_delete_action (GtkEntryCompletion *completion, gint index_);
426 gtk_entry_completion_delete_action(gtkEntryCompletion
, index
);
430 * Convenience function for setting up the most used case of this code: a
431 * completion list with just strings. This function will set up completion
432 * to have a list displaying all (and just) strings in the completion list,
433 * and to get those strings from column in the model of completion.
434 * This functions creates and adds a GtkCellRendererText for the selected
435 * column. If you need to set the text column, but don't want the cell
436 * renderer, use g_object_set() to set the ::text_column property directly.
438 * A GtkEntryCompletion.
440 * The column in the model of completion to get strings from.
443 public void setTextColumn(int column
)
445 // void gtk_entry_completion_set_text_column (GtkEntryCompletion *completion, gint column);
446 gtk_entry_completion_set_text_column(gtkEntryCompletion
, column
);
450 * Returns the column in the model of completion to get strings from.
452 * a GtkEntryCompletion
454 * the column containing the strings
457 public int getTextColumn()
459 // gint gtk_entry_completion_get_text_column (GtkEntryCompletion *completion);
460 return gtk_entry_completion_get_text_column(gtkEntryCompletion
);
464 * Sets whether the common prefix of the possible completions should
465 * be automatically inserted in the entry.
467 * a GtkEntryCompletion
469 * TRUE to do inline completion
472 public void setInlineCompletion(int inlineCompletion
)
474 // void gtk_entry_completion_set_inline_completion (GtkEntryCompletion *completion, gboolean inline_completion);
475 gtk_entry_completion_set_inline_completion(gtkEntryCompletion
, inlineCompletion
);
479 * Returns whether the common prefix of the possible completions should
480 * be automatically inserted in the entry.
482 * a GtkEntryCompletion
484 * TRUE if inline completion is turned on
487 public int getInlineCompletion()
489 // gboolean gtk_entry_completion_get_inline_completion (GtkEntryCompletion *completion);
490 return gtk_entry_completion_get_inline_completion(gtkEntryCompletion
);
494 * Sets whether the completions should be presented in a popup window.
496 * a GtkEntryCompletion
498 * TRUE to do popup completion
501 public void setPopupCompletion(int popupCompletion
)
503 // void gtk_entry_completion_set_popup_completion (GtkEntryCompletion *completion, gboolean popup_completion);
504 gtk_entry_completion_set_popup_completion(gtkEntryCompletion
, popupCompletion
);
508 * Returns whether the completions should be presented in a popup window.
510 * a GtkEntryCompletion
512 * TRUE if popup completion is turned on
515 public int getPopupCompletion()
517 // gboolean gtk_entry_completion_get_popup_completion (GtkEntryCompletion *completion);
518 return gtk_entry_completion_get_popup_completion(gtkEntryCompletion
);
522 * Sets whether the completion popup window will be resized to be the same
523 * width as the entry.
525 * a GtkEntryCompletion
527 * TRUE to make the width of the popup the same as the entry
530 public void setPopupSetWidth(int popupSetWidth
)
532 // void gtk_entry_completion_set_popup_set_width (GtkEntryCompletion *completion, gboolean popup_set_width);
533 gtk_entry_completion_set_popup_set_width(gtkEntryCompletion
, popupSetWidth
);
537 * Returns whether the completion popup window will be resized to the
538 * width of the entry.
540 * a GtkEntryCompletion
542 * TRUE if the popup window will be resized to the width of
546 public int getPopupSetWidth()
548 // gboolean gtk_entry_completion_get_popup_set_width (GtkEntryCompletion *completion);
549 return gtk_entry_completion_get_popup_set_width(gtkEntryCompletion
);
553 * Sets whether the completion popup window will appear even if there is
554 * only a single match. You may want to set this to FALSE if you
558 * a GtkEntryCompletion
559 * popup_single_match:
560 * TRUE if the popup should appear even for a single
564 public void setPopupSingleMatch(int popupSingleMatch
)
566 // void gtk_entry_completion_set_popup_single_match (GtkEntryCompletion *completion, gboolean popup_single_match);
567 gtk_entry_completion_set_popup_single_match(gtkEntryCompletion
, popupSingleMatch
);
571 * Returns whether the completion popup window will appear even if there is
572 * only a single match.
574 * a GtkEntryCompletion
576 * TRUE if the popup window will appear regardless of the
580 * The "inline-completion" property
581 * "inline-completion" gboolean : Read / Write
582 * Determines whether the common prefix of the possible completions
583 * should be inserted automatically in the entry. Note that this
584 * requires text-column to be set, even if you are using a custom
586 * Default value: FALSE
589 public int getPopupSingleMatch()
591 // gboolean gtk_entry_completion_get_popup_single_match (GtkEntryCompletion *completion);
592 return gtk_entry_completion_get_popup_single_match(gtkEntryCompletion
);