diff --git a/desktop/org.gnome.Geary.gschema.xml b/desktop/org.gnome.Geary.gschema.xml index bfaa3a0e..a64c4bc6 100644 --- a/desktop/org.gnome.Geary.gschema.xml +++ b/desktop/org.gnome.Geary.gschema.xml @@ -128,6 +128,12 @@ The zoom to apply on the conservation view. + + [-1,-1] + size of dettached composer window + The last recorded size of the dettached composer window. + + false Whether we migrated the old settings diff --git a/src/client/application/geary-config.vala b/src/client/application/geary-config.vala index a6782404..639fec7a 100644 --- a/src/client/application/geary-config.vala +++ b/src/client/application/geary-config.vala @@ -30,6 +30,7 @@ public class Configuration { public const string SPELL_CHECK_LANGUAGES = "spell-check-languages"; public const string SEARCH_STRATEGY_KEY = "search-strategy"; public const string CONVERSATION_VIEWER_ZOOM_KEY = "conversation-viewer-zoom"; + public const string COMPOSER_WINDOW_SIZE_KEY = "composer-window-size"; public enum DesktopEnvironment { @@ -172,6 +173,21 @@ public class Configuration { set { settings.set_double(CONVERSATION_VIEWER_ZOOM_KEY, value); } } + public int[] composer_window_size { + owned get { + int[] size = new int[2]; + var s = settings.get_value(COMPOSER_WINDOW_SIZE_KEY); + if (s.n_children () == 2) { + size = { (int) s.get_child_value(0), (int) s.get_child_value(1)}; + } else { + size = {-1,-1}; + } + return size; + } + set { + settings.set_value(COMPOSER_WINDOW_SIZE_KEY, value); + } + } // Creates a configuration object. public Configuration(string schema_id) { diff --git a/src/client/composer/composer-window.vala b/src/client/composer/composer-window.vala index 7c1e3b89..4c297c2a 100644 --- a/src/client/composer/composer-window.vala +++ b/src/client/composer/composer-window.vala @@ -20,7 +20,6 @@ public class ComposerWindow : Gtk.ApplicationWindow, ComposerContainer { private bool closing = false; - public ComposerWindow(ComposerWidget composer) { Object(type: Gtk.WindowType.TOPLEVEL); this.composer = composer; @@ -52,10 +51,48 @@ public class ComposerWindow : Gtk.ApplicationWindow, ComposerContainer { } public override void show() { - set_default_size(680, 600); + Gdk.Screen? screen = get_screen(); + if (screen != null) { + int screen_width = screen.get_width(); + int screen_height = screen.get_height(); + int[] size = GearyApplication.instance.config.composer_window_size; + + //check if stored values are reasonable + if (size[0] >= 0 && size[0] <= screen_width && + size[1] >= 0 && size[1] <= screen_height) + set_default_size(size[0], size[1]); + else + set_default_size(680, 600); + } + base.show(); } + private void save_window_geometry () { + Gdk.Screen? screen = get_screen(); + if (screen != null && !this.is_maximized) { + int screen_width = screen.get_width(); + int screen_height = screen.get_height(); + + int width = 0; + int height = 0; + + get_size(out width, out height); + + // Only store if the values are reasonable-looking. + if (width > 0 && width <= screen_width && + height > 0 && height <= screen_height) + GearyApplication.instance.config.composer_window_size = { width, height }; + } + } + + // Fired on window resize. Save window size for the next start. + public override void size_allocate(Gtk.Allocation allocation) { + base.size_allocate(allocation); + + this.save_window_geometry(); + } + public void close_container() { on_focus_out(); this.composer.editor.focus_in_event.disconnect(on_focus_in);