[geary/wip/714793-orientation2] Set orientation of layout in preferences



commit 0d462bbea9555cabc781bb7f92f538d24e8ffab4
Author: Robert Schroll <rschroll gmail com>
Date:   Mon Mar 9 00:25:30 2015 -0400

    Set orientation of layout in preferences
    
    There didn't seem to be a use case where you'd need to switch
    orientations often.

 desktop/org.yorba.geary.gschema.xml        |    6 ++--
 src/client/application/geary-config.vala   |    6 ++--
 src/client/components/main-window.vala     |   35 +++++++++------------------
 src/client/dialogs/preferences-dialog.vala |    2 +
 ui/preferences.glade                       |   19 +++++++++++++++
 5 files changed, 39 insertions(+), 29 deletions(-)
---
diff --git a/desktop/org.yorba.geary.gschema.xml b/desktop/org.yorba.geary.gschema.xml
index 307f215..2c435b3 100644
--- a/desktop/org.yorba.geary.gschema.xml
+++ b/desktop/org.yorba.geary.gschema.xml
@@ -38,10 +38,10 @@
         <description>Position of the folder list Paned grabber in the vertical orientation.</description>
     </key>
     
-    <key name="folder-list-pane-orientation" type="i">
-        <default>0</default>
+    <key name="folder-list-pane-horizontal" type="b">
+        <default>true</default>
         <summary>orientation of the folder list pane</summary>
-        <description>Orientation of the folder list Paned.</description>
+        <description>True if the folder list Paned is in the horizontal orientation.</description>
     </key>
     
     <key name="messages-pane-position" type="i">
diff --git a/src/client/application/geary-config.vala b/src/client/application/geary-config.vala
index b14eae4..14d1e97 100644
--- a/src/client/application/geary-config.vala
+++ b/src/client/application/geary-config.vala
@@ -12,7 +12,7 @@ public class Configuration {
     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 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";
@@ -54,8 +54,8 @@ public class Configuration {
         get { return settings.get_int(FOLDER_LIST_PANE_POSITION_VERTICAL_KEY); }
     }
     
-    public Gtk.Orientation folder_list_pane_orientation {
-        get { return (Gtk.Orientation) settings.get_int(FOLDER_LIST_PANE_ORIENTATION_KEY); }
+    public bool folder_list_pane_horizontal {
+        get { return settings.get_boolean(FOLDER_LIST_PANE_HORIZONTAL_KEY); }
     }
     
     public int messages_pane_position {
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 8522615..7b83905 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -22,11 +22,9 @@ public class MainWindow : Gtk.ApplicationWindow {
     public int window_width { get; set; }
     public int window_height { get; set; }
     public bool window_maximized { get; set; }
-    public int orientation { get; set; }
-
+    
     private Gtk.Paned folder_paned = new Gtk.Paned(Gtk.Orientation.HORIZONTAL);
     private Gtk.Paned conversations_paned = new Gtk.Paned(Gtk.Orientation.HORIZONTAL);
-    private Gtk.Button orientation_button = new Gtk.Button();
     
     private Gtk.ScrolledWindow conversation_list_scrolled;
     private MonitoredSpinner spinner = new MonitoredSpinner();
@@ -54,10 +52,7 @@ public class MainWindow : Gtk.ApplicationWindow {
         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");
-        // Indirection needed since we can't bind enums to settings, apparently.
-        config.bind(Configuration.FOLDER_LIST_PANE_ORIENTATION_KEY, this, "orientation");
-        bind_property("orientation", folder_paned, "orientation",
-            BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+        config.bind(Configuration.FOLDER_LIST_PANE_HORIZONTAL_KEY, this, "horizontal-orientation");
         // Update to layout
         if (config.folder_list_pane_position_horizontal == -1) {
             config.folder_list_pane_position_horizontal = config.folder_list_pane_position_old;
@@ -80,8 +75,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);
-        orientation_button.clicked.connect(change_orientation);
-        notify["orientation"].connect(on_orientation_changed);
+        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);
@@ -95,7 +90,7 @@ public class MainWindow : Gtk.ApplicationWindow {
             set_titlebar(main_toolbar);
         }
         
-        on_orientation_changed();
+        on_change_orientation();
         set_styling();
         create_layout();
     }
@@ -224,9 +219,6 @@ public class MainWindow : Gtk.ApplicationWindow {
         spinner.set_size_request(STATUS_BAR_HEIGHT - 2, -1);
         status_bar.add(spinner);
         
-        status_bar.pack_start(orientation_button, false, false, 0);
-        status_bar.reorder_child(orientation_button, 0);
-        
         folder_paned.get_style_context().add_class("sidebar-pane-separator");
         
         Gtk.Frame viewer_frame = new Gtk.Frame(null);
@@ -347,23 +339,20 @@ public class MainWindow : Gtk.ApplicationWindow {
         }
     }
     
-    private void change_orientation() {
+    private void on_change_orientation() {
+        bool horizontal = GearyApplication.instance.config.folder_list_pane_horizontal;
+        
         GLib.Settings.unbind(folder_paned, "position");
-        folder_paned.orientation = (folder_paned.orientation == Gtk.Orientation.HORIZONTAL)
-            ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL;
+        folder_paned.orientation = horizontal ? Gtk.Orientation.HORIZONTAL :
+            Gtk.Orientation.VERTICAL;
         
         int folder_list_width =
             GearyApplication.instance.config.folder_list_pane_position_horizontal;
-        if (folder_paned.orientation == Gtk.Orientation.HORIZONTAL)
+        if (horizontal)
             conversations_paned.position += folder_list_width;
         else
             conversations_paned.position -= folder_list_width;
-    }
-    
-    private void on_orientation_changed() {
-        bool horizontal = (folder_paned.orientation == Gtk.Orientation.HORIZONTAL);
-        orientation_button.label = horizontal ? "H" : "I";
-        // Cancels previous binding
+        
         GearyApplication.instance.config.bind(
             horizontal ? Configuration.FOLDER_LIST_PANE_POSITION_HORIZONTAL_KEY
             : Configuration.FOLDER_LIST_PANE_POSITION_VERTICAL_KEY,
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]