[gnome-builder/wip/chergert/layout] editor: add panel buttons to the header



commit d0c0ef5c07081e2df9f8329ddfdf502ff95f83f9
Author: Christian Hergert <chergert redhat com>
Date:   Sun Jul 2 23:49:17 2017 -0700

    editor: add panel buttons to the header

 data/gtk/menus.ui                          |   20 ------
 libide/editor/ide-editor-perspective.ui    |   16 ++++-
 libide/editor/ide-editor-workbench-addin.c |   88 ++++++++++++++++++++++------
 3 files changed, 82 insertions(+), 42 deletions(-)
---
diff --git a/data/gtk/menus.ui b/data/gtk/menus.ui
index 6057dec..24b6896 100644
--- a/data/gtk/menus.ui
+++ b/data/gtk/menus.ui
@@ -41,26 +41,6 @@
     </section>
   </menu>
   <menu id="gear-menu">
-    <section id="gear-menu-layout-section">
-      <attribute name="id">panel-section</attribute>
-      <attribute name="display-hint">horizontal-buttons</attribute>
-      <attribute name="text-direction">ltr</attribute>
-      <item>
-        <attribute name="label" translatable="yes">Show left panel</attribute>
-        <attribute name="action">perspective.left-visible</attribute>
-        <attribute name="verb-icon">builder-view-left-pane-symbolic</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">Show bottom panel</attribute>
-        <attribute name="action">perspective.bottom-visible</attribute>
-        <attribute name="verb-icon">builder-view-bottom-pane-symbolic</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">Show right panel</attribute>
-        <attribute name="action">perspective.right-visible</attribute>
-        <attribute name="verb-icon">builder-view-right-pane-symbolic</attribute>
-      </item>
-    </section>
     <section id="gear-menu-new-section">
       <item>
         <attribute name="label" translatable="yes">_New File</attribute>
diff --git a/libide/editor/ide-editor-perspective.ui b/libide/editor/ide-editor-perspective.ui
index bebd149..511c72e 100644
--- a/libide/editor/ide-editor-perspective.ui
+++ b/libide/editor/ide-editor-perspective.ui
@@ -1,9 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <template class="IdeEditorPerspective" parent="IdeLayout">
-    <child type="left">
-      <object class="IdeEditorSidebar" id="sidebar">
-        <property name="visible">true</property>
+    <child internal-child="left">
+      <object class="IdeLayoutPane">
+        <child>
+          <object class="IdeEditorSidebar" id="sidebar">
+            <property name="visible">true</property>
+          </object>
+        </child>
+      </object>
+    </child>
+    <child internal-child="right">
+      <object class="IdeLayoutPane">
+        <!-- This is a transient panel -->
+        <property name="reveal-child">false</property>
       </object>
     </child>
     <child>
diff --git a/libide/editor/ide-editor-workbench-addin.c b/libide/editor/ide-editor-workbench-addin.c
index 66e5c55..fde7251 100644
--- a/libide/editor/ide-editor-workbench-addin.c
+++ b/libide/editor/ide-editor-workbench-addin.c
@@ -45,7 +45,8 @@ struct _IdeEditorWorkbenchAddin
   /* Borrowed references */
   IdeWorkbench         *workbench;
   IdeEditorPerspective *perspective;
-  GtkWidget            *new_document_button;
+  GtkButton            *new_document_button;
+  GtkBox               *panels_box;
 };
 
 typedef struct
@@ -124,6 +125,66 @@ ide_editor_workbench_addin_init (IdeEditorWorkbenchAddin *self)
 }
 
 static void
+ide_editor_workbench_addin_add_buttons (IdeEditorWorkbenchAddin *self,
+                                        IdeWorkbenchHeaderBar   *header)
+{
+  GtkWidget *button;
+
+  g_assert (IDE_IS_EDITOR_WORKBENCH_ADDIN (self));
+  g_assert (IDE_IS_WORKBENCH_HEADER_BAR (header));
+
+  self->new_document_button = g_object_new (GTK_TYPE_BUTTON,
+                                            "action-name", "editor.new-file",
+                                            "child", g_object_new (GTK_TYPE_IMAGE,
+                                                                   "visible", TRUE,
+                                                                   "icon-name", "document-new-symbolic",
+                                                                   NULL),
+                                            NULL);
+  g_signal_connect (self->new_document_button,
+                    "destroy",
+                    G_CALLBACK (gtk_widget_destroyed),
+                    &self->new_document_button);
+  dzl_gtk_widget_add_style_class (GTK_WIDGET (self->new_document_button), "image-button");
+  ide_workbench_header_bar_insert_left (header, GTK_WIDGET (self->new_document_button), GTK_PACK_START, 0);
+
+  self->panels_box = g_object_new (GTK_TYPE_BOX,
+                                   "visible", TRUE,
+                                   NULL);
+  g_signal_connect (self->panels_box,
+                    "destroy",
+                    G_CALLBACK (gtk_widget_destroyed),
+                    &self->panels_box);
+  dzl_gtk_widget_add_style_class (GTK_WIDGET (self->panels_box), "linked");
+  ide_workbench_header_bar_insert_left (header, GTK_WIDGET (self->panels_box), GTK_PACK_START, 10);
+
+  button = g_object_new (GTK_TYPE_TOGGLE_BUTTON,
+                         "action-name", "dockbin.left-visible",
+                         "focus-on-click", FALSE,
+                         "child", g_object_new (GTK_TYPE_IMAGE,
+                                                "icon-name", "panel-left-pane-symbolic",
+                                                "margin-start", 12,
+                                                "margin-end", 12,
+                                                "visible", TRUE,
+                                                NULL),
+                         "visible", TRUE,
+                         NULL);
+  gtk_container_add (GTK_CONTAINER (self->panels_box), button);
+
+  button = g_object_new (GTK_TYPE_TOGGLE_BUTTON,
+                         "action-name", "dockbin.bottom-visible",
+                         "focus-on-click", FALSE,
+                         "child", g_object_new (GTK_TYPE_IMAGE,
+                                                "icon-name", "panel-bottom-pane-symbolic",
+                                                "margin-start", 12,
+                                                "margin-end", 12,
+                                                "visible", TRUE,
+                                                NULL),
+                         "visible", TRUE,
+                         NULL);
+  gtk_container_add (GTK_CONTAINER (self->panels_box), button);
+}
+
+static void
 ide_editor_workbench_addin_load (IdeWorkbenchAddin *addin,
                                  IdeWorkbench      *workbench)
 {
@@ -147,22 +208,8 @@ ide_editor_workbench_addin_load (IdeWorkbenchAddin *addin,
 
   header = ide_workbench_get_headerbar (workbench);
 
-  self->new_document_button = g_object_new (GTK_TYPE_BUTTON,
-                                            "action-name", "editor.new-file",
-                                            "child", g_object_new (GTK_TYPE_IMAGE,
-                                                                   "visible", TRUE,
-                                                                   "icon-name", "document-new-symbolic",
-                                                                   NULL),
-                                            NULL);
-  g_signal_connect (self->new_document_button,
-                    "destroy",
-                    G_CALLBACK (gtk_widget_destroyed),
-                    &self->new_document_button);
-  dzl_gtk_widget_add_style_class (self->new_document_button, "image-button");
-  ide_workbench_header_bar_insert_left (header,
-                                        self->new_document_button,
-                                        GTK_PACK_START,
-                                        0);
+  ide_editor_workbench_addin_add_buttons (self, header);
+
 
   self->perspective = g_object_new (IDE_TYPE_EDITOR_PERSPECTIVE,
                                     "manager", self->manager,
@@ -376,11 +423,14 @@ ide_editor_workbench_addin_perspective_set (IdeWorkbenchAddin *addin,
                                             IdePerspective    *perspective)
 {
   IdeEditorWorkbenchAddin *self = (IdeEditorWorkbenchAddin *)addin;
+  gboolean visible;
 
   g_assert (IDE_IS_EDITOR_WORKBENCH_ADDIN (self));
 
-  gtk_widget_set_visible (self->new_document_button,
-                          IDE_IS_EDITOR_PERSPECTIVE (perspective));
+  visible = IDE_IS_EDITOR_PERSPECTIVE (perspective);
+
+  gtk_widget_set_visible (GTK_WIDGET (self->new_document_button), visible);
+  gtk_widget_set_visible (GTK_WIDGET (self->panels_box), visible);
 }
 
 static void


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