[gtk+] Fix signal parameters in GtkEntryCompletion



commit bb91ebcb8fc914a6069e9962321d3f9b5ed9f714
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 21 23:50:46 2010 -0400

    Fix signal parameters in GtkEntryCompletion
    
    The ::match-selected and ::cursor-on-match signal were emitted
    with the internal filter model instead of the user-provided model.
    
    Fixes bug #555087.

 gtk/gtkentry.c           |    6 ++++-
 gtk/gtkentrycompletion.c |   51 +++++++++++++++++++++++++--------------------
 2 files changed, 33 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 4a93531..963cf33 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -9315,6 +9315,7 @@ gtk_entry_completion_key_press (GtkWidget   *widget,
             {
 
               GtkTreeIter iter;
+              GtkTreeIter child_iter;
               GtkTreeModel *model = NULL;
               GtkTreeSelection *sel;
               gboolean entry_set;
@@ -9322,12 +9323,15 @@ gtk_entry_completion_key_press (GtkWidget   *widget,
               sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view));
               if (!gtk_tree_selection_get_selected (sel, &model, &iter))
                 return FALSE;
+
+              gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model), &child_iter, &iter);
+              model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (model));
               
               if (completion->priv->completion_prefix == NULL)
                 completion->priv->completion_prefix = g_strdup (gtk_entry_get_text (GTK_ENTRY (completion->priv->entry)));
 
               g_signal_emit_by_name (completion, "cursor-on-match", model,
-                                     &iter, &entry_set);
+                                     &child_iter, &entry_set);
             }
         }
       else if (completion->priv->current_selected - matches >= 0)
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index 68b758a..8237387 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -178,20 +178,20 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
    * GtkEntryCompletion::insert-prefix:
    * @widget: the object which received the signal
    * @prefix: the common prefix of all possible completions
-   * 
-   * Gets emitted when the inline autocompletion is triggered. 
-   * The default behaviour is to make the entry display the 
+   *
+   * Gets emitted when the inline autocompletion is triggered.
+   * The default behaviour is to make the entry display the
    * whole prefix and select the newly inserted part.
    *
    * Applications may connect to this signal in order to insert only a
    * smaller part of the @prefix into the entry - e.g. the entry used in
-   * the #GtkFileChooser inserts only the part of the prefix up to the 
+   * the #GtkFileChooser inserts only the part of the prefix up to the
    * next '/'.
    *
    * Return value: %TRUE if the signal has been handled
-   * 
+   *
    * Since: 2.6
-   */ 
+   */
   entry_completion_signals[INSERT_PREFIX] =
     g_signal_new (I_("insert-prefix"),
                   G_TYPE_FROM_CLASS (klass),
@@ -207,16 +207,16 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
    * @widget: the object which received the signal
    * @model: the #GtkTreeModel containing the matches
    * @iter: a #GtkTreeIter positioned at the selected match
-   * 
-   * Gets emitted when a match from the list is selected. 
-   * The default behaviour is to replace the contents of the 
-   * entry with the contents of the text column in the row 
+   *
+   * Gets emitted when a match from the list is selected.
+   * The default behaviour is to replace the contents of the
+   * entry with the contents of the text column in the row
    * pointed to by @iter.
    *
    * Return value: %TRUE if the signal has been handled
-   * 
+   *
    * Since: 2.4
-   */ 
+   */
   entry_completion_signals[MATCH_SELECTED] =
     g_signal_new (I_("match-selected"),
                   G_TYPE_FROM_CLASS (klass),
@@ -227,22 +227,22 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
                   G_TYPE_BOOLEAN, 2,
                   GTK_TYPE_TREE_MODEL,
                   GTK_TYPE_TREE_ITER);
+
   /**
    * GtkEntryCompletion::cursor-on-match:
    * @widget: the object which received the signal
    * @model: the #GtkTreeModel containing the matches
    * @iter: a #GtkTreeIter positioned at the selected match
-   * 
+   *
    * Gets emitted when a match from the cursor is on a match
-   * of the list.The default behaviour is to replace the contents
-   * of the entry with the contents of the text column in the row 
+   * of the list. The default behaviour is to replace the contents
+   * of the entry with the contents of the text column in the row
    * pointed to by @iter.
    *
    * Return value: %TRUE if the signal has been handled
-   * 
+   *
    * Since: 2.12
-   */ 
-
+   */
   entry_completion_signals[CURSOR_ON_MATCH] =
     g_signal_new (I_("cursor-on-match"),
 		  G_TYPE_FROM_CLASS (klass),
@@ -253,7 +253,7 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
 		  G_TYPE_BOOLEAN, 2,
 		  GTK_TYPE_TREE_MODEL,
 		  GTK_TYPE_TREE_ITER);
-		  
+
   /**
    * GtkEntryCompletion::action-activated:
    * @widget: the object which received the signal
@@ -876,18 +876,23 @@ gtk_entry_completion_list_button_press (GtkWidget      *widget,
     {
       GtkTreeIter iter;
       gboolean entry_set;
+      GtkTreeModel *model;
+      GtkTreeIter child_iter;
 
       gtk_tree_model_get_iter (GTK_TREE_MODEL (completion->priv->filter_model),
                                &iter, path);
       gtk_tree_path_free (path);
+      gtk_tree_model_filter_convert_iter_to_child_iter (completion->priv->filter_model,
+                                                        &child_iter,
+                                                        &iter);
+      model = gtk_tree_model_filter_get_model (completion->priv->filter_model);
 
       g_signal_handler_block (completion->priv->entry,
-			      completion->priv->changed_id);
+                              completion->priv->changed_id);
       g_signal_emit (completion, entry_completion_signals[MATCH_SELECTED],
-                     0, GTK_TREE_MODEL (completion->priv->filter_model),
-                     &iter, &entry_set);
+                     0, model, &child_iter, &entry_set);
       g_signal_handler_unblock (completion->priv->entry,
-				completion->priv->changed_id);
+                                completion->priv->changed_id);
 
       _gtk_entry_completion_popdown (completion);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]