1 /* gtkentrycompletion.c
2 * Copyright (C) 2003 Kristian Rietveld <kris@gtk.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library 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 GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 #include "gtkentrycompletion.h"
22 #include "gtkentryprivate.h"
23 #include "gtkcelllayout.h"
26 #include "gtkcellrenderertext.h"
28 #include "gtktreeselection.h"
29 #include "gtktreeview.h"
30 #include "gtkscrolledwindow.h"
32 #include "gtkwindow.h"
35 #include "gtksignal.h"
36 #include "gtkmarshalers.h"
38 #include "gtkprivate.h"
58 PROP_MINIMUM_KEY_LENGTH,
60 PROP_INLINE_COMPLETION,
61 PROP_POPUP_COMPLETION,
63 PROP_POPUP_SINGLE_MATCH
66 #define GTK_ENTRY_COMPLETION_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ENTRY_COMPLETION, GtkEntryCompletionPrivate))
68 static void gtk_entry_completion_cell_layout_init (GtkCellLayoutIface *iface);
69 static void gtk_entry_completion_set_property (GObject *object,
73 static void gtk_entry_completion_get_property (GObject *object,
77 static void gtk_entry_completion_finalize (GObject *object);
79 static void gtk_entry_completion_pack_start (GtkCellLayout *cell_layout,
80 GtkCellRenderer *cell,
82 static void gtk_entry_completion_pack_end (GtkCellLayout *cell_layout,
83 GtkCellRenderer *cell,
85 static void gtk_entry_completion_clear (GtkCellLayout *cell_layout);
86 static void gtk_entry_completion_add_attribute (GtkCellLayout *cell_layout,
87 GtkCellRenderer *cell,
88 const char *attribute,
90 static void gtk_entry_completion_set_cell_data_func (GtkCellLayout *cell_layout,
91 GtkCellRenderer *cell,
92 GtkCellLayoutDataFunc func,
94 GDestroyNotify destroy);
95 static void gtk_entry_completion_clear_attributes (GtkCellLayout *cell_layout,
96 GtkCellRenderer *cell);
97 static void gtk_entry_completion_reorder (GtkCellLayout *cell_layout,
98 GtkCellRenderer *cell,
101 static gboolean gtk_entry_completion_visible_func (GtkTreeModel *model,
104 static gboolean gtk_entry_completion_popup_key_press (GtkWidget *widget,
107 static gboolean gtk_entry_completion_popup_button_press (GtkWidget *widget,
108 GdkEventButton *event,
110 static gboolean gtk_entry_completion_list_button_press (GtkWidget *widget,
111 GdkEventButton *event,
113 static gboolean gtk_entry_completion_action_button_press (GtkWidget *widget,
114 GdkEventButton *event,
116 static void gtk_entry_completion_selection_changed (GtkTreeSelection *selection,
118 static gboolean gtk_entry_completion_list_enter_notify (GtkWidget *widget,
119 GdkEventCrossing *event,
121 static gboolean gtk_entry_completion_list_motion_notify (GtkWidget *widget,
122 GdkEventMotion *event,
124 static void gtk_entry_completion_insert_action (GtkEntryCompletion *completion,
128 static void gtk_entry_completion_action_data_func (GtkTreeViewColumn *tree_column,
129 GtkCellRenderer *cell,
134 static gboolean gtk_entry_completion_match_selected (GtkEntryCompletion *completion,
137 static gboolean gtk_entry_completion_real_insert_prefix (GtkEntryCompletion *completion,
138 const gchar *prefix);
140 static guint entry_completion_signals[LAST_SIGNAL] = { 0 };
142 G_DEFINE_TYPE_WITH_CODE (GtkEntryCompletion, gtk_entry_completion, G_TYPE_OBJECT,
143 G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT,
144 gtk_entry_completion_cell_layout_init))
147 gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
149 GObjectClass *object_class;
151 object_class = (GObjectClass *)klass;
153 object_class->set_property = gtk_entry_completion_set_property;
154 object_class->get_property = gtk_entry_completion_get_property;
155 object_class->finalize = gtk_entry_completion_finalize;
157 klass->match_selected = gtk_entry_completion_match_selected;
158 klass->insert_prefix = gtk_entry_completion_real_insert_prefix;
161 * GtkEntryCompletion::insert-prefix:
162 * @widget: the object which received the signal
163 * @prefix: the common prefix of all possible completions
165 * Gets emitted when the inline autocompletion is triggered.
166 * The default behaviour is to make the entry display the
167 * whole prefix and select the newly inserted part.
169 * Applications may connect to this signal in order to insert only a
170 * smaller part of the @prefix into the entry - e.g. the entry used in
171 * the #GtkFileChooser inserts only the part of the prefix up to the
174 * Return value: %TRUE if the signal has been handled
178 entry_completion_signals[INSERT_PREFIX] =
179 g_signal_new (I_("insert_prefix"),
180 G_TYPE_FROM_CLASS (klass),
182 G_STRUCT_OFFSET (GtkEntryCompletionClass, insert_prefix),
183 _gtk_boolean_handled_accumulator, NULL,
184 _gtk_marshal_BOOLEAN__STRING,
189 * GtkEntryCompletion::match-selected:
190 * @widget: the object which received the signal
191 * @model: the #GtkTreeModel containing the matches
192 * @iter: a #GtkTreeIter positioned at the selected match
194 * Gets emitted when a match from the list is selected.
195 * The default behaviour is to replace the contents of the
196 * entry with the contents of the text column in the row
197 * pointed to by @iter.
199 * Return value: %TRUE if the signal has been handled
203 entry_completion_signals[MATCH_SELECTED] =
204 g_signal_new (I_("match_selected"),
205 G_TYPE_FROM_CLASS (klass),
207 G_STRUCT_OFFSET (GtkEntryCompletionClass, match_selected),
208 _gtk_boolean_handled_accumulator, NULL,
209 _gtk_marshal_BOOLEAN__OBJECT_BOXED,
215 * GtkEntryCompletion::action-activated:
216 * @widget: the object which received the signal
217 * @index: the index of the activated action
219 * Gets emitted when an action is activated.
223 entry_completion_signals[ACTION_ACTIVATED] =
224 g_signal_new (I_("action_activated"),
225 G_TYPE_FROM_CLASS (klass),
227 G_STRUCT_OFFSET (GtkEntryCompletionClass, action_activated),
229 _gtk_marshal_NONE__INT,
233 g_object_class_install_property (object_class,
235 g_param_spec_object ("model",
236 P_("Completion Model"),
237 P_("The model to find matches in"),
239 GTK_PARAM_READWRITE));
240 g_object_class_install_property (object_class,
241 PROP_MINIMUM_KEY_LENGTH,
242 g_param_spec_int ("minimum-key-length",
243 P_("Minimum Key Length"),
244 P_("Minimum length of the search key in order to look up matches"),
248 GTK_PARAM_READWRITE));
250 * GtkEntryCompletion:text-column:
252 * The column of the model containing the strings.
256 g_object_class_install_property (object_class,
258 g_param_spec_int ("text-column",
260 P_("The column of the model containing the strings."),
264 GTK_PARAM_READWRITE));
267 * GtkEntryCompletion:inline-completion:
269 * Determines whether the common prefix of the possible completions
270 * should be inserted automatically in the entry. Note that this
271 * requires text-column to be set, even if you are using a custom
276 g_object_class_install_property (object_class,
277 PROP_INLINE_COMPLETION,
278 g_param_spec_boolean ("inline-completion",
279 P_("Inline completion"),
280 P_("Whether the common prefix should be inserted automatically"),
282 GTK_PARAM_READWRITE));
284 * GtkEntryCompletion:popup-completion:
286 * Determines whether the possible completions should be
287 * shown in a popup window.
291 g_object_class_install_property (object_class,
292 PROP_POPUP_COMPLETION,
293 g_param_spec_boolean ("popup-completion",
294 P_("Popup completion"),
295 P_("Whether the completions should be shown in a popup window"),
297 GTK_PARAM_READWRITE));
300 * GtkEntryCompletion:popup-set-width:
302 * Determines whether the completions popup window will be
303 * resized to the width of the entry.
307 g_object_class_install_property (object_class,
308 PROP_POPUP_SET_WIDTH,
309 g_param_spec_boolean ("popup-set-width",
310 P_("Popup set width"),
311 P_("If TRUE, the popup window will have the same size as the entry"),
313 GTK_PARAM_READWRITE));
316 * GtkEntryCompletion:popup-single-match:
318 * Determines whether the completions popup window will shown
319 * for a single possible completion. You probably want to set
320 * this to %FALSE if you are using
321 * <link linkend="GtkEntryCompletion--inline-completion">inline
326 g_object_class_install_property (object_class,
327 PROP_POPUP_SINGLE_MATCH,
328 g_param_spec_boolean ("popup-single-match",
329 P_("Popup single match"),
330 P_("If TRUE, the popup window will appear for a single match."),
332 GTK_PARAM_READWRITE));
334 g_type_class_add_private (object_class, sizeof (GtkEntryCompletionPrivate));
338 gtk_entry_completion_cell_layout_init (GtkCellLayoutIface *iface)
340 iface->pack_start = gtk_entry_completion_pack_start;
341 iface->pack_end = gtk_entry_completion_pack_end;
342 iface->clear = gtk_entry_completion_clear;
343 iface->add_attribute = gtk_entry_completion_add_attribute;
344 iface->set_cell_data_func = gtk_entry_completion_set_cell_data_func;
345 iface->clear_attributes = gtk_entry_completion_clear_attributes;
346 iface->reorder = gtk_entry_completion_reorder;
350 gtk_entry_completion_init (GtkEntryCompletion *completion)
352 GtkCellRenderer *cell;
353 GtkTreeSelection *sel;
354 GtkEntryCompletionPrivate *priv;
355 GtkWidget *popup_frame;
357 /* yes, also priv, need to keep the code readable */
358 priv = completion->priv = GTK_ENTRY_COMPLETION_GET_PRIVATE (completion);
360 priv->minimum_key_length = 1;
361 priv->text_column = -1;
362 priv->has_completion = FALSE;
363 priv->inline_completion = FALSE;
364 priv->popup_completion = TRUE;
365 priv->popup_set_width = TRUE;
366 priv->popup_single_match = TRUE;
369 priv->filter_model = NULL;
371 priv->tree_view = gtk_tree_view_new ();
372 g_signal_connect (priv->tree_view, "button_press_event",
373 G_CALLBACK (gtk_entry_completion_list_button_press),
375 g_signal_connect (priv->tree_view, "enter_notify_event",
376 G_CALLBACK (gtk_entry_completion_list_enter_notify),
378 g_signal_connect (priv->tree_view, "motion_notify_event",
379 G_CALLBACK (gtk_entry_completion_list_motion_notify),
381 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->tree_view), FALSE);
382 gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (priv->tree_view), TRUE);
384 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
385 gtk_tree_selection_set_mode (sel, GTK_SELECTION_SINGLE);
386 gtk_tree_selection_unselect_all (sel);
387 g_signal_connect (sel, "changed",
388 G_CALLBACK (gtk_entry_completion_selection_changed),
390 priv->first_sel_changed = TRUE;
392 priv->column = gtk_tree_view_column_new ();
393 gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), priv->column);
395 priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
396 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
398 GTK_POLICY_AUTOMATIC);
399 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->scrolled_window),
402 /* a nasty hack to get the completions treeview to size nicely */
403 gtk_widget_set_size_request (GTK_SCROLLED_WINDOW (priv->scrolled_window)->vscrollbar, -1, 0);
406 priv->actions = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
409 gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->actions));
410 g_object_ref_sink (priv->action_view);
411 g_signal_connect (priv->action_view, "button_press_event",
412 G_CALLBACK (gtk_entry_completion_action_button_press),
414 g_signal_connect (priv->action_view, "enter_notify_event",
415 G_CALLBACK (gtk_entry_completion_list_enter_notify),
417 g_signal_connect (priv->action_view, "motion_notify_event",
418 G_CALLBACK (gtk_entry_completion_list_motion_notify),
420 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->action_view), FALSE);
421 gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (priv->action_view), TRUE);
423 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->action_view));
424 gtk_tree_selection_set_mode (sel, GTK_SELECTION_SINGLE);
425 gtk_tree_selection_unselect_all (sel);
427 cell = gtk_cell_renderer_text_new ();
428 gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (priv->action_view),
431 gtk_entry_completion_action_data_func,
436 priv->popup_window = gtk_window_new (GTK_WINDOW_POPUP);
437 gtk_window_set_resizable (GTK_WINDOW (priv->popup_window), FALSE);
438 g_signal_connect (priv->popup_window, "key_press_event",
439 G_CALLBACK (gtk_entry_completion_popup_key_press),
441 g_signal_connect (priv->popup_window, "button_press_event",
442 G_CALLBACK (gtk_entry_completion_popup_button_press),
445 popup_frame = gtk_frame_new (NULL);
446 gtk_frame_set_shadow_type (GTK_FRAME (popup_frame),
447 GTK_SHADOW_ETCHED_IN);
448 gtk_widget_show (popup_frame);
449 gtk_container_add (GTK_CONTAINER (priv->popup_window), popup_frame);
451 priv->vbox = gtk_vbox_new (FALSE, 0);
452 gtk_container_add (GTK_CONTAINER (popup_frame), priv->vbox);
454 gtk_container_add (GTK_CONTAINER (priv->scrolled_window), priv->tree_view);
455 gtk_box_pack_start (GTK_BOX (priv->vbox), priv->scrolled_window,
458 /* we don't want to see the action treeview when no actions have
459 * been inserted, so we pack the action treeview after the first
460 * action has been added
465 gtk_entry_completion_set_property (GObject *object,
470 GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (object);
471 GtkEntryCompletionPrivate *priv = completion->priv;
476 gtk_entry_completion_set_model (completion,
477 g_value_get_object (value));
480 case PROP_MINIMUM_KEY_LENGTH:
481 gtk_entry_completion_set_minimum_key_length (completion,
482 g_value_get_int (value));
485 case PROP_TEXT_COLUMN:
486 priv->text_column = g_value_get_int (value);
489 case PROP_INLINE_COMPLETION:
490 priv->inline_completion = g_value_get_boolean (value);
493 case PROP_POPUP_COMPLETION:
494 priv->popup_completion = g_value_get_boolean (value);
497 case PROP_POPUP_SET_WIDTH:
498 priv->popup_set_width = g_value_get_boolean (value);
501 case PROP_POPUP_SINGLE_MATCH:
502 priv->popup_single_match = g_value_get_boolean (value);
506 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
512 gtk_entry_completion_get_property (GObject *object,
517 GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (object);
522 g_value_set_object (value,
523 gtk_entry_completion_get_model (completion));
526 case PROP_MINIMUM_KEY_LENGTH:
527 g_value_set_int (value, gtk_entry_completion_get_minimum_key_length (completion));
530 case PROP_TEXT_COLUMN:
531 g_value_set_int (value, gtk_entry_completion_get_text_column (completion));
534 case PROP_INLINE_COMPLETION:
535 g_value_set_boolean (value, gtk_entry_completion_get_inline_completion (completion));
538 case PROP_POPUP_COMPLETION:
539 g_value_set_boolean (value, gtk_entry_completion_get_popup_completion (completion));
542 case PROP_POPUP_SET_WIDTH:
543 g_value_set_boolean (value, gtk_entry_completion_get_popup_set_width (completion));
546 case PROP_POPUP_SINGLE_MATCH:
547 g_value_set_boolean (value, gtk_entry_completion_get_popup_single_match (completion));
551 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
557 gtk_entry_completion_finalize (GObject *object)
559 GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (object);
560 GtkEntryCompletionPrivate *priv = completion->priv;
563 gtk_widget_destroy (priv->tree_view);
566 gtk_entry_set_completion (GTK_ENTRY (priv->entry), NULL);
569 g_object_unref (priv->actions, priv->actions);
570 if (priv->action_view)
571 g_object_unref (priv->action_view);
573 if (priv->case_normalized_key)
574 g_free (priv->case_normalized_key);
576 if (priv->popup_window)
577 gtk_widget_destroy (priv->popup_window);
579 if (priv->match_notify)
580 (* priv->match_notify) (priv->match_data);
582 G_OBJECT_CLASS (gtk_entry_completion_parent_class)->finalize (object);
585 /* implement cell layout interface */
587 gtk_entry_completion_pack_start (GtkCellLayout *cell_layout,
588 GtkCellRenderer *cell,
591 GtkEntryCompletionPrivate *priv;
593 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (cell_layout));
595 priv = GTK_ENTRY_COMPLETION_GET_PRIVATE (cell_layout);
597 gtk_tree_view_column_pack_start (priv->column, cell, expand);
601 gtk_entry_completion_pack_end (GtkCellLayout *cell_layout,
602 GtkCellRenderer *cell,
605 GtkEntryCompletionPrivate *priv;
607 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (cell_layout));
609 priv = GTK_ENTRY_COMPLETION_GET_PRIVATE (cell_layout);
611 gtk_tree_view_column_pack_end (priv->column, cell, expand);
615 gtk_entry_completion_clear (GtkCellLayout *cell_layout)
617 GtkEntryCompletionPrivate *priv;
619 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (cell_layout));
621 priv = GTK_ENTRY_COMPLETION_GET_PRIVATE (cell_layout);
623 gtk_tree_view_column_clear (priv->column);
627 gtk_entry_completion_add_attribute (GtkCellLayout *cell_layout,
628 GtkCellRenderer *cell,
629 const gchar *attribute,
632 GtkEntryCompletionPrivate *priv;
634 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (cell_layout));
636 priv = GTK_ENTRY_COMPLETION_GET_PRIVATE (cell_layout);
638 gtk_tree_view_column_add_attribute (priv->column, cell, attribute, column);
642 gtk_entry_completion_set_cell_data_func (GtkCellLayout *cell_layout,
643 GtkCellRenderer *cell,
644 GtkCellLayoutDataFunc func,
646 GDestroyNotify destroy)
648 GtkEntryCompletionPrivate *priv;
650 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (cell_layout));
652 priv = GTK_ENTRY_COMPLETION_GET_PRIVATE (cell_layout);
654 gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (priv->column),
655 cell, func, func_data, destroy);
659 gtk_entry_completion_clear_attributes (GtkCellLayout *cell_layout,
660 GtkCellRenderer *cell)
662 GtkEntryCompletionPrivate *priv;
664 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (cell_layout));
666 priv = GTK_ENTRY_COMPLETION_GET_PRIVATE (cell_layout);
668 gtk_tree_view_column_clear_attributes (priv->column, cell);
672 gtk_entry_completion_reorder (GtkCellLayout *cell_layout,
673 GtkCellRenderer *cell,
676 GtkEntryCompletionPrivate *priv;
678 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (cell_layout));
680 priv = GTK_ENTRY_COMPLETION_GET_PRIVATE (cell_layout);
682 gtk_cell_layout_reorder (GTK_CELL_LAYOUT (priv->column), cell, position);
685 /* all those callbacks */
687 gtk_entry_completion_default_completion_func (GtkEntryCompletion *completion,
693 gchar *normalized_string;
694 gchar *case_normalized_string;
696 gboolean ret = FALSE;
700 model = gtk_tree_model_filter_get_model (completion->priv->filter_model);
702 g_return_val_if_fail (gtk_tree_model_get_column_type (model, completion->priv->text_column) == G_TYPE_STRING,
705 gtk_tree_model_get (model, iter,
706 completion->priv->text_column, &item,
711 normalized_string = g_utf8_normalize (item, -1, G_NORMALIZE_ALL);
712 case_normalized_string = g_utf8_casefold (normalized_string, -1);
714 if (!strncmp (key, case_normalized_string, strlen (key)))
718 g_free (normalized_string);
719 g_free (case_normalized_string);
726 gtk_entry_completion_visible_func (GtkTreeModel *model,
730 gboolean ret = FALSE;
732 GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (data);
734 if (!completion->priv->case_normalized_key)
737 if (completion->priv->match_func)
738 ret = (* completion->priv->match_func) (completion,
739 completion->priv->case_normalized_key,
741 completion->priv->match_data);
742 else if (completion->priv->text_column >= 0)
743 ret = gtk_entry_completion_default_completion_func (completion,
744 completion->priv->case_normalized_key,
752 gtk_entry_completion_popup_key_press (GtkWidget *widget,
756 GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
758 if (!GTK_WIDGET_MAPPED (completion->priv->popup_window))
761 /* propagate event to the entry */
762 gtk_widget_event (completion->priv->entry, (GdkEvent *)event);
768 gtk_entry_completion_popup_button_press (GtkWidget *widget,
769 GdkEventButton *event,
772 GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
774 if (!GTK_WIDGET_MAPPED (completion->priv->popup_window))
777 /* if we come here, it's usually time to popdown */
778 _gtk_entry_completion_popdown (completion);
784 gtk_entry_completion_list_button_press (GtkWidget *widget,
785 GdkEventButton *event,
788 GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
789 GtkTreePath *path = NULL;
791 if (!GTK_WIDGET_MAPPED (completion->priv->popup_window))
794 if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
796 &path, NULL, NULL, NULL))
801 gtk_tree_model_get_iter (GTK_TREE_MODEL (completion->priv->filter_model),
803 gtk_tree_path_free (path);
805 g_signal_handler_block (completion->priv->entry,
806 completion->priv->changed_id);
807 g_signal_emit (completion, entry_completion_signals[MATCH_SELECTED],
808 0, GTK_TREE_MODEL (completion->priv->filter_model),
810 g_signal_handler_unblock (completion->priv->entry,
811 completion->priv->changed_id);
813 _gtk_entry_completion_popdown (completion);
822 gtk_entry_completion_action_button_press (GtkWidget *widget,
823 GdkEventButton *event,
826 GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
827 GtkTreePath *path = NULL;
829 if (!GTK_WIDGET_MAPPED (completion->priv->popup_window))
832 if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
834 &path, NULL, NULL, NULL))
836 g_signal_emit (completion, entry_completion_signals[ACTION_ACTIVATED],
837 0, gtk_tree_path_get_indices (path)[0]);
838 gtk_tree_path_free (path);
840 _gtk_entry_completion_popdown (completion);
848 gtk_entry_completion_action_data_func (GtkTreeViewColumn *tree_column,
849 GtkCellRenderer *cell,
854 gchar *string = NULL;
857 gtk_tree_model_get (model, iter,
880 gtk_entry_completion_selection_changed (GtkTreeSelection *selection,
883 GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (data);
885 if (completion->priv->first_sel_changed)
887 completion->priv->first_sel_changed = FALSE;
888 if (gtk_widget_is_focus (completion->priv->tree_view))
889 gtk_tree_selection_unselect_all (selection);
896 * gtk_entry_completion_new:
898 * Creates a new #GtkEntryCompletion object.
900 * Return value: A newly created #GtkEntryCompletion object.
905 gtk_entry_completion_new (void)
907 GtkEntryCompletion *completion;
909 completion = g_object_new (GTK_TYPE_ENTRY_COMPLETION, NULL);
915 * gtk_entry_completion_get_entry:
916 * @completion: A #GtkEntryCompletion.
918 * Gets the entry @completion has been attached to.
920 * Return value: The entry @completion has been attached to.
925 gtk_entry_completion_get_entry (GtkEntryCompletion *completion)
927 g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), NULL);
929 return completion->priv->entry;
933 * gtk_entry_completion_set_model:
934 * @completion: A #GtkEntryCompletion.
935 * @model: The #GtkTreeModel.
937 * Sets the model for a #GtkEntryCompletion. If @completion already has
938 * a model set, it will remove it before setting the new model.
939 * If model is %NULL, then it will unset the model.
944 gtk_entry_completion_set_model (GtkEntryCompletion *completion,
947 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
948 g_return_if_fail (model == NULL || GTK_IS_TREE_MODEL (model));
952 gtk_tree_view_set_model (GTK_TREE_VIEW (completion->priv->tree_view),
954 _gtk_entry_completion_popdown (completion);
955 completion->priv->filter_model = NULL;
959 /* code will unref the old filter model (if any) */
960 completion->priv->filter_model =
961 GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (model, NULL));
962 gtk_tree_model_filter_set_visible_func (completion->priv->filter_model,
963 gtk_entry_completion_visible_func,
967 gtk_tree_view_set_model (GTK_TREE_VIEW (completion->priv->tree_view),
968 GTK_TREE_MODEL (completion->priv->filter_model));
969 g_object_unref (completion->priv->filter_model);
971 g_object_notify (G_OBJECT (completion), "model");
973 if (GTK_WIDGET_VISIBLE (completion->priv->popup_window))
974 _gtk_entry_completion_resize_popup (completion);
978 * gtk_entry_completion_get_model:
979 * @completion: A #GtkEntryCompletion.
981 * Returns the model the #GtkEntryCompletion is using as data source.
982 * Returns %NULL if the model is unset.
984 * Return value: A #GtkTreeModel, or %NULL if none is currently being used.
989 gtk_entry_completion_get_model (GtkEntryCompletion *completion)
991 g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), NULL);
993 if (!completion->priv->filter_model)
996 return gtk_tree_model_filter_get_model (completion->priv->filter_model);
1000 * gtk_entry_completion_set_match_func:
1001 * @completion: A #GtkEntryCompletion.
1002 * @func: The #GtkEntryCompletionMatchFunc to use.
1003 * @func_data: The user data for @func.
1004 * @func_notify: Destroy notifier for @func_data.
1006 * Sets the match function for @completion to be @func. The match function
1007 * is used to determine if a row should or should not be in the completion
1013 gtk_entry_completion_set_match_func (GtkEntryCompletion *completion,
1014 GtkEntryCompletionMatchFunc func,
1016 GDestroyNotify func_notify)
1018 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
1020 if (completion->priv->match_notify)
1021 (* completion->priv->match_notify) (completion->priv->match_data);
1023 completion->priv->match_func = func;
1024 completion->priv->match_data = func_data;
1025 completion->priv->match_notify = func_notify;
1029 * gtk_entry_completion_set_minimum_key_length:
1030 * @completion: A #GtkEntryCompletion.
1031 * @length: The minimum length of the key in order to start completing.
1033 * Requires the length of the search key for @completion to be at least
1034 * @length. This is useful for long lists, where completing using a small
1035 * key takes a lot of time and will come up with meaningless results anyway
1036 * (ie, a too large dataset).
1041 gtk_entry_completion_set_minimum_key_length (GtkEntryCompletion *completion,
1044 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
1045 g_return_if_fail (length >= 0);
1047 if (completion->priv->minimum_key_length != length)
1049 completion->priv->minimum_key_length = length;
1051 g_object_notify (G_OBJECT (completion), "minimum-key-length");
1056 * gtk_entry_completion_get_minimum_key_length:
1057 * @completion: A #GtkEntryCompletion.
1059 * Returns the minimum key length as set for @completion.
1061 * Return value: The currently used minimum key length.
1066 gtk_entry_completion_get_minimum_key_length (GtkEntryCompletion *completion)
1068 g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), 0);
1070 return completion->priv->minimum_key_length;
1074 * gtk_entry_completion_complete:
1075 * @completion: A #GtkEntryCompletion.
1077 * Requests a completion operation, or in other words a refiltering of the
1078 * current list with completions, using the current key. The completion list
1079 * view will be updated accordingly.
1084 gtk_entry_completion_complete (GtkEntryCompletion *completion)
1088 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
1090 if (!completion->priv->filter_model)
1093 if (completion->priv->case_normalized_key)
1094 g_free (completion->priv->case_normalized_key);
1096 tmp = g_utf8_normalize (gtk_entry_get_text (GTK_ENTRY (completion->priv->entry)),
1097 -1, G_NORMALIZE_ALL);
1098 completion->priv->case_normalized_key = g_utf8_casefold (tmp, -1);
1101 gtk_tree_model_filter_refilter (completion->priv->filter_model);
1103 if (GTK_WIDGET_VISIBLE (completion->priv->popup_window))
1104 _gtk_entry_completion_resize_popup (completion);
1108 gtk_entry_completion_insert_action (GtkEntryCompletion *completion,
1110 const gchar *string,
1115 gtk_list_store_insert (completion->priv->actions, &iter, index);
1116 gtk_list_store_set (completion->priv->actions, &iter,
1121 if (!completion->priv->action_view->parent)
1123 GtkTreePath *path = gtk_tree_path_new_from_indices (0, -1);
1125 gtk_tree_view_set_cursor (GTK_TREE_VIEW (completion->priv->action_view),
1127 gtk_tree_path_free (path);
1129 gtk_box_pack_start (GTK_BOX (completion->priv->vbox),
1130 completion->priv->action_view, FALSE, FALSE, 0);
1131 gtk_widget_show (completion->priv->action_view);
1136 * gtk_entry_completion_insert_action_text:
1137 * @completion: A #GtkEntryCompletion.
1138 * @index_: The index of the item to insert.
1139 * @text: Text of the item to insert.
1141 * Inserts an action in @completion's action item list at position @index_
1142 * with text @text. If you want the action item to have markup, use
1143 * gtk_entry_completion_insert_action_markup().
1148 gtk_entry_completion_insert_action_text (GtkEntryCompletion *completion,
1152 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
1153 g_return_if_fail (text != NULL);
1155 gtk_entry_completion_insert_action (completion, index_, text, FALSE);
1159 * gtk_entry_completion_insert_action_markup:
1160 * @completion: A #GtkEntryCompletion.
1161 * @index_: The index of the item to insert.
1162 * @markup: Markup of the item to insert.
1164 * Inserts an action in @completion's action item list at position @index_
1165 * with markup @markup.
1170 gtk_entry_completion_insert_action_markup (GtkEntryCompletion *completion,
1172 const gchar *markup)
1174 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
1175 g_return_if_fail (markup != NULL);
1177 gtk_entry_completion_insert_action (completion, index_, markup, TRUE);
1181 * gtk_entry_completion_delete_action:
1182 * @completion: A #GtkEntryCompletion.
1183 * @index_: The index of the item to Delete.
1185 * Deletes the action at @index_ from @completion's action list.
1190 gtk_entry_completion_delete_action (GtkEntryCompletion *completion,
1195 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
1196 g_return_if_fail (index_ >= 0);
1198 gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (completion->priv->actions),
1199 &iter, NULL, index_);
1200 gtk_list_store_remove (completion->priv->actions, &iter);
1204 * gtk_entry_completion_set_text_column:
1205 * @completion: A #GtkEntryCompletion.
1206 * @column: The column in the model of @completion to get strings from.
1208 * Convenience function for setting up the most used case of this code: a
1209 * completion list with just strings. This function will set up @completion
1210 * to have a list displaying all (and just) strings in the completion list,
1211 * and to get those strings from @column in the model of @completion.
1213 * This functions creates and adds a #GtkCellRendererText for the selected
1214 * column. If you need to set the text column, but don't want the cell
1215 * renderer, use g_object_set() to set the ::text_column property directly.
1220 gtk_entry_completion_set_text_column (GtkEntryCompletion *completion,
1223 GtkCellRenderer *cell;
1225 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
1226 g_return_if_fail (column >= 0);
1228 completion->priv->text_column = column;
1230 cell = gtk_cell_renderer_text_new ();
1231 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion),
1233 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
1237 g_object_notify (G_OBJECT (completion), "text-column");
1241 * gtk_entry_completion_get_text_column:
1242 * @completion: a #GtkEntryCompletion
1244 * Returns the column in the model of @completion to get strings from.
1246 * Return value: the column containing the strings
1251 gtk_entry_completion_get_text_column (GtkEntryCompletion *completion)
1253 g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), -1);
1255 return completion->priv->text_column;
1261 gtk_entry_completion_list_enter_notify (GtkWidget *widget,
1262 GdkEventCrossing *event,
1265 GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (data);
1267 return completion->priv->ignore_enter;
1271 gtk_entry_completion_list_motion_notify (GtkWidget *widget,
1272 GdkEventMotion *event,
1275 GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (data);
1277 completion->priv->ignore_enter = FALSE;
1283 /* some nasty size requisition */
1285 _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
1288 gint matches, items, height, x_border, y_border;
1291 gint vertical_separator;
1292 GdkRectangle monitor;
1293 GtkRequisition popup_req;
1294 GtkRequisition entry_req;
1299 if (!completion->priv->entry->window)
1302 gdk_window_get_origin (completion->priv->entry->window, &x, &y);
1303 _gtk_entry_get_borders (GTK_ENTRY (completion->priv->entry), &x_border, &y_border);
1305 matches = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->filter_model), NULL);
1307 items = MIN (matches, 15);
1309 gtk_tree_view_column_cell_get_size (completion->priv->column, NULL,
1310 NULL, NULL, NULL, &height);
1312 gtk_widget_style_get (GTK_WIDGET (completion->priv->tree_view),
1313 "vertical-separator", &vertical_separator,
1316 height += vertical_separator;
1318 gtk_widget_realize (completion->priv->tree_view);
1321 gtk_widget_hide (completion->priv->scrolled_window);
1323 gtk_widget_show (completion->priv->scrolled_window);
1325 screen = gtk_widget_get_screen (GTK_WIDGET (completion->priv->entry));
1326 monitor_num = gdk_screen_get_monitor_at_window (screen,
1327 GTK_WIDGET (completion->priv->entry)->window);
1328 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
1330 if (completion->priv->popup_set_width)
1331 width = MIN (completion->priv->entry->allocation.width, monitor.width) - 2 * x_border;
1335 gtk_tree_view_columns_autosize (GTK_TREE_VIEW (completion->priv->tree_view));
1336 gtk_widget_set_size_request (completion->priv->tree_view, width, items * height);
1338 /* default on no match */
1339 completion->priv->current_selected = -1;
1341 items = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->actions), NULL);
1345 gtk_widget_show (completion->priv->action_view);
1346 gtk_widget_set_size_request (completion->priv->action_view, width, -1);
1349 gtk_widget_hide (completion->priv->action_view);
1351 gtk_widget_size_request (completion->priv->popup_window, &popup_req);
1352 gtk_widget_size_request (completion->priv->entry, &entry_req);
1356 else if (x + popup_req.width > monitor.x + monitor.width)
1357 x = monitor.x + monitor.width - popup_req.width;
1359 if (y + entry_req.height + popup_req.height <= monitor.y + monitor.height ||
1360 y - monitor.y < (monitor.y + monitor.height) - (y + entry_req.height))
1362 y += entry_req.height;
1367 y -= popup_req.height;
1373 path = gtk_tree_path_new_from_indices (above ? matches - 1 : 0, -1);
1374 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (completion->priv->tree_view), path,
1375 NULL, FALSE, 0.0, 0.0);
1376 gtk_tree_path_free (path);
1379 gtk_window_move (GTK_WINDOW (completion->priv->popup_window), x, y);
1385 _gtk_entry_completion_popup (GtkEntryCompletion *completion)
1387 GtkTreeViewColumn *column;
1389 GtkWidget *toplevel;
1391 if (GTK_WIDGET_MAPPED (completion->priv->popup_window))
1394 if (!GTK_WIDGET_MAPPED (completion->priv->entry))
1397 if (!GTK_WIDGET_HAS_FOCUS (completion->priv->entry))
1400 completion->priv->ignore_enter = TRUE;
1402 column = gtk_tree_view_get_column (GTK_TREE_VIEW (completion->priv->action_view), 0);
1403 renderers = gtk_tree_view_column_get_cell_renderers (column);
1404 gtk_widget_ensure_style (completion->priv->tree_view);
1405 g_object_set (GTK_CELL_RENDERER (renderers->data), "cell-background-gdk",
1406 &completion->priv->tree_view->style->bg[GTK_STATE_NORMAL],
1408 g_list_free (renderers);
1410 gtk_widget_show_all (completion->priv->vbox);
1412 _gtk_entry_completion_resize_popup (completion);
1414 toplevel = gtk_widget_get_toplevel (completion->priv->entry);
1415 if (GTK_IS_WINDOW (toplevel))
1416 gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
1417 GTK_WINDOW (completion->priv->popup_window));
1419 /* prevent the first row being focused */
1420 gtk_widget_grab_focus (completion->priv->tree_view);
1422 gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view)));
1423 gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->action_view)));
1426 gtk_widget_show (completion->priv->popup_window);
1428 gtk_grab_add (completion->priv->popup_window);
1429 gdk_pointer_grab (completion->priv->popup_window->window, TRUE,
1430 GDK_BUTTON_PRESS_MASK |
1431 GDK_BUTTON_RELEASE_MASK |
1432 GDK_POINTER_MOTION_MASK,
1433 NULL, NULL, GDK_CURRENT_TIME);
1437 _gtk_entry_completion_popdown (GtkEntryCompletion *completion)
1439 if (!GTK_WIDGET_MAPPED (completion->priv->popup_window))
1442 completion->priv->ignore_enter = FALSE;
1444 gdk_pointer_ungrab (GDK_CURRENT_TIME);
1445 gtk_grab_remove (completion->priv->popup_window);
1447 gtk_widget_hide (completion->priv->popup_window);
1451 gtk_entry_completion_match_selected (GtkEntryCompletion *completion,
1452 GtkTreeModel *model,
1457 gtk_tree_model_get (model, iter, completion->priv->text_column, &str, -1);
1458 gtk_entry_set_text (GTK_ENTRY (completion->priv->entry), str ? str : "");
1460 /* move cursor to the end */
1461 gtk_editable_set_position (GTK_EDITABLE (completion->priv->entry), -1);
1470 gtk_entry_completion_compute_prefix (GtkEntryCompletion *completion)
1473 gchar *prefix = NULL;
1477 if (completion->priv->text_column < 0)
1480 key = gtk_entry_get_text (GTK_ENTRY (completion->priv->entry));
1482 valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (completion->priv->filter_model),
1489 gtk_tree_model_get (GTK_TREE_MODEL (completion->priv->filter_model),
1490 &iter, completion->priv->text_column, &text,
1493 if (text && g_str_has_prefix (text, key))
1496 prefix = g_strdup (text);
1500 const gchar *q = text;
1502 while (*p && *p == *q)
1513 valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (completion->priv->filter_model),
1522 gtk_entry_completion_real_insert_prefix (GtkEntryCompletion *completion,
1523 const gchar *prefix)
1531 prefix_len = g_utf8_strlen (prefix, -1);
1533 key = gtk_entry_get_text (GTK_ENTRY (completion->priv->entry));
1534 key_len = g_utf8_strlen (key, -1);
1536 if (prefix_len > key_len)
1538 gint pos = prefix_len;
1540 gtk_editable_insert_text (GTK_EDITABLE (completion->priv->entry),
1541 prefix + strlen (key), -1, &pos);
1542 gtk_editable_select_region (GTK_EDITABLE (completion->priv->entry),
1543 key_len, prefix_len);
1545 completion->priv->has_completion = TRUE;
1553 * gtk_entry_completion_insert_prefix:
1554 * @completion: a #GtkEntryCompletion
1556 * Requests a prefix insertion.
1561 gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion)
1566 g_signal_handler_block (completion->priv->entry,
1567 completion->priv->insert_text_id);
1568 prefix = gtk_entry_completion_compute_prefix (completion);
1571 g_signal_emit (completion, entry_completion_signals[INSERT_PREFIX],
1575 g_signal_handler_unblock (completion->priv->entry,
1576 completion->priv->insert_text_id);
1580 * gtk_entry_completion_set_inline_completion:
1581 * @completion: a #GtkEntryCompletion
1582 * @inline_completion: %TRUE to do inline completion
1584 * Sets whether the common prefix of the possible completions should
1585 * be automatically inserted in the entry.
1590 gtk_entry_completion_set_inline_completion (GtkEntryCompletion *completion,
1591 gboolean inline_completion)
1593 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
1595 inline_completion = inline_completion != FALSE;
1597 if (completion->priv->inline_completion != inline_completion)
1599 completion->priv->inline_completion = inline_completion;
1601 g_object_notify (G_OBJECT (completion), "inline-completion");
1607 * gtk_entry_completion_get_inline_completion:
1608 * @completion: a #GtkEntryCompletion
1610 * Returns whether the common prefix of the possible completions should
1611 * be automatically inserted in the entry.
1613 * Return value: %TRUE if inline completion is turned on
1618 gtk_entry_completion_get_inline_completion (GtkEntryCompletion *completion)
1620 g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), FALSE);
1622 return completion->priv->inline_completion;
1626 * gtk_entry_completion_set_popup_completion:
1627 * @completion: a #GtkEntryCompletion
1628 * @popup_completion: %TRUE to do popup completion
1630 * Sets whether the completions should be presented in a popup window.
1635 gtk_entry_completion_set_popup_completion (GtkEntryCompletion *completion,
1636 gboolean popup_completion)
1638 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
1640 popup_completion = popup_completion != FALSE;
1642 if (completion->priv->popup_completion != popup_completion)
1644 completion->priv->popup_completion = popup_completion;
1646 g_object_notify (G_OBJECT (completion), "popup-completion");
1652 * gtk_entry_completion_get_popup_completion:
1653 * @completion: a #GtkEntryCompletion
1655 * Returns whether the completions should be presented in a popup window.
1657 * Return value: %TRUE if popup completion is turned on
1662 gtk_entry_completion_get_popup_completion (GtkEntryCompletion *completion)
1664 g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), TRUE);
1666 return completion->priv->popup_completion;
1670 * gtk_entry_completion_set_popup_set_width:
1671 * @completion: a #GtkEntryCompletion
1672 * @popup_set_width: %TRUE to make the width of the popup the same as the entry
1674 * Sets whether the completion popup window will be resized to be the same
1675 * width as the entry.
1680 gtk_entry_completion_set_popup_set_width (GtkEntryCompletion *completion,
1681 gboolean popup_set_width)
1683 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
1685 popup_set_width = popup_set_width != FALSE;
1687 if (completion->priv->popup_set_width != popup_set_width)
1689 completion->priv->popup_set_width = popup_set_width;
1691 g_object_notify (G_OBJECT (completion), "popup-set-width");
1696 * gtk_entry_completion_get_popup_set_width:
1697 * @completion: a #GtkEntryCompletion
1699 * Returns whether the completion popup window will be resized to the
1700 * width of the entry.
1702 * Return value: %TRUE if the popup window will be resized to the width of
1708 gtk_entry_completion_get_popup_set_width (GtkEntryCompletion *completion)
1710 g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), TRUE);
1712 return completion->priv->popup_set_width;
1717 * gtk_entry_completion_set_popup_single_match:
1718 * @completion: a #GtkEntryCompletion
1719 * @popup_single_match: %TRUE if the popup should appear even for a single
1722 * Sets whether the completion popup window will appear even if there is
1723 * only a single match. You may want to set this to %FALSE if you
1724 * are using <link linkend="GtkEntryCompletion--inline-completion">inline
1725 * completion</link>.
1730 gtk_entry_completion_set_popup_single_match (GtkEntryCompletion *completion,
1731 gboolean popup_single_match)
1733 g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
1735 popup_single_match = popup_single_match != FALSE;
1737 if (completion->priv->popup_single_match != popup_single_match)
1739 completion->priv->popup_single_match = popup_single_match;
1741 g_object_notify (G_OBJECT (completion), "popup-single-match");
1746 * gtk_entry_completion_get_popup_single_match:
1747 * @completion: a #GtkEntryCompletion
1749 * Returns whether the completion popup window will appear even if there is
1750 * only a single match.
1752 * Return value: %TRUE if the popup window will appear regardless of the
1753 * number of matches.
1758 gtk_entry_completion_get_popup_single_match (GtkEntryCompletion *completion)
1760 g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), TRUE);
1762 return completion->priv->popup_single_match;
1766 #define __GTK_ENTRY_COMPLETION_C__
1767 #include "gtkaliasdef.c"