[latexila] Add indent/unindent to the edit menu



commit 231e3b0d00d7b492757689f9e9c9bf0fc8b762b6
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Apr 6 13:47:27 2015 +0200

    Add indent/unindent to the edit menu
    
    Indent/unindent is now available in the GtkSourceView API. The feature
    was already available before, but just with keyboard shortcuts. Now the
    keyboard shortcuts are discoverable directly in the latexila UI.

 src/main_window_edit.vala |   34 +++++++++++++++++++++++++++++++++-
 src/ui/ui.xml             |    5 ++++-
 2 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/src/main_window_edit.vala b/src/main_window_edit.vala
index 0e326df..414be85 100644
--- a/src/main_window_edit.vala
+++ b/src/main_window_edit.vala
@@ -1,7 +1,7 @@
 /*
  * This file is part of LaTeXila.
  *
- * Copyright © 2012 Sébastien Wilmet
+ * Copyright © 2012, 2015 Sébastien Wilmet
  *
  * LaTeXila is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -54,6 +54,12 @@ public class MainWindowEdit
         { "EditSelectAll", "edit-select-all", N_("Select _All"), "<Control>A",
             N_("Select the entire document"), on_select_all },
 
+        { "EditIndent", "format-indent-more", N_("_Indent"), "Tab",
+            N_("Indent the selected lines"), on_indent },
+
+        { "EditUnindent", "format-indent-less", N_("_Unindent"), "<Shift>Tab",
+            N_("Unindent the selected lines"), on_unindent },
+
         { "EditComment", null, N_("_Comment"), "<Control>M",
             N_("Comment the selected lines (add the character \"%\")"),
             on_comment },
@@ -128,6 +134,8 @@ public class MainWindowEdit
             "EditPaste",
             "EditDelete",
             "EditSelectAll",
+            "EditIndent",
+            "EditUnindent",
             "EditComment",
             "EditUncomment",
             "EditCompletion"
@@ -240,6 +248,30 @@ public class MainWindowEdit
         _main_window.active_view.my_select_all ();
     }
 
+    public void on_indent ()
+    {
+        DocumentTab? tab = _main_window.active_tab;
+        return_if_fail (tab != null);
+
+        TextIter start;
+        TextIter end;
+        tab.document.get_selection_bounds (out start, out end);
+
+        tab.view.indent_lines (start, end);
+    }
+
+    public void on_unindent ()
+    {
+        DocumentTab? tab = _main_window.active_tab;
+        return_if_fail (tab != null);
+
+        TextIter start;
+        TextIter end;
+        tab.document.get_selection_bounds (out start, out end);
+
+        tab.view.unindent_lines (start, end);
+    }
+
     public void on_comment ()
     {
         return_if_fail (_main_window.active_tab != null);
diff --git a/src/ui/ui.xml b/src/ui/ui.xml
index faf0fdd..8f8c172 100644
--- a/src/ui/ui.xml
+++ b/src/ui/ui.xml
@@ -1,7 +1,7 @@
 <!--
 This file is part of LaTeXila.
 
-Copyright © 2010-2012 Sébastien Wilmet
+Copyright © 2010-2015 Sébastien Wilmet
 
 LaTeXila is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -45,6 +45,9 @@ along with LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
       <menuitem action="EditDelete" />
       <menuitem action="EditSelectAll" />
       <separator />
+      <menuitem action="EditIndent" />
+      <menuitem action="EditUnindent" />
+      <separator />
       <menuitem action="EditComment" />
       <menuitem action="EditUncomment" />
       <separator />


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]