From 7411f596afe064f52e49e778f81d0e88f0b13d3c Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 15 Feb 2008 01:10:36 +0000 Subject: Add Undo/Redo commands to the location entry, both in the context menu and linked to the main window commands. Bug #171179. svn path=/trunk/; revision=7945 --- src/ephy-window.c | 27 ++++++++++++++++++++++++--- src/window-commands.c | 40 +++++++++++++++++++++++++++++----------- 2 files changed, 53 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/ephy-window.c b/src/ephy-window.c index 93f9f16f7..46da33704 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -57,6 +57,7 @@ #include "ephy-find-toolbar.h" #include "ephy-embed-persist.h" #include "ephy-embed-factory.h" +#include "ephy-location-entry.h" #include #include @@ -1133,15 +1134,35 @@ update_edit_actions_sensitivity (EphyWindow *window, gboolean hide) if (GTK_IS_EDITABLE (widget)) { gboolean has_selection; - + GtkActionGroup *action_group; + GtkAction *location_action; + GSList *proxies; + GtkWidget *proxy; + + action_group = ephy_toolbar_get_action_group (window->priv->toolbar); + location_action = gtk_action_group_get_action (action_group, + "Location"); + proxies = gtk_action_get_proxies (location_action); + proxy = GTK_WIDGET (proxies->data); + has_selection = gtk_editable_get_selection_bounds (GTK_EDITABLE (widget), NULL, NULL); can_copy = has_selection; can_cut = has_selection; can_paste = TRUE; - can_undo = FALSE; - can_redo = FALSE; + if (proxy != NULL && + EPHY_IS_LOCATION_ENTRY (proxy) && + widget == ephy_location_entry_get_entry (EPHY_LOCATION_ENTRY (proxy))) + { + can_undo = ephy_location_entry_get_can_undo (EPHY_LOCATION_ENTRY (proxy)); + can_redo = ephy_location_entry_get_can_redo (EPHY_LOCATION_ENTRY (proxy)); + } + else + { + can_undo = FALSE; + can_redo = FALSE; + } } else { diff --git a/src/window-commands.c b/src/window-commands.c index 9bc698a67..dd5bd634d 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -355,14 +355,24 @@ window_cmd_edit_undo (GtkAction *action, { GtkWidget *widget; GtkWidget *embed; + GtkWidget *location_entry; widget = gtk_window_get_focus (GTK_WINDOW (window)); - embed = gtk_widget_get_ancestor (widget, EPHY_TYPE_EMBED); - - if (embed) + location_entry = gtk_widget_get_ancestor (widget, EPHY_TYPE_LOCATION_ENTRY); + + if (location_entry) + { + ephy_location_entry_reset (EPHY_LOCATION_ENTRY (location_entry)); + } + else { - ephy_command_manager_do_command (EPHY_COMMAND_MANAGER (embed), - "cmd_undo"); + embed = gtk_widget_get_ancestor (widget, EPHY_TYPE_EMBED); + + if (embed) + { + ephy_command_manager_do_command (EPHY_COMMAND_MANAGER (embed), + "cmd_undo"); + } } } @@ -372,17 +382,25 @@ window_cmd_edit_redo (GtkAction *action, { GtkWidget *widget; GtkWidget *embed; + GtkWidget *location_entry; widget = gtk_window_get_focus (GTK_WINDOW (window)); - embed = gtk_widget_get_ancestor (widget, EPHY_TYPE_EMBED); - - if (embed) + location_entry = gtk_widget_get_ancestor (widget, EPHY_TYPE_LOCATION_ENTRY); + + if (location_entry) { - ephy_command_manager_do_command (EPHY_COMMAND_MANAGER (embed), - "cmd_redo"); + ephy_location_entry_undo_reset (EPHY_LOCATION_ENTRY (location_entry)); + } + else + { + embed = gtk_widget_get_ancestor (widget, EPHY_TYPE_EMBED); + if (embed) + { + ephy_command_manager_do_command (EPHY_COMMAND_MANAGER (embed), + "cmd_redo"); + } } } - void window_cmd_edit_cut (GtkAction *action, EphyWindow *window) -- cgit v1.2.3