From ff33532ed315749e94eb83e92a5f7381fb8afae8 Mon Sep 17 00:00:00 2001 From: Chris Cromer Date: Sun, 23 Dec 2018 17:04:47 -0300 Subject: [PATCH] remember if maximized --- data/ui/sernatur.window.ui | 1 + src/sernatur-window.vala | 20 ++++++++++++++++++++ src/sernatur.vala | 1 + 3 files changed, 22 insertions(+) diff --git a/data/ui/sernatur.window.ui b/data/ui/sernatur.window.ui index 72a5a37..8c4e5e9 100644 --- a/data/ui/sernatur.window.ui +++ b/data/ui/sernatur.window.ui @@ -21,6 +21,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND SERNATUR sernatur False + diff --git a/src/sernatur-window.vala b/src/sernatur-window.vala index 6e76e01..54a85be 100644 --- a/src/sernatur-window.vala +++ b/src/sernatur-window.vala @@ -24,6 +24,26 @@ namespace Sernatur { [GtkTemplate (ui = "/cl/cromer/ubb/sernatur/sernatur.window.ui")] public class MainWindow : Gtk.ApplicationWindow { + /** + * This is a callback for when the window's state changes + * @param widget The widget that called this GtkCallback + * @param state The event window state_handler + * @return Returns true or false + */ + [GtkCallback] + private bool state_handler(Gtk.Widget widget, Gdk.EventWindowState state) { + Settings settings = new Settings ("cl.cromer.ubb.sernatur"); + if (state.changed_mask == Gdk.WindowState.MAXIMIZED && (state.new_window_state & Gdk.WindowState.MAXIMIZED) != 0) { + // Maximized + settings.set_boolean ("maximized", true); + } + else if (state.changed_mask == Gdk.WindowState.MAXIMIZED && (state.new_window_state & Gdk.WindowState.MAXIMIZED) == 0) { + // Unmaximized + settings.set_boolean ("maximized", false); + } + return true; + } + /** * Initialize the main window class * @param application The application used to make the GLib object diff --git a/src/sernatur.vala b/src/sernatur.vala index cdf2328..8864d9c 100644 --- a/src/sernatur.vala +++ b/src/sernatur.vala @@ -46,6 +46,7 @@ namespace Sernatur { try { window.icon = IconTheme.get_default ().load_icon ("sernatur", 48, 0); } + catch (Error e) { stderr.printf ("Could not load application icon: %s\n", e.message); }