[gnome-builder] editor: reimplement goto-line action for popover activation



commit 951331cfe22f77802f62edfebbcb8375ea25ef17
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jul 19 19:31:11 2016 -0700

    editor: reimplement goto-line action for popover activation
    
    This is fallout from the refactoring, and now it should work again.

 data/keybindings/default.css                      |    2 +-
 libide/editor/ide-editor-layout-stack-addin.c     |   20 ++++++++++++++++
 libide/editor/ide-editor-layout-stack-controls.c  |   24 +-------------------
 libide/editor/ide-editor-layout-stack-controls.h  |   25 +++++++++++++++++++++
 libide/editor/ide-editor-layout-stack-controls.ui |    2 +-
 libide/editor/ide-editor-view-actions.c           |   14 -----------
 6 files changed, 48 insertions(+), 39 deletions(-)
---
diff --git a/data/keybindings/default.css b/data/keybindings/default.css
index b0f9431..89e2966 100644
--- a/data/keybindings/default.css
+++ b/data/keybindings/default.css
@@ -21,7 +21,7 @@
   bind "<ctrl>j" { "join-lines" () };
   bind "<ctrl>u" { "change-case" (upper) };
   bind "<ctrl>l" { "change-case" (lower) };
-  bind "<ctrl>i" { "action" ("view", "goto-line", "") };
+  bind "<ctrl>i" { "action" ("editor-controls", "goto-line", "") };
   bind "<ctrl>asciitilde" { "change-case" (toggle) };
   bind "<ctrl><alt>d" { "duplicate-entire-line" ()};
 
diff --git a/libide/editor/ide-editor-layout-stack-addin.c b/libide/editor/ide-editor-layout-stack-addin.c
index f669e0e..e46dc11 100644
--- a/libide/editor/ide-editor-layout-stack-addin.c
+++ b/libide/editor/ide-editor-layout-stack-addin.c
@@ -50,10 +50,26 @@ ide_editor_layout_stack_addin_init (IdeEditorLayoutStackAddin *self)
 }
 
 static void
+goto_line_activate (GSimpleAction *action,
+                    GVariant      *param,
+                    gpointer       user_data)
+{
+  IdeEditorLayoutStackAddin *self = user_data;
+
+  g_assert (IDE_IS_EDITOR_LAYOUT_STACK_ADDIN (self));
+
+  gtk_widget_activate (GTK_WIDGET (self->controls->goto_line_button));
+}
+
+static void
 ide_editor_layout_stack_addin_load (IdeLayoutStackAddin *addin,
                                     IdeLayoutStack      *stack)
 {
   IdeEditorLayoutStackAddin *self = (IdeEditorLayoutStackAddin *)addin;
+  g_autoptr(GSimpleActionGroup) group = NULL;
+  static const GActionEntry entries[] = {
+    { "goto-line", goto_line_activate },
+  };
 
   g_assert (IDE_IS_EDITOR_LAYOUT_STACK_ADDIN (self));
   g_assert (IDE_IS_LAYOUT_STACK (stack));
@@ -64,6 +80,10 @@ ide_editor_layout_stack_addin_load (IdeLayoutStackAddin *addin,
                     G_CALLBACK (gtk_widget_destroyed),
                     &self->controls);
   ide_layout_stack_add_control (stack, GTK_WIDGET (self->controls), 0);
+
+  group = g_simple_action_group_new ();
+  g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), self);
+  gtk_widget_insert_action_group (GTK_WIDGET (stack), "editor-controls", G_ACTION_GROUP (group));
 }
 
 static void
diff --git a/libide/editor/ide-editor-layout-stack-controls.c 
b/libide/editor/ide-editor-layout-stack-controls.c
index fe592b7..26e1a19 100644
--- a/libide/editor/ide-editor-layout-stack-controls.c
+++ b/libide/editor/ide-editor-layout-stack-controls.c
@@ -18,35 +18,12 @@
 
 #define G_LOG_DOMAIN "ide-editor-layout-stack-controls"
 
-#include <egg-binding-group.h>
-#include <egg-signal-group.h>
-#include <egg-simple-popover.h>
 #include <glib/gi18n.h>
 
-#include "editor/ide-editor-frame.h"
 #include "editor/ide-editor-frame-private.h"
 #include "editor/ide-editor-layout-stack-controls.h"
-#include "editor/ide-editor-tweak-widget.h"
-#include "editor/ide-editor-view.h"
 #include "editor/ide-editor-view-private.h"
 
-struct _IdeEditorLayoutStackControls
-{
-  GtkBox                parent_instance;
-
-  IdeEditorView        *view;
-  EggBindingGroup      *document_bindings;
-  EggSignalGroup       *document_signals;
-
-  EggSimplePopover     *goto_line_popover;
-  GtkButton            *warning_button;
-  EggSimpleLabel       *line_label;
-  EggSimpleLabel       *column_label;
-  GtkLabel             *range_label;
-  GtkMenuButton        *tweak_button;
-  IdeEditorTweakWidget *tweak_widget;
-};
-
 G_DEFINE_TYPE (IdeEditorLayoutStackControls, ide_editor_layout_stack_controls, GTK_TYPE_BOX)
 
 static gboolean
@@ -260,6 +237,7 @@ ide_editor_layout_stack_controls_class_init (IdeEditorLayoutStackControlsClass *
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/builder/ui/ide-editor-layout-stack-controls.ui");
   gtk_widget_class_bind_template_child (widget_class, IdeEditorLayoutStackControls, column_label);
   gtk_widget_class_bind_template_child (widget_class, IdeEditorLayoutStackControls, goto_line_popover);
+  gtk_widget_class_bind_template_child (widget_class, IdeEditorLayoutStackControls, goto_line_button);
   gtk_widget_class_bind_template_child (widget_class, IdeEditorLayoutStackControls, line_label);
   gtk_widget_class_bind_template_child (widget_class, IdeEditorLayoutStackControls, range_label);
   gtk_widget_class_bind_template_child (widget_class, IdeEditorLayoutStackControls, warning_button);
diff --git a/libide/editor/ide-editor-layout-stack-controls.h 
b/libide/editor/ide-editor-layout-stack-controls.h
index 935e5f5..f5ffda3 100644
--- a/libide/editor/ide-editor-layout-stack-controls.h
+++ b/libide/editor/ide-editor-layout-stack-controls.h
@@ -20,7 +20,14 @@
 #define IDE_EDITOR_LAYOUT_STACK_CONTROLS_H
 
 #include <gtk/gtk.h>
+#include <egg-binding-group.h>
+#include <egg-signal-group.h>
+#include <egg-simple-label.h>
+#include <egg-simple-popover.h>
 
+#include "editor/ide-editor-frame.h"
+#include "editor/ide-editor-tweak-widget.h"
+#include "editor/ide-editor-view.h"
 #include "editor/ide-editor-view.h"
 
 G_BEGIN_DECLS
@@ -29,6 +36,24 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (IdeEditorLayoutStackControls, ide_editor_layout_stack_controls, IDE, 
EDITOR_LAYOUT_STACK_CONTROLS, GtkBox)
 
+struct _IdeEditorLayoutStackControls
+{
+  GtkBox                parent_instance;
+
+  IdeEditorView        *view;
+  EggBindingGroup      *document_bindings;
+  EggSignalGroup       *document_signals;
+
+  EggSimplePopover     *goto_line_popover;
+  GtkMenuButton        *goto_line_button;
+  GtkButton            *warning_button;
+  EggSimpleLabel       *line_label;
+  EggSimpleLabel       *column_label;
+  GtkLabel             *range_label;
+  GtkMenuButton        *tweak_button;
+  IdeEditorTweakWidget *tweak_widget;
+};
+
 void ide_editor_layout_stack_controls_set_view (IdeEditorLayoutStackControls *self,
                                                 IdeEditorView                *view);
 
diff --git a/libide/editor/ide-editor-layout-stack-controls.ui 
b/libide/editor/ide-editor-layout-stack-controls.ui
index 8fe6828..6b2f5ff 100644
--- a/libide/editor/ide-editor-layout-stack-controls.ui
+++ b/libide/editor/ide-editor-layout-stack-controls.ui
@@ -25,7 +25,7 @@
       </object>
     </child>
     <child>
-      <object class="GtkMenuButton">
+      <object class="GtkMenuButton" id="goto_line_button">
         <property name="popover">goto_line_popover</property>
         <property name="focus-on-click">false</property>
         <property name="tooltip-text" translatable="yes">Go to line number</property>
diff --git a/libide/editor/ide-editor-view-actions.c b/libide/editor/ide-editor-view-actions.c
index e7447eb..a54624b 100644
--- a/libide/editor/ide-editor-view-actions.c
+++ b/libide/editor/ide-editor-view-actions.c
@@ -665,24 +665,10 @@ ide_editor_view_actions_print (GSimpleAction *action,
   handle_print_result (self, GTK_PRINT_OPERATION (operation), result);
 }
 
-static void
-ide_editor_view_actions_goto_line (GSimpleAction *action,
-                                   GVariant      *param,
-                                   gpointer       user_data)
-{
-  IdeEditorView *self = user_data;
-
-  g_assert (IDE_IS_EDITOR_VIEW (self));
-
-  /* TODO: Reimplement goto as action from layoutstack */
-  //gtk_widget_activate (GTK_WIDGET (self->goto_line_button));
-}
-
 static GActionEntry IdeEditorViewActions[] = {
   { "auto-indent", NULL, NULL, "false", ide_editor_view_actions_auto_indent },
   { "close", ide_editor_view_actions_close },
   { "find-other-file", ide_editor_view_actions_find_other_file },
-  { "goto-line", ide_editor_view_actions_goto_line },
   { "highlight-current-line", NULL, NULL, "false", ide_editor_view_actions_highlight_current_line },
   { "language", NULL, "s", "''", ide_editor_view_actions_language },
   { "reload-buffer", ide_editor_view_actions_reload_buffer },


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