From 046e8b96bc77f0adfed67ed7f111a9e6002913f9 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Thu, 16 Dec 2004 13:30:21 +0000 Subject: Add "Clear" to entry context menu. Fixes bug #118395. 2004-12-16 Christian Persch * 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. --- lib/widgets/ephy-location-entry.c | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'lib/widgets') 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 #include #include +#include +#include +#include +#include +#include + #include #define EPHY_LOCATION_ENTRY_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_LOCATION_ENTRY, EphyLocationEntryPrivate)) @@ -327,6 +333,46 @@ entry_drag_drop_cb (GtkWidget *widget, return FALSE; } +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) { @@ -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", -- cgit v1.2.3