aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-06-08 02:53:22 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-06-08 02:53:22 +0800
commit2831e21efc64d249e62b5432933680233e3a1673 (patch)
tree152c35ccf47b17848fa8cf654ba75fd1ade3717b
parent80cd8d8b0e4e09a3e6f8628097cd6c9876053387 (diff)
downloadgsoc2013-epiphany-2831e21efc64d249e62b5432933680233e3a1673.tar.gz
gsoc2013-epiphany-2831e21efc64d249e62b5432933680233e3a1673.tar.zst
gsoc2013-epiphany-2831e21efc64d249e62b5432933680233e3a1673.zip
Remove some leftovers.
2003-06-07 Marco Pesenti Gritti <marco@it.gnome.org> * 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)
-rw-r--r--ChangeLog24
-rw-r--r--embed/mozilla/mozilla-notifiers.cpp18
-rw-r--r--lib/widgets/ephy-search-entry.c201
-rw-r--r--lib/widgets/ephy-search-entry.h59
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c30
-rw-r--r--src/ephy-history-window.c33
6 files changed, 296 insertions, 69 deletions
diff --git a/ChangeLog b/ChangeLog
index 7b55e57ad..76d3a7116 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
2003-06-07 Marco Pesenti Gritti <marco@it.gnome.org>
+ * 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)
+
+2003-06-07 Marco Pesenti Gritti <marco@it.gnome.org>
+
* data/epiphany.schemas.in:
* data/glade/prefs-dialog.glade:
* embed/ephy-embed-prefs.h:
diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp
index ce52e498e..58b306a13 100644
--- a/embed/mozilla/mozilla-notifiers.cpp
+++ b/embed/mozilla/mozilla-notifiers.cpp
@@ -107,12 +107,6 @@ mozilla_user_agent_notifier(GConfClient *client,
GConfEntry *entry,
EphyEmbedSingle *single);
-static void
-mozilla_socks_version_notifier (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- EphyEmbedSingle *single);
-
/* Keeps the list of the notifiers we installed for mozilla prefs */
/* to be able to remove them when exiting */
GList *mozilla_notifiers = NULL;
@@ -710,15 +704,3 @@ mozilla_user_agent_notifier (GConfClient *client,
break;
}
}
-
-static void
-mozilla_socks_version_notifier (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- EphyEmbedSingle *single)
-{
- int version;
- version = gconf_value_get_int(entry->value) + 4;
- mozilla_prefs_set_int ("network.proxy.socks_version",
- version);
-}
diff --git a/lib/widgets/ephy-search-entry.c b/lib/widgets/ephy-search-entry.c
new file mode 100644
index 000000000..9837da909
--- /dev/null
+++ b/lib/widgets/ephy-search-entry.c
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#include <gtk/gtklabel.h>
+#include <config.h>
+#include <libgnome/gnome-i18n.h>
+#include <string.h>
+
+#include "ephy-search-entry.h"
+
+static void ephy_search_entry_class_init (EphySearchEntryClass *klass);
+static void ephy_search_entry_init (EphySearchEntry *entry);
+static void ephy_search_entry_finalize (GObject *object);
+
+struct EphySearchEntryPrivate
+{
+ gboolean clearing;
+
+ guint timeout;
+};
+
+enum
+{
+ SEARCH,
+ LAST_SIGNAL
+};
+
+static GObjectClass *parent_class = NULL;
+
+static guint ephy_search_entry_signals[LAST_SIGNAL] = { 0 };
+
+GType
+ephy_search_entry_get_type (void)
+{
+ static GType ephy_search_entry_type = 0;
+
+ if (ephy_search_entry_type == 0)
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (EphySearchEntryClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) ephy_search_entry_class_init,
+ NULL,
+ NULL,
+ sizeof (EphySearchEntry),
+ 0,
+ (GInstanceInitFunc) ephy_search_entry_init
+ };
+
+ ephy_search_entry_type = g_type_register_static (GTK_TYPE_ENTRY,
+ "EphySearchEntry",
+ &our_info, 0);
+ }
+
+ return ephy_search_entry_type;
+}
+
+static void
+ephy_search_entry_class_init (EphySearchEntryClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ object_class->finalize = ephy_search_entry_finalize;
+
+ ephy_search_entry_signals[SEARCH] =
+ g_signal_new ("search",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EphySearchEntryClass, search),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+}
+
+static gboolean
+ephy_search_entry_timeout_cb (EphySearchEntry *entry)
+{
+ gdk_threads_enter ();
+
+ g_signal_emit (G_OBJECT (entry), ephy_search_entry_signals[SEARCH], 0,
+ gtk_entry_get_text (GTK_ENTRY (entry)));
+ entry->priv->timeout = 0;
+
+ gdk_threads_leave ();
+
+ return FALSE;
+}
+
+static void
+ephy_search_entry_changed_cb (GtkEditable *editable,
+ EphySearchEntry *entry)
+{
+ if (entry->priv->clearing == TRUE)
+ return;
+
+ if (entry->priv->timeout != 0)
+ {
+ g_source_remove (entry->priv->timeout);
+ entry->priv->timeout = 0;
+ }
+
+ entry->priv->timeout = g_timeout_add (300, (GSourceFunc) ephy_search_entry_timeout_cb, entry);
+}
+
+static gboolean
+ephy_search_entry_focus_out_event_cb (GtkWidget *widget,
+ GdkEventFocus *event,
+ EphySearchEntry *entry)
+{
+ if (entry->priv->timeout == 0)
+ return FALSE;
+
+ g_source_remove (entry->priv->timeout);
+ entry->priv->timeout = 0;
+
+ g_signal_emit (G_OBJECT (entry), ephy_search_entry_signals[SEARCH], 0,
+ gtk_entry_get_text (GTK_ENTRY (entry)));
+
+ return FALSE;
+}
+static void
+ephy_search_entry_init (EphySearchEntry *entry)
+{
+ entry->priv = g_new0 (EphySearchEntryPrivate, 1);
+
+ g_signal_connect (G_OBJECT (entry),
+ "changed",
+ G_CALLBACK (ephy_search_entry_changed_cb),
+ entry);
+ g_signal_connect (G_OBJECT (entry),
+ "focus_out_event",
+ G_CALLBACK (ephy_search_entry_focus_out_event_cb),
+ entry);
+}
+
+static void
+ephy_search_entry_finalize (GObject *object)
+{
+ EphySearchEntry *entry;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (EPHY_IS_SEARCH_ENTRY (object));
+
+ entry = EPHY_SEARCH_ENTRY (object);
+
+ g_return_if_fail (entry->priv != NULL);
+
+ g_free (entry->priv);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+GtkWidget *
+ephy_search_entry_new (void)
+{
+ GtkWidget *entry;
+
+ entry = GTK_WIDGET (g_object_new (EPHY_TYPE_SEARCH_ENTRY,
+ NULL));
+
+ return entry;
+}
+
+void
+ephy_search_entry_clear (EphySearchEntry *entry)
+{
+ if (entry->priv->timeout != 0)
+ {
+ g_source_remove (entry->priv->timeout);
+ entry->priv->timeout = 0;
+ }
+
+ entry->priv->clearing = TRUE;
+
+ gtk_entry_set_text (GTK_ENTRY (entry), "");
+
+ entry->priv->clearing = FALSE;
+}
diff --git a/lib/widgets/ephy-search-entry.h b/lib/widgets/ephy-search-entry.h
new file mode 100644
index 000000000..95f8339ad
--- /dev/null
+++ b/lib/widgets/ephy-search-entry.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EPHY_SEARCH_ENTRY_H
+#define EPHY_SEARCH_ENTRY_H
+
+#include <gtk/gtkentry.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_SEARCH_ENTRY (ephy_search_entry_get_type ())
+#define EPHY_SEARCH_ENTRY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_SEARCH_ENTRY, EphySearchEntry))
+#define EPHY_SEARCH_ENTRY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_SEARCH_ENTRY, EphySearchEntryClass))
+#define EPHY_IS_SEARCH_ENTRY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_SEARCH_ENTRY))
+#define EPHY_IS_SEARCH_ENTRY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_SEARCH_ENTRY))
+#define EPHY_SEARCH_ENTRY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_SEARCH_ENTRY, EphySearchEntryClass))
+
+typedef struct EphySearchEntryPrivate EphySearchEntryPrivate;
+
+typedef struct
+{
+ GtkEntry parent;
+
+ EphySearchEntryPrivate *priv;
+} EphySearchEntry;
+
+typedef struct
+{
+ GtkEntryClass parent;
+
+ void (*search) (EphySearchEntry *view, const char *text);
+} EphySearchEntryClass;
+
+GType ephy_search_entry_get_type (void);
+
+GtkWidget *ephy_search_entry_new (void);
+
+void ephy_search_entry_clear (EphySearchEntry *entry);
+
+G_END_DECLS
+
+#endif /* __EPHY_SEARCH_ENTRY_H */
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,
@@ -925,20 +924,6 @@ key_pressed_cb (EphyNodeView *view,
}
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,
EphyBookmarksEditor *editor)
@@ -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,
@@ -782,20 +780,6 @@ key_pressed_cb (EphyNodeView *view,
}
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,
EphyHistoryWindow *editor)
@@ -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);