save window maximized state

This commit is contained in:
Artem Anufrij 2017-08-11 21:13:39 +02:00
parent 6b836e79f5
commit 10e552b6ed

View file

@ -83,13 +83,18 @@ namespace Webpin {
var info = DesktopFile.get_app_by_url(webapp_uri); var info = DesktopFile.get_app_by_url(webapp_uri);
var width = info.get_string ("WebpinWindowWidth"); var width = info.get_string ("WebpinWindowWidth");
var height = info.get_string ("WebpinWindowHeight"); var height = info.get_string ("WebpinWindowHeight");
var state = info.get_string ("WebpinWindowMaximized");
if(width !=null && height != null) if (state != null && state == "max") {
this.maximize ();
} else if (width != null && height != null) {
set_default_size (int.parse(width), int.parse(height)); set_default_size (int.parse(width), int.parse(height));
else } else {
set_default_size (1000, 600); set_default_size (1000, 600);
}
this.delete_event.connect (() => { 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; return false;
}); });
@ -134,10 +139,11 @@ namespace Webpin {
is_full_screen = !is_full_screen; 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(); var file = web_app.get_desktop_file();
file.edit_propertie ("WebpinWindowWidth", width.to_string()); file.edit_propertie ("WebpinWindowWidth", width.to_string());
file.edit_propertie ("WebpinWindowHeight", height.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) { public override bool key_press_event (Gdk.EventKey event) {