[gnome-builder/wip/plugins] workbench: persist panel positions to gsettings
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/plugins] workbench: persist panel positions to gsettings
- Date: Thu, 11 Jun 2015 21:02:34 +0000 (UTC)
commit d6e658700af43012e0c952e46e8c35f90323af64
Author: Christian Hergert <christian hergert me>
Date: Thu Jun 11 14:02:23 2015 -0700
workbench: persist panel positions to gsettings
This keeps the panel visibility and panel positioning around for the next
run of Builder, restoring them during realize().
data/gsettings/Makefile.am | 5 +-
.../org.gnome.builder.workbench.gschema.xml | 39 ++++++++++
data/ui/gb-workbench.ui | 6 --
src/workbench/gb-workbench.c | 78 ++++++++++++++++++++
4 files changed, 120 insertions(+), 8 deletions(-)
---
diff --git a/data/gsettings/Makefile.am b/data/gsettings/Makefile.am
index 2b9a442..4a2fb30 100644
--- a/data/gsettings/Makefile.am
+++ b/data/gsettings/Makefile.am
@@ -1,9 +1,10 @@
gsettings_SCHEMAS = \
- org.gnome.builder.gschema.xml \
+ org.gnome.builder.code-insight.gschema.xml \
org.gnome.builder.editor.gschema.xml \
org.gnome.builder.editor.language.gschema.xml \
- org.gnome.builder.code-insight.gschema.xml \
+ org.gnome.builder.gschema.xml \
org.gnome.builder.project-tree.gschema.xml \
+ org.gnome.builder.workbench.gschema.xml \
$(NULL)
.PRECIOUS: $(gsettings_SCHEMAS)
diff --git a/data/gsettings/org.gnome.builder.workbench.gschema.xml
b/data/gsettings/org.gnome.builder.workbench.gschema.xml
new file mode 100644
index 0000000..d957396
--- /dev/null
+++ b/data/gsettings/org.gnome.builder.workbench.gschema.xml
@@ -0,0 +1,39 @@
+<schemalist>
+ <schema id="org.gnome.builder.workbench" path="/org/gnome/builder/workbench/"
gettext-domain="gnome-builder">
+ <key name="left-visible" type="b">
+ <default>true</default>
+ <summary>Show Left Panel</summary>
+ <description>If enabled, the left panel will be displayed.</description>
+ </key>
+ <key name="left-position" type="i">
+ <range min="1" max="1000"/>
+ <default>250</default>
+ <summary>Left Panel Position</summary>
+ <description>The width in pixel units of the left panel.</description>
+ </key>
+
+ <key name="right-visible" type="b">
+ <default>true</default>
+ <summary>Show Right Panel</summary>
+ <description>If enabled, the right panel will be displayed.</description>
+ </key>
+ <key name="right-position" type="i">
+ <range min="1" max="1000"/>
+ <default>250</default>
+ <summary>Right Panel Position</summary>
+ <description>The width in pixel units of the right panel.</description>
+ </key>
+
+ <key name="bottom-visible" type="b">
+ <default>true</default>
+ <summary>Show Bottom Panel</summary>
+ <description>If enabled, the bottom panel will be displayed.</description>
+ </key>
+ <key name="bottom-position" type="i">
+ <range min="1" max="1000"/>
+ <default>200</default>
+ <summary>Bottom Panel Position</summary>
+ <description>The width in pixel units of the bottom panel.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/data/ui/gb-workbench.ui b/data/ui/gb-workbench.ui
index 9454913..68b28af 100644
--- a/data/ui/gb-workbench.ui
+++ b/data/ui/gb-workbench.ui
@@ -146,16 +146,10 @@
<child internal-child="right_pane">
<object class="GbWorkspacePane">
</object>
- <packing>
- <property name="reveal">false</property>
- </packing>
</child>
<child internal-child="bottom_pane">
<object class="GbWorkspacePane">
</object>
- <packing>
- <property name="reveal">false</property>
- </packing>
</child>
</object>
</child>
diff --git a/src/workbench/gb-workbench.c b/src/workbench/gb-workbench.c
index 166a79e..060f2d7 100644
--- a/src/workbench/gb-workbench.c
+++ b/src/workbench/gb-workbench.c
@@ -59,6 +59,80 @@ static const GtkTargetEntry gDropTypes[] = {
};
static void
+gb_workbench_save_panel_state (GbWorkbench *self)
+{
+ g_autoptr(GSettings) settings = NULL;
+ GtkWidget *pane;
+ gboolean reveal;
+ guint position;
+
+ g_assert (GB_IS_WORKBENCH (self));
+
+ settings = g_settings_new ("org.gnome.builder.workbench");
+
+ pane = gb_workspace_get_left_pane (self->workspace);
+ gtk_container_child_get (GTK_CONTAINER (self->workspace), pane,
+ "reveal", &reveal,
+ "position", &position,
+ NULL);
+ g_settings_set_boolean (settings, "left-visible", reveal);
+ g_settings_set_int (settings, "left-position", position);
+
+ pane = gb_workspace_get_right_pane (self->workspace);
+ gtk_container_child_get (GTK_CONTAINER (self->workspace), pane,
+ "reveal", &reveal,
+ "position", &position,
+ NULL);
+ g_settings_set_boolean (settings, "right-visible", reveal);
+ g_settings_set_int (settings, "right-position", position);
+
+ pane = gb_workspace_get_bottom_pane (self->workspace);
+ gtk_container_child_get (GTK_CONTAINER (self->workspace), pane,
+ "reveal", &reveal,
+ "position", &position,
+ NULL);
+ g_settings_set_boolean (settings, "bottom-visible", reveal);
+ g_settings_set_int (settings, "bottom-position", position);
+}
+
+static void
+gb_workbench_restore_panel_state (GbWorkbench *self)
+{
+ g_autoptr(GSettings) settings = NULL;
+ GtkWidget *pane;
+ gboolean reveal;
+ guint position;
+
+ g_assert (GB_IS_WORKBENCH (self));
+
+ settings = g_settings_new ("org.gnome.builder.workbench");
+
+ pane = gb_workspace_get_left_pane (self->workspace);
+ reveal = g_settings_get_boolean (settings, "left-visible");
+ position = g_settings_get_int (settings, "left-position");
+ gtk_container_child_set (GTK_CONTAINER (self->workspace), pane,
+ "position", position,
+ "reveal", reveal,
+ NULL);
+
+ pane = gb_workspace_get_right_pane (self->workspace);
+ reveal = g_settings_get_boolean (settings, "right-visible");
+ position = g_settings_get_int (settings, "right-position");
+ gtk_container_child_set (GTK_CONTAINER (self->workspace), pane,
+ "position", position,
+ "reveal", reveal,
+ NULL);
+
+ pane = gb_workspace_get_bottom_pane (self->workspace);
+ reveal = g_settings_get_boolean (settings, "bottom-visible");
+ position = g_settings_get_int (settings, "bottom-position");
+ gtk_container_child_set (GTK_CONTAINER (self->workspace), pane,
+ "position", position,
+ "reveal", reveal,
+ NULL);
+}
+
+static void
gb_workbench__project_notify_name_cb (GbWorkbench *self,
GParamSpec *pspec,
IdeProject *project)
@@ -292,6 +366,8 @@ gb_workbench_delete_event (GtkWidget *widget,
return TRUE;
}
+ gb_workbench_save_panel_state (self);
+
return FALSE;
}
@@ -366,6 +442,8 @@ gb_workbench_realize (GtkWidget *widget)
{
GbWorkbench *self = (GbWorkbench *)widget;
+ gb_workbench_restore_panel_state (self);
+
if (GTK_WIDGET_CLASS (gb_workbench_parent_class)->realize)
GTK_WIDGET_CLASS (gb_workbench_parent_class)->realize (widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]