From 10e552b6edb7789403bb0f12f29103762945c86a Mon Sep 17 00:00:00 2001 From: Artem Anufrij Date: Fri, 11 Aug 2017 21:13:39 +0200 Subject: [PATCH] save window maximized state --- src/WebWindow.vala | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/WebWindow.vala b/src/WebWindow.vala index 4550cea..dbcfdbd 100644 --- a/src/WebWindow.vala +++ b/src/WebWindow.vala @@ -81,17 +81,22 @@ namespace Webpin { this.set_titlebar (headerbar); var info = DesktopFile.get_app_by_url(webapp_uri); - var width = info.get_string("WebpinWindowWidth"); - var height = info.get_string("WebpinWindowHeight"); + var width = info.get_string ("WebpinWindowWidth"); + var height = info.get_string ("WebpinWindowHeight"); + var state = info.get_string ("WebpinWindowMaximized"); + + if (state != null && state == "max") { + this.maximize (); + } else if (width != null && height != null) { + set_default_size (int.parse(width), int.parse(height)); + } else { + set_default_size (1000, 600); + } - if(width !=null && height != null) - set_default_size (int.parse(width), int.parse(height)); - else - set_default_size (1000, 600); this.delete_event.connect (() => { - update_window_state(this.get_allocated_width (), this.get_allocated_height () ); + update_window_state(this.get_allocated_width (), this.get_allocated_height (), this.is_maximized); return false; - }); + }); this.destroy.connect(Gtk.main_quit); @@ -134,10 +139,11 @@ namespace Webpin { is_full_screen = !is_full_screen; } - public void update_window_state (int width, int height) { + public void update_window_state (int width, int height, bool is_maximized) { var file = web_app.get_desktop_file(); file.edit_propertie ("WebpinWindowWidth", width.to_string()); file.edit_propertie ("WebpinWindowHeight", height.to_string()); + file.edit_propertie ("WebpinWindowMaximized", is_maximized == true ? "max" : "norm"); } public override bool key_press_event (Gdk.EventKey event) {