Window settings are now saved when a window is repositioned or resized
This commit is contained in:
parent
f4e32478e6
commit
754433d884
@ -503,6 +503,16 @@ window_populate(AgWindow *window)
|
||||
gtk_widget_show_all(priv->grid);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ag_window_configure_event_cb(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data)
|
||||
{
|
||||
AgWindow *window = AG_WINDOW(widget);
|
||||
|
||||
ag_window_settings_save(GTK_WINDOW(window), ag_settings_peek_window_settings(window->priv->settings));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
ag_window_new(AgApp *app)
|
||||
{
|
||||
@ -515,6 +525,7 @@ ag_window_new(AgApp *app)
|
||||
window_populate(window);
|
||||
|
||||
gtk_window_set_icon_name(GTK_WINDOW(window), "astrognome");
|
||||
g_signal_connect(window, "configure-event", G_CALLBACK(ag_window_configure_event_cb), NULL);
|
||||
|
||||
ag_window_settings_restore(GTK_WINDOW(window), ag_settings_peek_window_settings(window->priv->settings));
|
||||
|
||||
@ -587,3 +598,21 @@ ag_window_settings_restore(GtkWindow *window, GSettings *settings)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ag_window_settings_save(GtkWindow *window, GSettings *settings)
|
||||
{
|
||||
GdkWindowState state;
|
||||
gint width,
|
||||
height;
|
||||
gboolean maximized;
|
||||
|
||||
state = gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(window)));
|
||||
maximized = ((state & GDK_WINDOW_STATE_MAXIMIZED) == GDK_WINDOW_STATE_MAXIMIZED);
|
||||
|
||||
g_settings_set_boolean(settings, "maximized", maximized);
|
||||
|
||||
gtk_window_get_size(window, &width, &height);
|
||||
g_settings_set_int(settings, "width", width);
|
||||
g_settings_set_int(settings, "height", height);
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,8 @@ void ag_window_set_uri(AgWindow *window,
|
||||
gchar *ag_window_get_uri(AgWindow *window);
|
||||
void ag_window_settings_restore(GtkWindow *window,
|
||||
GSettings *settings);
|
||||
void ag_window_settings_save(GtkWindow *window,
|
||||
GSettings *settings);
|
||||
|
||||
#define AG_WINDOW_ERROR (ag_window_error_quark())
|
||||
GQuark ag_window_error_quark(void);
|
||||
|
Loading…
Reference in New Issue
Block a user