[tepl] WindowActionsEdit: move remaining GActions



commit 538ae69eadccd7c8ed6871e3647a4ec5148e484c
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon May 4 01:00:55 2020 +0200

    WindowActionsEdit: move remaining GActions

 tepl/tepl-application-window.c  | 48 -----------------------------------------
 tepl/tepl-window-actions-edit.c | 46 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 48 deletions(-)
---
diff --git a/tepl/tepl-application-window.c b/tepl/tepl-application-window.c
index 73b07f2..55dabc6 100644
--- a/tepl/tepl-application-window.c
+++ b/tepl/tepl-application-window.c
@@ -112,50 +112,6 @@ G_DEFINE_TYPE_WITH_CODE (TeplApplicationWindow,
                         G_IMPLEMENT_INTERFACE (TEPL_TYPE_TAB_GROUP,
                                                tepl_tab_group_interface_init))
 
-static void
-indent_cb (GSimpleAction *action,
-          GVariant      *parameter,
-          gpointer       user_data)
-{
-       TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
-       TeplView *view;
-
-       view = tepl_tab_group_get_active_view (TEPL_TAB_GROUP (tepl_window));
-
-       if (view != NULL)
-       {
-               TeplBuffer *buffer;
-               GtkTextIter start;
-               GtkTextIter end;
-
-               buffer = tepl_tab_group_get_active_buffer (TEPL_TAB_GROUP (tepl_window));
-               gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (buffer), &start, &end);
-               gtk_source_view_indent_lines (GTK_SOURCE_VIEW (view), &start, &end);
-       }
-}
-
-static void
-unindent_cb (GSimpleAction *action,
-            GVariant      *parameter,
-            gpointer       user_data)
-{
-       TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
-       TeplView *view;
-
-       view = tepl_tab_group_get_active_view (TEPL_TAB_GROUP (tepl_window));
-
-       if (view != NULL)
-       {
-               TeplBuffer *buffer;
-               GtkTextIter start;
-               GtkTextIter end;
-
-               buffer = tepl_tab_group_get_active_buffer (TEPL_TAB_GROUP (tepl_window));
-               gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (buffer), &start, &end);
-               gtk_source_view_unindent_lines (GTK_SOURCE_VIEW (view), &start, &end);
-       }
-}
-
 static void
 update_goto_line_action_sensitivity (TeplApplicationWindow *tepl_window)
 {
@@ -446,10 +402,6 @@ add_actions (TeplApplicationWindow *tepl_window)
         * in tepl-application.c.
         */
        const GActionEntry entries[] = {
-               /* Edit menu */
-               { "tepl-indent", indent_cb },
-               { "tepl-unindent", unindent_cb },
-
                /* Search menu */
                { "tepl-goto-line", goto_line_activate_cb, NULL, "false", goto_line_change_state_cb },
        };
diff --git a/tepl/tepl-window-actions-edit.c b/tepl/tepl-window-actions-edit.c
index bca13c0..ec81566 100644
--- a/tepl/tepl-window-actions-edit.c
+++ b/tepl/tepl-window-actions-edit.c
@@ -133,6 +133,50 @@ select_all_activate_cb (GSimpleAction *action,
        }
 }
 
+static void
+indent_activate_cb (GSimpleAction *action,
+                   GVariant      *parameter,
+                   gpointer       user_data)
+{
+       TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+       TeplView *view;
+
+       view = tepl_tab_group_get_active_view (TEPL_TAB_GROUP (tepl_window));
+
+       if (view != NULL)
+       {
+               TeplBuffer *buffer;
+               GtkTextIter start;
+               GtkTextIter end;
+
+               buffer = tepl_tab_group_get_active_buffer (TEPL_TAB_GROUP (tepl_window));
+               gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (buffer), &start, &end);
+               gtk_source_view_indent_lines (GTK_SOURCE_VIEW (view), &start, &end);
+       }
+}
+
+static void
+unindent_activate_cb (GSimpleAction *action,
+                     GVariant      *parameter,
+                     gpointer       user_data)
+{
+       TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+       TeplView *view;
+
+       view = tepl_tab_group_get_active_view (TEPL_TAB_GROUP (tepl_window));
+
+       if (view != NULL)
+       {
+               TeplBuffer *buffer;
+               GtkTextIter start;
+               GtkTextIter end;
+
+               buffer = tepl_tab_group_get_active_buffer (TEPL_TAB_GROUP (tepl_window));
+               gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (buffer), &start, &end);
+               gtk_source_view_unindent_lines (GTK_SOURCE_VIEW (view), &start, &end);
+       }
+}
+
 void
 _tepl_window_actions_edit_add_actions (TeplApplicationWindow *tepl_window)
 {
@@ -146,6 +190,8 @@ _tepl_window_actions_edit_add_actions (TeplApplicationWindow *tepl_window)
                { "tepl-paste", paste_activate_cb },
                { "tepl-delete", delete_activate_cb },
                { "tepl-select-all", select_all_activate_cb },
+               { "tepl-indent", indent_activate_cb },
+               { "tepl-unindent", unindent_activate_cb },
        };
 
        g_return_if_fail (TEPL_IS_APPLICATION_WINDOW (tepl_window));


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