[Xfce4-commits] <midori:master> Consolidate search entries in sokoke_search_entry_new
Christian Dywan
noreply at xfce.org
Mon Aug 6 00:34:02 CEST 2012
Updating branch refs/heads/master
to b925dbca33bc1283299097f7903102a4ffb1fef3 (commit)
from 4cd88d574648220e6c6242dae43bc486185af5c3 (commit)
commit b925dbca33bc1283299097f7903102a4ffb1fef3
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun Aug 5 22:23:51 2012 +0200
Consolidate search entries in sokoke_search_entry_new
extensions/cookie-manager/cookie-manager-page.c | 16 +----------
midori/midori-searchaction.c | 3 +-
midori/sokoke.c | 33 +++++++----------------
midori/sokoke.h | 5 +--
panels/midori-bookmarks.c | 21 +-------------
panels/midori-history.c | 21 +-------------
toolbars/midori-findbar.c | 18 +------------
7 files changed, 19 insertions(+), 98 deletions(-)
diff --git a/extensions/cookie-manager/cookie-manager-page.c b/extensions/cookie-manager/cookie-manager-page.c
index d8a71ad..2fe35c4 100644
--- a/extensions/cookie-manager/cookie-manager-page.c
+++ b/extensions/cookie-manager/cookie-manager-page.c
@@ -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);
diff --git a/midori/midori-searchaction.c b/midori/midori-searchaction.c
index 76dbda4..705e87d 100644
--- a/midori/midori-searchaction.c
+++ b/midori/midori-searchaction.c
@@ -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);
diff --git a/midori/sokoke.c b/midori/sokoke.c
index ce3ea4c..34d2b09 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -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*
diff --git a/midori/sokoke.h b/midori/sokoke.h
index 488a225..dcd6232 100644
--- a/midori/sokoke.h
+++ b/midori/sokoke.h
@@ -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__ */
diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c
index 0a7b880..0f6b5d7 100644
--- a/panels/midori-bookmarks.c
+++ b/panels/midori-bookmarks.c
@@ -1012,16 +1012,6 @@ midori_bookmarks_filter_entry_changed_cb (GtkEntry* entry,
}
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)
{
GtkWidget* entry;
@@ -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);
diff --git a/panels/midori-history.c b/panels/midori-history.c
index 8c6edfd..b8ac99e 100644
--- a/panels/midori-history.c
+++ b/panels/midori-history.c
@@ -975,16 +975,6 @@ midori_history_filter_entry_changed_cb (GtkEntry* entry,
}
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);
diff --git a/toolbars/midori-findbar.c b/toolbars/midori-findbar.c
index 8bb167e..3c61795 100644
--- a/toolbars/midori-findbar.c
+++ b/toolbars/midori-findbar.c
@@ -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",
More information about the Xfce4-commits
mailing list