[gnome-builder] view: bring back goto line popover activation



commit 9bad416c3abcfcb17ef1ad17988237c092c82cba
Author: Sebastien Lafargue <slafargue gnome org>
Date:   Thu Aug 17 23:13:28 2017 +0200

    view: bring back goto line popover activation
    
    We have lost this (<ctrl>i in Builder default keyboard mode)
    in the UI revamp.

 data/keybindings/default.css                     |    2 +-
 libide/editor/ide-editor-layout-stack-controls.c |   24 ++++++++++++++++++++++
 libide/editor/ide-editor-layout-stack-controls.h |    2 +
 3 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/data/keybindings/default.css b/data/keybindings/default.css
index 0f7fb42..f961368 100644
--- a/data/keybindings/default.css
+++ b/data/keybindings/default.css
@@ -17,7 +17,7 @@
   bind "<ctrl>j" { "join-lines" () };
   bind "<ctrl>u" { "change-case" (upper) };
   bind "<ctrl>l" { "change-case" (lower) };
-  bind "<ctrl>i" { "action" ("editor-controls", "goto-line", "") };
+  bind "<ctrl>i" { "action" ("editor-view", "goto-line", "") };
   bind "<ctrl>asciitilde" { "change-case" (toggle) };
   bind "<ctrl><alt>d" { "duplicate-entire-line" ()};
 
diff --git a/libide/editor/ide-editor-layout-stack-controls.c 
b/libide/editor/ide-editor-layout-stack-controls.c
index 0ad0d8a..d3333f0 100644
--- a/libide/editor/ide-editor-layout-stack-controls.c
+++ b/libide/editor/ide-editor-layout-stack-controls.c
@@ -198,6 +198,17 @@ warning_button_clicked (IdeEditorLayoutStackControls *self,
 }
 
 static void
+show_goto_line (GSimpleAction                 *action,
+                GVariant                      *param,
+                IdeEditorLayoutStackControls  *self)
+{
+  g_assert (G_IS_SIMPLE_ACTION (action));
+  g_assert (IDE_IS_EDITOR_LAYOUT_STACK_CONTROLS (self));
+
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->goto_line_button), TRUE);
+}
+
+static void
 ide_editor_layout_stack_controls_bind (IdeEditorLayoutStackControls *self,
                                        GtkTextBuffer                *buffer,
                                        DzlSignalGroup               *buffer_signals)
@@ -219,6 +230,7 @@ ide_editor_layout_stack_controls_finalize (GObject *object)
 
   g_clear_object (&self->buffer_bindings);
   g_clear_object (&self->buffer_signals);
+  g_clear_object (&self->goto_line_action);
 
   self->view = NULL;
 
@@ -289,12 +301,21 @@ ide_editor_layout_stack_controls_init (IdeEditorLayoutStackControls *self)
                                    G_CALLBACK (document_cursor_moved),
                                    self,
                                    G_CONNECT_SWAPPED);
+
+  self->goto_line_action = g_simple_action_new ("goto-line", NULL);
+  g_signal_connect_object (self->goto_line_action,
+                           "activate",
+                           G_CALLBACK (show_goto_line),
+                           self,
+                           0);
 }
 
 void
 ide_editor_layout_stack_controls_set_view (IdeEditorLayoutStackControls *self,
                                            IdeEditorView                *view)
 {
+  GActionGroup *editor_view_group;
+
   g_return_if_fail (IDE_IS_EDITOR_LAYOUT_STACK_CONTROLS (self));
   g_return_if_fail (!view || IDE_IS_EDITOR_VIEW (view));
 
@@ -321,5 +342,8 @@ ide_editor_layout_stack_controls_set_view (IdeEditorLayoutStackControls *self,
                         &self->view);
       dzl_binding_group_set_source (self->buffer_bindings, view->buffer);
       dzl_signal_group_set_target (self->buffer_signals, view->buffer);
+
+      if (NULL != (editor_view_group = gtk_widget_get_action_group (GTK_WIDGET (view), "editor-view")))
+        g_action_map_add_action (G_ACTION_MAP (editor_view_group), G_ACTION (self->goto_line_action));
     }
 }
diff --git a/libide/editor/ide-editor-layout-stack-controls.h 
b/libide/editor/ide-editor-layout-stack-controls.h
index f63d806..d28967e 100644
--- a/libide/editor/ide-editor-layout-stack-controls.h
+++ b/libide/editor/ide-editor-layout-stack-controls.h
@@ -43,6 +43,8 @@ struct _IdeEditorLayoutStackControls
   DzlSimpleLabel       *line_label;
   DzlSimpleLabel       *column_label;
   GtkLabel             *range_label;
+
+  GSimpleAction        *goto_line_action;
 };
 
 void ide_editor_layout_stack_controls_set_view (IdeEditorLayoutStackControls *self,


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