[gnome-builder] editor: restore previous sidebar size



commit b2bf28dd4aba1c1f8fac35c36d1993bce059df21
Author: Christian Hergert <christian hergert me>
Date:   Thu Apr 9 15:18:41 2015 -0700

    editor: restore previous sidebar size

 src/editor/gb-editor-workspace-actions.c |    9 ++++++++-
 src/editor/gb-editor-workspace-private.h |    4 +++-
 src/editor/gb-editor-workspace.c         |    4 ++++
 3 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/editor/gb-editor-workspace-actions.c b/src/editor/gb-editor-workspace-actions.c
index 8d2c818..f10f3f0 100644
--- a/src/editor/gb-editor-workspace-actions.c
+++ b/src/editor/gb-editor-workspace-actions.c
@@ -24,6 +24,7 @@
 #include "gb-workbench.h"
 
 #define ANIMATION_DURATION_MSEC 250
+#define MIN_PANED_SAVE_POSTION  100
 
 static void
 gb_editor_workspace_actions_show_sidebar (GSimpleAction *action,
@@ -39,6 +40,12 @@ gb_editor_workspace_actions_show_sidebar (GSimpleAction *action,
 
   if (!g_variant_get_boolean (variant) && visible)
     {
+      guint position;
+
+      position = gtk_paned_get_position (self->project_paned);
+      if (position > MIN_PANED_SAVE_POSTION)
+        self->sidebar_position = position;
+
       ide_object_animate_full (self->project_paned,
                                IDE_ANIMATION_EASE_IN_CUBIC,
                                ANIMATION_DURATION_MSEC,
@@ -57,7 +64,7 @@ gb_editor_workspace_actions_show_sidebar (GSimpleAction *action,
                           IDE_ANIMATION_EASE_IN_CUBIC,
                           ANIMATION_DURATION_MSEC,
                           NULL,
-                          "position", 250,
+                          "position", self->sidebar_position,
                           NULL);
       g_simple_action_set_state (action, variant);
     }
diff --git a/src/editor/gb-editor-workspace-private.h b/src/editor/gb-editor-workspace-private.h
index 31ed136..e849799 100644
--- a/src/editor/gb-editor-workspace-private.h
+++ b/src/editor/gb-editor-workspace-private.h
@@ -27,7 +27,7 @@ G_BEGIN_DECLS
 
 struct _GbEditorWorkspace
 {
-  GbWorkspace  parent_instance;
+  GbWorkspace    parent_instance;
 
   GtkPaned      *project_paned;
   GtkBox        *project_sidebar;
@@ -36,6 +36,8 @@ struct _GbEditorWorkspace
   GbTree        *project_tree;
   GbTreeBuilder *project_tree_builder;
   GbViewGrid    *view_grid;
+
+  guint          sidebar_position;
 };
 
 G_END_DECLS
diff --git a/src/editor/gb-editor-workspace.c b/src/editor/gb-editor-workspace.c
index 904977a..e50eebd 100644
--- a/src/editor/gb-editor-workspace.c
+++ b/src/editor/gb-editor-workspace.c
@@ -33,6 +33,8 @@
 #include "gb-view-grid.h"
 #include "gb-widget.h"
 
+#define SIDEBAR_POSITION 250
+
 G_DEFINE_TYPE (GbEditorWorkspace, gb_editor_workspace, GB_TYPE_WORKSPACE)
 
 static void
@@ -152,6 +154,8 @@ gb_editor_workspace_constructed (GObject *object)
 
   G_OBJECT_CLASS (gb_editor_workspace_parent_class)->constructed (object);
 
+  self->sidebar_position = gtk_paned_get_position (self->project_paned) ?: SIDEBAR_POSITION;
+
   gb_editor_workspace_actions_init (self);
   gb_project_tree_actions_init (self);
 


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