aboutsummaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-12-31 20:19:51 +0100
committerfiaxh <git@mx.ax.lt>2017-12-31 22:48:14 +0100
commitc7c1fb51246f52801de118e1f519630a51adefdb (patch)
tree5ccc394ba6c525d24b586a63cc52cf5a348ab926 /main/src
parent119e7cce4ffb2774fa77bbfcef5dda80a5483f3f (diff)
downloaddino-c7c1fb51246f52801de118e1f519630a51adefdb.tar.gz
dino-c7c1fb51246f52801de118e1f519630a51adefdb.zip
Restore window state (size, maximized, position)
Diffstat (limited to 'main/src')
-rw-r--r--main/src/ui/unified_window.vala31
1 files changed, 30 insertions, 1 deletions
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;