Consolidate search entries in sokoke_search_entry_new

This commit is contained in:
Christian Dywan 2012-08-05 22:23:51 +02:00
parent 4cd88d5746
commit b925dbca33
7 changed files with 19 additions and 98 deletions

View 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)); 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) static void cm_tree_selection_changed_cb(GtkTreeSelection *selection, CookieManagerPage *cmp)
{ {
GList *rows; GList *rows;
@ -1134,14 +1126,8 @@ static void cookie_manager_page_init(CookieManagerPage *self)
gtk_container_add(GTK_CONTAINER(tree_swin), treeview); gtk_container_add(GTK_CONTAINER(tree_swin), treeview);
gtk_widget_show(tree_swin); gtk_widget_show(tree_swin);
priv->filter_entry = gtk_icon_entry_new(); priv->filter_entry = sokoke_search_entry_new (_("Search Cookies by Name or Domain"));
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);
gtk_widget_show(priv->filter_entry); 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, "changed", G_CALLBACK(cm_filter_entry_changed_cb), self);
g_signal_connect(priv->filter_entry, "activate", G_CALLBACK(cm_filter_entry_changed_cb), self); g_signal_connect(priv->filter_entry, "activate", G_CALLBACK(cm_filter_entry_changed_cb), self);

View file

@ -311,8 +311,7 @@ midori_search_action_create_tool_item (GtkAction* action)
GtkWidget* alignment; GtkWidget* alignment;
toolitem = GTK_WIDGET (gtk_tool_item_new ()); toolitem = GTK_WIDGET (gtk_tool_item_new ());
entry = gtk_icon_entry_new (); entry = sokoke_search_entry_new (NULL);
sokoke_entry_set_clear_button_visible (GTK_ENTRY (entry), TRUE);
gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (entry), gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_PRIMARY, TRUE); GTK_ICON_ENTRY_PRIMARY, TRUE);
alignment = gtk_alignment_new (0, 0.5, 1, 0.1); alignment = gtk_alignment_new (0, 0.5, 1, 0.1);

View file

@ -1630,15 +1630,15 @@ sokoke_entry_icon_released_cb (GtkEntry* entry,
gtk_widget_grab_focus (GTK_WIDGET (entry)); gtk_widget_grab_focus (GTK_WIDGET (entry));
} }
void GtkWidget*
sokoke_entry_set_clear_button_visible (GtkEntry* entry, sokoke_search_entry_new (const gchar* placeholder_text)
gboolean visible)
{ {
g_return_if_fail (GTK_IS_ENTRY (entry)); GtkWidget* entry = gtk_entry_new ();
gtk_entry_set_placeholder_text (GTK_ENTRY (entry), placeholder_text);
gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (entry), gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
GTK_ICON_ENTRY_SECONDARY, TRUE); GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND);
if (visible) gtk_icon_entry_set_icon_highlight (GTK_ENTRY (entry),
GTK_ENTRY_ICON_SECONDARY, TRUE);
{ {
g_object_connect (entry, g_object_connect (entry,
"signal::icon-release", "signal::icon-release",
@ -1649,22 +1649,9 @@ sokoke_entry_set_clear_button_visible (GtkEntry* entry,
G_CALLBACK (sokoke_entry_focus_out_event_cb), entry, G_CALLBACK (sokoke_entry_focus_out_event_cb), entry,
"signal::changed", "signal::changed",
G_CALLBACK (sokoke_entry_changed_cb), entry, NULL); G_CALLBACK (sokoke_entry_changed_cb), entry, NULL);
sokoke_entry_changed_cb ((GtkEditable*)entry, entry); sokoke_entry_changed_cb ((GtkEditable*)entry, GTK_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);
} }
return entry;
} }
gchar* gchar*

View file

@ -206,8 +206,7 @@ sokoke_build_thumbnail_path (const gchar* name);
gchar* gchar*
midori_download_prepare_tooltip_text (WebKitDownload* download); midori_download_prepare_tooltip_text (WebKitDownload* download);
void GtkWidget*
sokoke_entry_set_clear_button_visible (GtkEntry* entry, sokoke_search_entry_new (const gchar* placeholder_text);
gboolean visible);
#endif /* !__SOKOKE_H__ */ #endif /* !__SOKOKE_H__ */

View file

@ -1011,16 +1011,6 @@ midori_bookmarks_filter_entry_changed_cb (GtkEntry* entry,
midori_bookmarks_filter_timeout_cb, bookmarks); 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 static void
midori_bookmarks_init (MidoriBookmarks* bookmarks) midori_bookmarks_init (MidoriBookmarks* bookmarks)
{ {
@ -1034,15 +1024,8 @@ midori_bookmarks_init (MidoriBookmarks* bookmarks)
GtkTreeSelection* selection; GtkTreeSelection* selection;
/* Create the filter entry */ /* Create the filter entry */
entry = gtk_icon_entry_new (); entry = sokoke_search_entry_new (_("Search Bookmarks"));
gtk_entry_set_placeholder_text (GTK_ENTRY (entry), _("Search Bookmarks")); g_signal_connect_after (entry, "changed",
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",
G_CALLBACK (midori_bookmarks_filter_entry_changed_cb), bookmarks); G_CALLBACK (midori_bookmarks_filter_entry_changed_cb), bookmarks);
box = gtk_hbox_new (FALSE, 0); box = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 3); gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 3);

View file

@ -974,16 +974,6 @@ midori_history_filter_entry_changed_cb (GtkEntry* entry,
katze_assign (history->filter, NULL); 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 static void
midori_history_selection_changed_cb (GtkTreeView* treeview, midori_history_selection_changed_cb (GtkTreeView* treeview,
MidoriHistory* history) MidoriHistory* history)
@ -1004,15 +994,8 @@ midori_history_init (MidoriHistory* history)
GtkTreeSelection* selection; GtkTreeSelection* selection;
/* Create the filter entry */ /* Create the filter entry */
entry = gtk_icon_entry_new (); entry = sokoke_search_entry_new (_("Search History"));
gtk_entry_set_placeholder_text (GTK_ENTRY (entry), _("Search History")); g_signal_connect_after (entry, "changed",
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",
G_CALLBACK (midori_history_filter_entry_changed_cb), history); G_CALLBACK (midori_history_filter_entry_changed_cb), history);
box = gtk_hbox_new (FALSE, 0); box = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 3); gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 3);

View file

@ -93,18 +93,6 @@ midori_findbar_find_key_press_event_cb (MidoriFindbar* findbar,
return FALSE; 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 static gboolean
midori_findbar_case_sensitive (MidoriFindbar* findbar) 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 */ /* i18n: A panel at the bottom, to search text in pages */
gtk_label_new_with_mnemonic (_("_Inline Find:"))); gtk_label_new_with_mnemonic (_("_Inline Find:")));
gtk_toolbar_insert (GTK_TOOLBAR (findbar), toolitem, -1); gtk_toolbar_insert (GTK_TOOLBAR (findbar), toolitem, -1);
findbar->find_text = gtk_icon_entry_new (); findbar->find_text = sokoke_search_entry_new (NULL);
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);
g_signal_connect (findbar->find_text, "activate", g_signal_connect (findbar->find_text, "activate",
G_CALLBACK (midori_findbar_next_activate_cb), findbar); G_CALLBACK (midori_findbar_next_activate_cb), findbar);
g_signal_connect (findbar->find_text, "preedit-changed", g_signal_connect (findbar->find_text, "preedit-changed",