diff options
author | Søren Sandmann <sandmann@redhat.com> | 2008-03-10 01:56:07 -0400 |
---|---|---|
committer | Søren Sandmann <sandmann@redhat.com> | 2008-03-10 01:56:07 -0400 |
commit | db720a7d4af167626543785e637468e95eeace95 (patch) | |
tree | 1a0b91f5bfd371f73234dfe897da5f3da43de71f | |
parent | 0853697df23c1ced2d47514d7aa41860300a13cc (diff) |
Remember adjustments
-rw-r--r-- | siv.c | 14 | ||||
-rw-r--r-- | siv.h | 6 | ||||
-rw-r--r-- | window.c | 28 |
3 files changed, 43 insertions, 5 deletions
@@ -83,6 +83,8 @@ foreach (gpointer key, gpointer value, gpointer user_data) g_key_file_set_integer (key_file, filename, "background", meta->background); g_key_file_set_integer (key_file, filename, "smooth_image", meta->smooth_image); g_key_file_set_integer (key_file, filename, "zoom_level", meta->zoom_level); + g_key_file_set_integer (key_file, filename, "hadj", meta->hadj); + g_key_file_set_integer (key_file, filename, "vadj", meta->vadj); } void @@ -94,7 +96,9 @@ app_set_meta_data (App *app, int window_height, gboolean smooth_image, BackgroundType background, - int zoom_level) + int zoom_level, + int vadj, + int hadj) { GKeyFile *keyfile = g_key_file_new (); MetaData *data = g_hash_table_lookup (app->meta_data, filename); @@ -115,6 +119,8 @@ app_set_meta_data (App *app, data->background = background; data->smooth_image = smooth_image; data->zoom_level = zoom_level; + data->hadj = hadj; + data->vadj = vadj; g_hash_table_foreach (app->meta_data, foreach, keyfile); @@ -199,6 +205,12 @@ load_meta_data (void) if (!get_int (keyfile, group, "zoom_level", &(data->zoom_level))) data->zoom_level = 0; + + if (!get_int (keyfile, group, "vadj", &(data->vadj))) + data->vadj = 0; + + if (!get_int (keyfile, group, "hadj", &(data->hadj))) + data->hadj = 0; g_hash_table_insert (result, g_strdup (group), data); } @@ -30,6 +30,8 @@ struct MetaData BackgroundType background; gboolean smooth_image; int zoom_level; + int vadj; + int hadj; }; /* App */ @@ -47,7 +49,9 @@ void app_set_meta_data (App *data, int window_width, gboolean smooth_image, BackgroundType background, - int zoom_level); + int zoom_level, + int vadj, + int hadj); /* Window */ @@ -18,6 +18,9 @@ struct Window GtkAllocation allocation; App * app; + + int hadj; + int vadj; }; static void * @@ -209,6 +212,7 @@ save_meta_data (Window *window) { BackgroundType bg; gboolean smooth; + GtkAdjustment *hadj, *vadj; gtk_window_get_position (get_widget (window, "main_window"), &x, &y); gtk_window_get_size (get_widget (window, "main_window"), &width, &height); @@ -231,12 +235,16 @@ save_meta_data (Window *window) } smooth = gtk_check_menu_item_get_active (get_widget (window, "menu_smooth_image")); + + vadj = gtk_scrolled_window_get_vadjustment (get_widget (window, "scrolled_window")); + hadj = gtk_scrolled_window_get_hadjustment (get_widget (window, "scrolled_window")); app_set_meta_data (window->app, window->filename, x, y, width, height, bg, smooth, - window->zoom_level); + window->zoom_level, + vadj->value, hadj->value); } } @@ -542,6 +550,10 @@ window_load_file (Window *window, const char *filename, GError **err) data->smooth_image); window->zoom_level = data->zoom_level; + + /* Adjustments have to be set after the window is shown */ + window->hadj = data->hadj; + window->vadj = data->vadj; } else { @@ -549,6 +561,7 @@ window_load_file (Window *window, const char *filename, GError **err) } rebuild (window); + return TRUE; } } @@ -562,8 +575,7 @@ window_new (App *app) window->app = app; gtk_widget_add_events (get_widget (window, "drawing_area"), GDK_SCROLL_MASK); - gtk_widget_set_redraw_on_allocate ( - get_widget (window, "drawing_area"), FALSE); + gtk_widget_set_redraw_on_allocate (get_widget (window, "drawing_area"), FALSE); gtk_widget_realize (get_widget (window, "main_window")); @@ -606,7 +618,17 @@ window_free (Window *window) void window_show (Window *window) { + GtkAdjustment *vadj, *hadj; + gtk_widget_show (get_widget (window, "main_window")); gtk_window_set_focus (get_widget (window, "main_window"), NULL); + + /* We have to do this after the window is shown */ + + hadj = gtk_scrolled_window_get_hadjustment (get_widget (window, "scrolled_window")); + vadj = gtk_scrolled_window_get_vadjustment (get_widget (window, "scrolled_window")); + + gtk_adjustment_set_value (vadj, window->vadj); + gtk_adjustment_set_value (hadj, window->hadj); } |