[gnome-builder] command-bar: fix vsplit



commit 8ba87252d50651675fd344b27498537822e6c5f4
Author: Sebastien Lafargue <slafargue gnome org>
Date:   Tue Sep 19 16:16:09 2017 +0200

    command-bar: fix vsplit
    
    Due to a missing parameter and some missinng logic,
    both vsplit and vsplit [filename] weren't working.

 data/gtk/menus.ui                        |    1 +
 libide/layout/ide-layout-stack-actions.c |   40 +++++++++++++++++++++++++----
 2 files changed, 35 insertions(+), 6 deletions(-)
---
diff --git a/data/gtk/menus.ui b/data/gtk/menus.ui
index e849629..89758b9 100644
--- a/data/gtk/menus.ui
+++ b/data/gtk/menus.ui
@@ -285,6 +285,7 @@
         <attribute name="id">editor-document-open-in-new-frame</attribute>
         <attribute name="label" translatable="yes">Open in New Frame</attribute>
         <attribute name="action">layoutstack.open-in-new-frame</attribute>
+        <attribute name="target" type="s">""</attribute>
       </item>
       <item>
         <attribute name="label" translatable="yes">Split</attribute>
diff --git a/libide/layout/ide-layout-stack-actions.c b/libide/layout/ide-layout-stack-actions.c
index 4ce887c..b1678e1 100644
--- a/libide/layout/ide-layout-stack-actions.c
+++ b/libide/layout/ide-layout-stack-actions.c
@@ -19,6 +19,8 @@
 #include "ide-layout-stack.h"
 #include "ide-layout-private.h"
 
+#include <ide.h>
+
 static void
 ide_layout_stack_actions_next_view (GSimpleAction *action,
                                     GVariant      *variant,
@@ -129,6 +131,9 @@ ide_layout_stack_actions_open_in_new_frame (GSimpleAction *action,
                                             gpointer       user_data)
 {
   IdeLayoutStack *self = user_data;
+
+  const gchar *filepath;
+
   IdeLayoutView *view;
   IdeLayoutStack *dest;
   GtkWidget *grid;
@@ -137,14 +142,37 @@ ide_layout_stack_actions_open_in_new_frame (GSimpleAction *action,
 
   g_assert (G_IS_SIMPLE_ACTION (action));
   g_assert (IDE_IS_LAYOUT_STACK (self));
+  g_assert (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING));
 
-  view = ide_layout_stack_get_visible_child (self);
+  filepath = g_variant_get_string (variant, NULL);
+  if (!ide_str_empty0 (filepath))
+    {
+      IdeContext *context;
+      IdeBufferManager *buffer_manager;
+      g_autoptr (GFile) file = NULL;
+      IdeBuffer *buffer;
+
+      context = ide_widget_get_context (GTK_WIDGET (self));
+      buffer_manager = ide_context_get_buffer_manager (context);
+      file = g_file_new_for_path (filepath);
+      if (NULL != (buffer = ide_buffer_manager_find_buffer (buffer_manager, file)))
+        view = g_object_new (IDE_TYPE_EDITOR_VIEW,
+                             "buffer", buffer,
+                             "visible", TRUE,
+                             NULL);
+      else
+        return;
+    }
+  else
+    {
+      view = ide_layout_stack_get_visible_child (self);
 
-  g_return_if_fail (view != NULL);
-  g_return_if_fail (IDE_IS_LAYOUT_VIEW (view));
-  g_return_if_fail (ide_layout_view_get_can_split (view));
+      g_return_if_fail (view != NULL);
+      g_return_if_fail (IDE_IS_LAYOUT_VIEW (view));
+      g_return_if_fail (ide_layout_view_get_can_split (view));
 
-  view = ide_layout_view_create_split_view (view);
+      view = ide_layout_view_create_split_view (view);
+    }
 
   if (view == NULL)
     {
@@ -293,7 +321,7 @@ ide_layout_stack_actions_show_list (GSimpleAction *action,
 }
 
 static const GActionEntry actions[] = {
-  { "open-in-new-frame", ide_layout_stack_actions_open_in_new_frame },
+  { "open-in-new-frame", ide_layout_stack_actions_open_in_new_frame, "s" },
   { "close-stack",       ide_layout_stack_actions_close_stack },
   { "close-view",        ide_layout_stack_actions_close_view },
   { "next-view",         ide_layout_stack_actions_next_view },


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