diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-12-16 21:30:21 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-12-16 21:30:21 +0800 |
commit | 046e8b96bc77f0adfed67ed7f111a9e6002913f9 (patch) | |
tree | 3443e16d3397445dec98fa8700d7729dfe5da3f8 /lib/widgets/ephy-location-entry.c | |
parent | 37f5375bc8c2d18dfe776332d0206806f672d81b (diff) | |
download | gsoc2013-epiphany-046e8b96bc77f0adfed67ed7f111a9e6002913f9.tar.gz gsoc2013-epiphany-046e8b96bc77f0adfed67ed7f111a9e6002913f9.tar.zst gsoc2013-epiphany-046e8b96bc77f0adfed67ed7f111a9e6002913f9.zip |
Add "Clear" to entry context menu. Fixes bug #118395.
2004-12-16 Christian Persch <chpe@cvs.gnome.org>
* lib/widgets/ephy-location-entry.c: (entry_clear_activate_cb),
(entry_populate_popup_cb),
(ephy_location_entry_construct_contents):
Add "Clear" to entry context menu. Fixes bug #118395.
Diffstat (limited to 'lib/widgets/ephy-location-entry.c')
-rw-r--r-- | lib/widgets/ephy-location-entry.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c index 100af8f58..683b6fb08 100644 --- a/lib/widgets/ephy-location-entry.c +++ b/lib/widgets/ephy-location-entry.c @@ -35,6 +35,12 @@ #include <gtk/gtkcellrenderertext.h> #include <gtk/gtkcelllayout.h> #include <gtk/gtktreemodelsort.h> +#include <gtk/gtkstock.h> +#include <gtk/gtkimage.h> +#include <gtk/gtkimagemenuitem.h> +#include <gtk/gtkseparatormenuitem.h> +#include <glib/gi18n.h> + #include <string.h> #define EPHY_LOCATION_ENTRY_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_LOCATION_ENTRY, EphyLocationEntryPrivate)) @@ -328,6 +334,46 @@ entry_drag_drop_cb (GtkWidget *widget, } static void +entry_clear_activate_cb (GtkMenuItem *item, + EphyLocationEntry *entry) +{ + EphyLocationEntryPrivate *priv = entry->priv; + + priv->user_changed = FALSE; + gtk_entry_set_text (GTK_ENTRY (priv->entry), ""); + priv->user_changed = TRUE; +} + +static void +entry_populate_popup_cb (GtkEntry *entry, + GtkMenu *menu, + EphyLocationEntry *lentry) +{ + GtkWidget *image; + GtkWidget *menuitem; + + menuitem = gtk_separator_menu_item_new (); + gtk_widget_show (menuitem); + gtk_menu_shell_prepend (GTK_MENU_SHELL(menu), menuitem); + + /* Clear and Copy mnemonics conflict, make custom menuitem */ + image = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU); + gtk_widget_show (image); + + /* To translators: the mnemonic shouldn't conflict with any of the + * stock items in the GtkEntry context menu (Cut, Copy, Paste, Delete, + * and Insert Unicode control character.) */ + menuitem = gtk_image_menu_item_new_with_mnemonic (_("Cl_ear")); + gtk_widget_show (menuitem); + + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(menuitem), image); + gtk_menu_shell_prepend (GTK_MENU_SHELL(menu), menuitem); + + g_signal_connect (menuitem , "activate", + G_CALLBACK (entry_clear_activate_cb), lentry); +} + +static void ephy_location_entry_construct_contents (EphyLocationEntry *le) { EphyLocationEntryPrivate *p = le->priv; @@ -339,6 +385,8 @@ ephy_location_entry_construct_contents (EphyLocationEntry *le) gtk_container_add (GTK_CONTAINER (le), p->entry); gtk_widget_show (p->entry); + g_signal_connect (p->entry, "populate_popup", + G_CALLBACK (entry_populate_popup_cb), le); g_signal_connect (p->entry, "button_press_event", G_CALLBACK (entry_button_press_cb), le); g_signal_connect (p->entry, "changed", |