aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/widgets/ephy-search-entry.c60
-rw-r--r--lib/widgets/ephy-search-entry.h6
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c17
-rw-r--r--src/ephy-history-window.c38
4 files changed, 46 insertions, 75 deletions
diff --git a/lib/widgets/ephy-search-entry.c b/lib/widgets/ephy-search-entry.c
index 838266a99..c1e4f3611 100644
--- a/lib/widgets/ephy-search-entry.c
+++ b/lib/widgets/ephy-search-entry.c
@@ -15,7 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $Id$
*/
#include "config.h"
@@ -45,7 +44,7 @@ enum
static guint ephy_search_entry_signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE (EphySearchEntry, ephy_search_entry, EPHY_TYPE_ICON_ENTRY)
+G_DEFINE_TYPE (EphySearchEntry, ephy_search_entry, GTK_TYPE_ENTRY)
static void
ephy_search_entry_class_init (EphySearchEntryClass *klass)
@@ -69,9 +68,8 @@ ephy_search_entry_class_init (EphySearchEntryClass *klass)
static gboolean
ephy_search_entry_timeout_cb (EphySearchEntry *entry)
{
- g_signal_emit (G_OBJECT (entry), ephy_search_entry_signals[SEARCH], 0,
- gtk_entry_get_text (GTK_ENTRY (ephy_icon_entry_get_entry
- (EPHY_ICON_ENTRY (entry)))));
+ g_signal_emit (entry, ephy_search_entry_signals[SEARCH], 0,
+ gtk_entry_get_text (GTK_ENTRY (entry)));
entry->priv->timeout = 0;
return FALSE;
@@ -83,9 +81,8 @@ ephy_search_entry_changed_cb (GtkEditable *editable,
{
if (entry->priv->clearing == TRUE)
{
- g_signal_emit (G_OBJECT (entry), ephy_search_entry_signals[SEARCH], 0,
- gtk_entry_get_text (GTK_ENTRY (ephy_icon_entry_get_entry
- (EPHY_ICON_ENTRY (entry)))));
+ g_signal_emit (entry, ephy_search_entry_signals[SEARCH], 0,
+ gtk_entry_get_text (GTK_ENTRY (entry)));
return;
}
@@ -109,16 +106,49 @@ ephy_search_entry_destroy_cb (GtkEditable *editable,
}
}
+static gboolean
+search_entry_clear_cb (GtkWidget *entry,
+ GtkEntryIconPosition position,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ guint state = event->state & gtk_accelerator_get_default_mod_mask ();
+
+ if (event->button == 1 /* left */ &&
+ state == 0 &&
+ position == GTK_ENTRY_ICON_SECONDARY)
+ {
+ ephy_search_entry_clear (EPHY_SEARCH_ENTRY (entry));
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
ephy_search_entry_init (EphySearchEntry *entry)
{
entry->priv = EPHY_SEARCH_ENTRY_GET_PRIVATE (entry);
- g_signal_connect (ephy_icon_entry_get_entry (EPHY_ICON_ENTRY (entry)),
+ gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ GTK_STOCK_CLEAR);
+ gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ TRUE);
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ _("Clear"));
+ g_signal_connect (entry,
+ "icon-pressed",
+ G_CALLBACK (search_entry_clear_cb),
+ NULL);
+ g_signal_connect (entry,
"destroy",
G_CALLBACK (ephy_search_entry_destroy_cb),
entry);
- g_signal_connect (ephy_icon_entry_get_entry (EPHY_ICON_ENTRY (entry)),
+ g_signal_connect (entry,
"changed",
G_CALLBACK (ephy_search_entry_changed_cb),
entry);
@@ -134,12 +164,7 @@ ephy_search_entry_init (EphySearchEntry *entry)
GtkWidget *
ephy_search_entry_new (void)
{
- GtkWidget *entry;
-
- entry = GTK_WIDGET (g_object_new (EPHY_TYPE_SEARCH_ENTRY,
- NULL));
-
- return entry;
+ return gtk_widget_new (EPHY_TYPE_SEARCH_ENTRY, NULL);
}
/**
@@ -160,8 +185,7 @@ ephy_search_entry_clear (EphySearchEntry *entry)
entry->priv->clearing = TRUE;
- gtk_entry_set_text (GTK_ENTRY (ephy_icon_entry_get_entry
- (EPHY_ICON_ENTRY (entry))), "");
+ 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
index 08446a882..f97ab0692 100644
--- a/lib/widgets/ephy-search-entry.h
+++ b/lib/widgets/ephy-search-entry.h
@@ -25,7 +25,7 @@
#ifndef EPHY_SEARCH_ENTRY_H
#define EPHY_SEARCH_ENTRY_H
-#include "ephy-icon-entry.h"
+#include <gtk/gtk.h>
G_BEGIN_DECLS
@@ -42,14 +42,14 @@ typedef struct _EphySearchEntryPrivate EphySearchEntryPrivate;
struct _EphySearchEntryClass
{
- EphyIconEntryClass parent;
+ GtkEntryClass parent;
void (*search) (EphySearchEntry *view, const char *text);
};
struct _EphySearchEntry
{
- EphyIconEntry parent;
+ GtkEntry parent;
/*< private >*/
EphySearchEntryPrivate *priv;
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 403c21f33..4175dec1f 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -1604,8 +1604,6 @@ build_search_box (EphyBookmarksEditor *editor)
GtkWidget *box;
GtkWidget *label;
GtkWidget *entry;
- GtkWidget *cleaner;
- GtkWidget *ebox;
char *str;
box = gtk_hbox_new (FALSE, 6);
@@ -1615,21 +1613,6 @@ build_search_box (EphyBookmarksEditor *editor)
entry = ephy_search_entry_new ();
editor->priv->search_entry = entry;
- cleaner = gtk_image_new_from_stock (GTK_STOCK_CLEAR,
- GTK_ICON_SIZE_MENU);
- ebox = gtk_event_box_new ();
- gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
-
- gtk_widget_add_events (ebox, GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK);
- g_signal_connect (ebox , "button-release-event",
- G_CALLBACK (search_entry_clear_cb),
- entry);
- gtk_widget_set_tooltip_text (ebox,
- _("Clear"));
- gtk_container_add (GTK_CONTAINER (ebox), cleaner);
- ephy_icon_entry_pack_widget ((EPHY_ICON_ENTRY (entry)), ebox, FALSE);
-
g_signal_connect (G_OBJECT (entry), "search",
G_CALLBACK (search_entry_search_cb),
editor);
diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c
index 961828067..d38493ca3 100644
--- a/src/ephy-history-window.c
+++ b/src/ephy-history-window.c
@@ -916,8 +916,7 @@ add_by_word_filter (EphyHistoryWindow *editor, EphyNodeFilter *filter, int level
{
const char *search_text;
- search_text = gtk_entry_get_text (GTK_ENTRY (ephy_icon_entry_get_entry
- (EPHY_ICON_ENTRY (editor->priv->search_entry))));
+ search_text = gtk_entry_get_text (GTK_ENTRY (editor->priv->search_entry));
if (search_text == NULL) return;
ephy_node_filter_add_expression
@@ -1017,31 +1016,11 @@ time_combo_changed_cb (GtkWidget *combo, EphyHistoryWindow *editor)
setup_filters (editor, TRUE, TRUE);
}
-static gboolean
-search_entry_clear_cb (GtkWidget *ebox,
- GdkEventButton *event,
- GtkWidget *entry)
-{
- guint state = event->state & gtk_accelerator_get_default_mod_mask ();
-
- if (event->type == GDK_BUTTON_RELEASE &&
- event->button == 1 /* left */ &&
- state == 0)
- {
- ephy_search_entry_clear (EPHY_SEARCH_ENTRY (entry));
-
- return TRUE;
- }
-
- return FALSE;
-}
-
static GtkWidget *
build_search_box (EphyHistoryWindow *editor)
{
GtkWidget *box, *label, *entry;
GtkWidget *combo;
- GtkWidget *cleaner, *ebox;
char *str;
int time_range;
@@ -1054,21 +1033,6 @@ build_search_box (EphyHistoryWindow *editor)
add_entry_monitor (editor, entry);
editor->priv->search_entry = entry;
- cleaner = gtk_image_new_from_stock (GTK_STOCK_CLEAR,
- GTK_ICON_SIZE_MENU);
- ebox = gtk_event_box_new ();
- gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
-
- gtk_widget_add_events (ebox, GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK);
- g_signal_connect (ebox , "button-release-event",
- G_CALLBACK (search_entry_clear_cb),
- entry);
- gtk_widget_set_tooltip_text (ebox,
- _("Clear"));
- gtk_container_add (GTK_CONTAINER (ebox), cleaner);
- ephy_icon_entry_pack_widget ((EPHY_ICON_ENTRY (entry)), ebox, FALSE);
-
gtk_widget_show_all (entry);
label = gtk_label_new (NULL);