[geary/wip/714793-orientation: 2/3] Allow changing orientation of left paned
- From: Robert Schroll <rschroll src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/714793-orientation: 2/3] Allow changing orientation of left paned
- Date: Fri, 13 Feb 2015 04:52:59 +0000 (UTC)
commit a5831578337ac949568223a56b06fba223198427
Author: Robert Schroll <rschroll gmail com>
Date: Thu Feb 12 16:14:09 2015 -0500
Allow changing orientation of left paned
desktop/org.yorba.geary.gschema.xml | 12 ++++++++++
src/client/application/geary-config.vala | 10 ++++++++
src/client/components/main-window.vala | 35 +++++++++++++++++++++++++++++-
3 files changed, 56 insertions(+), 1 deletions(-)
---
diff --git a/desktop/org.yorba.geary.gschema.xml b/desktop/org.yorba.geary.gschema.xml
index cef596d..c56d44e 100644
--- a/desktop/org.yorba.geary.gschema.xml
+++ b/desktop/org.yorba.geary.gschema.xml
@@ -26,6 +26,18 @@
<description>Position of the folder list Paned grabber.</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-orientation" type="i">
+ <default>0</default>
+ <summary>orientation of the folder list pane</summary>
+ <description>Orientation of the folder list Paned.</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 71a148c..a220000 100644
--- a/src/client/application/geary-config.vala
+++ b/src/client/application/geary-config.vala
@@ -10,6 +10,8 @@ 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_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";
public const string COMPOSER_PANE_POSITION_KEY = "composer-pane-position";
public const string AUTOSELECT_KEY = "autoselect";
@@ -42,6 +44,14 @@ public class Configuration {
get { return settings.get_int(FOLDER_LIST_PANE_POSITION_KEY); }
}
+ public int folder_list_pane_position_vertical {
+ 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 int messages_pane_position {
get { return settings.get_int(MESSAGES_PANE_POSITION_KEY); }
}
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index ea8593f..cae6f86 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -22,9 +22,11 @@ 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();
@@ -48,11 +50,14 @@ 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");
+ // 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);
add_accel_group(GearyApplication.instance.ui_manager.get_accel_group());
@@ -70,6 +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.controller.notify[GearyController.PROP_CURRENT_CONVERSATION].
connect(on_conversation_monitor_changed);
GearyApplication.instance.controller.folder_selected.connect(on_folder_selected);
@@ -83,6 +90,7 @@ public class MainWindow : Gtk.ApplicationWindow {
set_titlebar(main_toolbar);
}
+ on_orientation_changed();
set_styling();
create_layout();
}
@@ -214,6 +222,9 @@ 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);
@@ -334,6 +345,28 @@ public class MainWindow : Gtk.ApplicationWindow {
}
}
+ private void change_orientation() {
+ GLib.Settings.unbind(folder_paned, "position");
+ 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;
+ if (folder_paned.orientation == Gtk.Orientation.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_KEY
+ : Configuration.FOLDER_LIST_PANE_POSITION_VERTICAL_KEY,
+ folder_paned, "position");
+ }
+
private void update_headerbar() {
if (current_folder == null) {
main_toolbar.account = null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]