[geary/wip/714793-orientation2] Adjust settings to keep layout the same on upgrade



commit 12793d52e54209871f63e37d53163e97283d12e2
Author: Robert Schroll <rschroll gmail com>
Date:   Wed Feb 25 18:07:57 2015 -0500

    Adjust settings to keep layout the same on upgrade

 desktop/org.yorba.geary.gschema.xml      |    6 ++++++
 src/client/application/geary-config.vala |    9 ++++++++-
 src/client/components/main-window.vala   |   10 ++++++++--
 3 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/desktop/org.yorba.geary.gschema.xml b/desktop/org.yorba.geary.gschema.xml
index c56d44e..307f215 100644
--- a/desktop/org.yorba.geary.gschema.xml
+++ b/desktop/org.yorba.geary.gschema.xml
@@ -26,6 +26,12 @@
         <description>Position of the folder list Paned grabber.</description>
     </key>
     
+    <key name="folder-list-pane-position-horizontal" type="i">
+        <default>-1</default>
+        <summary>position of folder list pane when horizontal</summary>
+        <description>Position of the folder list Paned grabber in the horizontal orientation.</description>
+    </key>
+    
     <key name="folder-list-pane-position-vertical" type="i">
         <default>200</default>
         <summary>position of folder list pane when vertical</summary>
diff --git a/src/client/application/geary-config.vala b/src/client/application/geary-config.vala
index a220000..b14eae4 100644
--- a/src/client/application/geary-config.vala
+++ b/src/client/application/geary-config.vala
@@ -10,6 +10,7 @@ public class Configuration {
     public const string WINDOW_HEIGHT_KEY = "window-height";
     public const string WINDOW_MAXIMIZE_KEY = "window-maximize";
     public const string FOLDER_LIST_PANE_POSITION_KEY = "folder-list-pane-position";
+    public const string FOLDER_LIST_PANE_POSITION_HORIZONTAL_KEY = "folder-list-pane-position-horizontal";
     public const string FOLDER_LIST_PANE_POSITION_VERTICAL_KEY = "folder-list-pane-position-vertical";
     public const string FOLDER_LIST_PANE_ORIENTATION_KEY = "folder-list-pane-orientation";
     public const string MESSAGES_PANE_POSITION_KEY = "messages-pane-position";
@@ -40,10 +41,15 @@ public class Configuration {
         get { return settings.get_boolean(WINDOW_MAXIMIZE_KEY); }
     }
     
-    public int folder_list_pane_position {
+    public int folder_list_pane_position_old {
         get { return settings.get_int(FOLDER_LIST_PANE_POSITION_KEY); }
     }
     
+    public int folder_list_pane_position_horizontal {
+        get { return settings.get_int(FOLDER_LIST_PANE_POSITION_HORIZONTAL_KEY); }
+        set { settings.set_int(FOLDER_LIST_PANE_POSITION_HORIZONTAL_KEY, value); }
+    }
+    
     public int folder_list_pane_position_vertical {
         get { return settings.get_int(FOLDER_LIST_PANE_POSITION_VERTICAL_KEY); }
     }
@@ -54,6 +60,7 @@ public class Configuration {
     
     public int messages_pane_position {
         get { return settings.get_int(MESSAGES_PANE_POSITION_KEY); }
+        set { settings.set_int(MESSAGES_PANE_POSITION_KEY, value); }
     }
     
     public int composer_pane_position {
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index fcee808..c5b7593 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -58,6 +58,11 @@ public class MainWindow : Gtk.ApplicationWindow {
         config.bind(Configuration.FOLDER_LIST_PANE_ORIENTATION_KEY, this, "orientation");
         bind_property("orientation", folder_paned, "orientation",
             BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+        // Update to layout
+        if (config.folder_list_pane_position_horizontal == -1) {
+            config.folder_list_pane_position_horizontal = config.folder_list_pane_position_old;
+            config.messages_pane_position += config.folder_list_pane_position_old;
+        }
         
         add_accel_group(GearyApplication.instance.ui_manager.get_accel_group());
         
@@ -349,7 +354,8 @@ public class MainWindow : Gtk.ApplicationWindow {
         folder_paned.orientation = (folder_paned.orientation == Gtk.Orientation.HORIZONTAL)
             ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL;
         
-        int folder_list_width = GearyApplication.instance.config.folder_list_pane_position;
+        int folder_list_width =
+            GearyApplication.instance.config.folder_list_pane_position_horizontal;
         if (folder_paned.orientation == Gtk.Orientation.HORIZONTAL)
             conversations_paned.position += folder_list_width;
         else
@@ -365,7 +371,7 @@ public class MainWindow : Gtk.ApplicationWindow {
         orientation_button.image = image;
         // Cancels previous binding
         GearyApplication.instance.config.bind(
-            horizontal ? Configuration.FOLDER_LIST_PANE_POSITION_KEY
+            horizontal ? Configuration.FOLDER_LIST_PANE_POSITION_HORIZONTAL_KEY
             : Configuration.FOLDER_LIST_PANE_POSITION_VERTICAL_KEY,
             folder_paned, "position");
     }


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