Commit ce4fc5f9 authored by Christian Hergert's avatar Christian Hergert
Browse files

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().
parent b43b2229
......@@ -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;
}
......@@ -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);
}
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="IdeEditorUtilities" parent="IdeLayoutPane">
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="visible">true</property>
<child>
<object class="GtkStackSwitcher" id="stack_switcher">
<property name="orientation">vertical</property>
<property name="vexpand">true</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GtkStack" id="stack">
<property name="transition-type">crossfade</property>
<property name="homogeneous">false</property>
<property name="visible">true</property>
</object>
</child>
</object>
</child>
</template>
</interface>
......@@ -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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment