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); }