[Xfce4-commits] <ristretto:master> Add 'enable-cache' option Add maximum-render-quality of 1MP (can be configured with later commits) Destroy open_folder dialog after use Update TODO

Stephan Arts stephan at xfce.org
Wed Aug 12 12:18:23 CEST 2009


Updating branch refs/heads/master
         to cc07db14e094aead5cd174d641f44ef5ac2a911e (commit)
       from 42db1caddceb8fbb5516b1e7e6790a9e92da2107 (commit)

commit cc07db14e094aead5cd174d641f44ef5ac2a911e
Author: Stephan Arts <stephan at xfce.org>
Date:   Mon Apr 27 21:30:09 2009 +0200

    Add 'enable-cache' option
    Add maximum-render-quality of 1MP (can be configured with later commits)
    Destroy open_folder dialog after use
    Update TODO

 TODO                     |    1 +
 configure.in.in          |    6 ++--
 src/image.c              |   69 ++++++++++++++++++++++++++++++++++++-
 src/image.h              |    5 ++-
 src/main_window.c        |    6 ++-
 src/picture_viewer.c     |   85 +++++++++++++++++++++++++++-------------------
 src/preferences_dialog.c |   56 +++++++++++++++++++++++++++++-
 src/settings.c           |   18 ++++++++++
 8 files changed, 202 insertions(+), 44 deletions(-)

diff --git a/TODO b/TODO
index 54cd5cd..63fd4c5 100644
--- a/TODO
+++ b/TODO
@@ -2,6 +2,7 @@
 
 - Implement preferences dialog
 - Add a file-properties dialog
+- Generate and save thumbnails
 
 - Support setting wallpapers
     - xfdesktop
diff --git a/configure.in.in b/configure.in.in
index 306f662..64493a2 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -58,10 +58,10 @@ XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.16.0])
 XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.16.0])
 XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.16.0])
 XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.34])
-XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0])
-XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.6.0])
+XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.6.0])
 
-XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.5.93])
+XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.6.0])
 
 dnl **************************
 dnl *** Check for xsltproc ***
diff --git a/src/image.c b/src/image.c
index 82d23fe..d84d421 100644
--- a/src/image.c
+++ b/src/image.c
@@ -54,6 +54,8 @@ rstto_image_dispose (GObject *object);
 static void
 cb_rstto_image_area_prepared (GdkPixbufLoader *loader, RsttoImage *image);
 static void
+cb_rstto_image_size_prepared (GdkPixbufLoader *loader, gint width, gint height, RsttoImage *image);
+static void
 cb_rstto_image_closed (GdkPixbufLoader *loader, RsttoImage *image);
 static gboolean
 cb_rstto_image_update(RsttoImage *image);
@@ -110,6 +112,9 @@ struct _RsttoImagePriv
     ExifData *exif_data;
     GdkPixbuf *thumbnail;
     GdkPixbuf *pixbuf;
+    gint       width;
+    gint       height;
+    gboolean full_size;
 
     GdkPixbufAnimation  *animation;
     GdkPixbufAnimationIter *iter;
@@ -373,12 +378,15 @@ cb_rstto_image_read_input_stream_ready (GObject *source_object, GAsyncResult *re
  * Return value: TRUE on success.
  */
 gboolean
-rstto_image_load (RsttoImage *image, gboolean empty_cache, GError **error)
+rstto_image_load (RsttoImage *image, gboolean empty_cache, gboolean full_size, GError **error)
 {
     g_return_val_if_fail (image != NULL, FALSE);
 
     RsttoImageCache *cache = rstto_image_cache_new ();
 
+    /* NEW */
+    image->priv->full_size = full_size;
+
     /* Check if a GIOChannel is present, if so... the load is already in progress */
     /* The image needs to be loaded if:
      *   a) The image is already loaded but there is
@@ -400,6 +408,7 @@ rstto_image_load (RsttoImage *image, gboolean empty_cache, GError **error)
 
         /* connect the signal-handlers */
         g_signal_connect(image->priv->loader, "area-prepared", G_CALLBACK(cb_rstto_image_area_prepared), image);
+        g_signal_connect(image->priv->loader, "size-prepared", G_CALLBACK(cb_rstto_image_size_prepared), image);
         /*g_signal_connect(image->priv->loader, "area-updated", G_CALLBACK(cb_rstto_image_area_updated), image);*/
         g_signal_connect(image->priv->loader, "closed", G_CALLBACK(cb_rstto_image_closed), image);
 
@@ -456,6 +465,36 @@ rstto_image_get_file (RsttoImage *image)
     return image->priv->file;
 }
 
+/**
+ * rstto_image_get_width:
+ * @image:
+ *
+ * Return value: width of the image
+ */
+gint
+rstto_image_get_width (RsttoImage *image)
+{
+    g_return_val_if_fail (image != NULL, NULL);
+    g_return_val_if_fail (image->priv != NULL, NULL);
+
+    return image->priv->width;
+}
+
+/**
+ * rstto_image_get_height:
+ * @image:
+ *
+ * Return value: height of the image
+ */
+gint
+rstto_image_get_height (RsttoImage *image)
+{
+    g_return_val_if_fail (image != NULL, NULL);
+    g_return_val_if_fail (image->priv != NULL, NULL);
+
+    return image->priv->height;
+}
+
 
 /**
  * rstto_image_get_thumbnail:
@@ -582,6 +621,33 @@ rstto_image_pop_transformation (RsttoImage *image, GError **error)
  */
 
 /**
+ * cb_rstto_image_size_prepared:
+ * @loader:
+ * @width;
+ * @height;
+ * @image:
+ *
+ */
+static void
+cb_rstto_image_size_prepared (GdkPixbufLoader *loader, gint width, gint height, RsttoImage *image)
+{
+    image->priv->width = width;
+    image->priv->height = height;
+
+    if (image->priv->full_size == FALSE)
+    {
+    	g_debug ("FULLSIZE == FALSE");
+        if (width > 1024)
+		width = 1024;
+        if (height > 1024)
+		height = 1024;
+    	gdk_pixbuf_loader_set_size (loader, width, height);
+    }
+    else
+    	g_debug ("FULLSIZE == TRUE");
+}
+
+/**
  * cb_rstto_image_area_prepared:
  * @loader:
  * @image:
@@ -590,6 +656,7 @@ rstto_image_pop_transformation (RsttoImage *image, GError **error)
 static void
 cb_rstto_image_area_prepared (GdkPixbufLoader *loader, RsttoImage *image)
 {
+
     image->priv->animation = gdk_pixbuf_loader_get_animation (loader);
     image->priv->iter = gdk_pixbuf_animation_get_iter (image->priv->animation, NULL);
     if (image->priv->pixbuf)
diff --git a/src/image.h b/src/image.h
index 089c6db..c4d8c6d 100644
--- a/src/image.h
+++ b/src/image.h
@@ -74,9 +74,12 @@ GType       rstto_image_get_type ();
 
 GdkPixbuf *rstto_image_get_thumbnail (RsttoImage *image);
 GdkPixbuf *rstto_image_get_pixbuf (RsttoImage *image);
+gint rstto_image_get_widht (RsttoImage *image);
+gint rstto_image_get_height (RsttoImage *image);
+
 GFile *rstto_image_get_file (RsttoImage *image);
 void rstto_image_unload (RsttoImage *image);
-gboolean rstto_image_load (RsttoImage *image, gboolean empty_cache, GError **error);
+gboolean rstto_image_load (RsttoImage *image, gboolean empty_cache, gboolean full_size, GError **error);
 
 gboolean
 rstto_image_push_transformation (RsttoImage *image, GObject *transformation, GError **error);
diff --git a/src/main_window.c b/src/main_window.c
index 4b78e7b..2f3ce05 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -739,7 +739,7 @@ cb_rstto_main_window_rotate_cw (GtkWidget *widget, RsttoMainWindow *window)
     {
         transform = rstto_image_transform_orientation_new ( FALSE, FALSE, GDK_PIXBUF_ROTATE_CLOCKWISE);
         rstto_image_push_transformation (image, G_OBJECT (transform), NULL);
-        rstto_image_load (image, TRUE, NULL);
+        rstto_image_load (image, TRUE, FALSE, NULL);
     }
 }
 
@@ -763,7 +763,7 @@ cb_rstto_main_window_rotate_ccw (GtkWidget *widget, RsttoMainWindow *window)
     {
         transform = rstto_image_transform_orientation_new ( FALSE, FALSE, GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE);
         rstto_image_push_transformation (image, G_OBJECT (transform), NULL);
-        rstto_image_load (image, TRUE, NULL);
+        rstto_image_load (image, TRUE, FALSE, NULL);
     }
 }
 
@@ -968,6 +968,8 @@ cb_rstto_main_window_open_folder (GtkWidget *widget, RsttoMainWindow *window)
         g_object_set_property (G_OBJECT(window->priv->settings_manager), "current-uri", &current_uri_val);
     }
 
+    gtk_widget_destroy(dialog);
+
     if (file)
     {
         g_object_unref (file);
diff --git a/src/picture_viewer.c b/src/picture_viewer.c
index b2c2bad..ad5bd50 100644
--- a/src/picture_viewer.c
+++ b/src/picture_viewer.c
@@ -642,14 +642,19 @@ rstto_picture_viewer_set_scale(RsttoPictureViewer *viewer, gdouble scale)
 
         if (src_pixbuf)
         {
-            gdouble width = (gdouble)gdk_pixbuf_get_width (src_pixbuf);
-            gdouble height = (gdouble)gdk_pixbuf_get_height (src_pixbuf);
+            gdouble image_width = (gdouble)rstto_image_get_width (viewer->priv->image);
+            gdouble image_height = (gdouble)rstto_image_get_height (viewer->priv->image);
 
+            gdouble pixbuf_width = (gdouble)gdk_pixbuf_get_width (src_pixbuf);
+            gdouble pixbuf_height = (gdouble)gdk_pixbuf_get_height (src_pixbuf);
 
-            viewer->hadjustment->upper = width * scale;
+            gdouble image_scale = pixbuf_width / image_width;
+
+
+            viewer->hadjustment->upper = image_width *scale;
             gtk_adjustment_changed(viewer->hadjustment);
 
-            viewer->vadjustment->upper = height * scale;
+            viewer->vadjustment->upper = image_height * scale;
             gtk_adjustment_changed(viewer->vadjustment);
 
             viewer->hadjustment->value = (((viewer->hadjustment->value +
@@ -715,14 +720,8 @@ rstto_picture_viewer_calculate_scale (RsttoPictureViewer *viewer)
 
     if (viewer->priv->image != NULL)
     {   
-        p_src_pixbuf = rstto_image_get_pixbuf (viewer->priv->image);
-        if (p_src_pixbuf)
-        {
-
-            width = gdk_pixbuf_get_width (p_src_pixbuf);
-            height = gdk_pixbuf_get_height (p_src_pixbuf);
-
-        }
+        width = rstto_image_get_width (viewer->priv->image);
+        height = rstto_image_get_height (viewer->priv->image);
     }
 
     if (width > 0 && height > 0)
@@ -855,23 +854,30 @@ rstto_picture_viewer_calculate_adjustments (RsttoPictureViewer *viewer, gdouble
 {
     GdkPixbuf *p_src_pixbuf;
     GtkWidget *widget = GTK_WIDGET (viewer);
-    gdouble width, height;
+    gdouble image_width, image_height;
+    gdouble pixbuf_width, pixbuf_height;
+    gdouble image_scale;
     gboolean vadjustment_changed = FALSE;
     gboolean hadjustment_changed = FALSE;
 
     if (viewer->priv->image != NULL)
     {   
         p_src_pixbuf = rstto_image_get_pixbuf (viewer->priv->image);
-        if (p_src_pixbuf)
+        if (p_src_pixbuf != NULL)
         {
-            width = (gdouble)gdk_pixbuf_get_width (p_src_pixbuf);
-            height = (gdouble)gdk_pixbuf_get_height (p_src_pixbuf);
+            image_width = (gdouble)rstto_image_get_width (viewer->priv->image);
+            image_height = (gdouble)rstto_image_get_height (viewer->priv->image);
+
+            pixbuf_width = (gdouble)gdk_pixbuf_get_width (p_src_pixbuf);
+            pixbuf_height = (gdouble)gdk_pixbuf_get_height (p_src_pixbuf);
+
+            image_scale = pixbuf_width / image_width;
 
 
             if(viewer->hadjustment)
             {
-                viewer->hadjustment->page_size = widget->allocation.width;
-                viewer->hadjustment->upper = width * scale;
+                viewer->hadjustment->page_size = widget->allocation.width / image_scale;
+                viewer->hadjustment->upper = image_width * (scale / image_scale);
                 viewer->hadjustment->lower = 0;
                 viewer->hadjustment->step_increment = 1;
                 viewer->hadjustment->page_increment = 100;
@@ -888,8 +894,8 @@ rstto_picture_viewer_calculate_adjustments (RsttoPictureViewer *viewer, gdouble
             }
             if(viewer->vadjustment)
             {
-                viewer->vadjustment->page_size = widget->allocation.height;
-                viewer->vadjustment->upper = height * scale;
+                viewer->vadjustment->page_size = widget->allocation.height / image_scale;
+                viewer->vadjustment->upper = image_height * (scale / image_scale);
                 viewer->vadjustment->lower = 0;
                 viewer->vadjustment->step_increment = 1;
                 viewer->vadjustment->page_increment = 100;
@@ -943,10 +949,12 @@ cb_rstto_picture_viewer_queued_repaint (RsttoPictureViewer *viewer)
     gdouble *p_scale = NULL;
     gboolean *p_fit_to_screen= NULL;
     gdouble scale;
+    gdouble image_scale = 1;
     gdouble thumb_scale = 1;
     gdouble thumb_width = 0;
     gboolean fit_to_screen = FALSE;
-    gdouble width, height;
+    gdouble image_width, image_height;
+    gdouble pixbuf_width, pixbuf_height;
     GtkWidget *widget = GTK_WIDGET (viewer);
 
     if (viewer->priv->image != NULL)
@@ -954,8 +962,13 @@ cb_rstto_picture_viewer_queued_repaint (RsttoPictureViewer *viewer)
         p_src_pixbuf = rstto_image_get_pixbuf (viewer->priv->image);
         if (p_src_pixbuf)
         {
-            width = (gdouble)gdk_pixbuf_get_width (p_src_pixbuf);
-            height = (gdouble)gdk_pixbuf_get_height (p_src_pixbuf);
+            image_width = (gdouble)rstto_image_get_width (viewer->priv->image);
+            image_height = (gdouble)rstto_image_get_height (viewer->priv->image);
+
+            pixbuf_width = (gdouble)gdk_pixbuf_get_width (p_src_pixbuf);
+            pixbuf_height = (gdouble)gdk_pixbuf_get_height (p_src_pixbuf);
+
+            image_scale = pixbuf_width / image_width;
             if (viewer->priv->state != RSTTO_PICTURE_VIEWER_STATE_NORMAL)
             {
                 switch (viewer->priv->state)
@@ -963,7 +976,7 @@ cb_rstto_picture_viewer_queued_repaint (RsttoPictureViewer *viewer)
                     case RSTTO_PICTURE_VIEWER_STATE_PREVIEW:
                         p_src_pixbuf = rstto_image_get_thumbnail (viewer->priv->image);
                         thumb_width = (gdouble)gdk_pixbuf_get_width (p_src_pixbuf);
-                        thumb_scale = (thumb_width / width);
+                        thumb_scale = (thumb_width / image_width);
                         break;
                     default:
                         break;
@@ -1001,21 +1014,23 @@ cb_rstto_picture_viewer_queued_repaint (RsttoPictureViewer *viewer)
              *  tmp_scale is the factor between the original image and the thumbnail,
              *  when looking at the actual image, tmp_scale == 1.0
              */
-            gdouble x = viewer->hadjustment->value;
-            gdouble y = viewer->vadjustment->value;
+            gdouble x = viewer->hadjustment->value * image_scale;
+            gdouble y = viewer->vadjustment->value * image_scale;
+
+            g_debug ("O %f:%d:%f", y, widget->allocation.height, image_height);
 
             p_tmp_pixbuf = gdk_pixbuf_new_subpixbuf (p_src_pixbuf,
-                                               (gint)(x/scale * thumb_scale), 
-                                               (gint)(y/scale * thumb_scale),
-                                               (gint)((widget->allocation.width / scale) < width?
-                                                      (widget->allocation.width / scale)*thumb_scale:width*thumb_scale),
-                                               (gint)((widget->allocation.height / scale) < height?
-                                                      (widget->allocation.height / scale)*thumb_scale:height*thumb_scale));
+                                               (gint)(x/scale * thumb_scale * image_scale), 
+                                               (gint)(y/scale * thumb_scale * image_scale),
+                                               (gint)((widget->allocation.width / scale) < image_width?
+                                                      (widget->allocation.width / scale)*thumb_scale*image_scale:image_width*thumb_scale*image_scale),
+                                               (gint)((widget->allocation.height / scale) < image_height?
+                                                      (widget->allocation.height / scale)*image_scale*thumb_scale:image_height*thumb_scale*image_scale));
 
             if(p_tmp_pixbuf)
             {
-                gint dst_width = gdk_pixbuf_get_width (p_tmp_pixbuf)*(scale/thumb_scale);
-                gint dst_height = gdk_pixbuf_get_height (p_tmp_pixbuf)*(scale/thumb_scale);
+                gint dst_width = gdk_pixbuf_get_width (p_tmp_pixbuf)*(scale/thumb_scale/image_scale);
+                gint dst_height = gdk_pixbuf_get_height (p_tmp_pixbuf)*(scale/thumb_scale/image_scale);
                 viewer->priv->dst_pixbuf = gdk_pixbuf_scale_simple (p_tmp_pixbuf,
                                         dst_width>0?dst_width:1,
                                         dst_height>0?dst_height:1,
@@ -1254,7 +1269,7 @@ rstto_picture_viewer_set_image (RsttoPictureViewer *viewer, RsttoImage *image)
             fit_to_screen = g_new0 (gboolean, 1);
             g_object_set_data (G_OBJECT (viewer->priv->image), "viewer-fit-to-screen", fit_to_screen);
         }
-        rstto_image_load (viewer->priv->image, FALSE, NULL);
+        rstto_image_load (viewer->priv->image, FALSE, FALSE, NULL);
     }
     else
     {
diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c
index 296108b..a8f9e74 100644
--- a/src/preferences_dialog.c
+++ b/src/preferences_dialog.c
@@ -43,6 +43,8 @@ cb_rstto_preferences_dialog_bgcolor_override_toggled (GtkToggleButton *, gpointe
 static void
 cb_rstto_preferences_dialog_bgcolor_color_set (GtkColorButton *, gpointer);
 static void
+cb_rstto_preferences_dialog_cache_check_button_toggled (GtkToggleButton *, gpointer);
+static void
 cb_rstto_preferences_dialog_cache_preload_check_button_toggled (GtkToggleButton *, gpointer);
 static void
 cb_rstto_preferences_dialog_cache_spin_button_value_changed (GtkSpinButton *, gpointer);
@@ -61,9 +63,12 @@ struct _RsttoPreferencesDialogPriv
 
         GtkWidget *cache_frame;
         GtkWidget *cache_vbox;
+        GtkWidget *cache_sub_vbox;
         GtkWidget *cache_hbox;
         GtkWidget *cache_size_label;
         GtkWidget *cache_size_unit;
+        GtkWidget *cache_check_button;
+	GtkWidget *cache_alignment;
         GtkWidget *cache_spin_button;
         GtkWidget *cache_preload_check_button;
 
@@ -169,7 +174,11 @@ rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
 
     dialog->priv->display_tab.cache_size_label = gtk_label_new (_("Cache size"));
     dialog->priv->display_tab.cache_size_unit = gtk_label_new (_("MB"));
-    dialog->priv->display_tab.cache_hbox = gtk_hbox_new(FALSE, 4);
+    dialog->priv->display_tab.cache_hbox = gtk_hbox_new (FALSE, 4);
+    dialog->priv->display_tab.cache_sub_vbox = gtk_vbox_new (FALSE, 4);
+    dialog->priv->display_tab.cache_check_button = gtk_check_button_new_with_label (_("Enable cache"));
+    dialog->priv->display_tab.cache_alignment = gtk_alignment_new (0, 0, 1, 1);
+    gtk_alignment_set_padding (GTK_ALIGNMENT (dialog->priv->display_tab.cache_alignment), 0, 0, 20, 0);
     dialog->priv->display_tab.cache_spin_button = gtk_spin_button_new(GTK_ADJUSTMENT(cache_adjustment), 1.0, 0);
     dialog->priv->display_tab.cache_preload_check_button = gtk_check_button_new_with_label (_("Preload images"));
 
@@ -181,12 +190,26 @@ rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
                                  dialog->priv->display_tab.cache_size_unit, FALSE, FALSE, 0);
 
     gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.cache_vbox), 
-                                 dialog->priv->display_tab.cache_hbox, FALSE, FALSE, 0);
+                                 dialog->priv->display_tab.cache_check_button, FALSE, FALSE, 0);
     gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.cache_vbox), 
+                                 dialog->priv->display_tab.cache_alignment, FALSE, FALSE, 0);
+    gtk_container_add (GTK_CONTAINER (dialog->priv->display_tab.cache_alignment),
+                                      dialog->priv->display_tab.cache_sub_vbox);
+    gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.cache_sub_vbox), 
                                  dialog->priv->display_tab.cache_preload_check_button, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.cache_sub_vbox), 
+                                 dialog->priv->display_tab.cache_hbox, FALSE, FALSE, 0);
     
     /* set current value */
     g_value_init (&value, G_TYPE_BOOLEAN);
+    g_object_get_property (G_OBJECT(settings_manager), "enable-cache", &value);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->display_tab.cache_check_button),
+                                  g_value_get_boolean (&value));
+    gtk_widget_set_sensitive (GTK_WIDGET (dialog->priv->display_tab.cache_sub_vbox),
+                              g_value_get_boolean (&value));
+    g_value_unset (&value);
+
+    g_value_init (&value, G_TYPE_BOOLEAN);
     g_object_get_property (G_OBJECT(settings_manager), "preload-images", &value);
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->display_tab.cache_preload_check_button),
                                   g_value_get_boolean (&value));
@@ -205,6 +228,8 @@ rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
     g_value_unset (&value);
 
     /* connect signals */
+    g_signal_connect (G_OBJECT (dialog->priv->display_tab.cache_check_button), 
+                      "toggled", (GCallback)cb_rstto_preferences_dialog_cache_check_button_toggled, dialog);
     g_signal_connect (G_OBJECT (dialog->priv->display_tab.cache_preload_check_button), 
                       "toggled", (GCallback)cb_rstto_preferences_dialog_cache_preload_check_button_toggled, dialog);
     g_signal_connect (G_OBJECT (dialog->priv->display_tab.cache_spin_button), 
@@ -355,6 +380,33 @@ cb_rstto_preferences_dialog_bgcolor_color_set (GtkColorButton *button, gpointer
 }
 
 static void
+cb_rstto_preferences_dialog_cache_check_button_toggled (GtkToggleButton *button, 
+                                                        gpointer user_data)
+{
+    RsttoPreferencesDialog *dialog = GTK_WIDGET (user_data);
+    RsttoSettings *settings = rstto_settings_new();
+
+    GValue value = {0, };
+    g_value_init (&value, G_TYPE_BOOLEAN);
+
+    if (gtk_toggle_button_get_active (button))
+    {
+        g_value_set_boolean (&value, TRUE);
+    	gtk_widget_set_sensitive (GTK_WIDGET (dialog->priv->display_tab.cache_sub_vbox), TRUE);
+    }
+    else
+    {
+        g_value_set_boolean (&value, FALSE);
+    	gtk_widget_set_sensitive (GTK_WIDGET (dialog->priv->display_tab.cache_sub_vbox), FALSE);
+    }
+    
+    g_object_set_property (G_OBJECT (settings), "enable-cache", &value);
+
+    g_value_unset (&value);
+
+}
+
+static void
 cb_rstto_preferences_dialog_cache_preload_check_button_toggled (GtkToggleButton *button, 
                                                                 gpointer user_data)
 {
diff --git a/src/settings.c b/src/settings.c
index 076fa4e..865ba2a 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -55,6 +55,7 @@ enum
     PROP_0,
     PROP_SHOW_TOOLBAR,
     PROP_TOOLBAR_OPEN_FOLDER,
+    PROP_ENABLE_CACHE,
     PROP_PRELOAD_IMAGES,
     PROP_CACHE_SIZE,
     PROP_WINDOW_WIDTH,
@@ -101,6 +102,7 @@ struct _RsttoSettingsPriv
     gboolean  show_toolbar;
     gboolean  toolbar_open_folder;
     gboolean  preload_images;
+    gboolean  enable_cache;
     guint     cache_size;
     guint     window_width;
     guint     window_height;
@@ -151,6 +153,7 @@ rstto_settings_init (GObject *object)
     xfconf_g_property_bind_gdkcolor (settings->priv->channel, "/window/bgcolor", settings, "bgcolor");
     xfconf_g_property_bind (settings->priv->channel, "/window/bgcolor-override", G_TYPE_BOOLEAN, settings, "bgcolor-override");
     xfconf_g_property_bind (settings->priv->channel, "/image/preload", G_TYPE_BOOLEAN, settings, "preload-images");
+    xfconf_g_property_bind (settings->priv->channel, "/image/cache", G_TYPE_BOOLEAN, settings, "enable-cache");
     xfconf_g_property_bind (settings->priv->channel, "/image/cache-size", G_TYPE_UINT, settings, "cache-size");
 }
 
@@ -220,6 +223,15 @@ rstto_settings_class_init (GObjectClass *object_class)
                                      PROP_PRELOAD_IMAGES,
                                      pspec);
 
+    pspec = g_param_spec_boolean ("enable-cache",
+                                  "",
+                                  "",
+                                  TRUE,
+                                  G_PARAM_READWRITE);
+    g_object_class_install_property (object_class,
+                                     PROP_ENABLE_CACHE,
+                                     pspec);
+
     pspec = g_param_spec_uint    ("cache-size",
                                   "",
                                   "",
@@ -381,6 +393,9 @@ rstto_settings_set_property    (GObject      *object,
         case PROP_PRELOAD_IMAGES:
             settings->priv->preload_images = g_value_get_boolean (value);
             break;
+        case PROP_ENABLE_CACHE:
+            settings->priv->enable_cache = g_value_get_boolean (value);
+            break;
         case PROP_CACHE_SIZE:
             settings->priv->cache_size = g_value_get_uint (value);
             break;
@@ -443,6 +458,9 @@ rstto_settings_get_property    (GObject    *object,
         case PROP_PRELOAD_IMAGES:
             g_value_set_boolean (value, settings->priv->preload_images);
             break;
+        case PROP_ENABLE_CACHE:
+            g_value_set_boolean (value, settings->priv->enable_cache);
+            break;
         case PROP_CACHE_SIZE:
             g_value_set_uint (value, settings->priv->cache_size);
             break;



More information about the Xfce4-commits mailing list