handle settings for window size
This commit is contained in:
@@ -28,11 +28,11 @@ namespace Sernatur {
|
||||
* 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
|
||||
* @return Returns true if the event is handled or false if it isn't
|
||||
*/
|
||||
[GtkCallback]
|
||||
private bool state_handler(Gtk.Widget widget, Gdk.EventWindowState state) {
|
||||
Settings settings = new Settings ("cl.cromer.ubb.sernatur");
|
||||
private bool maximize_window(Gtk.Widget widget, Gdk.EventWindowState state) {
|
||||
Settings settings = new Settings ("cl.cromer.ubb.sernatur.window");
|
||||
if (state.changed_mask == Gdk.WindowState.MAXIMIZED && (state.new_window_state & Gdk.WindowState.MAXIMIZED) != 0) {
|
||||
// Maximized
|
||||
settings.set_boolean ("maximized", true);
|
||||
@@ -44,6 +44,20 @@ namespace Sernatur {
|
||||
return true;
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
private bool resize_window(Gtk.Widget widget, Gdk.Event event) {
|
||||
Settings settings = new Settings ("cl.cromer.ubb.sernatur.window");
|
||||
if (event.get_event_type () == Gdk.EventType.CONFIGURE && !settings.get_boolean ("maximized")) {
|
||||
if (settings.get_int ("width") != event.get_window ().get_width ()) {
|
||||
settings.set_int ("width", event.get_window ().get_width ());
|
||||
}
|
||||
if (settings.get_int ("height") != event.get_window ().get_height ()) {
|
||||
settings.set_int ("height", event.get_window ().get_height ());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the main window class
|
||||
* @param application The application used to make the GLib object
|
||||
@@ -52,7 +66,7 @@ namespace Sernatur {
|
||||
GLib.Object (application: application);
|
||||
Database conn;
|
||||
|
||||
Settings settings = new Settings ("cl.cromer.ubb.sernatur");
|
||||
Settings settings = new Settings ("cl.cromer.ubb.sernatur.db");
|
||||
string host = settings.get_string ("host");
|
||||
string port = settings.get_string ("port");
|
||||
string options = settings.get_string ("options");
|
||||
|
@@ -39,16 +39,19 @@ namespace Sernatur {
|
||||
*/
|
||||
public override void activate () {
|
||||
window = new MainWindow (this);
|
||||
GLib.Settings settings = new GLib.Settings ("cl.cromer.ubb.sernatur");
|
||||
GLib.Settings settings = new GLib.Settings ("cl.cromer.ubb.sernatur.window");
|
||||
|
||||
window.set_default_size (settings.get_int("width"), settings.get_int("height"));
|
||||
|
||||
if (settings.get_boolean ("maximized")) {
|
||||
window.maximize ();
|
||||
}
|
||||
|
||||
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);
|
||||
stderr.printf (dgettext (null, "Could not load application icon: %s\n"), e.message);
|
||||
}
|
||||
window.present ();
|
||||
}
|
||||
|
Reference in New Issue
Block a user