]> spindle.queued.net Git - midori/commitdiff
Consolidate search entries in sokoke_search_entry_new
authorChristian Dywan <christian@twotoasts.de>
Sun, 5 Aug 2012 20:23:51 +0000 (22:23 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 5 Aug 2012 22:32:01 +0000 (00:32 +0200)
extensions/cookie-manager/cookie-manager-page.c
midori/midori-searchaction.c
midori/sokoke.c
midori/sokoke.h
panels/midori-bookmarks.c
panels/midori-history.c
toolbars/midori-findbar.c

index d8a71add86562e4c24487c7a7e77949e461b6cc5..2fe35c4d78a9f2d87f6f563909c7da1b68c1a615 100644 (file)
@@ -823,14 +823,6 @@ static void cm_filter_entry_changed_cb(GtkEditable *editable, CookieManagerPage
                gtk_tree_view_collapse_all(GTK_TREE_VIEW(priv->treeview));
 }
 
-
-static void cm_filter_entry_clear_icon_released_cb(GtkIconEntry *e, gint pos, gint btn, gpointer data)
-{
-       if (pos == GTK_ICON_ENTRY_SECONDARY)
-               gtk_entry_set_text(GTK_ENTRY(e), "");
-}
-
-
 static void cm_tree_selection_changed_cb(GtkTreeSelection *selection, CookieManagerPage *cmp)
 {
        GList *rows;
@@ -1134,14 +1126,8 @@ static void cookie_manager_page_init(CookieManagerPage *self)
        gtk_container_add(GTK_CONTAINER(tree_swin), treeview);
        gtk_widget_show(tree_swin);
 
-       priv->filter_entry = gtk_icon_entry_new();
-       gtk_entry_set_placeholder_text (GTK_ENTRY (priv->filter_entry), _("Search Cookies by Name or Domain"));
-       gtk_entry_set_icon_from_stock (GTK_ENTRY (priv->filter_entry),
-               GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND);
-       sokoke_entry_set_clear_button_visible (GTK_ENTRY (priv->filter_entry), TRUE);
+       priv->filter_entry = sokoke_search_entry_new (_("Search Cookies by Name or Domain"));
        gtk_widget_show(priv->filter_entry);
-       g_signal_connect(priv->filter_entry, "icon-release",
-               G_CALLBACK(cm_filter_entry_clear_icon_released_cb), NULL);
        g_signal_connect(priv->filter_entry, "changed", G_CALLBACK(cm_filter_entry_changed_cb), self);
        g_signal_connect(priv->filter_entry, "activate", G_CALLBACK(cm_filter_entry_changed_cb), self);
 
index 76dbda4b6317221f6ab3787385c436b5faae9a72..705e87d67b92004be360b10795637c902bd6b8ac 100644 (file)
@@ -311,8 +311,7 @@ midori_search_action_create_tool_item (GtkAction* action)
     GtkWidget* alignment;
 
     toolitem = GTK_WIDGET (gtk_tool_item_new ());
-    entry = gtk_icon_entry_new ();
-    sokoke_entry_set_clear_button_visible (GTK_ENTRY (entry), TRUE);
+    entry = sokoke_search_entry_new (NULL);
     gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (entry),
                                        GTK_ICON_ENTRY_PRIMARY, TRUE);
     alignment = gtk_alignment_new (0, 0.5, 1, 0.1);
index ce3ea4ca8a49551a311ecf121ee133c0836aaa72..34d2b098f74d52bec4cb580e8b6b21fc4defbd38 100644 (file)
@@ -1630,15 +1630,15 @@ sokoke_entry_icon_released_cb (GtkEntry*            entry,
     gtk_widget_grab_focus (GTK_WIDGET (entry));
 }
 
-void
-sokoke_entry_set_clear_button_visible (GtkEntry* entry,
-                                       gboolean  visible)
+GtkWidget*
+sokoke_search_entry_new (const gchar* placeholder_text)
 {
-    g_return_if_fail (GTK_IS_ENTRY (entry));
-
-    gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (entry),
-        GTK_ICON_ENTRY_SECONDARY, TRUE);
-    if (visible)
+    GtkWidget* entry = gtk_entry_new ();
+    gtk_entry_set_placeholder_text (GTK_ENTRY (entry), placeholder_text);
+    gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
+                                   GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND);
+    gtk_icon_entry_set_icon_highlight (GTK_ENTRY (entry),
+        GTK_ENTRY_ICON_SECONDARY, TRUE);
     {
         g_object_connect (entry,
             "signal::icon-release",
@@ -1649,22 +1649,9 @@ sokoke_entry_set_clear_button_visible (GtkEntry* entry,
             G_CALLBACK (sokoke_entry_focus_out_event_cb), entry,
             "signal::changed",
             G_CALLBACK (sokoke_entry_changed_cb), entry, NULL);
-        sokoke_entry_changed_cb ((GtkEditable*)entry, entry);
-    }
-    else
-    {
-        g_object_disconnect (entry,
-            "any_signal::icon-release",
-            G_CALLBACK (sokoke_entry_icon_released_cb), NULL,
-            "any_signal::focus-in-event",
-            G_CALLBACK (sokoke_entry_focus_out_event_cb), entry,
-            "any_signal::focus-out-event",
-            G_CALLBACK (sokoke_entry_focus_out_event_cb), entry,
-            "any_signal::changed",
-            G_CALLBACK (sokoke_entry_changed_cb), entry, NULL);
-        gtk_icon_entry_set_icon_from_stock (
-            GTK_ICON_ENTRY (entry), GTK_ICON_ENTRY_SECONDARY, NULL);
+        sokoke_entry_changed_cb ((GtkEditable*)entry, GTK_ENTRY (entry));
     }
+    return entry;
 }
 
 gchar*
index 488a2259d08932bc0e01b66b222794ddf481f4ab..dcd62325a1d8920b1c542ef73f8f1c17b8351f12 100644 (file)
@@ -206,8 +206,7 @@ sokoke_build_thumbnail_path (const gchar* name);
 gchar*
 midori_download_prepare_tooltip_text (WebKitDownload* download);
 
-void
-sokoke_entry_set_clear_button_visible (GtkEntry*           entry,
-                                       gboolean            visible);
+GtkWidget*
+sokoke_search_entry_new               (const gchar*        placeholder_text);
 
 #endif /* !__SOKOKE_H__ */
index 0a7b88083f6f5e446ff24ce857a8e53661cb0140..0f6b5d716fc0b605d99af8e75d3776b639393d89 100644 (file)
@@ -1011,16 +1011,6 @@ midori_bookmarks_filter_entry_changed_cb (GtkEntry*        entry,
         midori_bookmarks_filter_timeout_cb, bookmarks);
 }
 
-static void
-midori_bookmarks_filter_entry_clear_cb (GtkEntry*        entry,
-                                        gint             icon_pos,
-                                        gint             button,
-                                        MidoriBookmarks* bookmarks)
-{
-    if (icon_pos == GTK_ICON_ENTRY_SECONDARY)
-        gtk_entry_set_text (entry, "");
-}
-
 static void
 midori_bookmarks_init (MidoriBookmarks* bookmarks)
 {
@@ -1034,15 +1024,8 @@ midori_bookmarks_init (MidoriBookmarks* bookmarks)
     GtkTreeSelection* selection;
 
     /* Create the filter entry */
-    entry = gtk_icon_entry_new ();
-    gtk_entry_set_placeholder_text (GTK_ENTRY (entry), _("Search Bookmarks"));
-    gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry),
-                                        GTK_ICON_ENTRY_PRIMARY,
-                                        GTK_STOCK_FIND);
-    sokoke_entry_set_clear_button_visible (GTK_ENTRY (entry), TRUE);
-    g_signal_connect (entry, "icon-release",
-        G_CALLBACK (midori_bookmarks_filter_entry_clear_cb), bookmarks);
-    g_signal_connect (entry, "changed",
+    entry = sokoke_search_entry_new (_("Search Bookmarks"));
+    g_signal_connect_after (entry, "changed",
         G_CALLBACK (midori_bookmarks_filter_entry_changed_cb), bookmarks);
     box = gtk_hbox_new (FALSE, 0);
     gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 3);
index 8c6edfd17b439f45c3afcbd6795fc7dabd85d949..b8ac99ee9c90d4e125ef04e60c5d0d1c7da3827e 100644 (file)
@@ -974,16 +974,6 @@ midori_history_filter_entry_changed_cb (GtkEntry*      entry,
         katze_assign (history->filter, NULL);
 }
 
-static void
-midori_history_filter_entry_clear_cb (GtkEntry*      entry,
-                                      gint           icon_pos,
-                                      gint           button,
-                                      MidoriHistory* history)
-{
-    if (icon_pos == GTK_ICON_ENTRY_SECONDARY)
-        gtk_entry_set_text (entry, "");
-}
-
 static void
 midori_history_selection_changed_cb (GtkTreeView*   treeview,
                                      MidoriHistory* history)
@@ -1004,15 +994,8 @@ midori_history_init (MidoriHistory* history)
     GtkTreeSelection* selection;
 
     /* Create the filter entry */
-    entry = gtk_icon_entry_new ();
-    gtk_entry_set_placeholder_text (GTK_ENTRY (entry), _("Search History"));
-    gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (entry),
-                                        GTK_ICON_ENTRY_PRIMARY,
-                                        GTK_STOCK_FIND);
-    sokoke_entry_set_clear_button_visible (GTK_ENTRY (entry), TRUE);
-    g_signal_connect (entry, "icon-release",
-        G_CALLBACK (midori_history_filter_entry_clear_cb), history);
-    g_signal_connect (entry, "changed",
+    entry = sokoke_search_entry_new (_("Search History"));
+    g_signal_connect_after (entry, "changed",
         G_CALLBACK (midori_history_filter_entry_changed_cb), history);
     box = gtk_hbox_new (FALSE, 0);
     gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 3);
index 8bb167e02403a7ba0dbb0dee4f64729c52802ac6..3c61795641f15869ec32ed32549a827911ec25bf 100644 (file)
@@ -93,18 +93,6 @@ midori_findbar_find_key_press_event_cb (MidoriFindbar* findbar,
     return FALSE;
 }
 
-static void
-midori_findbar_entry_clear_icon_released_cb (GtkIconEntry* entry,
-                                             gint          icon_pos,
-                                             gint          button,
-                                             MidoriFindbar*findbar)
-{
-    if (icon_pos == GTK_ICON_ENTRY_SECONDARY)
-    {
-        midori_findbar_set_icon (findbar, GTK_ICON_ENTRY_PRIMARY, STOCK_EDIT_FIND);
-    }
-}
-
 static gboolean
 midori_findbar_case_sensitive (MidoriFindbar* findbar)
 {
@@ -276,11 +264,7 @@ midori_findbar_init (MidoriFindbar* findbar)
         /* i18n: A panel at the bottom, to search text in pages */
         gtk_label_new_with_mnemonic (_("_Inline Find:")));
     gtk_toolbar_insert (GTK_TOOLBAR (findbar), toolitem, -1);
-    findbar->find_text = gtk_icon_entry_new ();
-    midori_findbar_set_icon (findbar, GTK_ICON_ENTRY_PRIMARY, STOCK_EDIT_FIND);
-    sokoke_entry_set_clear_button_visible (GTK_ENTRY (findbar->find_text), TRUE);
-    g_signal_connect (findbar->find_text, "icon-release",
-        G_CALLBACK (midori_findbar_entry_clear_icon_released_cb), findbar);
+    findbar->find_text = sokoke_search_entry_new (NULL);
     g_signal_connect (findbar->find_text, "activate",
         G_CALLBACK (midori_findbar_next_activate_cb), findbar);
     g_signal_connect (findbar->find_text, "preedit-changed",