remember if maximized

This commit is contained in:
Chris Cromer 2018-12-23 17:04:47 -03:00
parent 6a6968c240
commit ff33532ed3
Signed by: cromer
GPG Key ID: 39CC813FF3C8708A
3 changed files with 22 additions and 0 deletions

View File

@ -21,6 +21,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<property name="title">SERNATUR</property>
<property name="icon_name">sernatur</property>
<property name="show_menubar">False</property>
<signal name="window-state-event" handler="state_handler" swapped="no"/>
<child>
<placeholder/>
</child>

View File

@ -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

View File

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