[Xfce4-commits] ristretto:ristretto-0.0 Add image_quality as a property that can be configured (default to 2MP)

2011-10-23 Thread Stephan Arts
Updating branch refs/heads/ristretto-0.0
 to 8ad85cec725c16125ca2ca1ee38d3262a44b6421 (commit)
   from cc07db14e094aead5cd174d641f44ef5ac2a911e (commit)

commit 8ad85cec725c16125ca2ca1ee38d3262a44b6421
Author: Stephan Arts step...@xfce.org
Date:   Mon Apr 27 23:30:18 2009 +0200

Add image_quality as a property that can be configured (default to 2MP)

 src/image.c  |   24 +++-
 src/image.h  |2 +-
 src/main_window.c|   19 +--
 src/picture_viewer.c |9 -
 src/settings.c   |   21 +
 5 files changed, 58 insertions(+), 17 deletions(-)

diff --git a/src/image.c b/src/image.c
index d84d421..0b831e0 100644
--- a/src/image.c
+++ b/src/image.c
@@ -114,7 +114,7 @@ struct _RsttoImagePriv
 GdkPixbuf *pixbuf;
 gint   width;
 gint   height;
-gboolean full_size;
+guint  max_size;
 
 GdkPixbufAnimation  *animation;
 GdkPixbufAnimationIter *iter;
@@ -378,14 +378,14 @@ 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, gboolean full_size, 
GError **error)
+rstto_image_load (RsttoImage *image, gboolean empty_cache, guint max_size, 
GError **error)
 {
 g_return_val_if_fail (image != NULL, FALSE);
 
 RsttoImageCache *cache = rstto_image_cache_new ();
 
 /* NEW */
-image-priv-full_size = full_size;
+image-priv-max_size = max_size;
 
 /* Check if a GIOChannel is present, if so... the load is already in 
progress */
 /* The image needs to be loaded if:
@@ -474,8 +474,8 @@ rstto_image_get_file (RsttoImage *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);
+g_return_val_if_fail (image != NULL, 0);
+g_return_val_if_fail (image-priv != NULL, 0);
 
 return image-priv-width;
 }
@@ -489,8 +489,8 @@ rstto_image_get_width (RsttoImage *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);
+g_return_val_if_fail (image != NULL, 0);
+g_return_val_if_fail (image-priv != NULL, 0);
 
 return image-priv-height;
 }
@@ -634,14 +634,12 @@ cb_rstto_image_size_prepared (GdkPixbufLoader *loader, 
gint width, gint height,
 image-priv-width = width;
 image-priv-height = height;
 
-if (image-priv-full_size == FALSE)
+if (image-priv-max_size  0)
 {
g_debug (FULLSIZE == FALSE);
-if (width  1024)
-   width = 1024;
-if (height  1024)
-   height = 1024;
-   gdk_pixbuf_loader_set_size (loader, width, height);
+gdouble ratio = (gdouble)(image-priv-max_size*1000)/(gdouble)(width 
* height);
+
+   gdk_pixbuf_loader_set_size (loader, width*ratio, height*ratio);
 }
 else
g_debug (FULLSIZE == TRUE);
diff --git a/src/image.h b/src/image.h
index c4d8c6d..af30567 100644
--- a/src/image.h
+++ b/src/image.h
@@ -79,7 +79,7 @@ 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, gboolean 
full_size, GError **error);
+gboolean rstto_image_load (RsttoImage *image, gboolean empty_cache, guint 
max_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 2f3ce05..1c159cb 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -732,6 +732,12 @@ cb_rstto_main_window_rotate_cw (GtkWidget *widget, 
RsttoMainWindow *window)
 RsttoImageTransformation *transform;
 RsttoImage *image = NULL;
 
+RsttoSettings *settings_manager = rstto_settings_new();
+GValue max_size = {0,};
+
+g_value_init (max_size, G_TYPE_UINT);
+g_object_get_property (G_OBJECT(settings_manager), image-quality, 
max_size);
+
 if (window-priv-iter)
 image = rstto_navigator_iter_get_image (window-priv-iter);
 
@@ -739,8 +745,10 @@ 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, FALSE, NULL);
+rstto_image_load (image, TRUE, g_value_get_uint (max_size), NULL);
 }
+
+g_value_unset (max_size);
 }
 
 /**
@@ -756,6 +764,12 @@ cb_rstto_main_window_rotate_ccw (GtkWidget *widget, 
RsttoMainWindow *window)
 RsttoImageTransformation *transform;
 RsttoImage *image = NULL;
 
+RsttoSettings *settings_manager = rstto_settings_new();
+GValue max_size = {0,};
+
+

[Xfce4-commits] ristretto:ristretto-0.0 Add image_quality as a property that can be configured (default to 2MP)

2011-10-23 Thread Stephan Arts
Updating branch refs/heads/ristretto-0.0
 to 8ad85cec725c16125ca2ca1ee38d3262a44b6421 (commit)
   from cc07db14e094aead5cd174d641f44ef5ac2a911e (commit)

commit 8ad85cec725c16125ca2ca1ee38d3262a44b6421
Author: Stephan Arts step...@xfce.org
Date:   Mon Apr 27 23:30:18 2009 +0200

Add image_quality as a property that can be configured (default to 2MP)

 src/image.c  |   24 +++-
 src/image.h  |2 +-
 src/main_window.c|   19 +--
 src/picture_viewer.c |9 -
 src/settings.c   |   21 +
 5 files changed, 58 insertions(+), 17 deletions(-)

diff --git a/src/image.c b/src/image.c
index d84d421..0b831e0 100644
--- a/src/image.c
+++ b/src/image.c
@@ -114,7 +114,7 @@ struct _RsttoImagePriv
 GdkPixbuf *pixbuf;
 gint   width;
 gint   height;
-gboolean full_size;
+guint  max_size;
 
 GdkPixbufAnimation  *animation;
 GdkPixbufAnimationIter *iter;
@@ -378,14 +378,14 @@ 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, gboolean full_size, 
GError **error)
+rstto_image_load (RsttoImage *image, gboolean empty_cache, guint max_size, 
GError **error)
 {
 g_return_val_if_fail (image != NULL, FALSE);
 
 RsttoImageCache *cache = rstto_image_cache_new ();
 
 /* NEW */
-image-priv-full_size = full_size;
+image-priv-max_size = max_size;
 
 /* Check if a GIOChannel is present, if so... the load is already in 
progress */
 /* The image needs to be loaded if:
@@ -474,8 +474,8 @@ rstto_image_get_file (RsttoImage *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);
+g_return_val_if_fail (image != NULL, 0);
+g_return_val_if_fail (image-priv != NULL, 0);
 
 return image-priv-width;
 }
@@ -489,8 +489,8 @@ rstto_image_get_width (RsttoImage *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);
+g_return_val_if_fail (image != NULL, 0);
+g_return_val_if_fail (image-priv != NULL, 0);
 
 return image-priv-height;
 }
@@ -634,14 +634,12 @@ cb_rstto_image_size_prepared (GdkPixbufLoader *loader, 
gint width, gint height,
 image-priv-width = width;
 image-priv-height = height;
 
-if (image-priv-full_size == FALSE)
+if (image-priv-max_size  0)
 {
g_debug (FULLSIZE == FALSE);
-if (width  1024)
-   width = 1024;
-if (height  1024)
-   height = 1024;
-   gdk_pixbuf_loader_set_size (loader, width, height);
+gdouble ratio = (gdouble)(image-priv-max_size*1000)/(gdouble)(width 
* height);
+
+   gdk_pixbuf_loader_set_size (loader, width*ratio, height*ratio);
 }
 else
g_debug (FULLSIZE == TRUE);
diff --git a/src/image.h b/src/image.h
index c4d8c6d..af30567 100644
--- a/src/image.h
+++ b/src/image.h
@@ -79,7 +79,7 @@ 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, gboolean 
full_size, GError **error);
+gboolean rstto_image_load (RsttoImage *image, gboolean empty_cache, guint 
max_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 2f3ce05..1c159cb 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -732,6 +732,12 @@ cb_rstto_main_window_rotate_cw (GtkWidget *widget, 
RsttoMainWindow *window)
 RsttoImageTransformation *transform;
 RsttoImage *image = NULL;
 
+RsttoSettings *settings_manager = rstto_settings_new();
+GValue max_size = {0,};
+
+g_value_init (max_size, G_TYPE_UINT);
+g_object_get_property (G_OBJECT(settings_manager), image-quality, 
max_size);
+
 if (window-priv-iter)
 image = rstto_navigator_iter_get_image (window-priv-iter);
 
@@ -739,8 +745,10 @@ 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, FALSE, NULL);
+rstto_image_load (image, TRUE, g_value_get_uint (max_size), NULL);
 }
+
+g_value_unset (max_size);
 }
 
 /**
@@ -756,6 +764,12 @@ cb_rstto_main_window_rotate_ccw (GtkWidget *widget, 
RsttoMainWindow *window)
 RsttoImageTransformation *transform;
 RsttoImage *image = NULL;
 
+RsttoSettings *settings_manager = rstto_settings_new();
+GValue max_size = {0,};
+
+