From b446f6693c136813dd6ad780ab826a45939e89ce Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 4 Nov 2003 09:08:47 +0000 Subject: update undo/redo sensitivity 2003-11-04 Marco Pesenti Gritti * src/ephy-window.c: (window_cmd_edit): update undo/redo sensitivity 2003-11-04 David Adam Bordoley * data/ui/epiphany-ui.xml: * src/window-commands.c: (window_cmd_edit_undo), (window_cmd_edit_redo): * src/window-commands.h: Menus for Undo/Redo --- ChangeLog | 15 +++++++++++++++ data/ui/epiphany-ui.xml | 3 +++ src/ephy-window.c | 20 +++++++++++++++++++- src/window-commands.c | 34 ++++++++++++++++++++++++++++++++++ src/window-commands.h | 6 ++++++ 5 files changed, 77 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 890c46b91..cf52fe8c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2003-11-04 Marco Pesenti Gritti + + * src/ephy-window.c: (window_cmd_edit): + + update undo/redo sensitivity + +2003-11-04 David Adam Bordoley + + * data/ui/epiphany-ui.xml: + * src/window-commands.c: (window_cmd_edit_undo), + (window_cmd_edit_redo): + * src/window-commands.h: + + Menus for Undo/Redo + 2003-11-04 Marco Pesenti Gritti * data/ui/epiphany-ui.xml: diff --git a/data/ui/epiphany-ui.xml b/data/ui/epiphany-ui.xml index 5c6b2cf0d..a9cbdc49a 100644 --- a/data/ui/epiphany-ui.xml +++ b/data/ui/epiphany-ui.xml @@ -14,6 +14,9 @@ + + + diff --git a/src/ephy-window.c b/src/ephy-window.c index 03b1d70d2..cbc45f074 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -109,6 +109,12 @@ static GtkActionEntry ephy_menu_entries [] = { G_CALLBACK (window_cmd_file_close_window) }, /* Edit menu */ + { "EditUndo", GTK_STOCK_UNDO, N_("_Undo"), "Z", + N_("Undo the last action"), + G_CALLBACK (window_cmd_edit_undo) }, + { "EditRedo", GTK_STOCK_REDO, N_("Re_do"), "Z", + N_("Redo the last undone action"), + G_CALLBACK (window_cmd_edit_redo) }, { "EditCut", GTK_STOCK_CUT, N_("Cu_t"), "X", N_("Cut the selection"), G_CALLBACK (window_cmd_edit_cut) }, @@ -350,7 +356,7 @@ window_cmd_edit (GtkAction *action, { GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window)); GtkActionGroup *action_group; - gboolean can_copy, can_cut; + gboolean can_copy, can_cut, can_undo, can_redo; if (GTK_IS_EDITABLE (widget)) { @@ -361,6 +367,8 @@ window_cmd_edit (GtkAction *action, can_copy = has_selection; can_cut = has_selection; + can_undo = FALSE; + can_redo = FALSE; } else { @@ -373,6 +381,10 @@ window_cmd_edit (GtkAction *action, (EPHY_COMMAND_MANAGER (embed), "cmd_copy", &can_copy); ephy_command_manager_get_command_state (EPHY_COMMAND_MANAGER (embed), "cmd_cut", &can_cut); + ephy_command_manager_get_command_state + (EPHY_COMMAND_MANAGER (embed), "cmd_undo", &can_undo); + ephy_command_manager_get_command_state + (EPHY_COMMAND_MANAGER (embed), "cmd_redo", &can_redo); } action_group = window->priv->action_group; @@ -382,6 +394,12 @@ window_cmd_edit (GtkAction *action, action = gtk_action_group_get_action (action_group, "EditCut"); g_object_set (action, "sensitive", can_cut, NULL); + + action = gtk_action_group_get_action (action_group, "EditUndo"); + g_object_set (action, "sensitive", can_undo, NULL); + + action = gtk_action_group_get_action (action_group, "EditRedo"); + g_object_set (action, "sensitive", can_redo, NULL); } static void diff --git a/src/window-commands.c b/src/window-commands.c index 4d9e54e33..d7d48834b 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -398,6 +398,40 @@ window_cmd_file_close_window (GtkAction *action, ephy_window_remove_tab (window, tab); } +void +window_cmd_edit_undo (GtkAction *action, + EphyWindow *window) +{ + GtkWidget *widget; + GtkWidget *embed; + + widget = gtk_window_get_focus (GTK_WINDOW (window)); + embed = gtk_widget_get_ancestor (widget, EPHY_TYPE_EMBED); + + if (embed) + { + ephy_command_manager_do_command (EPHY_COMMAND_MANAGER (embed), + "cmd_undo"); + } +} + +void +window_cmd_edit_redo (GtkAction *action, + EphyWindow *window) +{ + GtkWidget *widget; + GtkWidget *embed; + + widget = gtk_window_get_focus (GTK_WINDOW (window)); + 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) diff --git a/src/window-commands.h b/src/window-commands.h index 2f0f8bc14..63640abbe 100644 --- a/src/window-commands.h +++ b/src/window-commands.h @@ -80,6 +80,12 @@ void window_cmd_file_send_to (GtkAction *action, void window_cmd_file_close_window (GtkAction *action, EphyWindow *window); +void window_cmd_edit_undo (GtkAction *action, + EphyWindow *window); + +void window_cmd_edit_redo (GtkAction *action, + EphyWindow *window); + void window_cmd_edit_cut (GtkAction *action, EphyWindow *window); -- cgit v1.2.3