diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | lib/widgets/ephy-search-entry.c | 18 | ||||
-rw-r--r-- | lib/widgets/ephy-search-entry.h | 6 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks-editor.c | 40 |
4 files changed, 68 insertions, 9 deletions
@@ -1,5 +1,18 @@ 2007-09-09 Cosimo Cecchi <cosimoc@svn.gnome.org> + * lib/widgets/ephy-search-entry.c: (ephy_search_entry_get_type), + (ephy_search_entry_timeout_cb), (ephy_search_entry_changed_cb), + (ephy_search_entry_init), (ephy_search_entry_clear): + * lib/widgets/ephy-search-entry.h: + * src/bookmarks/ephy-bookmarks-editor.c: (search_entry_clear_cb), + (build_search_box): + + Modifies the EphySearchEntry to inherit from EphyIconEntry instead of + GtkEntry, to have icons on it. Adds a cleaner icon in the search + entry of Bookmarks Editor. Fixes bug #463469. + +2007-09-09 Cosimo Cecchi <cosimoc@svn.gnome.org> + * src/ephy-toolbar-editor.c: (ephy_toolbar_editor_constructor): Marks as translatable some toolbar editor strings and removes diff --git a/lib/widgets/ephy-search-entry.c b/lib/widgets/ephy-search-entry.c index 5d8330770..efb7a15e3 100644 --- a/lib/widgets/ephy-search-entry.c +++ b/lib/widgets/ephy-search-entry.c @@ -21,6 +21,7 @@ #include "config.h" #include <gtk/gtklabel.h> +#include <gtk/gtkentry.h> #include <glib/gi18n.h> #include <string.h> @@ -68,7 +69,7 @@ ephy_search_entry_get_type (void) (GInstanceInitFunc) ephy_search_entry_init }; - type = g_type_register_static (GTK_TYPE_ENTRY, + type = g_type_register_static (EPHY_TYPE_ICON_ENTRY, "EphySearchEntry", &our_info, 0); } @@ -101,7 +102,8 @@ 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 (entry))); + gtk_entry_get_text (GTK_ENTRY (ephy_icon_entry_get_entry + (EPHY_ICON_ENTRY (entry))))); entry->priv->timeout = 0; return FALSE; @@ -112,7 +114,12 @@ ephy_search_entry_changed_cb (GtkEditable *editable, EphySearchEntry *entry) { 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))))); return; + } if (entry->priv->timeout != 0) { @@ -139,11 +146,11 @@ ephy_search_entry_init (EphySearchEntry *entry) { entry->priv = EPHY_SEARCH_ENTRY_GET_PRIVATE (entry); - g_signal_connect (G_OBJECT (entry), + g_signal_connect (ephy_icon_entry_get_entry (EPHY_ICON_ENTRY (entry)), "destroy", G_CALLBACK (ephy_search_entry_destroy_cb), entry); - g_signal_connect (G_OBJECT (entry), + g_signal_connect (ephy_icon_entry_get_entry (EPHY_ICON_ENTRY (entry)), "changed", G_CALLBACK (ephy_search_entry_changed_cb), entry); @@ -171,7 +178,8 @@ ephy_search_entry_clear (EphySearchEntry *entry) entry->priv->clearing = TRUE; - gtk_entry_set_text (GTK_ENTRY (entry), ""); + gtk_entry_set_text (GTK_ENTRY (ephy_icon_entry_get_entry + (EPHY_ICON_ENTRY (entry))), ""); entry->priv->clearing = FALSE; } diff --git a/lib/widgets/ephy-search-entry.h b/lib/widgets/ephy-search-entry.h index 3ffd2f47e..abb90cc47 100644 --- a/lib/widgets/ephy-search-entry.h +++ b/lib/widgets/ephy-search-entry.h @@ -21,7 +21,7 @@ #ifndef EPHY_SEARCH_ENTRY_H #define EPHY_SEARCH_ENTRY_H -#include <gtk/gtkentry.h> +#include "ephy-icon-entry.h" G_BEGIN_DECLS @@ -38,7 +38,7 @@ typedef struct _EphySearchEntryClass EphySearchEntryClass; struct _EphySearchEntry { - GtkEntry parent; + EphyIconEntry parent; /*< private >*/ EphySearchEntryPrivate *priv; @@ -46,7 +46,7 @@ struct _EphySearchEntry struct _EphySearchEntryClass { - GtkEntryClass parent; + EphyIconEntryClass parent; void (*search) (EphySearchEntry *view, const char *text); }; diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index c853afc83..1e7b3f4a2 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -1605,12 +1605,33 @@ search_entry_search_cb (GtkWidget *entry, const char *search_text, EphyBookmarks ephy_node_filter_done_changing (editor->priv->bookmarks_filter); } +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 && + state == 0 /* left */) + { + ephy_search_entry_clear (EPHY_SEARCH_ENTRY (entry)); + + return TRUE; + } + + return FALSE; +} + static GtkWidget * build_search_box (EphyBookmarksEditor *editor) { GtkWidget *box; GtkWidget *label; GtkWidget *entry; + GtkWidget *cleaner; + GtkWidget *ebox; char *str; box = gtk_hbox_new (FALSE, 6); @@ -1619,12 +1640,29 @@ build_search_box (EphyBookmarksEditor *editor) entry = ephy_search_entry_new (); editor->priv->search_entry = entry; - gtk_widget_show (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); add_entry_monitor (editor, entry); add_focus_monitor (editor, entry); + + gtk_widget_show_all (entry); label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); |