]> Pileus Git - ~andy/gtk/commitdiff
Set the entry in the default handler of the ::match-selected signal.
authorMatthias Clasen <mclasen@redhat.com>
Mon, 10 May 2004 19:10:27 +0000 (19:10 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 10 May 2004 19:10:27 +0000 (19:10 +0000)
2004-05-10  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkentrycompletion.c (gtk_entry_completion_list_button_press):
Set the entry in the default handler of the ::match-selected signal.
(#137226)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkentrycompletion.c

index d5cbf40fc601a44b3f0745f741f83105ad752f3d..e812338dc3cce23d5a7f8afbfbb2903fdf2c7c2c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2004-05-10  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkentrycompletion.c (gtk_entry_completion_list_button_press): 
+       Set the entry in the default handler of the ::match-selected signal.
+       (#137226)
+
        * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't
        do the move-selected-item below pointer thingie, do the 
        place-below-or-above one.
index d5cbf40fc601a44b3f0745f741f83105ad752f3d..e812338dc3cce23d5a7f8afbfbb2903fdf2c7c2c 100644 (file)
@@ -1,5 +1,9 @@
 2004-05-10  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkentrycompletion.c (gtk_entry_completion_list_button_press): 
+       Set the entry in the default handler of the ::match-selected signal.
+       (#137226)
+
        * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't
        do the move-selected-item below pointer thingie, do the 
        place-below-or-above one.
index d5cbf40fc601a44b3f0745f741f83105ad752f3d..e812338dc3cce23d5a7f8afbfbb2903fdf2c7c2c 100644 (file)
@@ -1,5 +1,9 @@
 2004-05-10  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkentrycompletion.c (gtk_entry_completion_list_button_press): 
+       Set the entry in the default handler of the ::match-selected signal.
+       (#137226)
+
        * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't
        do the move-selected-item below pointer thingie, do the 
        place-below-or-above one.
index d5cbf40fc601a44b3f0745f741f83105ad752f3d..e812338dc3cce23d5a7f8afbfbb2903fdf2c7c2c 100644 (file)
@@ -1,5 +1,9 @@
 2004-05-10  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkentrycompletion.c (gtk_entry_completion_list_button_press): 
+       Set the entry in the default handler of the ::match-selected signal.
+       (#137226)
+
        * gtk/gtkcombobox.c (gtk_combo_box_menu_position_below): If we don't
        do the move-selected-item below pointer thingie, do the 
        place-below-or-above one.
index 0edfe85d3204624ff0416e690f79ec107db910d7..1d1ab74ea191822ac5b85c8baff06ec122dfea98 100644 (file)
@@ -119,6 +119,9 @@ static void     gtk_entry_completion_action_data_func    (GtkTreeViewColumn
                                                           GtkTreeIter             *iter,
                                                           gpointer                 data);
 
+static gboolean gtk_entry_completion_match_selected      (GtkEntryCompletion *completion,
+                                                         GtkTreeModel       *model,
+                                                         GtkTreeIter        *iter);
 
 static GObjectClass *parent_class = NULL;
 static guint entry_completion_signals[LAST_SIGNAL] = { 0 };
@@ -175,6 +178,8 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
   object_class->get_property = gtk_entry_completion_get_property;
   object_class->finalize = gtk_entry_completion_finalize;
 
+  klass->match_selected = gtk_entry_completion_match_selected;
+
   /**
    * GtkEntryCompletion::match-selected:
    * @widget: the object which received the signal
@@ -630,8 +635,8 @@ gtk_entry_completion_list_button_press (GtkWidget      *widget,
                                      event->x, event->y,
                                      &path, NULL, NULL, NULL))
     {
-      gboolean entry_set;
       GtkTreeIter iter;
+      gboolean entry_set;
 
       gtk_tree_model_get_iter (GTK_TREE_MODEL (completion->priv->filter_model),
                                &iter, path);
@@ -645,29 +650,8 @@ gtk_entry_completion_list_button_press (GtkWidget      *widget,
       g_signal_handler_unblock (completion->priv->entry,
                                completion->priv->changed_id);
 
-      if (!entry_set)
-        {
-          gchar *str = NULL;
-
-          gtk_tree_model_get (GTK_TREE_MODEL (completion->priv->filter_model),
-                              &iter,
-                              completion->priv->text_column, &str,
-                              -1);
-
-          g_signal_handler_block (completion->priv->entry,
-                                  completion->priv->changed_id);
-          gtk_entry_set_text (GTK_ENTRY (completion->priv->entry), str);
-          g_signal_handler_unblock (completion->priv->entry,
-                                    completion->priv->changed_id);
-
-          /* move cursor to the end */
-          gtk_editable_set_position (GTK_EDITABLE (completion->priv->entry),
-                                     -1);
-
-          g_free (str);
-        }
-
       _gtk_entry_completion_popdown (completion);
+
       return TRUE;
     }
 
@@ -1227,3 +1211,21 @@ _gtk_entry_completion_popdown (GtkEntryCompletion *completion)
 
   gtk_widget_hide (completion->priv->popup_window);
 }
+
+static gboolean 
+gtk_entry_completion_match_selected (GtkEntryCompletion *completion,
+                                    GtkTreeModel       *model,
+                                    GtkTreeIter        *iter)
+{
+  gchar *str = NULL;
+
+  gtk_tree_model_get (model, iter, completion->priv->text_column, &str, -1);
+  gtk_entry_set_text (GTK_ENTRY (completion->priv->entry), str);
+  
+  /* move cursor to the end */
+  gtk_editable_set_position (GTK_EDITABLE (completion->priv->entry), -1);
+  
+  g_free (str);
+
+  return TRUE;
+}