From 404f5ee056ab2ab759855e6a6f5b4c5283090ac5 Mon Sep 17 00:00:00 2001 From: Artem Anufrij Date: Fri, 20 Apr 2018 21:13:02 +0200 Subject: [PATCH] restore position for hidden windows --- src/Objects/DesktopFile.vala | 18 ++++++++++++++++-- src/Windows/WebApp.vala | 9 +++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Objects/DesktopFile.vala b/src/Objects/DesktopFile.vala index c3b2c54..1a42a46 100644 --- a/src/Objects/DesktopFile.vala +++ b/src/Objects/DesktopFile.vala @@ -139,13 +139,13 @@ namespace Webpin { } } - public bool edit_property (string propertie, string val) { + public bool edit_property (string property, string val) { bool return_value = false; try { string filename = GLib.Environment.get_user_data_dir () + "/applications/" + file.get_string ("Desktop Entry", "Name") + "-webpin.desktop"; file = new GLib.KeyFile (); file.load_from_file (filename, KeyFileFlags.NONE); - file.set_string ("Desktop Entry", propertie, val); + file.set_string ("Desktop Entry", property, val); return_value = file.save_to_file (filename); } catch (Error err) { warning (err.message); @@ -154,6 +154,20 @@ namespace Webpin { return return_value; } + public new string get_property (string property) { + string return_value = ""; + try { + string filename = GLib.Environment.get_user_data_dir () + "/applications/" + file.get_string ("Desktop Entry", "Name") + "-webpin.desktop"; + file = new GLib.KeyFile (); + file.load_from_file (filename, KeyFileFlags.NONE); + return_value = file.get_string ("Desktop Entry", property); + } catch (Error err) { + warning (err.message); + } + + return return_value; + } + public GLib.DesktopAppInfo save_to_file () { GLib.DesktopAppInfo return_value = null; try { diff --git a/src/Windows/WebApp.vala b/src/Windows/WebApp.vala index 4df4ce5..908cf64 100644 --- a/src/Windows/WebApp.vala +++ b/src/Windows/WebApp.vala @@ -135,6 +135,15 @@ namespace Webpin.Windows { load_settings (); this.show_all (); + + this.show.connect ( + () => { + var x = desktop_file.get_property ("X-Webpin-WindowX"); + var y = desktop_file.get_property ("X-Webpin-WindowY"); + if (x != null && y != null) { + this.move (int.parse (x), int.parse (y)); + } + }); } private void set_color (Gdk.RGBA color) {