[geary] Allow changing orientation of left paned



commit 4139076509b858f01c7bc3b049536daa983c5763
Author: Robert Schroll <rschroll gmail com>
Date:   Thu Feb 12 16:14:09 2015 -0500

    Allow changing orientation of left paned
    
    The orientation is set in the preferences dialog.  There are new
    configuration keys to track the pane positions, and a bit of code that
    will set them the first time based on the current settings.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=714793

 desktop/org.yorba.geary.gschema.xml        |   18 +++++++++++++++++
 src/client/application/geary-config.vala   |   19 +++++++++++++++++-
 src/client/components/main-window.vala     |   29 +++++++++++++++++++++++++++-
 src/client/dialogs/preferences-dialog.vala |    2 +
 ui/preferences.glade                       |   19 ++++++++++++++++++
 5 files changed, 85 insertions(+), 2 deletions(-)
---
diff --git a/desktop/org.yorba.geary.gschema.xml b/desktop/org.yorba.geary.gschema.xml
index cef596d..2c435b3 100644
--- a/desktop/org.yorba.geary.gschema.xml
+++ b/desktop/org.yorba.geary.gschema.xml
@@ -26,6 +26,24 @@
         <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>
+        <description>Position of the folder list Paned grabber in the vertical orientation.</description>
+    </key>
+    
+    <key name="folder-list-pane-horizontal" type="b">
+        <default>true</default>
+        <summary>orientation of the folder list pane</summary>
+        <description>True if the folder list Paned is in the horizontal orientation.</description>
+    </key>
+    
     <key name="messages-pane-position" type="i">
         <default>250</default>
         <summary>position of message list pane</summary>
diff --git a/src/client/application/geary-config.vala b/src/client/application/geary-config.vala
index 21db870..221cb34 100644
--- a/src/client/application/geary-config.vala
+++ b/src/client/application/geary-config.vala
@@ -10,6 +10,9 @@ 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_HORIZONTAL_KEY = "folder-list-pane-horizontal";
     public const string MESSAGES_PANE_POSITION_KEY = "messages-pane-position";
     public const string COMPOSER_PANE_POSITION_KEY = "composer-pane-position";
     public const string AUTOSELECT_KEY = "autoselect";
@@ -38,12 +41,26 @@ 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); }
+    }
+    
+    public bool folder_list_pane_horizontal {
+        get { return settings.get_boolean(FOLDER_LIST_PANE_HORIZONTAL_KEY); }
+    }
+    
     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 df41727..239724d 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -48,11 +48,15 @@ public class MainWindow : Gtk.ApplicationWindow {
         // the value in dconf changes *immediately*, and stays saved
         // in the event of a crash.
         Configuration config = GearyApplication.instance.config;
-        config.bind(Configuration.FOLDER_LIST_PANE_POSITION_KEY, folder_paned, "position");
         config.bind(Configuration.MESSAGES_PANE_POSITION_KEY, conversations_paned, "position");
         config.bind(Configuration.WINDOW_WIDTH_KEY, this, "window-width");
         config.bind(Configuration.WINDOW_HEIGHT_KEY, this, "window-height");
         config.bind(Configuration.WINDOW_MAXIMIZE_KEY, this, "window-maximized");
+        // 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());
         
@@ -70,6 +74,8 @@ public class MainWindow : Gtk.ApplicationWindow {
         key_press_event.connect(on_key_press_event);
         key_release_event.connect(on_key_release_event);
         focus_in_event.connect(on_focus_event);
+        GearyApplication.instance.config.settings.changed[
+            Configuration.FOLDER_LIST_PANE_HORIZONTAL_KEY].connect(on_change_orientation);
         GearyApplication.instance.controller.notify[GearyController.PROP_CURRENT_CONVERSATION].
             connect(on_conversation_monitor_changed);
         GearyApplication.instance.controller.folder_selected.connect(on_folder_selected);
@@ -83,6 +89,7 @@ public class MainWindow : Gtk.ApplicationWindow {
             set_titlebar(main_toolbar);
         }
         
+        on_change_orientation();
         set_styling();
         create_layout();
     }
@@ -321,6 +328,26 @@ public class MainWindow : Gtk.ApplicationWindow {
         }
     }
     
+    private void on_change_orientation() {
+        bool horizontal = GearyApplication.instance.config.folder_list_pane_horizontal;
+        
+        GLib.Settings.unbind(folder_paned, "position");
+        folder_paned.orientation = horizontal ? Gtk.Orientation.HORIZONTAL :
+            Gtk.Orientation.VERTICAL;
+        
+        int folder_list_width =
+            GearyApplication.instance.config.folder_list_pane_position_horizontal;
+        if (horizontal)
+            conversations_paned.position += folder_list_width;
+        else
+            conversations_paned.position -= folder_list_width;
+        
+        GearyApplication.instance.config.bind(
+            horizontal ? Configuration.FOLDER_LIST_PANE_POSITION_HORIZONTAL_KEY
+            : Configuration.FOLDER_LIST_PANE_POSITION_VERTICAL_KEY,
+            folder_paned, "position");
+    }
+    
     private void update_headerbar() {
         if (current_folder == null) {
             main_toolbar.title = null;
diff --git a/src/client/dialogs/preferences-dialog.vala b/src/client/dialogs/preferences-dialog.vala
index 3808699..389711e 100644
--- a/src/client/dialogs/preferences-dialog.vala
+++ b/src/client/dialogs/preferences-dialog.vala
@@ -18,6 +18,8 @@ public class PreferencesDialog : Object {
         Configuration config = GearyApplication.instance.config;
         config.bind(Configuration.AUTOSELECT_KEY, builder.get_object("autoselect"), "active");
         config.bind(Configuration.DISPLAY_PREVIEW_KEY, builder.get_object("display_preview"), "active");
+        config.bind(Configuration.FOLDER_LIST_PANE_HORIZONTAL_KEY,
+            builder.get_object("three_pane_view"), "active");
         config.bind(Configuration.SPELL_CHECK_KEY, builder.get_object("spell_check"), "active");
         config.bind(Configuration.PLAY_SOUNDS_KEY, builder.get_object("play_sounds"), "active");
         config.bind(Configuration.SHOW_NOTIFICATIONS_KEY, builder.get_object("show_notifications"), 
"active");
diff --git a/ui/preferences.glade b/ui/preferences.glade
index 4c8928f..93232ae 100644
--- a/ui/preferences.glade
+++ b/ui/preferences.glade
@@ -80,6 +80,25 @@
               </object>
               <packing>
                 <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="three_pane_view">
+                <property name="label" translatable="yes">Use _three pane view</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="margin_left">12</property>
+                <property name="margin_right">5</property>
+                <property name="margin_top">5</property>
+                <property name="margin_bottom">5</property>
+                <property name="use_underline">True</property>
+                <property name="xalign">0</property>
+                <property name="draw_indicator">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
                 <property name="top_attach">3</property>
               </packing>
             </child>


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