From e004251447181ac717162ab7bd2aa97ae2cf91f4 Mon Sep 17 00:00:00 2001 From: Olivier Duchateau Date: Sun, 5 May 2019 18:29:19 +0200 Subject: [PATCH] Persist zoom level in images list --- src/main_window.c | 11 ++++++++++- src/settings.c | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/main_window.c b/src/main_window.c index 745792c..f12b616 100644 --- a/src/main_window.c +++ b/src/main_window.c @@ -1366,6 +1366,7 @@ rstto_main_window_image_list_iter_changed (RsttoMainWindow *window) GDesktopAppInfo *app_info = NULL; const GdkPixbuf *pixbuf = NULL; GdkPixbuf *tmp; + gdouble scale; GtkWidget *open_with_menu = gtk_menu_new(); GtkWidget *open_with_window_menu = gtk_menu_new(); @@ -1383,10 +1384,18 @@ rstto_main_window_image_list_iter_changed (RsttoMainWindow *window) rstto_icon_bar_show_active (RSTTO_ICON_BAR (window->priv->thumbnailbar)); content_type = rstto_file_get_content_type (cur_file); + if (rstto_settings_get_boolean_property (RSTTO_SETTINGS (window->priv->settings_manager), "keep-zoom")) + { + scale = rstto_image_viewer_get_scale (RSTTO_IMAGE_VIEWER (window->priv->image_viewer)); + } + else + { + scale = -1.0; + } rstto_image_viewer_set_file ( RSTTO_IMAGE_VIEWER(window->priv->image_viewer), cur_file, - -1.0, + scale, 0); pixbuf = rstto_file_get_thumbnail (cur_file, THUMBNAIL_SIZE_SMALL); diff --git a/src/settings.c b/src/settings.c index 118fd79..82a644c 100644 --- a/src/settings.c +++ b/src/settings.c @@ -77,6 +77,7 @@ enum PROP_ERROR_MISSING_THUMBNAILER, PROP_SORT_TYPE, PROP_THUMBNAIL_SIZE, + PROP_KEEP_ZOOM, }; GType @@ -128,6 +129,7 @@ struct _RsttoSettingsPriv gchar *desktop_type; gboolean use_thunar_properties; gboolean maximize_on_startup; + gboolean keep_zoom; RsttoThumbnailSize thumbnail_size; RsttoSortType sort_type; @@ -188,6 +190,7 @@ rstto_settings_init (GObject *object) settings->priv->hide_thumbnails_fullscreen = TRUE; settings->priv->errors.missing_thumbnailer = TRUE; settings->priv->thumbnail_size = THUMBNAIL_SIZE_NORMAL; + settings->priv->keep_zoom = FALSE; xfconf_g_property_bind ( settings->priv->channel, @@ -339,6 +342,13 @@ rstto_settings_init (GObject *object) settings, "desktop-type"); + xfconf_g_property_bind ( + settings->priv->channel, + "/image/keep-zoom", + G_TYPE_BOOLEAN, + settings, + "keep-zoom"); + } @@ -608,6 +618,17 @@ rstto_settings_class_init (GObjectClass *object_class) object_class, PROP_THUMBNAIL_SIZE, pspec); + + pspec = g_param_spec_boolean ( + "keep-zoom", + "", + "", + FALSE, + G_PARAM_READWRITE); + g_object_class_install_property ( + object_class, + PROP_KEEP_ZOOM, + pspec); } /** @@ -807,6 +828,9 @@ rstto_settings_set_property (GObject *object, case PROP_THUMBNAIL_SIZE: settings->priv->thumbnail_size = g_value_get_uint (value); break; + case PROP_KEEP_ZOOM: + settings->priv->keep_zoom = g_value_get_boolean (value); + break; default: break; } @@ -895,6 +919,9 @@ rstto_settings_get_property (GObject *object, value, settings->priv->thumbnail_size); break; + case PROP_KEEP_ZOOM: + g_value_set_boolean (value, settings->priv->keep_zoom); + break; default: break; -- 2.20.1