From c7c1fb51246f52801de118e1f519630a51adefdb Mon Sep 17 00:00:00 2001 From: fiaxh Date: Sun, 31 Dec 2017 20:19:51 +0100 Subject: Restore window state (size, maximized, position) --- main/src/ui/unified_window.vala | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'main/src') diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala index 15218e17..8bcb2c57 100644 --- a/main/src/ui/unified_window.vala +++ b/main/src/ui/unified_window.vala @@ -21,10 +21,15 @@ public class UnifiedWindow : Window { private StreamInteractor stream_interactor; private Conversation? conversation; + private Application app; public UnifiedWindow(Application application, StreamInteractor stream_interactor) { - Object(application : application, default_width : 1200, default_height : 700); + Object(application : application); this.stream_interactor = stream_interactor; + this.app = application; + + restore_window_size(); + this.get_style_context().add_class("dino-main"); setup_headerbar(); @@ -120,6 +125,30 @@ public class UnifiedWindow : Window { } } + private void restore_window_size() { + default_width = app.settings.current_width; + default_height = app.settings.current_height; + if (app.settings.is_maximized) this.maximize(); + if (app.settings.position_x != -1 && app.settings.position_y != -1) { + move(app.settings.position_x, app.settings.position_y); + } + + delete_event.connect(() => { + int x, y; + get_position(out x, out y); + app.settings.position_x = x; + app.settings.position_y = y; + + int width, height; + get_size(out width, out height); + app.settings.current_width = width; + app.settings.current_height = height; + + app.settings.is_maximized = is_maximized; + return false; + }); + } + private bool on_focus_in_event() { stream_interactor.get_module(ChatInteraction.IDENTITY).on_window_focus_in(conversation); urgency_hint = false; -- cgit v1.2.3-54-g00ecf