[gnome-builder/editor-layout] wip on editor layout changes



commit 927fb3523a04515ba25aa7370e3d1142468fa995
Author: Christian Hergert <christian hergert me>
Date:   Sun Nov 23 21:41:11 2014 -0800

    wip on editor layout changes

 data/icons/Makefile.am                             |   14 ++++-
 data/icons/hicolor/16x16/apps/builder-drag-tab.png |  Bin 0 -> 213 bytes
 .../icons/hicolor/16x16/apps/builder-split-tab.png |  Bin 0 -> 220 bytes
 src/editor/gb-editor-tab.c                         |    2 +
 src/resources/css/builder.Adwaita.css              |   32 ++++++++++
 src/resources/ui/gb-editor-tab.ui                  |    1 -
 src/resources/ui/gb-editor-workspace.ui            |   27 +++++++-
 src/resources/ui/gb-tab.ui                         |   66 +++++++++++++++++++-
 src/tabs/gb-tab.c                                  |   64 ++++++++++++++++++-
 9 files changed, 195 insertions(+), 11 deletions(-)
---
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am
index 1898a67..ae6c1a9 100644
--- a/data/icons/Makefile.am
+++ b/data/icons/Makefile.am
@@ -5,9 +5,21 @@ nobase_icon_DATA = \
        hicolor/256x256/apps/builder.png \
        hicolor/512x512/apps/builder.png \
        hicolor/16x16/apps/builder.png \
+       hicolor/16x16/apps/builder-drag-tab.png \
+       hicolor/16x16/apps/builder-split-tab.png \
        hicolor/32x32/apps/builder.png \
        hicolor/48x48/apps/builder.png \
-       hicolor/24x24/apps/builder.png
+       hicolor/24x24/apps/builder.png \
+       hicolor/scalable/apps/builder-documentation-symbolic.svg \
+       hicolor/scalable/apps/builder-editor-symbolic.svg \
+       hicolor/scalable/autocomplete/lang-enum-value-symbolic.svg \
+       hicolor/scalable/autocomplete/struct-field-symbolic.svg \
+       hicolor/scalable/autocomplete/lang-class-symbolic.svg \
+       hicolor/scalable/autocomplete/lang-struct-symbolic.svg \
+       hicolor/scalable/autocomplete/lang-enum-symbolic.svg \
+       hicolor/scalable/autocomplete/lang-method-symbolic.svg \
+       hicolor/scalable/autocomplete/lang-function-symbolic.svg \
+       $(NULL)
 
 EXTRA_DIST = \
        $(nobase_icon_DATA) \
diff --git a/data/icons/hicolor/16x16/apps/builder-drag-tab.png 
b/data/icons/hicolor/16x16/apps/builder-drag-tab.png
new file mode 100644
index 0000000..6b318b6
Binary files /dev/null and b/data/icons/hicolor/16x16/apps/builder-drag-tab.png differ
diff --git a/data/icons/hicolor/16x16/apps/builder-split-tab.png 
b/data/icons/hicolor/16x16/apps/builder-split-tab.png
new file mode 100644
index 0000000..34186c2
Binary files /dev/null and b/data/icons/hicolor/16x16/apps/builder-split-tab.png differ
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index 18f1a45..b083022 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -950,6 +950,8 @@ gb_editor_tab_constructed (GObject *object)
 
   priv = tab->priv;
 
+  G_OBJECT_CLASS (gb_editor_tab_parent_class)->constructed (object);
+
   if (!priv->document)
     priv->document = gb_editor_document_new ();
 
diff --git a/src/resources/css/builder.Adwaita.css b/src/resources/css/builder.Adwaita.css
index ed06a53..8675466 100644
--- a/src/resources/css/builder.Adwaita.css
+++ b/src/resources/css/builder.Adwaita.css
@@ -160,3 +160,35 @@ GbCommandBar GtkEntry {
     color: #eeeeec;
 }
 
+
+/*
+ * Styling of main window header bar.
+ */
+GbWorkbench GtkHeaderBar {
+    border-bottom: none;
+}
+
+
+/*
+ * Tab header styling.
+ */
+GbTab .tab-close-button {
+    border-right: none;
+    border-top-right-radius: 0px;
+    border-bottom-right-radius: 0px;
+}
+GbTab .tab-drag-button {
+    border-left: none;
+    border-top-left-radius: 0px;
+    border-bottom-left-radius: 0px;
+}
+
+#project-title {
+    border-left: none;
+    border-right: none;
+    border-top-left-radius: 0px;
+    border-bottom-left-radius: 0px;
+    border-top-right-radius: 0px;
+    border-bottom-right-radius: 0px;
+}
+
diff --git a/src/resources/ui/gb-editor-tab.ui b/src/resources/ui/gb-editor-tab.ui
index 56c9fef..010563a 100644
--- a/src/resources/ui/gb-editor-tab.ui
+++ b/src/resources/ui/gb-editor-tab.ui
@@ -4,7 +4,6 @@
   <template class="GbEditorTab" parent="GbTab">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="orientation">horizontal</property>
     <property name="expand">True</property>
     <child internal-child="content">
       <object class="GtkBox" id="content">
diff --git a/src/resources/ui/gb-editor-workspace.ui b/src/resources/ui/gb-editor-workspace.ui
index 26e4635..083c1ce 100644
--- a/src/resources/ui/gb-editor-workspace.ui
+++ b/src/resources/ui/gb-editor-workspace.ui
@@ -8,12 +8,30 @@
         <property name="orientation">horizontal</property>
         <property name="position">250</property>
         <child>
-          <object class="GtkScrolledWindow" id="scroller">
-            <property name="visible">False</property>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkLabel" id="project_label">
+                <property name="name">project-title</property>
+                <property name="visible">True</property>
+                <property name="label"></property>
+                <property name="xalign">0.0</property>
+                <style>
+                  <class name="button"/>
+                </style>
+              </object>
+            </child>
             <child>
-              <object class="GbTree" id="tree">
-                <property name="headers-visible">False</property>
+              <object class="GtkScrolledWindow" id="scroller">
                 <property name="visible">True</property>
+                <property name="vexpand">True</property>
+                <child>
+                  <object class="GbTree" id="tree">
+                    <property name="headers-visible">False</property>
+                    <property name="visible">True</property>
+                  </object>
+                </child>
               </object>
             </child>
           </object>
@@ -22,6 +40,7 @@
           <object class="GbMultiNotebook" id="multi_notebook">
             <property name="group-name">GB_EDITOR_WORKSPACE</property>
             <property name="visible">True</property>
+            <property name="show-tabs">False</property>
           </object>
         </child>
       </object>
diff --git a/src/resources/ui/gb-tab.ui b/src/resources/ui/gb-tab.ui
index 8676860..c879154 100644
--- a/src/resources/ui/gb-tab.ui
+++ b/src/resources/ui/gb-tab.ui
@@ -2,12 +2,76 @@
 <interface>
   <!-- interface-requires gtk+ 3.8 -->
   <template class="GbTab" parent="GtkBox">
-    <property name="orientation">GTK_ORIENTATION_VERTICAL</property>
     <child>
       <object class="GtkBox" id="header_box">
         <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
         <property name="visible">True</property>
         <property name="vexpand">False</property>
+        <style>
+          <class name="linked"/>
+        </style>
+        <child>
+          <object class="GtkButton" id="drag_button">
+            <property name="visible">True</property>
+            <property name="hexpand">False</property>
+            <style>
+              <class name="image-button"/>
+              <class name="tab-drag-button"/>
+            </style>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="icon-name">builder-drag-tab</property>
+                <property name="icon-size">1</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkComboBox" id="documents_combo">
+            <property name="visible">True</property>
+            <property name="hexpand">True</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkComboBox" id="symbols_combo">
+            <property name="visible">True</property>
+            <property name="hexpand">True</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkButton" id="split_button">
+            <property name="visible">True</property>
+            <property name="hexpand">False</property>
+            <style>
+              <class name="image-button"/>
+            </style>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="icon-name">builder-split-tab</property>
+                <property name="icon-size">1</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkButton" id="close_button">
+            <property name="visible">True</property>
+            <property name="hexpand">False</property>
+            <style>
+              <class name="tab-close-button"/>
+              <class name="image-button"/>
+            </style>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="icon-name">window-close-symbolic</property>
+                <property name="icon-size">1</property>
+              </object>
+            </child>
+          </object>
+        </child>
       </object>
     </child>
     <child>
diff --git a/src/tabs/gb-tab.c b/src/tabs/gb-tab.c
index d9555d9..01ef233 100644
--- a/src/tabs/gb-tab.c
+++ b/src/tabs/gb-tab.c
@@ -16,8 +16,12 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#define G_LOG_DOMAIN "tab"
+
 #include <glib/gi18n.h>
 
+#include "gb-log.h"
+#include "gb-notebook.h"
 #include "gb-tab.h"
 
 struct _GbTabPrivate
@@ -25,10 +29,12 @@ struct _GbTabPrivate
   GtkWidget *content;
   GtkWidget *footer_box;
   GtkWidget *header_box;
+  GtkWidget *drag_button;
 
   gchar    *icon_name;
   gchar    *title;
-  gboolean  dirty;
+
+  guint     dirty : 1;
 };
 
 enum {
@@ -53,8 +59,11 @@ G_DEFINE_TYPE_EXTENDED (GbTab, gb_tab, GTK_TYPE_BOX, 0,
                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
                                                buildable_init))
 
-static GParamSpec *gParamSpecs [LAST_PROP];
-static guint       gSignals [LAST_SIGNAL];
+static GParamSpec     *gParamSpecs [LAST_PROP];
+static guint           gSignals [LAST_SIGNAL];
+static GtkTargetEntry  gTargets [] = {
+  { "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 },
+};
 
 GtkWidget *
 gb_tab_get_header_area (GbTab *tab)
@@ -160,6 +169,33 @@ gb_tab_thaw_drag (GbTab *tab)
   g_signal_emit (tab, gSignals[THAW_DRAG], 0);
 }
 
+static gboolean
+gb_tab_on_drag_button_press (GtkWidget      *button,
+                             GdkEventButton *event,
+                             GbTab          *tab)
+{
+  GtkTargetList *source_targets;
+  GtkWidget *parent;
+
+  ENTRY;
+
+  g_return_if_fail (GB_IS_TAB (tab));
+
+  if ((event->button == GDK_BUTTON_PRIMARY) &&
+      (parent = gtk_widget_get_parent (GTK_WIDGET (tab))) &&
+      GB_IS_NOTEBOOK (parent))
+    {
+      source_targets = gtk_target_list_new (gTargets, G_N_ELEMENTS (gTargets));
+      gtk_drag_begin_with_coordinates (parent, source_targets, GDK_ACTION_MOVE,
+                                       event->button, (GdkEvent *)event,
+                                       event->x, event->y);
+      gtk_target_list_unref (source_targets);
+      RETURN (TRUE);
+    }
+
+  RETURN (FALSE);
+}
+
 static void
 gb_tab_finalize (GObject *object)
 {
@@ -226,20 +262,37 @@ gb_tab_set_property (GObject      *object,
 }
 
 static void
+gb_tab_constructed (GObject *object)
+{
+  GbTab *tab = (GbTab *)object;
+
+  g_return_if_fail (GB_IS_TAB (tab));
+
+  G_OBJECT_CLASS (gb_tab_parent_class)->constructed (object);
+
+  g_signal_connect (tab->priv->drag_button,
+                    "button-press-event",
+                    G_CALLBACK (gb_tab_on_drag_button_press),
+                    tab);
+}
+
+static void
 gb_tab_class_init (GbTabClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
+  object_class->constructed = gb_tab_constructed;
   object_class->finalize = gb_tab_finalize;
   object_class->get_property = gb_tab_get_property;
   object_class->set_property = gb_tab_set_property;
 
   gtk_widget_class_set_template_from_resource (widget_class,
                                                "/org/gnome/builder/ui/gb-tab.ui");
-  gtk_widget_class_bind_template_child_private (widget_class, GbTab, header_box);
   gtk_widget_class_bind_template_child_private (widget_class, GbTab, content);
+  gtk_widget_class_bind_template_child_private (widget_class, GbTab, drag_button);
   gtk_widget_class_bind_template_child_private (widget_class, GbTab, footer_box);
+  gtk_widget_class_bind_template_child_private (widget_class, GbTab, header_box);
 
   gParamSpecs [PROP_DIRTY] =
     g_param_spec_boolean ("dirty",
@@ -307,6 +360,9 @@ gb_tab_init (GbTab *tab)
 {
   tab->priv = gb_tab_get_instance_private (tab);
 
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (tab),
+                                  GTK_ORIENTATION_VERTICAL);
+
   gtk_widget_init_template (GTK_WIDGET (tab));
 }
 


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