diff options
author | Christian Dywan <christian@twotoasts.de> | 2018-11-26 08:30:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-26 08:30:12 +0200 |
commit | 1a097f77449a7870549dbbbb76480c2f23d1d5af (patch) | |
tree | a5b58fefe435bcc18fd42b84222e49f0d11afcd7 | |
parent | 6194db688aff4dd14be6cbae0ef79755fec780f1 (diff) | |
download | midori-git-1a097f77449a7870549dbbbb76480c2f23d1d5af.tar.gz |
(Re)store last window width and height (#180)
- Save the size of a non-tiled/ -maximized/ -fullscreen browser
- Use the last known dimensions as the default size
-rw-r--r-- | core/browser.vala | 13 | ||||
-rw-r--r-- | core/settings.vala | 11 | ||||
-rw-r--r-- | ui/browser.ui | 2 |
3 files changed, 24 insertions, 2 deletions
diff --git a/core/browser.vala b/core/browser.vala index f65a2ebd..23dd1b6f 100644 --- a/core/browser.vala +++ b/core/browser.vala @@ -320,6 +320,11 @@ namespace Midori { if (web_context.is_ephemeral ()) { get_style_context ().add_class ("incognito"); } + + if (settings.last_window_width > 0 && settings.last_window_height > 0) { + default_width = settings.last_window_width; + default_height = settings.last_window_height; + } } void update_decoration_layout () { @@ -340,6 +345,14 @@ namespace Midori { get_size (out width, null); is_small = width < 500; + if (!(get_style_context ().has_class ("tiled") || is_maximized || is_fullscreen)) { + int height; + get_size (null, out height); + var settings = CoreSettings.get_default (); + settings.last_window_width = width; + settings.last_window_height = height; + } + return result; } diff --git a/core/settings.vala b/core/settings.vala index 7924fa94..7d7173f8 100644 --- a/core/settings.vala +++ b/core/settings.vala @@ -49,6 +49,17 @@ namespace Midori { set_boolean ("extensions", "lib%s.so".printf (plugin), enabled); } + public int last_window_width { get { + return get_string ("settings", "last-window-width", "710").to_int (); + } set { + set_string ("settings", "last-window-width", value.to_string ()); + } } + public int last_window_height { get { + return get_string ("settings", "last-window-height", "530").to_int (); + } set { + set_string ("settings", "last-window-height", value.to_string ()); + } } + // Note: Speed Dial is saved as Blank Page for compatibility reasons public StartupType load_on_startup { get { var startup = get_string ("settings", "load-on-startup", "MIDORI_STARTUP_LAST_OPEN_PAGES"); diff --git a/ui/browser.ui b/ui/browser.ui index 6567841b..a57554bb 100644 --- a/ui/browser.ui +++ b/ui/browser.ui @@ -15,8 +15,6 @@ </widgets> </object> <template class="MidoriBrowser" parent="GtkApplicationWindow"> - <property name="default-width">710</property> - <property name="default-height">530</property> <child type="titlebar"> <object class="GtkPaned"> <property name="visible">yes</property> |