[latexila/wip/latexila-next] MainWindowEdit: use undo/redo Tepl GActions
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila/wip/latexila-next] MainWindowEdit: use undo/redo Tepl GActions
- Date: Sat, 19 Aug 2017 16:12:25 +0000 (UTC)
commit 876fbf140179ccc730c5904c4a598f1871159ef7
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Aug 19 18:08:39 2017 +0200
MainWindowEdit: use undo/redo Tepl GActions
src/main_window_edit.vala | 67 ++++-----------------------------------------
1 files changed, 6 insertions(+), 61 deletions(-)
---
diff --git a/src/main_window_edit.vala b/src/main_window_edit.vala
index aea856d..1aab7fd 100644
--- a/src/main_window_edit.vala
+++ b/src/main_window_edit.vala
@@ -30,10 +30,10 @@ public class MainWindowEdit
{ "Edit", null, N_("_Edit") },
{ "EditUndo", "edit-undo", N_("_Undo"), "<Control>Z",
- N_("Undo the last action"), on_undo },
+ N_("Undo the last action") },
{ "EditRedo", "edit-redo", N_("_Redo"), "<Shift><Control>Z",
- N_("Redo the last undone action"), on_redo },
+ N_("Redo the last undone action") },
{ "EditCut", "edit-cut", N_("Cu_t"), "<Control>X",
N_("Cut the selection") },
@@ -90,6 +90,10 @@ public class MainWindowEdit
LatexilaApp app = LatexilaApp.get_instance ();
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "tepl-undo",
+ _action_group, "EditUndo");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "tepl-redo",
+ _action_group, "EditRedo");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "tepl-cut",
_action_group, "EditCut");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "tepl-copy",
@@ -110,21 +114,8 @@ public class MainWindowEdit
{
bool sensitive = _main_window.active_tab != null;
- set_edit_actions_sensitivity (sensitive);
-
- if (sensitive)
- {
- set_undo_sensitivity ();
- set_redo_sensitivity ();
- }
- }
-
- private void set_edit_actions_sensitivity (bool sensitive)
- {
string[] action_names =
{
- "EditUndo",
- "EditRedo",
"EditIndent",
"EditUnindent",
"EditComment",
@@ -139,54 +130,8 @@ public class MainWindowEdit
}
}
- private void set_undo_sensitivity ()
- {
- bool can_undo = false;
-
- if (_main_window.active_tab != null)
- can_undo = _main_window.active_document.can_undo;
-
- Gtk.Action action = _action_group.get_action ("EditUndo");
- action.sensitive = can_undo;
- }
-
- private void set_redo_sensitivity ()
- {
- bool can_redo = false;
-
- if (_main_window.active_tab != null)
- can_redo = _main_window.active_document.can_redo;
-
- Gtk.Action action = _action_group.get_action ("EditRedo");
- action.sensitive = can_redo;
- }
-
/* Gtk.Action callbacks */
- public void on_undo ()
- {
- return_if_fail (_main_window.active_tab != null);
-
- if (_main_window.active_document.can_undo)
- {
- _main_window.active_document.undo ();
- _main_window.active_view.scroll_to_cursor ();
- _main_window.active_view.grab_focus ();
- }
- }
-
- public void on_redo ()
- {
- return_if_fail (_main_window.active_tab != null);
-
- if (_main_window.active_document.can_redo)
- {
- _main_window.active_document.redo ();
- _main_window.active_view.scroll_to_cursor ();
- _main_window.active_view.grab_focus ();
- }
- }
-
public void on_indent ()
{
DocumentTab? tab = _main_window.active_tab;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]