[gnome-builder] editor: make >>split command work all the time



commit f2a8419290235fdfcfc767344723d48024f99962
Author: Anoop Chandu <anoopchandu96 gmail com>
Date:   Tue Dec 27 15:43:18 2016 +0530

    editor: make >>split command work all the time
    
    Previously all ide-layout-views in the same ide-layout-stack share same
    view-stack.split-down action state. This patch makes view-stack.split-down
    action not having any state and whenever it is activated it toggles split
    state of active view by getting and setting reverse state.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776356

 libide/editor/ide-editor-view.c             |   11 +++++++++++
 libide/workbench/ide-layout-stack-actions.c |   14 +++++---------
 libide/workbench/ide-layout-view.c          |   17 +++++++++++++++++
 libide/workbench/ide-layout-view.h          |    2 ++
 plugins/terminal/gb-terminal-view.c         |   11 +++++++++++
 5 files changed, 46 insertions(+), 9 deletions(-)
---
diff --git a/libide/editor/ide-editor-view.c b/libide/editor/ide-editor-view.c
index 3bf80b2..5f269a8 100644
--- a/libide/editor/ide-editor-view.c
+++ b/libide/editor/ide-editor-view.c
@@ -462,6 +462,16 @@ addin_unload_source_view (PeasExtensionSet *set,
   ide_editor_view_addin_unload_source_view (IDE_EDITOR_VIEW_ADDIN (exten), source_view);
 }
 
+static gboolean
+ide_editor_view_get_split_view (IdeLayoutView *view)
+{
+  IdeEditorView *self = (IdeEditorView *)view;
+
+  g_assert (IDE_IS_EDITOR_VIEW (self));
+
+  return (self->frame2 != NULL);
+}
+
 static void
 ide_editor_view_set_split_view (IdeLayoutView *view,
                                 gboolean       split_view)
@@ -824,6 +834,7 @@ ide_editor_view_class_init (IdeEditorViewClass *klass)
   view_class->create_split = ide_editor_view_create_split;
   view_class->get_special_title = ide_editor_view_get_special_title;
   view_class->get_modified = ide_editor_view_get_modified;
+  view_class->get_split_view = ide_editor_view_get_split_view;
   view_class->set_split_view = ide_editor_view_set_split_view;
   view_class->set_back_forward_list = ide_editor_view_set_back_forward_list;
   view_class->navigate_to = ide_editor_view_navigate_to;
diff --git a/libide/workbench/ide-layout-stack-actions.c b/libide/workbench/ide-layout-stack-actions.c
index a3c054c..502a073 100644
--- a/libide/workbench/ide-layout-stack-actions.c
+++ b/libide/workbench/ide-layout-stack-actions.c
@@ -122,14 +122,11 @@ do_split_down_cb (GObject      *object,
                   GAsyncResult *result,
                   gpointer      user_data)
 {
-  g_autoptr(GSimpleAction) action = user_data;
-  GTask *task = (GTask *)result;
   IdeLayoutView *view = (IdeLayoutView *)object;
-  GVariant *param = g_task_get_task_data (task);
-  gboolean split_view = g_variant_get_boolean (param);
 
-  ide_layout_view_set_split_view (view, split_view);
-  g_simple_action_set_state (action, param);
+  g_assert (IDE_IS_LAYOUT_VIEW (view));
+
+  ide_layout_view_set_split_view (view, !ide_layout_view_get_split_view (view));
 }
 
 static void
@@ -147,8 +144,7 @@ ide_layout_stack_actions_split_down (GSimpleAction *action,
   if (!IDE_IS_LAYOUT_VIEW (active_view))
     return;
 
-  task = g_task_new (active_view, NULL, do_split_down_cb, g_object_ref (action));
-  g_task_set_task_data (task, g_variant_ref (param), (GDestroyNotify)g_variant_unref);
+  task = g_task_new (active_view, NULL, do_split_down_cb, NULL);
   g_task_return_boolean (task, TRUE);
 }
 
@@ -305,7 +301,7 @@ static const GActionEntry gbViewStackActions[] = {
   { "next-view", ide_layout_stack_actions_next_view },
   { "previous-view", ide_layout_stack_actions_previous_view },
   { "show-list", ide_layout_stack_actions_show_list },
-  { "split-down", NULL, NULL, "false", ide_layout_stack_actions_split_down },
+  { "split-down", ide_layout_stack_actions_split_down },
   { "split-left", ide_layout_stack_actions_split_left, "s", NULL, NULL },
   { "split-right", ide_layout_stack_actions_split_right },
 };
diff --git a/libide/workbench/ide-layout-view.c b/libide/workbench/ide-layout-view.c
index 433cd9e..7afcaac 100644
--- a/libide/workbench/ide-layout-view.c
+++ b/libide/workbench/ide-layout-view.c
@@ -98,6 +98,23 @@ ide_layout_view_create_split (IdeLayoutView *self,
 }
 
 /**
+ * ide_layout_view_get_split_view:
+ * @self: A #IdeLayoutView.
+ *
+ * Returns whether view is split or not.
+ */
+gboolean
+ide_layout_view_get_split_view (IdeLayoutView *self)
+{
+  g_return_val_if_fail (IDE_IS_LAYOUT_VIEW (self), FALSE);
+
+  if (IDE_LAYOUT_VIEW_GET_CLASS (self)->get_split_view)
+    return IDE_LAYOUT_VIEW_GET_CLASS (self)->get_split_view (self);
+
+  return FALSE;
+}
+
+/**
  * ide_layout_view_set_split_view:
  * @self: A #IdeLayoutView.
  * @split_view: if the split should be enabled.
diff --git a/libide/workbench/ide-layout-view.h b/libide/workbench/ide-layout-view.h
index 423abd4..ca436f2 100644
--- a/libide/workbench/ide-layout-view.h
+++ b/libide/workbench/ide-layout-view.h
@@ -41,6 +41,7 @@ struct _IdeLayoutViewClass
   gchar         *(*get_special_title)     (IdeLayoutView             *self);
   IdeLayoutView *(*create_split)          (IdeLayoutView             *self,
                                            GFile                     *file);
+  gboolean       (*get_split_view)        (IdeLayoutView             *self);
   void           (*set_split_view)        (IdeLayoutView             *self,
                                            gboolean                   split_view);
   void           (*set_back_forward_list) (IdeLayoutView             *self,
@@ -67,6 +68,7 @@ gboolean       ide_layout_view_get_can_split         (IdeLayoutView
 gchar         *ide_layout_view_get_title             (IdeLayoutView             *self);
 gchar         *ide_layout_view_get_special_title     (IdeLayoutView             *self);
 gboolean       ide_layout_view_get_modified          (IdeLayoutView             *self);
+gboolean       ide_layout_view_get_split_view        (IdeLayoutView             *self);
 void           ide_layout_view_set_split_view        (IdeLayoutView             *self,
                                                       gboolean                   split_view);
 void           ide_layout_view_set_back_forward_list (IdeLayoutView             *self,
diff --git a/plugins/terminal/gb-terminal-view.c b/plugins/terminal/gb-terminal-view.c
index 42ceb64..bccac42 100644
--- a/plugins/terminal/gb-terminal-view.c
+++ b/plugins/terminal/gb-terminal-view.c
@@ -554,6 +554,16 @@ gb_terminal_view_set_font_name (GbTerminalView *self,
     }
 }
 
+static gboolean
+gb_terminal_get_split_view (IdeLayoutView *view)
+{
+  GbTerminalView *self = (GbTerminalView *)view;
+
+  g_assert (GB_IS_TERMINAL_VIEW (self));
+
+  return (self->terminal_bottom != NULL);
+}
+
 static void
 gb_terminal_set_split_view (IdeLayoutView   *view,
                             gboolean         split_view)
@@ -747,6 +757,7 @@ gb_terminal_view_class_init (GbTerminalViewClass *klass)
 
   view_class->get_title = gb_terminal_get_title;
   view_class->create_split = gb_terminal_create_split;
+  view_class->get_split_view =  gb_terminal_get_split_view;
   view_class->set_split_view =  gb_terminal_set_split_view;
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/builder/plugins/terminal/gb-terminal-view.ui");


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