save window maximized state

This commit is contained in:
Artem Anufrij 2017-08-11 21:16:18 +02:00
parent 10e552b6ed
commit 01538d3154

View file

@ -85,14 +85,16 @@ namespace Webpin {
var height = info.get_string ("WebpinWindowHeight"); var height = info.get_string ("WebpinWindowHeight");
var state = info.get_string ("WebpinWindowMaximized"); var state = info.get_string ("WebpinWindowMaximized");
if (state != null && state == "max") { if (width != null && height != null) {
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);
} }
if (state != null && state == "max") {
this.maximize ();
}
this.delete_event.connect (() => { this.delete_event.connect (() => {
update_window_state(this.get_allocated_width (), this.get_allocated_height (), this.is_maximized); update_window_state(this.get_allocated_width (), this.get_allocated_height (), this.is_maximized);
return false; return false;
@ -139,12 +141,17 @@ namespace Webpin {
is_full_screen = !is_full_screen; is_full_screen = !is_full_screen;
} }
public void update_window_state (int width, int height, bool is_maximized) { 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 ("WebpinWindowHeight", height.to_string()); if (is_maximized) {
file.edit_propertie ("WebpinWindowMaximized", is_maximized == true ? "max" : "norm"); file.edit_propertie ("WebpinWindowMaximized", "max");
} } else {
file.edit_propertie ("WebpinWindowWidth", width.to_string());
file.edit_propertie ("WebpinWindowHeight", height.to_string());
file.edit_propertie ("WebpinWindowMaximized", "norm");
}
}
public override bool key_press_event (Gdk.EventKey event) { public override bool key_press_event (Gdk.EventKey event) {
bool handled = true; bool handled = true;