2001-02-15 15:57:45 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
2001-03-06 16:59:40 +00:00
|
|
|
#include <bonobo/Bonobo.h>
|
2001-04-23 09:57:40 +00:00
|
|
|
#include <bonobo/bonobo-moniker-util.h>
|
Added gnome-vfs flags.
2001-06-01 Jens Finke <jens@gnome.org>
* Makefile.am (INCLUDES), (eog_collection_LDADD): Added gnome-vfs
flags.
* cimage.[ch] (cimage_new): Create GnomeVFSURI from text uri and
use cimage_new_uri.
(cimage_new_uri): New function, creates an cimage from
GnomeVFSURI.
(cimage_get_uri): Return GnomeVFSURI object.
(cimage_is_directory): Use GnomeVFS functions to determine file
type.
* eog-collection-model.c (loading_context_free): New helper
function.
(directory_visit_cb): New function, opens a single file contained
in a directory.
(real_storage_loading): Renamed to real_dir_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(directory_filter_cb): New function, determines what kind of files
we can handle within a directory.
(real_stream_loading): Renamed to real_file_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(eog_collection_model_set_uri),
(eog_collection_model_set_uri_list),
(prepare_context): Use GnomeVFS functions, removed all the
BonoboStorage/Stream stuff.
* eog-collection-view.c (eog_collection_view_get_prop): Adapted to
cimage changes.
* eog-image-loader.c (load_uri): Use GnomeVFS functions, removed
all the BonoboStorage/Stream stuff.
* eog-item-factory-simple.c (ii_factory_update_item): Adapted to
cimage changes.
* main.c (init_server_factory): Call gnome-vfs-init.
2001-06-01 09:19:40 +00:00
|
|
|
#include <libgnomevfs/gnome-vfs-types.h>
|
|
|
|
#include <libgnomevfs/gnome-vfs-uri.h>
|
|
|
|
#include <libgnomevfs/gnome-vfs-ops.h>
|
2001-02-15 15:57:45 +00:00
|
|
|
|
|
|
|
#include "eog-image-loader.h"
|
|
|
|
#include "cimage.h"
|
|
|
|
#include <gdk-pixbuf/gdk-pixbuf-loader.h>
|
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
typedef struct {
|
|
|
|
EogImageLoader *loader;
|
|
|
|
CImage *cimg;
|
|
|
|
GdkPixbufLoader *pbf_loader;
|
|
|
|
} EILContext;
|
|
|
|
|
2001-03-06 16:59:40 +00:00
|
|
|
enum {
|
|
|
|
LOADING_FINISHED,
|
|
|
|
LOADING_CANCELED,
|
|
|
|
LOADING_FAILED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint eog_image_loader_signals [LAST_SIGNAL];
|
|
|
|
|
2001-02-15 15:57:45 +00:00
|
|
|
struct _EogImageLoaderPrivate {
|
|
|
|
gint thumb_width;
|
|
|
|
gint thumb_height;
|
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
GList *queue;
|
|
|
|
gint idle_handler_id;
|
|
|
|
|
2001-02-15 15:57:45 +00:00
|
|
|
gboolean active;
|
2001-04-23 09:57:40 +00:00
|
|
|
gboolean cancel_loading;
|
2001-02-15 15:57:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GtkObjectClass *parent_class;
|
|
|
|
|
|
|
|
static void eog_image_loader_class_init (EogImageLoaderClass *klass);
|
|
|
|
static void eog_image_loader_init (EogImageLoader *loader);
|
|
|
|
static void eog_image_loader_destroy (GtkObject *obj);
|
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
static gint setup_next_uri (EogImageLoader *loader);
|
|
|
|
|
2001-02-15 15:57:45 +00:00
|
|
|
GtkType
|
|
|
|
eog_image_loader_get_type (void)
|
|
|
|
{
|
|
|
|
static GtkType type = 0;
|
|
|
|
|
|
|
|
if (!type) {
|
|
|
|
GtkTypeInfo info = {
|
|
|
|
"EogImageLoader",
|
|
|
|
sizeof (EogImageLoader),
|
|
|
|
sizeof (EogImageLoaderClass),
|
|
|
|
(GtkClassInitFunc) eog_image_loader_class_init,
|
|
|
|
(GtkObjectInitFunc) eog_image_loader_init,
|
|
|
|
NULL, /* reserved 1 */
|
|
|
|
NULL, /* reserved 2 */
|
|
|
|
(GtkClassInitFunc) NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
type = gtk_type_unique (
|
|
|
|
gtk_object_get_type (), &info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eog_image_loader_class_init (EogImageLoaderClass *klass)
|
|
|
|
{
|
|
|
|
GtkObjectClass *obj_class = (GtkObjectClass*) klass;
|
|
|
|
|
|
|
|
parent_class = gtk_type_class (gtk_object_get_type ());
|
|
|
|
|
2001-03-06 16:59:40 +00:00
|
|
|
eog_image_loader_signals [LOADING_FINISHED] =
|
|
|
|
gtk_signal_new ("loading_finished",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
obj_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (EogImageLoaderClass, loading_finished),
|
|
|
|
gtk_marshal_NONE__POINTER,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
TYPE_CIMAGE);
|
|
|
|
eog_image_loader_signals [LOADING_CANCELED] =
|
|
|
|
gtk_signal_new ("loading_canceled",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
obj_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (EogImageLoaderClass, loading_canceled),
|
|
|
|
gtk_marshal_NONE__POINTER,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
TYPE_CIMAGE);
|
|
|
|
eog_image_loader_signals [LOADING_FAILED] =
|
|
|
|
gtk_signal_new ("loading_failed",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
obj_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (EogImageLoaderClass, loading_failed),
|
|
|
|
gtk_marshal_NONE__POINTER,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
TYPE_CIMAGE);
|
|
|
|
|
|
|
|
gtk_object_class_add_signals (obj_class, eog_image_loader_signals, LAST_SIGNAL);
|
|
|
|
|
2001-02-15 15:57:45 +00:00
|
|
|
obj_class->destroy = eog_image_loader_destroy;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eog_image_loader_init (EogImageLoader *loader)
|
|
|
|
{
|
|
|
|
EogImageLoaderPrivate *priv;
|
|
|
|
|
|
|
|
priv = g_new0 (EogImageLoaderPrivate, 1);
|
2001-04-23 09:57:40 +00:00
|
|
|
priv->queue = NULL;
|
|
|
|
priv->idle_handler_id = -1;
|
|
|
|
priv->cancel_loading = FALSE;
|
2001-02-15 15:57:45 +00:00
|
|
|
|
|
|
|
loader->priv = priv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eog_image_loader_destroy (GtkObject *obj)
|
|
|
|
{
|
|
|
|
EogImageLoader *loader;
|
|
|
|
|
|
|
|
g_return_if_fail (obj != NULL);
|
2001-03-06 16:59:40 +00:00
|
|
|
g_return_if_fail (EOG_IS_IMAGE_LOADER (obj));
|
2001-02-15 15:57:45 +00:00
|
|
|
|
|
|
|
loader = EOG_IMAGE_LOADER (obj);
|
|
|
|
|
|
|
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EogImageLoader*
|
|
|
|
eog_image_loader_new (gint thumb_width, gint thumb_height)
|
|
|
|
{
|
|
|
|
EogImageLoader *loader;
|
|
|
|
|
|
|
|
loader = gtk_type_new (eog_image_loader_get_type ());
|
|
|
|
loader->priv->thumb_width = thumb_width;
|
|
|
|
loader->priv->thumb_height = thumb_height;
|
|
|
|
|
|
|
|
return loader;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Scales a width/height pair to fit in a specific size */
|
|
|
|
static void
|
|
|
|
scale_to_fit (int src_w, int src_h, int fit_w, int fit_h, int *dest_w, int *dest_h)
|
|
|
|
{
|
|
|
|
*dest_w = fit_w;
|
|
|
|
*dest_h = (src_h * *dest_w) / src_w;
|
|
|
|
|
|
|
|
if (*dest_h > fit_h) {
|
|
|
|
*dest_h = fit_h;
|
|
|
|
*dest_w = (src_w * *dest_h) / src_h;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert (*dest_w <= fit_w);
|
|
|
|
g_assert (*dest_h <= fit_h);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkPixbuf*
|
|
|
|
scale_image (EogImageLoader *loader, GdkPixbuf *image)
|
|
|
|
{
|
|
|
|
EogImageLoaderPrivate *priv;
|
|
|
|
GdkPixbuf *thumb;
|
|
|
|
gint pixbuf_w, pixbuf_h;
|
|
|
|
gint thumb_w, thumb_h;
|
|
|
|
|
|
|
|
priv = loader->priv;
|
|
|
|
|
|
|
|
if (image) {
|
|
|
|
pixbuf_w = gdk_pixbuf_get_width (image);
|
|
|
|
pixbuf_h = gdk_pixbuf_get_height (image);
|
|
|
|
} else
|
|
|
|
pixbuf_w = pixbuf_h = 0;
|
|
|
|
|
|
|
|
if (pixbuf_w > priv->thumb_width || pixbuf_h > priv->thumb_height) {
|
|
|
|
scale_to_fit (pixbuf_w, pixbuf_h,
|
|
|
|
priv->thumb_width, priv->thumb_height,
|
|
|
|
&thumb_w, &thumb_h);
|
|
|
|
thumb = gdk_pixbuf_scale_simple (image,
|
|
|
|
thumb_w,
|
|
|
|
thumb_h,
|
|
|
|
GDK_INTERP_NEAREST);
|
|
|
|
} else {
|
|
|
|
thumb_w = pixbuf_w;
|
|
|
|
thumb_h = pixbuf_h;
|
|
|
|
thumb = image;
|
|
|
|
gdk_pixbuf_ref (thumb);
|
|
|
|
}
|
|
|
|
|
|
|
|
return thumb;
|
|
|
|
}
|
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
static void
|
|
|
|
loading_canceled (EILContext *ctx)
|
|
|
|
{
|
|
|
|
EogImageLoader *loader;
|
|
|
|
|
|
|
|
g_return_if_fail (ctx != NULL);
|
|
|
|
g_return_if_fail (ctx->loader != NULL);
|
|
|
|
|
|
|
|
loader = ctx->loader;
|
|
|
|
|
2001-05-21 21:48:14 +00:00
|
|
|
#ifdef COLLECTION_DEBUG
|
2001-04-23 09:57:40 +00:00
|
|
|
g_message ("Loading canceled\n");
|
2001-05-21 21:48:14 +00:00
|
|
|
#endif
|
2001-04-23 09:57:40 +00:00
|
|
|
gtk_signal_emit (GTK_OBJECT (ctx->loader),
|
|
|
|
eog_image_loader_signals [LOADING_CANCELED],
|
|
|
|
ctx->cimg);
|
|
|
|
if (ctx->pbf_loader)
|
|
|
|
gdk_pixbuf_loader_close (ctx->pbf_loader);
|
|
|
|
g_free (ctx);
|
|
|
|
|
|
|
|
loader->priv->cancel_loading = FALSE;
|
|
|
|
g_list_free (loader->priv->queue);
|
|
|
|
loader->priv->queue = NULL;
|
|
|
|
loader->priv->active = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
loading_finished (EILContext *ctx)
|
|
|
|
{
|
|
|
|
EogImageLoader *loader;
|
|
|
|
gboolean loading_failed = FALSE;
|
|
|
|
|
|
|
|
loader = ctx->loader;
|
|
|
|
|
|
|
|
if (cimage_has_loading_failed (ctx->cimg))
|
|
|
|
loading_failed = TRUE;
|
|
|
|
else {
|
|
|
|
GdkPixbuf *pbf;
|
|
|
|
GdkPixbuf *thumb;
|
|
|
|
|
|
|
|
/* scale loaded image */
|
|
|
|
pbf = gdk_pixbuf_loader_get_pixbuf (ctx->pbf_loader);
|
|
|
|
|
|
|
|
if (pbf != NULL) {
|
|
|
|
thumb = scale_image (loader, pbf);
|
|
|
|
|
2001-05-21 21:48:14 +00:00
|
|
|
#ifdef COLLECTION_DEBUG
|
2001-04-23 09:57:40 +00:00
|
|
|
g_message ("Successfully finished loading for: %s\n", cimage_get_uri (ctx->cimg));
|
2001-05-21 21:48:14 +00:00
|
|
|
#endif
|
2001-04-23 09:57:40 +00:00
|
|
|
|
|
|
|
cimage_set_thumbnail (ctx->cimg, thumb);
|
2001-05-30 16:45:28 +00:00
|
|
|
cimage_set_image_dimensions (ctx->cimg,
|
|
|
|
gdk_pixbuf_get_width (pbf),
|
|
|
|
gdk_pixbuf_get_height (pbf));
|
2001-04-23 09:57:40 +00:00
|
|
|
|
|
|
|
gdk_pixbuf_unref (thumb);
|
|
|
|
gdk_pixbuf_unref (pbf);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (ctx->loader),
|
|
|
|
eog_image_loader_signals [LOADING_FINISHED],
|
|
|
|
ctx->cimg);
|
|
|
|
} else {
|
|
|
|
loading_failed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (loading_failed) {
|
2001-05-21 21:48:14 +00:00
|
|
|
#ifdef COLLECTION_DEBUG
|
Added gnome-vfs flags.
2001-06-01 Jens Finke <jens@gnome.org>
* Makefile.am (INCLUDES), (eog_collection_LDADD): Added gnome-vfs
flags.
* cimage.[ch] (cimage_new): Create GnomeVFSURI from text uri and
use cimage_new_uri.
(cimage_new_uri): New function, creates an cimage from
GnomeVFSURI.
(cimage_get_uri): Return GnomeVFSURI object.
(cimage_is_directory): Use GnomeVFS functions to determine file
type.
* eog-collection-model.c (loading_context_free): New helper
function.
(directory_visit_cb): New function, opens a single file contained
in a directory.
(real_storage_loading): Renamed to real_dir_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(directory_filter_cb): New function, determines what kind of files
we can handle within a directory.
(real_stream_loading): Renamed to real_file_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(eog_collection_model_set_uri),
(eog_collection_model_set_uri_list),
(prepare_context): Use GnomeVFS functions, removed all the
BonoboStorage/Stream stuff.
* eog-collection-view.c (eog_collection_view_get_prop): Adapted to
cimage changes.
* eog-image-loader.c (load_uri): Use GnomeVFS functions, removed
all the BonoboStorage/Stream stuff.
* eog-item-factory-simple.c (ii_factory_update_item): Adapted to
cimage changes.
* main.c (init_server_factory): Call gnome-vfs-init.
2001-06-01 09:19:40 +00:00
|
|
|
g_message ("Loading failed for: %s\n", cimage_get_uri (ctx->cimg)->text);
|
2001-05-21 21:48:14 +00:00
|
|
|
#endif
|
2001-04-23 09:57:40 +00:00
|
|
|
cimage_set_loading_failed (ctx->cimg);
|
|
|
|
gtk_signal_emit (GTK_OBJECT (ctx->loader),
|
|
|
|
eog_image_loader_signals [LOADING_FAILED],
|
|
|
|
ctx->cimg);
|
|
|
|
}
|
|
|
|
g_free (ctx);
|
|
|
|
|
|
|
|
setup_next_uri (loader);
|
|
|
|
}
|
|
|
|
|
2001-02-15 15:57:45 +00:00
|
|
|
static gint
|
2001-04-23 09:57:40 +00:00
|
|
|
load_uri (EILContext *ctx)
|
2001-02-15 15:57:45 +00:00
|
|
|
{
|
|
|
|
EogImageLoaderPrivate *priv;
|
Added gnome-vfs flags.
2001-06-01 Jens Finke <jens@gnome.org>
* Makefile.am (INCLUDES), (eog_collection_LDADD): Added gnome-vfs
flags.
* cimage.[ch] (cimage_new): Create GnomeVFSURI from text uri and
use cimage_new_uri.
(cimage_new_uri): New function, creates an cimage from
GnomeVFSURI.
(cimage_get_uri): Return GnomeVFSURI object.
(cimage_is_directory): Use GnomeVFS functions to determine file
type.
* eog-collection-model.c (loading_context_free): New helper
function.
(directory_visit_cb): New function, opens a single file contained
in a directory.
(real_storage_loading): Renamed to real_dir_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(directory_filter_cb): New function, determines what kind of files
we can handle within a directory.
(real_stream_loading): Renamed to real_file_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(eog_collection_model_set_uri),
(eog_collection_model_set_uri_list),
(prepare_context): Use GnomeVFS functions, removed all the
BonoboStorage/Stream stuff.
* eog-collection-view.c (eog_collection_view_get_prop): Adapted to
cimage changes.
* eog-image-loader.c (load_uri): Use GnomeVFS functions, removed
all the BonoboStorage/Stream stuff.
* eog-item-factory-simple.c (ii_factory_update_item): Adapted to
cimage changes.
* main.c (init_server_factory): Call gnome-vfs-init.
2001-06-01 09:19:40 +00:00
|
|
|
guchar *buffer;
|
2001-03-06 16:59:40 +00:00
|
|
|
gint p = 0;
|
Added gnome-vfs flags.
2001-06-01 Jens Finke <jens@gnome.org>
* Makefile.am (INCLUDES), (eog_collection_LDADD): Added gnome-vfs
flags.
* cimage.[ch] (cimage_new): Create GnomeVFSURI from text uri and
use cimage_new_uri.
(cimage_new_uri): New function, creates an cimage from
GnomeVFSURI.
(cimage_get_uri): Return GnomeVFSURI object.
(cimage_is_directory): Use GnomeVFS functions to determine file
type.
* eog-collection-model.c (loading_context_free): New helper
function.
(directory_visit_cb): New function, opens a single file contained
in a directory.
(real_storage_loading): Renamed to real_dir_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(directory_filter_cb): New function, determines what kind of files
we can handle within a directory.
(real_stream_loading): Renamed to real_file_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(eog_collection_model_set_uri),
(eog_collection_model_set_uri_list),
(prepare_context): Use GnomeVFS functions, removed all the
BonoboStorage/Stream stuff.
* eog-collection-view.c (eog_collection_view_get_prop): Adapted to
cimage changes.
* eog-image-loader.c (load_uri): Use GnomeVFS functions, removed
all the BonoboStorage/Stream stuff.
* eog-item-factory-simple.c (ii_factory_update_item): Adapted to
cimage changes.
* main.c (init_server_factory): Call gnome-vfs-init.
2001-06-01 09:19:40 +00:00
|
|
|
GnomeVFSResult result;
|
|
|
|
GnomeVFSHandle *handle;
|
|
|
|
GnomeVFSFileSize bytes_read;
|
2001-03-06 16:59:40 +00:00
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
priv = ctx->loader->priv;
|
2001-02-15 15:57:45 +00:00
|
|
|
|
|
|
|
/* remove idle handler */
|
|
|
|
gtk_idle_remove (priv->idle_handler_id);
|
2001-04-23 09:57:40 +00:00
|
|
|
priv->idle_handler_id = -1;
|
|
|
|
|
|
|
|
/* try to obtain BonoboStream */
|
Added gnome-vfs flags.
2001-06-01 Jens Finke <jens@gnome.org>
* Makefile.am (INCLUDES), (eog_collection_LDADD): Added gnome-vfs
flags.
* cimage.[ch] (cimage_new): Create GnomeVFSURI from text uri and
use cimage_new_uri.
(cimage_new_uri): New function, creates an cimage from
GnomeVFSURI.
(cimage_get_uri): Return GnomeVFSURI object.
(cimage_is_directory): Use GnomeVFS functions to determine file
type.
* eog-collection-model.c (loading_context_free): New helper
function.
(directory_visit_cb): New function, opens a single file contained
in a directory.
(real_storage_loading): Renamed to real_dir_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(directory_filter_cb): New function, determines what kind of files
we can handle within a directory.
(real_stream_loading): Renamed to real_file_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(eog_collection_model_set_uri),
(eog_collection_model_set_uri_list),
(prepare_context): Use GnomeVFS functions, removed all the
BonoboStorage/Stream stuff.
* eog-collection-view.c (eog_collection_view_get_prop): Adapted to
cimage changes.
* eog-image-loader.c (load_uri): Use GnomeVFS functions, removed
all the BonoboStorage/Stream stuff.
* eog-item-factory-simple.c (ii_factory_update_item): Adapted to
cimage changes.
* main.c (init_server_factory): Call gnome-vfs-init.
2001-06-01 09:19:40 +00:00
|
|
|
result = gnome_vfs_open_uri (&handle, cimage_get_uri (ctx->cimg),
|
|
|
|
GNOME_VFS_OPEN_READ);
|
|
|
|
if (result != GNOME_VFS_OK) {
|
2001-04-23 09:57:40 +00:00
|
|
|
cimage_set_loading_failed (ctx->cimg);
|
|
|
|
loading_finished (ctx);
|
|
|
|
return FALSE;
|
|
|
|
}
|
Added gnome-vfs flags.
2001-06-01 Jens Finke <jens@gnome.org>
* Makefile.am (INCLUDES), (eog_collection_LDADD): Added gnome-vfs
flags.
* cimage.[ch] (cimage_new): Create GnomeVFSURI from text uri and
use cimage_new_uri.
(cimage_new_uri): New function, creates an cimage from
GnomeVFSURI.
(cimage_get_uri): Return GnomeVFSURI object.
(cimage_is_directory): Use GnomeVFS functions to determine file
type.
* eog-collection-model.c (loading_context_free): New helper
function.
(directory_visit_cb): New function, opens a single file contained
in a directory.
(real_storage_loading): Renamed to real_dir_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(directory_filter_cb): New function, determines what kind of files
we can handle within a directory.
(real_stream_loading): Renamed to real_file_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(eog_collection_model_set_uri),
(eog_collection_model_set_uri_list),
(prepare_context): Use GnomeVFS functions, removed all the
BonoboStorage/Stream stuff.
* eog-collection-view.c (eog_collection_view_get_prop): Adapted to
cimage changes.
* eog-image-loader.c (load_uri): Use GnomeVFS functions, removed
all the BonoboStorage/Stream stuff.
* eog-item-factory-simple.c (ii_factory_update_item): Adapted to
cimage changes.
* main.c (init_server_factory): Call gnome-vfs-init.
2001-06-01 09:19:40 +00:00
|
|
|
g_assert (handle != NULL);
|
2001-03-06 16:59:40 +00:00
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
/* create loader */
|
|
|
|
ctx->pbf_loader = gdk_pixbuf_loader_new ();
|
2001-02-15 15:57:45 +00:00
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
/* loading image from stream */
|
Added gnome-vfs flags.
2001-06-01 Jens Finke <jens@gnome.org>
* Makefile.am (INCLUDES), (eog_collection_LDADD): Added gnome-vfs
flags.
* cimage.[ch] (cimage_new): Create GnomeVFSURI from text uri and
use cimage_new_uri.
(cimage_new_uri): New function, creates an cimage from
GnomeVFSURI.
(cimage_get_uri): Return GnomeVFSURI object.
(cimage_is_directory): Use GnomeVFS functions to determine file
type.
* eog-collection-model.c (loading_context_free): New helper
function.
(directory_visit_cb): New function, opens a single file contained
in a directory.
(real_storage_loading): Renamed to real_dir_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(directory_filter_cb): New function, determines what kind of files
we can handle within a directory.
(real_stream_loading): Renamed to real_file_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(eog_collection_model_set_uri),
(eog_collection_model_set_uri_list),
(prepare_context): Use GnomeVFS functions, removed all the
BonoboStorage/Stream stuff.
* eog-collection-view.c (eog_collection_view_get_prop): Adapted to
cimage changes.
* eog-image-loader.c (load_uri): Use GnomeVFS functions, removed
all the BonoboStorage/Stream stuff.
* eog-item-factory-simple.c (ii_factory_update_item): Adapted to
cimage changes.
* main.c (init_server_factory): Call gnome-vfs-init.
2001-06-01 09:19:40 +00:00
|
|
|
buffer = g_new0 (guchar, 4096);
|
2001-04-23 09:57:40 +00:00
|
|
|
while (!priv->cancel_loading) {
|
2001-03-06 16:59:40 +00:00
|
|
|
|
Added gnome-vfs flags.
2001-06-01 Jens Finke <jens@gnome.org>
* Makefile.am (INCLUDES), (eog_collection_LDADD): Added gnome-vfs
flags.
* cimage.[ch] (cimage_new): Create GnomeVFSURI from text uri and
use cimage_new_uri.
(cimage_new_uri): New function, creates an cimage from
GnomeVFSURI.
(cimage_get_uri): Return GnomeVFSURI object.
(cimage_is_directory): Use GnomeVFS functions to determine file
type.
* eog-collection-model.c (loading_context_free): New helper
function.
(directory_visit_cb): New function, opens a single file contained
in a directory.
(real_storage_loading): Renamed to real_dir_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(directory_filter_cb): New function, determines what kind of files
we can handle within a directory.
(real_stream_loading): Renamed to real_file_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(eog_collection_model_set_uri),
(eog_collection_model_set_uri_list),
(prepare_context): Use GnomeVFS functions, removed all the
BonoboStorage/Stream stuff.
* eog-collection-view.c (eog_collection_view_get_prop): Adapted to
cimage changes.
* eog-image-loader.c (load_uri): Use GnomeVFS functions, removed
all the BonoboStorage/Stream stuff.
* eog-item-factory-simple.c (ii_factory_update_item): Adapted to
cimage changes.
* main.c (init_server_factory): Call gnome-vfs-init.
2001-06-01 09:19:40 +00:00
|
|
|
result = gnome_vfs_read (handle, buffer,
|
|
|
|
4096, &bytes_read);
|
|
|
|
|
|
|
|
if (result == GNOME_VFS_ERROR_EOF) break;
|
|
|
|
|
|
|
|
if (result != GNOME_VFS_OK)
|
2001-04-23 09:57:40 +00:00
|
|
|
goto loading_error;
|
|
|
|
|
Added gnome-vfs flags.
2001-06-01 Jens Finke <jens@gnome.org>
* Makefile.am (INCLUDES), (eog_collection_LDADD): Added gnome-vfs
flags.
* cimage.[ch] (cimage_new): Create GnomeVFSURI from text uri and
use cimage_new_uri.
(cimage_new_uri): New function, creates an cimage from
GnomeVFSURI.
(cimage_get_uri): Return GnomeVFSURI object.
(cimage_is_directory): Use GnomeVFS functions to determine file
type.
* eog-collection-model.c (loading_context_free): New helper
function.
(directory_visit_cb): New function, opens a single file contained
in a directory.
(real_storage_loading): Renamed to real_dir_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(directory_filter_cb): New function, determines what kind of files
we can handle within a directory.
(real_stream_loading): Renamed to real_file_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(eog_collection_model_set_uri),
(eog_collection_model_set_uri_list),
(prepare_context): Use GnomeVFS functions, removed all the
BonoboStorage/Stream stuff.
* eog-collection-view.c (eog_collection_view_get_prop): Adapted to
cimage changes.
* eog-image-loader.c (load_uri): Use GnomeVFS functions, removed
all the BonoboStorage/Stream stuff.
* eog-item-factory-simple.c (ii_factory_update_item): Adapted to
cimage changes.
* main.c (init_server_factory): Call gnome-vfs-init.
2001-06-01 09:19:40 +00:00
|
|
|
if (bytes_read == 0) break; /* reached end of stream */
|
2001-02-15 15:57:45 +00:00
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
if(!gdk_pixbuf_loader_write(ctx->pbf_loader,
|
Added gnome-vfs flags.
2001-06-01 Jens Finke <jens@gnome.org>
* Makefile.am (INCLUDES), (eog_collection_LDADD): Added gnome-vfs
flags.
* cimage.[ch] (cimage_new): Create GnomeVFSURI from text uri and
use cimage_new_uri.
(cimage_new_uri): New function, creates an cimage from
GnomeVFSURI.
(cimage_get_uri): Return GnomeVFSURI object.
(cimage_is_directory): Use GnomeVFS functions to determine file
type.
* eog-collection-model.c (loading_context_free): New helper
function.
(directory_visit_cb): New function, opens a single file contained
in a directory.
(real_storage_loading): Renamed to real_dir_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(directory_filter_cb): New function, determines what kind of files
we can handle within a directory.
(real_stream_loading): Renamed to real_file_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(eog_collection_model_set_uri),
(eog_collection_model_set_uri_list),
(prepare_context): Use GnomeVFS functions, removed all the
BonoboStorage/Stream stuff.
* eog-collection-view.c (eog_collection_view_get_prop): Adapted to
cimage changes.
* eog-image-loader.c (load_uri): Use GnomeVFS functions, removed
all the BonoboStorage/Stream stuff.
* eog-item-factory-simple.c (ii_factory_update_item): Adapted to
cimage changes.
* main.c (init_server_factory): Call gnome-vfs-init.
2001-06-01 09:19:40 +00:00
|
|
|
buffer, bytes_read)) {
|
2001-04-23 09:57:40 +00:00
|
|
|
goto loading_error;
|
2001-02-15 15:57:45 +00:00
|
|
|
}
|
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
/* update gui every 50th time */
|
|
|
|
if (p++ % 50 == 0)
|
|
|
|
while (gtk_events_pending ())
|
|
|
|
gtk_main_iteration ();
|
2001-02-15 15:57:45 +00:00
|
|
|
}
|
2001-03-06 16:59:40 +00:00
|
|
|
|
Added gnome-vfs flags.
2001-06-01 Jens Finke <jens@gnome.org>
* Makefile.am (INCLUDES), (eog_collection_LDADD): Added gnome-vfs
flags.
* cimage.[ch] (cimage_new): Create GnomeVFSURI from text uri and
use cimage_new_uri.
(cimage_new_uri): New function, creates an cimage from
GnomeVFSURI.
(cimage_get_uri): Return GnomeVFSURI object.
(cimage_is_directory): Use GnomeVFS functions to determine file
type.
* eog-collection-model.c (loading_context_free): New helper
function.
(directory_visit_cb): New function, opens a single file contained
in a directory.
(real_storage_loading): Renamed to real_dir_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(directory_filter_cb): New function, determines what kind of files
we can handle within a directory.
(real_stream_loading): Renamed to real_file_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(eog_collection_model_set_uri),
(eog_collection_model_set_uri_list),
(prepare_context): Use GnomeVFS functions, removed all the
BonoboStorage/Stream stuff.
* eog-collection-view.c (eog_collection_view_get_prop): Adapted to
cimage changes.
* eog-image-loader.c (load_uri): Use GnomeVFS functions, removed
all the BonoboStorage/Stream stuff.
* eog-item-factory-simple.c (ii_factory_update_item): Adapted to
cimage changes.
* main.c (init_server_factory): Call gnome-vfs-init.
2001-06-01 09:19:40 +00:00
|
|
|
g_free (buffer);
|
|
|
|
gnome_vfs_close (handle);
|
2001-06-30 15:54:13 +00:00
|
|
|
gdk_pixbuf_loader_close (ctx->pbf_loader);
|
2001-04-23 09:57:40 +00:00
|
|
|
|
|
|
|
if (priv->cancel_loading)
|
|
|
|
loading_canceled (ctx);
|
|
|
|
else
|
|
|
|
loading_finished (ctx);
|
|
|
|
|
|
|
|
return TRUE;
|
2001-03-06 16:59:40 +00:00
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
loading_error:
|
|
|
|
cimage_set_loading_failed (ctx->cimg);
|
Added gnome-vfs flags.
2001-06-01 Jens Finke <jens@gnome.org>
* Makefile.am (INCLUDES), (eog_collection_LDADD): Added gnome-vfs
flags.
* cimage.[ch] (cimage_new): Create GnomeVFSURI from text uri and
use cimage_new_uri.
(cimage_new_uri): New function, creates an cimage from
GnomeVFSURI.
(cimage_get_uri): Return GnomeVFSURI object.
(cimage_is_directory): Use GnomeVFS functions to determine file
type.
* eog-collection-model.c (loading_context_free): New helper
function.
(directory_visit_cb): New function, opens a single file contained
in a directory.
(real_storage_loading): Renamed to real_dir_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(directory_filter_cb): New function, determines what kind of files
we can handle within a directory.
(real_stream_loading): Renamed to real_file_loading, uses GnomeVFS
functions now, removed all the BonoboStorage/Stream stuff.
(eog_collection_model_set_uri),
(eog_collection_model_set_uri_list),
(prepare_context): Use GnomeVFS functions, removed all the
BonoboStorage/Stream stuff.
* eog-collection-view.c (eog_collection_view_get_prop): Adapted to
cimage changes.
* eog-image-loader.c (load_uri): Use GnomeVFS functions, removed
all the BonoboStorage/Stream stuff.
* eog-item-factory-simple.c (ii_factory_update_item): Adapted to
cimage changes.
* main.c (init_server_factory): Call gnome-vfs-init.
2001-06-01 09:19:40 +00:00
|
|
|
g_free (buffer);
|
|
|
|
gnome_vfs_close (handle);
|
2001-04-23 09:57:40 +00:00
|
|
|
loading_finished (ctx);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
setup_next_uri (EogImageLoader *loader)
|
|
|
|
{
|
|
|
|
EILContext *ctx = NULL;
|
|
|
|
EogImageLoaderPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (loader != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (EOG_IS_IMAGE_LOADER (loader), FALSE);
|
2001-02-15 15:57:45 +00:00
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
priv = loader->priv;
|
|
|
|
if (priv->idle_handler_id != -1)
|
|
|
|
gtk_idle_remove (priv->idle_handler_id);
|
|
|
|
priv->idle_handler_id = -1;
|
|
|
|
|
|
|
|
if (priv->queue != NULL) {
|
|
|
|
ctx = g_new0 (EILContext, 1);
|
|
|
|
ctx->loader = loader;
|
|
|
|
ctx->pbf_loader = NULL;
|
|
|
|
ctx->cimg = (CImage*) priv->queue->data;
|
|
|
|
|
|
|
|
priv->queue = g_list_remove (priv->queue, ctx->cimg);
|
|
|
|
|
2001-05-21 21:48:14 +00:00
|
|
|
#ifdef COLLECTION_DEBUG
|
2001-04-23 09:57:40 +00:00
|
|
|
g_message ("Open image: %s\n", cimage_get_uri (ctx->cimg));
|
2001-05-21 21:48:14 +00:00
|
|
|
#endif
|
2001-04-23 09:57:40 +00:00
|
|
|
|
|
|
|
priv->idle_handler_id = gtk_idle_add ((GtkFunction) load_uri, ctx);
|
|
|
|
} else {
|
|
|
|
priv->active = FALSE;
|
|
|
|
}
|
|
|
|
|
2001-02-15 15:57:45 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-04-23 09:57:40 +00:00
|
|
|
eog_image_loader_start (EogImageLoader *loader, CImage *img)
|
2001-02-15 15:57:45 +00:00
|
|
|
{
|
2001-04-23 09:57:40 +00:00
|
|
|
EogImageLoaderPrivate *priv;
|
|
|
|
|
2001-02-15 15:57:45 +00:00
|
|
|
g_return_if_fail (loader != NULL);
|
2001-04-23 09:57:40 +00:00
|
|
|
g_return_if_fail (EOG_IS_IMAGE_LOADER (loader));
|
2001-02-15 15:57:45 +00:00
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
priv = loader->priv;
|
2001-02-15 15:57:45 +00:00
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
priv->queue = g_list_append (priv->queue, img);
|
2001-03-06 16:59:40 +00:00
|
|
|
|
2001-04-23 09:57:40 +00:00
|
|
|
if (!priv->active) {
|
|
|
|
priv->active = TRUE;
|
|
|
|
priv->idle_handler_id = gtk_idle_add ((GtkFunction) setup_next_uri, loader);
|
2001-02-15 15:57:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
eog_image_loader_stop (EogImageLoader *loader)
|
|
|
|
{
|
|
|
|
g_return_if_fail (loader != NULL);
|
2001-04-23 09:57:40 +00:00
|
|
|
g_return_if_fail (EOG_IS_IMAGE_LOADER (loader));
|
|
|
|
|
|
|
|
loader->priv->cancel_loading = TRUE;
|
2001-02-15 15:57:45 +00:00
|
|
|
}
|
2001-04-23 09:57:40 +00:00
|
|
|
|
|
|
|
|