diff options
author | Amit Chaudhuri <amit.k.chaudhuri@gmail.com> | 2013-02-12 13:03:23 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-02-28 15:36:27 -0800 |
commit | d742d7b391fb1e28e784161368689b05af791b71 (patch) | |
tree | 6af51be4f6ed155ac8183a217a694c527459f9a6 /gtk-gui.c | |
parent | cfdde3ff630ca3f58f9b03d59dde274bba5151f6 (diff) | |
download | subsurface-d742d7b391fb1e28e784161368689b05af791b71.tar.gz |
Remember window size
This commit has gone through a few iterations and I trimmed it down to
what I consider the "conservative minimum" - so this only stores window
size, not window position. And in my mind that's the more relevant part,
anyway. Have your window manager position the window at a "smart" spot on
your screen...
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r-- | gtk-gui.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -319,6 +319,29 @@ static void file_open(GtkWidget *w, gpointer data) gtk_widget_destroy(dialog); } +void save_window_geometry(void) +{ + /* GDK_GRAVITY_NORTH_WEST assumed ( it is the default ) */ + int window_width, window_height; + gtk_window_get_size(GTK_WINDOW (main_window), &window_width, &window_height); + subsurface_set_conf_int("window_width", window_width); + subsurface_set_conf_int("window_height", window_height); +} + +void restore_window_geometry(void) +{ + int window_width, window_height; + + window_height = subsurface_get_conf_int("window_height"); + window_width = subsurface_get_conf_int("window_width"); + + window_height == -1 ? window_height = 300 : window_height; + window_width == -1 ? window_width = 700 : window_width; + + gtk_window_resize (GTK_WINDOW (main_window), window_width, window_height); + +} + gboolean on_delete(GtkWidget* w, gpointer data) { /* Make sure to flush any modified dive data */ @@ -329,6 +352,7 @@ gboolean on_delete(GtkWidget* w, gpointer data) quit = ask_save_changes(); if (quit){ + save_window_geometry(); return FALSE; /* go ahead, kill the program, we're good now */ } else { return TRUE; /* We are not leaving */ @@ -352,6 +376,7 @@ static void quit(GtkWidget *w, gpointer data) quit = ask_save_changes(); if (quit){ + save_window_geometry(); dive_list_destroy(); gtk_main_quit(); } @@ -1647,6 +1672,7 @@ void init_ui(int *argcp, char ***argvp) g_signal_connect (G_OBJECT (win), "key_press_event", G_CALLBACK (on_key_press), dive_list); gtk_widget_set_app_paintable(win, TRUE); + restore_window_geometry(); gtk_widget_show_all(win); return; |