eog r4350 - in trunk: . src
- From: csaavedra svn gnome org
- To: svn-commits-list gnome org
- Subject: eog r4350 - in trunk: . src
- Date: Mon, 11 Feb 2008 18:50:30 +0000 (GMT)
Author: csaavedra
Date: Mon Feb 11 18:50:30 2008
New Revision: 4350
URL: http://svn.gnome.org/viewvc/eog?rev=4350&view=rev
Log:
2008-02-11 Claudio Saavedra <csaavedra alumnos utalca cl>
* src/eog-jobs.c: (eog_job_thumbnail_dispose),
(eog_job_thumbnail_new), (eog_job_thumbnail_run):
* src/eog-jobs.h:
* src/eog-list-store.c: (eog_job_thumbnail_cb),
(eog_list_store_add_thumbnail_job):
* src/eog-thumbnail.c: (create_thumbnail_from_pixbuf),
(eog_thumbnail_load): Load thumbnail from EogImage instead of
GnomeVFSURI.
* src/eog-thumbnail.h:
* src/eog-window.c:
Use the pixbuf data in EogImage to create a thumbnail if this exists
and thumbnail under ~/.thumbnail is not valid/doesn't exist.
Improves performance and memory usage. Fixes bug #515250.
Modified:
trunk/ChangeLog
trunk/src/eog-jobs.c
trunk/src/eog-jobs.h
trunk/src/eog-list-store.c
trunk/src/eog-thumbnail.c
trunk/src/eog-thumbnail.h
trunk/src/eog-window.c
Modified: trunk/src/eog-jobs.c
==============================================================================
--- trunk/src/eog-jobs.c (original)
+++ trunk/src/eog-jobs.c Mon Feb 11 18:50:30 2008
@@ -152,9 +152,9 @@
job = EOG_JOB_THUMBNAIL (object);
- if (job->uri_entry) {
- gnome_vfs_uri_unref (job->uri_entry);
- job->uri_entry = NULL;
+ if (job->image) {
+ g_object_unref (job->image);
+ job->image = NULL;
}
if (job->thumbnail) {
@@ -176,15 +176,14 @@
}
EogJob *
-eog_job_thumbnail_new (GnomeVFSURI *uri_entry)
+eog_job_thumbnail_new (EogImage *image)
{
EogJobThumbnail *job;
job = g_object_new (EOG_TYPE_JOB_THUMBNAIL, NULL);
- if (uri_entry) {
- gnome_vfs_uri_ref (uri_entry);
- job->uri_entry = uri_entry;
+ if (image) {
+ job->image = g_object_ref (image);
}
return EOG_JOB (job);
@@ -202,7 +201,7 @@
EOG_JOB (job)->error = NULL;
}
- job->thumbnail = eog_thumbnail_load (job->uri_entry,
+ job->thumbnail = eog_thumbnail_load (job->image,
&EOG_JOB (job)->error);
if (!job->thumbnail) {
Modified: trunk/src/eog-jobs.h
==============================================================================
--- trunk/src/eog-jobs.h (original)
+++ trunk/src/eog-jobs.h Mon Feb 11 18:50:30 2008
@@ -125,7 +125,7 @@
struct _EogJobThumbnail
{
EogJob parent;
- GnomeVFSURI *uri_entry;
+ EogImage *image;
GdkPixbuf *thumbnail;
};
@@ -214,7 +214,7 @@
/* EogJobThumbnail */
GType eog_job_thumbnail_get_type (void) G_GNUC_CONST;
-EogJob *eog_job_thumbnail_new (GnomeVFSURI *uri_entry);
+EogJob *eog_job_thumbnail_new (EogImage *image);
void eog_job_thumbnail_run (EogJobThumbnail *thumbnail);
/* EogJobLoad */
Modified: trunk/src/eog-list-store.c
==============================================================================
--- trunk/src/eog-list-store.c (original)
+++ trunk/src/eog-list-store.c Mon Feb 11 18:50:30 2008
@@ -275,12 +275,15 @@
GtkTreeIter iter;
EogImage *image;
GdkPixbuf *thumbnail;
-
+ GnomeVFSURI *uri;
+
g_return_if_fail (EOG_IS_LIST_STORE (data));
store = EOG_LIST_STORE (data);
- if (is_file_in_list_store_uri (store, job->uri_entry, &iter)) {
+ uri = eog_image_get_uri (job->image);
+
+ if (is_file_in_list_store_uri (store, uri, &iter)) {
gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
EOG_LIST_STORE_EOG_IMAGE, &image,
-1);
@@ -303,6 +306,8 @@
g_object_unref (thumbnail);
}
+
+ gnome_vfs_uri_unref (uri);
}
static void
@@ -730,7 +735,6 @@
{
EogImage *image;
EogJob *job;
- GnomeVFSURI *uri;
gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
EOG_LIST_STORE_EOG_IMAGE, &image,
@@ -742,9 +746,7 @@
return;
}
- uri = eog_image_get_uri (image);
- job = eog_job_thumbnail_new (uri);
- gnome_vfs_uri_unref (uri);
+ job = eog_job_thumbnail_new (image);
g_signal_connect (job,
"finished",
Modified: trunk/src/eog-thumbnail.c
==============================================================================
--- trunk/src/eog-thumbnail.c (original)
+++ trunk/src/eog-thumbnail.c Mon Feb 11 18:50:30 2008
@@ -107,6 +107,30 @@
return thumb;
}
+static GdkPixbuf *
+create_thumbnail_from_pixbuf (EogThumbData *data,
+ GdkPixbuf *pixbuf,
+ GError **error)
+{
+ GdkPixbuf *thumb;
+ gint width, height;
+ gfloat perc;
+
+ g_assert (factory != NULL);
+
+ width = gdk_pixbuf_get_width (pixbuf);
+ height = gdk_pixbuf_get_height (pixbuf);
+
+ perc = CLAMP (128.0/(MAX (width, height)), 0, 1);
+
+ thumb = gnome_thumbnail_scale_down_pixbuf (pixbuf,
+ width*perc, height*perc);
+
+ gnome_thumbnail_factory_save_thumbnail (factory, thumb, data->uri_str, data->mtime);
+
+ return thumb;
+}
+
static GdkPixbuf*
create_thumbnail (EogThumbData *data, GError **error)
{
@@ -446,16 +470,20 @@
}
GdkPixbuf*
-eog_thumbnail_load (GnomeVFSURI *uri, GError **error)
+eog_thumbnail_load (EogImage *image, GError **error)
{
GdkPixbuf *thumb = NULL;
+ GnomeVFSURI *uri;
EogThumbData *data;
+ GdkPixbuf *pixbuf;
- g_return_val_if_fail (uri != NULL, NULL);
+ g_return_val_if_fail (image != NULL, NULL);
g_return_val_if_fail (error != NULL && *error == NULL, NULL);
-
- data = eog_thumb_data_new (uri, error);
+ uri = eog_image_get_uri (image);
+ data = eog_thumb_data_new (uri, error);
+ gnome_vfs_uri_unref (uri);
+
if (data == NULL)
return NULL;
@@ -463,7 +491,13 @@
thumb = get_valid_thumbnail (data, error);
if (*error == NULL && thumb == NULL) {
- thumb = create_thumbnail (data, error);
+ pixbuf = eog_image_get_pixbuf (image);
+ if (pixbuf != NULL) {
+ thumb = create_thumbnail_from_pixbuf (data, pixbuf, error);
+ g_object_unref (pixbuf);
+ } else {
+ thumb = create_thumbnail (data, error);
+ }
}
eog_thumb_data_free (data);
Modified: trunk/src/eog-thumbnail.h
==============================================================================
--- trunk/src/eog-thumbnail.h (original)
+++ trunk/src/eog-thumbnail.h Mon Feb 11 18:50:30 2008
@@ -27,6 +27,7 @@
#include <libgnomevfs/gnome-vfs.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
+#include "eog-image.h"
G_BEGIN_DECLS
@@ -37,7 +38,7 @@
void eog_thumbnail_add_frame (GdkPixbuf **thumbnail);
-GdkPixbuf* eog_thumbnail_load (GnomeVFSURI *uri,
+GdkPixbuf* eog_thumbnail_load (EogImage *image,
GError **error);
Modified: trunk/src/eog-window.c
==============================================================================
--- trunk/src/eog-window.c (original)
+++ trunk/src/eog-window.c Mon Feb 11 18:50:30 2008
@@ -49,7 +49,6 @@
#include "eog-job-queue.h"
#include "eog-jobs.h"
#include "eog-util.h"
-#include "eog-thumbnail.h"
#include "eog-print-image-setup.h"
#include "eog-save-as-dialog-helper.h"
#include "eog-plugin-engine.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]