[gnome-builder] editor: hide panels on supplemental editor surfaces
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: hide panels on supplemental editor surfaces
- Date: Sat, 26 Jan 2019 17:16:03 +0000 (UTC)
commit b5ccdd922a00adb521fbc074d54b5a9c963cd896
Author: Christian Hergert <chergert redhat com>
Date: Sat Jan 26 09:12:25 2019 -0800
editor: hide panels on supplemental editor surfaces
This makes the panels hidden when creating non-primary workspaces. This
happens when starting builder to open a file, or when creating a secondary
workspace from the "New Workspace" menu item.
src/libide/editor/ide-editor-private.h | 2 +
src/libide/editor/ide-editor-surface.c | 66 ++++++++++++++++++++++++-
src/plugins/editor/gbp-editor-workspace-addin.c | 1 +
3 files changed, 67 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/editor/ide-editor-private.h b/src/libide/editor/ide-editor-private.h
index 1a3a3996e..6e1cbd54d 100644
--- a/src/libide/editor/ide-editor-private.h
+++ b/src/libide/editor/ide-editor-private.h
@@ -48,6 +48,8 @@ struct _IdeEditorSurface
/* State before entering focus mode */
guint prefocus_had_left : 1;
guint prefocus_had_bottom : 1;
+
+ guint restore_panel : 1;
};
struct _IdeEditorPage
diff --git a/src/libide/editor/ide-editor-surface.c b/src/libide/editor/ide-editor-surface.c
index 78f3ffde4..278fd8b3f 100644
--- a/src/libide/editor/ide-editor-surface.c
+++ b/src/libide/editor/ide-editor-surface.c
@@ -38,10 +38,18 @@ typedef struct
IdeLocation *location;
} FocusLocation;
+enum {
+ PROP_0,
+ PROP_RESTORE_PANEL,
+ N_PROPS
+};
+
static void ide_editor_surface_focus_location_full (IdeEditorSurface *self,
IdeLocation *location,
gboolean open_if_not_found);
+static GParamSpec *properties [N_PROPS];
+
G_DEFINE_TYPE (IdeEditorSurface, ide_editor_surface, IDE_TYPE_SURFACE)
static void
@@ -86,7 +94,7 @@ ide_editor_surface_restore_panel_state (IdeEditorSurface *self)
settings = g_settings_new ("org.gnome.builder.workbench");
pane = dzl_dock_bin_get_left_edge (DZL_DOCK_BIN (self));
- reveal = g_settings_get_boolean (settings, "left-visible");
+ reveal = self->restore_panel ? g_settings_get_boolean (settings, "left-visible") : FALSE;
position = g_settings_get_int (settings, "left-position");
dzl_dock_revealer_set_position (DZL_DOCK_REVEALER (pane), position);
set_reveal_child_without_transition (DZL_DOCK_REVEALER (pane), reveal);
@@ -97,7 +105,7 @@ ide_editor_surface_restore_panel_state (IdeEditorSurface *self)
set_reveal_child_without_transition (DZL_DOCK_REVEALER (pane), FALSE);
pane = dzl_dock_bin_get_bottom_edge (DZL_DOCK_BIN (self));
- reveal = g_settings_get_boolean (settings, "bottom-visible");
+ reveal = self->restore_panel ? g_settings_get_boolean (settings, "bottom-visible") : FALSE;
position = g_settings_get_int (settings, "bottom-position");
dzl_dock_revealer_set_position (DZL_DOCK_REVEALER (pane), position);
set_reveal_child_without_transition (DZL_DOCK_REVEALER (pane), reveal);
@@ -113,6 +121,9 @@ ide_editor_surface_save_panel_state (IdeEditorSurface *self)
g_assert (IDE_IS_EDITOR_SURFACE (self));
+ if (!self->restore_panel)
+ return;
+
/* TODO: possibly belongs in editor settings */
settings = g_settings_new ("org.gnome.builder.workbench");
@@ -458,6 +469,44 @@ ide_editor_surface_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (ide_editor_surface_parent_class)->realize (widget);
}
+static void
+ide_editor_surface_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ IdeEditorSurface *self = IDE_EDITOR_SURFACE (object);
+
+ switch (prop_id)
+ {
+ case PROP_RESTORE_PANEL:
+ g_value_set_boolean (value, self->restore_panel);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ide_editor_surface_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ IdeEditorSurface *self = IDE_EDITOR_SURFACE (object);
+
+ switch (prop_id)
+ {
+ case PROP_RESTORE_PANEL:
+ self->restore_panel = g_value_get_boolean (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
static void
ide_editor_surface_class_init (IdeEditorSurfaceClass *klass)
{
@@ -465,6 +514,10 @@ ide_editor_surface_class_init (IdeEditorSurfaceClass *klass)
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
DzlDockBinClass *dock_bin_class = DZL_DOCK_BIN_CLASS (klass);
IdeSurfaceClass *surface_class = IDE_SURFACE_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = ide_editor_surface_get_property;
+ object_class->set_property = ide_editor_surface_set_property;
widget_class->destroy = ide_editor_surface_destroy;
widget_class->hierarchy_changed = ide_editor_surface_hierarchy_changed;
@@ -484,6 +537,13 @@ ide_editor_surface_class_init (IdeEditorSurfaceClass *klass)
gtk_widget_class_bind_template_child (widget_class, IdeEditorSurface, overlay);
gtk_widget_class_bind_template_child (widget_class, IdeEditorSurface, loading_stack);
+ properties [PROP_RESTORE_PANEL] =
+ g_param_spec_boolean ("restore-panel", NULL, NULL,
+ TRUE,
+ (G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
+
g_type_ensure (IDE_TYPE_EDITOR_SIDEBAR);
g_type_ensure (IDE_TYPE_GRID);
}
@@ -493,6 +553,8 @@ ide_editor_surface_init (IdeEditorSurface *self)
{
IdeEditorSidebar *sidebar;
+ self->restore_panel = TRUE;
+
gtk_widget_init_template (GTK_WIDGET (self));
ide_surface_set_icon_name (IDE_SURFACE (self), "builder-editor-symbolic");
diff --git a/src/plugins/editor/gbp-editor-workspace-addin.c b/src/plugins/editor/gbp-editor-workspace-addin.c
index b9c2d0edb..0ec47ad3d 100644
--- a/src/plugins/editor/gbp-editor-workspace-addin.c
+++ b/src/plugins/editor/gbp-editor-workspace-addin.c
@@ -240,6 +240,7 @@ gbp_editor_workspace_addin_load (IdeWorkspaceAddin *addin,
/* Add the editor surface to the workspace */
self->surface = g_object_new (IDE_TYPE_EDITOR_SURFACE,
"name", "editor",
+ "restore-panel", IDE_IS_PRIMARY_WORKSPACE (workspace),
"visible", TRUE,
NULL);
g_signal_connect (self->surface,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]