[gnome-builder] editor: use DzlDockStack for utilities panel



commit ce4fc5f9c8f9476edce156a54bef961e1d8a7107
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jan 20 21:32:50 2018 -0800

    editor: use DzlDockStack for utilities panel
    
    This will help us fix a few issues including the initial selection as well
    as fixing dynamic selection of children with dzl_dock_item_present().

 data/themes/shared/shared-editor.css      | 28 +++++++++++++
 src/libide/editor/ide-editor-utilities.c  | 67 +++++++------------------------
 src/libide/editor/ide-editor-utilities.ui | 25 ------------
 src/libide/libide.gresource.xml           |  1 -
 4 files changed, 42 insertions(+), 79 deletions(-)
---
diff --git a/data/themes/shared/shared-editor.css b/data/themes/shared/shared-editor.css
index 4f26acec0..f08f4b694 100644
--- a/data/themes/shared/shared-editor.css
+++ b/data/themes/shared/shared-editor.css
@@ -103,3 +103,31 @@ ideeditorsidebar .flat-menu-button:checked,
 ideeditorsidebar .flat-menu-button:hover {
   opacity: 1;
 }
+
+/* utilities panel buttons */
+ideeditorutilities dzltab {
+  background: @theme_bg_color;
+  padding: 6px 8px;
+  border-style: solid;
+  border-color: @borders;
+  border-width: 1px 1px 0 1px;
+}
+ideeditorutilities dzltab:checked {
+  background-color: mix(@theme_bg_color, @borders, 0.3);
+}
+ideeditorutilities dzltab:hover {
+  background-color: mix(@theme_bg_color, @borders, 0.1);
+}
+ideeditorutilities dzltab:first-child {
+  border-radius: 6px 6px 0 0;
+  border-width: 1px 1px 0 1px;
+}
+ideeditorutilities dzltab:last-child {
+  border-radius: 6px;
+  border-radius: 0 0 6px 6px;
+  border-bottom-width: 1px;
+}
+ideeditorutilities dzltabstrip {
+  margin: 3px 0px 5px 0;
+  border-style: none;
+}
diff --git a/src/libide/editor/ide-editor-utilities.c b/src/libide/editor/ide-editor-utilities.c
index d142e9a15..5339e1618 100644
--- a/src/libide/editor/ide-editor-utilities.c
+++ b/src/libide/editor/ide-editor-utilities.c
@@ -37,60 +37,22 @@
 
 struct _IdeEditorUtilities
 {
-  IdeLayoutPane     parent_instance;
-
-  GtkStackSwitcher *stack_switcher;
-  GtkStack         *stack;
-
-  guint             loading : 1;
+  IdeLayoutPane  parent_instance;
+  DzlDockStack  *stack;
 };
 
 G_DEFINE_TYPE (IdeEditorUtilities, ide_editor_utilities, IDE_TYPE_LAYOUT_PANE)
 
-static void
-tweak_radio_button (GtkWidget *widget,
-                    gpointer   user_data)
-{
-  gtk_widget_set_vexpand (widget, TRUE);
-}
-
 static void
 ide_editor_utilities_add (GtkContainer *container,
                           GtkWidget    *widget)
 {
   IdeEditorUtilities *self = (IdeEditorUtilities *)container;
 
-  if (self->loading)
-    GTK_CONTAINER_CLASS (ide_editor_utilities_parent_class)->add (container, widget);
-  else
-    gtk_container_add (GTK_CONTAINER (self->stack), widget);
-
-  if (DZL_IS_DOCK_WIDGET (widget))
-    {
-      g_autofree gchar *icon_name = NULL;
-      g_autofree gchar *title = NULL;
-
-      g_object_get (widget,
-                    "icon-name", &icon_name,
-                    "title", &title,
-                    NULL);
+  g_assert (IDE_IS_EDITOR_UTILITIES (self));
+  g_assert (GTK_IS_WIDGET (widget));
 
-      gtk_container_child_set (GTK_CONTAINER (self->stack), widget,
-                               "title", title,
-                               "icon-name", icon_name,
-                               NULL);
-    }
-
-  if (self->stack_switcher != NULL)
-    gtk_container_foreach (GTK_CONTAINER (self->stack_switcher),
-                           tweak_radio_button,
-                           NULL);
-}
-
-static void
-ide_editor_utilities_destroy (GtkWidget *widget)
-{
-  GTK_WIDGET_CLASS (ide_editor_utilities_parent_class)->destroy (widget);
+  gtk_container_add (GTK_CONTAINER (self->stack), widget);
 }
 
 static void
@@ -99,22 +61,21 @@ ide_editor_utilities_class_init (IdeEditorUtilitiesClass *klass)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
 
-  widget_class->destroy = ide_editor_utilities_destroy;
-
   container_class->add = ide_editor_utilities_add;
 
-  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/builder/ui/ide-editor-utilities.ui");
-  gtk_widget_class_bind_template_child (widget_class, IdeEditorUtilities, stack_switcher);
-  gtk_widget_class_bind_template_child (widget_class, IdeEditorUtilities, stack);
   gtk_widget_class_set_css_name (widget_class, "ideeditorutilities");
 }
 
 static void
 ide_editor_utilities_init (IdeEditorUtilities *self)
 {
-  self->loading = TRUE;
-  gtk_widget_init_template (GTK_WIDGET (self));
-  self->loading = FALSE;
-
-  gtk_stack_switcher_set_stack (self->stack_switcher, self->stack);
+  self->stack = g_object_new (DZL_TYPE_DOCK_STACK,
+                              "visible", TRUE,
+                              NULL);
+  GTK_CONTAINER_CLASS (ide_editor_utilities_parent_class)->add (GTK_CONTAINER (self),
+                                                                GTK_WIDGET (self->stack));
+  g_object_set (self->stack,
+                "style", DZL_TAB_ICONS,
+                "edge", GTK_POS_LEFT,
+                NULL);
 }
diff --git a/src/libide/libide.gresource.xml b/src/libide/libide.gresource.xml
index e74c5df14..26f034a50 100644
--- a/src/libide/libide.gresource.xml
+++ b/src/libide/libide.gresource.xml
@@ -68,7 +68,6 @@
     <file preprocess="xml-stripblanks" alias="ide-layout-pane.ui">layout/ide-layout-pane.ui</file>
     <file preprocess="xml-stripblanks" 
alias="ide-layout-stack-header.ui">layout/ide-layout-stack-header.ui</file>
     <file preprocess="xml-stripblanks" alias="ide-layout-stack.ui">layout/ide-layout-stack.ui</file>
-    <file preprocess="xml-stripblanks" alias="ide-editor-utilities.ui">editor/ide-editor-utilities.ui</file>
     <file preprocess="xml-stripblanks" 
alias="ide-editor-perspective.ui">editor/ide-editor-perspective.ui</file>
     <file preprocess="xml-stripblanks" 
alias="ide-editor-properties.ui">editor/ide-editor-properties.ui</file>
     <file preprocess="xml-stripblanks" 
alias="ide-editor-layout-stack-controls.ui">editor/ide-editor-layout-stack-controls.ui</file>


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