From 2831e21efc64d249e62b5432933680233e3a1673 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Sat, 7 Jun 2003 18:53:22 +0000 Subject: Remove some leftovers. 2003-06-07 Marco Pesenti Gritti * embed/mozilla/mozilla-notifiers.cpp: Remove some leftovers. * lib/widgets/Makefile.am: * lib/widgets/ephy-search-entry.c: (ephy_search_entry_get_type), (ephy_search_entry_class_init), (ephy_search_entry_timeout_cb), (ephy_search_entry_changed_cb), (ephy_search_entry_focus_out_event_cb), (ephy_search_entry_init), (ephy_search_entry_finalize), (ephy_search_entry_new), (ephy_search_entry_clear): * lib/widgets/ephy-search-entry.h: * src/bookmarks/ephy-bookmarks-editor.c: (keyword_node_selected_cb), (search_entry_search_cb), (build_search_box): * src/ephy-history-window.c: (site_node_selected_cb), (search_entry_search_cb), (build_search_box): Implement a search entry that delays searches a bit after the user pressed key, to have autoapply but make it interactive enough. (Based on rhythmbox one) --- src/bookmarks/ephy-bookmarks-editor.c | 30 ++++++------------------------ src/ephy-history-window.c | 33 ++++++--------------------------- 2 files changed, 12 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index 81e6e1e4b..616fa10b9 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -53,6 +53,7 @@ #include "ephy-debug.h" #include "ephy-gui.h" #include "ephy-stock-icons.h" +#include "ephy-search-entry.h" static GtkTargetEntry topic_drag_dest_types [] = { @@ -90,8 +91,6 @@ static void ephy_bookmarks_editor_get_property (GObject *object, GParamSpec *pspec); static void ephy_bookmarks_editor_update_menu (EphyBookmarksEditor *editor); -static void search_entry_changed_cb (GtkWidget *entry, - EphyBookmarksEditor *editor); static void cmd_open_bookmarks_in_tabs (EggAction *action, EphyBookmarksEditor *editor); static void cmd_open_bookmarks_in_browser (EggAction *action, @@ -924,20 +923,6 @@ key_pressed_cb (EphyNodeView *view, return FALSE; } -static void -reset_search_entry (EphyBookmarksEditor *editor) -{ - g_signal_handlers_block_by_func - (G_OBJECT (editor->priv->search_entry), - G_CALLBACK (search_entry_changed_cb), - editor); - gtk_entry_set_text (GTK_ENTRY (editor->priv->search_entry), ""); - g_signal_handlers_unblock_by_func - (G_OBJECT (editor->priv->search_entry), - G_CALLBACK (search_entry_changed_cb), - editor); -} - static void keyword_node_selected_cb (EphyNodeView *view, EphyNode *node, @@ -952,7 +937,7 @@ keyword_node_selected_cb (EphyNodeView *view, } else { - reset_search_entry (editor); + ephy_search_entry_clear (EPHY_SEARCH_ENTRY (editor->priv->search_entry)); bookmarks_filter (editor, node); } } @@ -969,10 +954,9 @@ keyword_node_show_popup_cb (GtkWidget *view, EphyBookmarksEditor *editor) } static void -search_entry_changed_cb (GtkWidget *entry, EphyBookmarksEditor *editor) +search_entry_search_cb (GtkWidget *entry, const char *search_text, EphyBookmarksEditor *editor) { EphyNode *all; - char *search_text; g_signal_handlers_block_by_func (G_OBJECT (editor->priv->key_view), @@ -1004,8 +988,6 @@ search_entry_changed_cb (GtkWidget *entry, EphyBookmarksEditor *editor) ephy_node_filter_done_changing (editor->priv->bookmarks_filter); GDK_THREADS_LEAVE (); - - g_free (search_text); } static GtkWidget * @@ -1020,11 +1002,11 @@ build_search_box (EphyBookmarksEditor *editor) gtk_container_set_border_width (GTK_CONTAINER (box), 6); gtk_widget_show (box); - entry = gtk_entry_new (); + entry = ephy_search_entry_new (); editor->priv->search_entry = entry; gtk_widget_show (entry); - g_signal_connect (G_OBJECT (entry), "changed", - G_CALLBACK (search_entry_changed_cb), + g_signal_connect (G_OBJECT (entry), "search", + G_CALLBACK (search_entry_search_cb), editor); add_entry_monitor (editor, entry); add_focus_monitor (editor, entry); diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c index aaefb7b66..53433e6fc 100644 --- a/src/ephy-history-window.c +++ b/src/ephy-history-window.c @@ -37,7 +37,6 @@ #include "ephy-history-window.h" #include "ephy-shell.h" #include "ephy-dnd.h" -#include "ephy-prefs.h" #include "egg-action-group.h" #include "egg-toggle-action.h" #include "egg-menu-merge.h" @@ -50,6 +49,7 @@ #include "ephy-gui.h" #include "toolbar.h" #include "ephy-stock-icons.h" +#include "ephy-search-entry.h" static GtkTargetEntry page_drag_types [] = { @@ -73,8 +73,6 @@ static void ephy_history_window_get_property (GObject *object, GParamSpec *pspec); static void ephy_history_window_dispose (GObject *object); -static void search_entry_changed_cb (GtkWidget *entry, - EphyHistoryWindow *editor); static void cmd_open_bookmarks_in_tabs (EggAction *action, EphyHistoryWindow *editor); static void cmd_open_bookmarks_in_browser (EggAction *action, @@ -781,20 +779,6 @@ key_pressed_cb (EphyNodeView *view, return FALSE; } -static void -reset_search_entry (EphyHistoryWindow *editor) -{ - g_signal_handlers_block_by_func - (G_OBJECT (editor->priv->search_entry), - G_CALLBACK (search_entry_changed_cb), - editor); - gtk_entry_set_text (GTK_ENTRY (editor->priv->search_entry), ""); - g_signal_handlers_unblock_by_func - (G_OBJECT (editor->priv->search_entry), - G_CALLBACK (search_entry_changed_cb), - editor); -} - static void site_node_selected_cb (EphyNodeView *view, EphyNode *node, @@ -809,16 +793,15 @@ site_node_selected_cb (EphyNodeView *view, } else { - reset_search_entry (editor); + ephy_search_entry_clear (EPHY_SEARCH_ENTRY (editor->priv->search_entry)); pages_filter (editor, node); } } static void -search_entry_changed_cb (GtkWidget *entry, EphyHistoryWindow *editor) +search_entry_search_cb (GtkWidget *entry, char *search_text, EphyHistoryWindow *editor) { EphyNode *all; - char *search_text; g_signal_handlers_block_by_func (G_OBJECT (editor->priv->sites_view), @@ -832,8 +815,6 @@ search_entry_changed_cb (GtkWidget *entry, EphyHistoryWindow *editor) G_CALLBACK (site_node_selected_cb), editor); - search_text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); - GDK_THREADS_ENTER (); ephy_node_filter_empty (editor->priv->pages_filter); @@ -850,8 +831,6 @@ search_entry_changed_cb (GtkWidget *entry, EphyHistoryWindow *editor) ephy_node_filter_done_changing (editor->priv->pages_filter); GDK_THREADS_LEAVE (); - - g_free (search_text); } static GtkWidget * @@ -866,13 +845,13 @@ build_search_box (EphyHistoryWindow *editor) gtk_container_set_border_width (GTK_CONTAINER (box), 6); gtk_widget_show (box); - entry = gtk_entry_new (); + entry = ephy_search_entry_new (); add_focus_monitor (editor, entry); add_entry_monitor (editor, entry); editor->priv->search_entry = entry; gtk_widget_show (entry); - g_signal_connect (G_OBJECT (entry), "changed", - G_CALLBACK (search_entry_changed_cb), + g_signal_connect (G_OBJECT (entry), "search", + G_CALLBACK (search_entry_search_cb), editor); label = gtk_label_new (NULL); -- cgit v1.2.3