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));
}
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);

View 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);

View 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*

View 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__ */

View 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);

View 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);

View 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",