[Xfce4-commits] <midori:master> Pass action to cell renderer callback rather than the entry

Christian Dywan noreply at xfce.org
Fri Feb 12 00:38:01 CET 2010


Updating branch refs/heads/master
         to f19412bc709a474045021d756542d1c2a1289056 (commit)
       from f733f453d237066511e772ddbbd1dbb90f070b9a (commit)

commit f19412bc709a474045021d756542d1c2a1289056
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Feb 11 23:55:36 2010 +0100

    Pass action to cell renderer callback rather than the entry
    
    The entry pointer is only meaningful if completion was triggered
    by typing or editing in an entry.
    We shouldn't render a key in results if the arrow button opened the
    completion popup.
    We need to check the key in the callback to avoid accidentally
    working with an entry of a different window.

 midori/midori-locationaction.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c
index 73f99e1..94777b1 100644
--- a/midori/midori-locationaction.c
+++ b/midori/midori-locationaction.c
@@ -417,7 +417,7 @@ midori_location_action_popup_timeout_cb (gpointer data)
             NULL);
         gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), renderer,
                                             midori_location_entry_render_text_cb,
-                                            action->entry, NULL);
+                                            action, NULL);
         gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
 
         action->popup = popup;
@@ -517,6 +517,7 @@ midori_location_action_popdown_completion (MidoriLocationAction* location_action
     if (G_LIKELY (location_action->popup))
     {
         gtk_widget_hide (location_action->popup);
+        katze_assign (location_action->key, NULL);
         gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (
             GTK_TREE_VIEW (location_action->treeview)));
     }
@@ -1013,13 +1014,13 @@ midori_location_entry_render_text_cb (GtkCellLayout*   layout,
                                       GtkTreeIter*     iter,
                                       gpointer         data)
 {
+    MidoriLocationAction* action = data;
     gchar* uri;
     gchar* title;
     GdkColor* background;
     gchar* desc;
     gchar* desc_uri;
     gchar* desc_title;
-    GtkWidget* entry;
     const gchar* str;
     gchar* key;
     gchar* start;
@@ -1028,16 +1029,9 @@ midori_location_entry_render_text_cb (GtkCellLayout*   layout,
     gchar** parts;
     size_t len;
 
-    entry = data;
-
     gtk_tree_model_get (model, iter, URI_COL, &uri, TITLE_COL, &title,
         BACKGROUND_COL, &background, -1);
 
-    desc = desc_uri = desc_title = key = NULL;
-    str = gtk_entry_get_text (GTK_ENTRY (entry));
-    if (!str)
-        return;
-
     if (background != NULL) /* A search engine action */
     {
         g_object_set (renderer, "text", title,
@@ -1047,6 +1041,12 @@ midori_location_entry_render_text_cb (GtkCellLayout*   layout,
         return;
     }
 
+    desc = desc_uri = desc_title = key = NULL;
+    if (action->key)
+        str = action->key;
+    else
+        str = "";
+
     key = g_utf8_strdown (str, -1);
     len = strlen (key);
 
@@ -1274,7 +1274,7 @@ midori_location_action_connect_proxy (GtkAction* action,
         g_object_set_data (G_OBJECT (renderer), "location-action", action);
         gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (entry), renderer, TRUE);
         gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
-            renderer, midori_location_entry_render_text_cb, child, NULL);
+            renderer, midori_location_entry_render_text_cb, action, NULL);
 
         gtk_combo_box_set_active (GTK_COMBO_BOX (entry), -1);
         if (location_action->history)



More information about the Xfce4-commits mailing list