[Xfce4-commits] <ristretto:master> Add image_quality as a property that can be configured (default to 2MP)
Stephan Arts
stephan at xfce.org
Wed Aug 12 12:18:24 CEST 2009
Updating branch refs/heads/master
to 8ad85cec725c16125ca2ca1ee38d3262a44b6421 (commit)
from cc07db14e094aead5cd174d641f44ef5ac2a911e (commit)
commit 8ad85cec725c16125ca2ca1ee38d3262a44b6421
Author: Stephan Arts <stephan at 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,};
+
+ 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);
@@ -763,8 +777,9 @@ 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, FALSE, NULL);
+ rstto_image_load (image, TRUE, g_value_get_uint (&max_size), NULL);
}
+ g_value_unset (&max_size);
}
diff --git a/src/picture_viewer.c b/src/picture_viewer.c
index ad5bd50..4a3fa34 100644
--- a/src/picture_viewer.c
+++ b/src/picture_viewer.c
@@ -1240,6 +1240,12 @@ rstto_picture_viewer_set_image (RsttoPictureViewer *viewer, RsttoImage *image)
gdouble *scale = NULL;
gboolean *fit_to_screen = 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 (viewer->priv->image)
{
g_signal_handlers_disconnect_by_func (viewer->priv->image, cb_rstto_picture_viewer_image_updated, viewer);
@@ -1269,7 +1275,8 @@ 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, FALSE, NULL);
+
+ rstto_image_load (viewer->priv->image, FALSE, g_value_get_uint (&max_size), NULL);
}
else
{
diff --git a/src/settings.c b/src/settings.c
index 865ba2a..e8e3370 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -58,6 +58,7 @@ enum
PROP_ENABLE_CACHE,
PROP_PRELOAD_IMAGES,
PROP_CACHE_SIZE,
+ PROP_IMAGE_QUALITY,
PROP_WINDOW_WIDTH,
PROP_WINDOW_HEIGHT,
PROP_BGCOLOR,
@@ -104,6 +105,7 @@ struct _RsttoSettingsPriv
gboolean preload_images;
gboolean enable_cache;
guint cache_size;
+ guint image_quality;
guint window_width;
guint window_height;
gchar *last_file_path;
@@ -136,6 +138,7 @@ rstto_settings_init (GObject *object)
settings->priv->slideshow_timeout = 5000;
settings->priv->bgcolor = g_new0 (GdkColor, 1);
+ settings->priv->image_quality = 2000;
xfconf_g_property_bind (settings->priv->channel, "/window/width", G_TYPE_UINT, settings, "window-width");
xfconf_g_property_bind (settings->priv->channel, "/window/height", G_TYPE_UINT, settings, "window-height");
@@ -155,6 +158,7 @@ rstto_settings_init (GObject *object)
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");
+ xfconf_g_property_bind (settings->priv->channel, "/image/quality", G_TYPE_UINT, settings, "image-quality");
}
@@ -243,6 +247,17 @@ rstto_settings_class_init (GObjectClass *object_class)
PROP_CACHE_SIZE,
pspec);
+ pspec = g_param_spec_uint ("image-quality",
+ "",
+ "",
+ 0,
+ G_MAXUINT,
+ 2000,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class,
+ PROP_IMAGE_QUALITY,
+ pspec);
+
pspec = g_param_spec_string ("current-uri",
"",
"",
@@ -396,6 +411,9 @@ rstto_settings_set_property (GObject *object,
case PROP_ENABLE_CACHE:
settings->priv->enable_cache = g_value_get_boolean (value);
break;
+ case PROP_IMAGE_QUALITY:
+ settings->priv->image_quality = g_value_get_uint (value);
+ break;
case PROP_CACHE_SIZE:
settings->priv->cache_size = g_value_get_uint (value);
break;
@@ -461,6 +479,9 @@ rstto_settings_get_property (GObject *object,
case PROP_ENABLE_CACHE:
g_value_set_boolean (value, settings->priv->enable_cache);
break;
+ case PROP_IMAGE_QUALITY:
+ g_value_set_uint (value, settings->priv->image_quality);
+ break;
case PROP_CACHE_SIZE:
g_value_set_uint (value, settings->priv->cache_size);
break;
More information about the Xfce4-commits
mailing list