Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog31
-rw-r--r--backend/ev-document-factory.c28
-rw-r--r--backend/ev-document-factory.h3
-rw-r--r--properties/ev-properties-main.c13
-rw-r--r--shell/Makefile.am2
-rw-r--r--shell/ev-job-queue.c14
-rw-r--r--shell/ev-job-queue.h1
-rw-r--r--shell/ev-job-xfer.c141
-rw-r--r--shell/ev-job-xfer.h57
-rw-r--r--shell/ev-jobs.c158
-rw-r--r--shell/ev-jobs.h46
-rw-r--r--shell/ev-window.c246
-rw-r--r--thumbnailer/evince-thumbnailer.c17
13 files changed, 282 insertions, 475 deletions
diff --git a/ChangeLog b/ChangeLog
index ba35ec2..e6ee0d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2006-04-03 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
+
+ * backend/ev-document-factory.c: (get_document_from_uri),
+ (ev_document_factory_get_document):
+ * backend/ev-document-factory.h:
+ * properties/ev-properties-main.c: (ev_properties_get_pages):
+ * shell/Makefile.am:
+ * shell/ev-job-queue.c: (handle_job), (search_for_jobs_unlocked),
+ (no_jobs_available_unlocked), (ev_job_queue_init), (find_queue),
+ (ev_job_queue_remove_job):
+ * shell/ev-job-queue.h:
+ * shell/ev-job-xfer.c:
+ * shell/ev-job-xfer.h:
+ * shell/ev-jobs.c: (ev_job_fonts_init), (ev_job_fonts_class_init),
+ (ev_job_fonts_new), (ev_job_fonts_run), (ev_job_xfer_init),
+ (ev_job_xfer_dispose), (ev_job_xfer_class_init), (ev_job_xfer_new),
+ (ev_job_xfer_run):
+ * shell/ev-jobs.h:
+ * shell/ev-window.c: (ev_window_is_empty),
+ (password_dialog_response), (ev_window_clear_xfer_job),
+ (ev_window_xfer_job_cb), (ev_window_open_uri),
+ (ev_window_cmd_focus_page_selector),
+ (ev_window_cmd_scroll_forward), (ev_window_cmd_scroll_backward),
+ (ev_window_cmd_continuous), (ev_window_cmd_dual),
+ (ev_window_cmd_view_best_fit), (ev_window_cmd_view_page_width),
+ (ev_window_dispose):
+ * thumbnailer/evince-thumbnailer.c: (evince_thumbnail_pngenc_get):
+
+ * Cleanup mime type detection on document load. Fix for the
+ bug #336448.
+
2006-04-02 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
* shell/ev-sidebar-thumbnails.c: (ev_sidebar_thumbnails_dispose):
diff --git a/backend/ev-document-factory.c b/backend/ev-document-factory.c
index c7314ec..c02801f 100644
--- a/backend/ev-document-factory.c
+++ b/backend/ev-document-factory.c
@@ -142,7 +142,7 @@ mime_type_supported_by_gdk_pixbuf (const gchar *mime_type)
}
#endif
-EvDocument*
+static EvDocument*
ev_document_factory_get_from_mime (const char *mime_type)
{
int i;
@@ -230,7 +230,7 @@ ev_document_factory_get_all_mime_types (void)
}
static EvDocument *
-get_document_from_uri (const char *uri, gboolean slow, gchar **mime_type, GError **error)
+get_document_from_uri (const char *uri, gboolean slow, GError **error)
{
EvDocument *document = NULL;
@@ -271,32 +271,36 @@ get_document_from_uri (const char *uri, gboolean slow, gchar **mime_type, GError
return NULL;
}
- if (mime_type != NULL) {
- *mime_type = g_strdup (info->mime_type);
- }
-
gnome_vfs_file_info_unref (info);
return document;
}
EvDocument *
-ev_document_factory_get_document (const char *uri, gchar **mime_type, GError **error)
+ev_document_factory_get_document (const char *uri, GError **error)
{
EvDocument *document;
- document = get_document_from_uri (uri, FALSE, mime_type, error);
+ document = get_document_from_uri (uri, FALSE, error);
- if (document != NULL) {
- return document;
+ if (*error != NULL) {
+ return NULL;
}
+
+ ev_document_load (document, uri, error);
- if (error) {
+ if (*error) {
g_error_free (*error);
*error = NULL;
}
- document = get_document_from_uri (uri, TRUE, mime_type, error);
+ document = get_document_from_uri (uri, TRUE, error);
+
+ if (*error != NULL) {
+ return NULL;
+ }
+
+ ev_document_load (document, uri, error);
return document;
}
diff --git a/backend/ev-document-factory.h b/backend/ev-document-factory.h
index b2c9659..215f50b 100644
--- a/backend/ev-document-factory.h
+++ b/backend/ev-document-factory.h
@@ -36,8 +36,7 @@ typedef enum {
EV_BACKEND_COMICS
} EvBackend;
-EvDocument* ev_document_factory_get_from_mime (const char *mime_type);
-EvDocument* ev_document_factory_get_document (const char *uri, gchar **mime_type, GError **error);
+EvDocument* ev_document_factory_get_document (const char *uri, GError **error);
EvBackend ev_document_factory_get_backend (EvDocument *document);
void ev_document_factory_add_filters (GtkWidget *chooser, EvDocument *document);
diff --git a/properties/ev-properties-main.c b/properties/ev-properties-main.c
index c97f7fc..f726591 100644
--- a/properties/ev-properties-main.c
+++ b/properties/ev-properties-main.c
@@ -83,7 +83,6 @@ ev_properties_get_pages (NautilusPropertyPageProvider *provider,
GList *files)
{
GError *error = NULL;
- char *mime;
EvDocument *document;
GList *pages = NULL;
NautilusFileInfo *file;
@@ -98,20 +97,18 @@ ev_properties_get_pages (NautilusPropertyPageProvider *provider,
file = files->data;
/* okay, make the page */
- mime = nautilus_file_info_get_mime_type (file);
- document = ev_document_factory_get_from_mime (mime);
- g_free (mime);
if (document == NULL)
goto end;
uri = nautilus_file_info_get_uri (file);
- if (!ev_document_load (document, uri, &error)) {
- if (error) {
- g_error_free (error);
- }
+ document = ev_document_factory_get_document (uri, &error);
+
+ if (error) {
+ g_error_free (error);
goto end;
}
+
label = gtk_label_new (_("Document"));
page = ev_properties_view_new ();
ev_properties_view_set_info (EV_PROPERTIES_VIEW (page),
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 0e80fe9..f54c5e2 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -24,8 +24,6 @@ evince_SOURCES= \
ev-job-queue.c \
ev-jobs.h \
ev-jobs.c \
- ev-job-xfer.c \
- ev-job-xfer.h \
ev-marshal.c \
ev-marshal.h \
ev-metadata-manager.c \
diff --git a/shell/ev-job-queue.c b/shell/ev-job-queue.c
index a860f37..c8c51d8 100644
--- a/shell/ev-job-queue.c
+++ b/shell/ev-job-queue.c
@@ -12,7 +12,6 @@ static GQueue *render_queue_high = NULL;
static GQueue *render_queue_low = NULL;
static GQueue *thumbnail_queue_high = NULL;
static GQueue *thumbnail_queue_low = NULL;
-static GQueue *load_queue = NULL;
static GQueue *xfer_queue = NULL;
static GQueue *fonts_queue = NULL;
@@ -96,8 +95,6 @@ handle_job (EvJob *job)
ev_job_thumbnail_run (EV_JOB_THUMBNAIL (job));
else if (EV_IS_JOB_LINKS (job))
ev_job_links_run (EV_JOB_LINKS (job));
- else if (EV_IS_JOB_LOAD (job))
- ev_job_load_run (EV_JOB_LOAD (job));
else if (EV_IS_JOB_XFER (job))
ev_job_xfer_run (EV_JOB_XFER (job));
else if (EV_IS_JOB_RENDER (job))
@@ -135,10 +132,6 @@ search_for_jobs_unlocked (void)
if (job)
return job;
- job = (EvJob *) g_queue_pop_head (load_queue);
- if (job)
- return job;
-
job = (EvJob *) g_queue_pop_head (xfer_queue);
if (job)
return job;
@@ -160,7 +153,6 @@ no_jobs_available_unlocked (void)
return g_queue_is_empty (render_queue_high)
&& g_queue_is_empty (render_queue_low)
&& g_queue_is_empty (links_queue)
- && g_queue_is_empty (load_queue)
&& g_queue_is_empty (xfer_queue)
&& g_queue_is_empty (thumbnail_queue_high)
&& g_queue_is_empty (thumbnail_queue_low)
@@ -220,7 +212,6 @@ ev_job_queue_init (void)
ev_queue_mutex = g_mutex_new ();
links_queue = g_queue_new ();
- load_queue = g_queue_new ();
xfer_queue = g_queue_new ();
render_queue_high = g_queue_new ();
render_queue_low = g_queue_new ();
@@ -256,9 +247,6 @@ find_queue (EvJob *job,
return thumbnail_queue_high;
else
return thumbnail_queue_low;
- } else if (EV_IS_JOB_LOAD (job)) {
- /* the priority doesn't effect load */
- return load_queue;
} else if (EV_IS_JOB_XFER (job)) {
/* the priority doesn't effect xfer */
return xfer_queue;
@@ -403,8 +391,6 @@ ev_job_queue_remove_job (EvJob *job)
retval = retval || remove_job_from_queue_locked (render_queue_low, job);
} else if (EV_IS_JOB_LINKS (job)) {
retval = remove_job_from_queue_locked (links_queue, job);
- } else if (EV_IS_JOB_LOAD (job)) {
- retval = remove_job_from_queue_locked (load_queue, job);
} else if (EV_IS_JOB_XFER (job)) {
retval = remove_job_from_queue_locked (xfer_queue, job);
} else if (EV_IS_JOB_FONTS (job)) {
diff --git a/shell/ev-job-queue.h b/shell/ev-job-queue.h
index 0a2f24c..e6e4c0e 100644
--- a/shell/ev-job-queue.h
+++ b/shell/ev-job-queue.h
@@ -22,7 +22,6 @@
#include <gtk/gtk.h>
#include "ev-jobs.h"
-#include "ev-job-xfer.h"
G_BEGIN_DECLS
diff --git a/shell/ev-job-xfer.c b/shell/ev-job-xfer.c
deleted file mode 100644
index b169f46..0000000
--- a/shell/ev-job-xfer.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/* this file is part of evince, a gnome document viewer
- *
- * Copyright (C) 2005 Red Hat, Inc
- *
- * Evince is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Evince is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-
-#include "ev-job-xfer.h"
-#include "ev-file-helpers.h"
-#include "ev-document-factory.h"
-
-#include <glib/gi18n.h>
-#include <glib.h>
-
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-xfer.h>
-
-static void ev_job_xfer_init (EvJobXfer *job);
-static void ev_job_xfer_class_init (EvJobXferClass *class);
-
-G_DEFINE_TYPE (EvJobXfer, ev_job_xfer, EV_TYPE_JOB)
-
-static void ev_job_xfer_init (EvJobXfer *job) { /* Do Nothing */ }
-
-static void
-ev_job_xfer_dispose (GObject *object)
-{
- EvJobXfer *job = EV_JOB_XFER (object);
-
- if (job->uri) {
- g_free (job->uri);
- job->uri = NULL;
- }
-
- if (job->local_uri) {
- g_free (job->local_uri);
- job->local_uri = NULL;
- }
-
- if (job->error) {
- g_error_free (job->error);
- job->error = NULL;
- }
-
- (* G_OBJECT_CLASS (ev_job_xfer_parent_class)->dispose) (object);
-}
-
-static void
-ev_job_xfer_class_init (EvJobXferClass *class)
-{
- GObjectClass *oclass;
-
- oclass = G_OBJECT_CLASS (class);
-
- oclass->dispose = ev_job_xfer_dispose;
-}
-
-
-EvJob *
-ev_job_xfer_new (const gchar *uri)
-{
- EvJobXfer *job;
-
- job = g_object_new (EV_TYPE_JOB_XFER, NULL);
-
- job->uri = g_strdup (uri);
-
- return EV_JOB (job);
-}
-
-void
-ev_job_xfer_run (EvJobXfer *job)
-{
- EvDocument *document;
- GError *error = NULL;
- GnomeVFSURI *source_uri;
- GnomeVFSURI *target_uri;
-
- g_return_if_fail (EV_IS_JOB_XFER (job));
-
- if (job->error) {
- g_error_free (job->error);
- job->error = NULL;
- }
-
- document = ev_document_factory_get_document (job->uri, NULL, &error);
-
- if (document != NULL) {
- EV_JOB (job)->document = document;
- } else {
- job->error = error;
- EV_JOB (job)->finished = TRUE;
- return;
- }
-
- source_uri = gnome_vfs_uri_new (job->uri);
- if (!gnome_vfs_uri_is_local (source_uri)) {
- char *tmp_name;
- char *base_name;
-
- tmp_name = ev_tmp_filename ();
- base_name = g_path_get_basename (job->uri);
- job->local_uri = g_strconcat ("file:", tmp_name, base_name, NULL);
- g_free (tmp_name);
-
- target_uri = gnome_vfs_uri_new (job->local_uri);
-
- gnome_vfs_xfer_uri (source_uri, target_uri,
- GNOME_VFS_XFER_DEFAULT | GNOME_VFS_XFER_FOLLOW_LINKS,
- GNOME_VFS_XFER_ERROR_MODE_ABORT,
- GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
- NULL,
- job);
- gnome_vfs_uri_unref (target_uri);
- }
- gnome_vfs_uri_unref (source_uri);
-
- EV_JOB (job)->finished = TRUE;
- return;
-}
-
-
diff --git a/shell/ev-job-xfer.h b/shell/ev-job-xfer.h
deleted file mode 100644
index 256a60e..0000000
--- a/shell/ev-job-xfer.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* this file is part of evince, a gnome document viewer
- *
- * Copyright (C) 2005 Red Hat, Inc
- *
- * Evince is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Evince is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __EV_JOB_XFER_H__
-#define __EV_JOB_XFER_H__
-
-#include <gtk/gtk.h>
-#include "ev-document.h"
-#include "ev-jobs.h"
-
-G_BEGIN_DECLS
-
-typedef struct _EvJobXfer EvJobXfer;
-typedef struct _EvJobXferClass EvJobXferClass;
-
-#define EV_TYPE_JOB_XFER (ev_job_xfer_get_type())
-#define EV_JOB_XFER(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_XFER, EvJobXfer))
-#define EV_JOB_XFER_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass), EV_TYPE_JOB_XFER, EvJobXferClass))
-#define EV_IS_JOB_XFER(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_XFER))
-
-struct _EvJobXfer
-{
- EvJob parent;
- GError *error;
- char *uri;
- char *local_uri;
-};
-
-struct _EvJobXferClass
-{
- EvJobClass parent_class;
-};
-
-/* EvJobXfer */
-GType ev_job_xfer_get_type (void);
-EvJob *ev_job_xfer_new (const gchar *uri);
-void ev_job_xfer_run (EvJobXfer *xfer);
-
-G_END_DECLS
-
-#endif /* __EV_JOB_XFER_H__ */
diff --git a/shell/ev-jobs.c b/shell/ev-jobs.c
index 0f9bf73..7a37b2b 100644
--- a/shell/ev-jobs.c
+++ b/shell/ev-jobs.c
@@ -2,10 +2,17 @@
#include "ev-job-queue.h"
#include "ev-document-thumbnails.h"
#include "ev-document-links.h"
+#include "ev-document-factory.h"
+#include "ev-file-helpers.h"
#include "ev-document-fonts.h"
#include "ev-selection.h"
#include "ev-async-renderer.h"
+#include <libgnomevfs/gnome-vfs-uri.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
+#include <libgnomevfs/gnome-vfs-ops.h>
+#include <libgnomevfs/gnome-vfs-xfer.h>
+
static void ev_job_init (EvJob *job);
static void ev_job_class_init (EvJobClass *class);
static void ev_job_links_init (EvJobLinks *job);
@@ -14,8 +21,8 @@ static void ev_job_render_init (EvJobRender *job);
static void ev_job_render_class_init (EvJobRenderClass *class);
static void ev_job_thumbnail_init (EvJobThumbnail *job);
static void ev_job_thumbnail_class_init (EvJobThumbnailClass *class);
-static void ev_job_load_init (EvJobLoad *job);
-static void ev_job_load_class_init (EvJobLoadClass *class);
+static void ev_job_xfer_init (EvJobXfer *job);
+static void ev_job_xfer_class_init (EvJobXferClass *class);
enum
{
@@ -29,8 +36,8 @@ G_DEFINE_TYPE (EvJob, ev_job, G_TYPE_OBJECT)
G_DEFINE_TYPE (EvJobLinks, ev_job_links, EV_TYPE_JOB)
G_DEFINE_TYPE (EvJobRender, ev_job_render, EV_TYPE_JOB)
G_DEFINE_TYPE (EvJobThumbnail, ev_job_thumbnail, EV_TYPE_JOB)
-G_DEFINE_TYPE (EvJobLoad, ev_job_load, EV_TYPE_JOB)
G_DEFINE_TYPE (EvJobFonts, ev_job_fonts, EV_TYPE_JOB)
+G_DEFINE_TYPE (EvJobXfer, ev_job_xfer, EV_TYPE_JOB)
static void ev_job_init (EvJob *job) { /* Do Nothing */ }
@@ -166,38 +173,6 @@ ev_job_thumbnail_class_init (EvJobThumbnailClass *class)
oclass->dispose = ev_job_thumbnail_dispose;
}
-static void ev_job_load_init (EvJobLoad *job) { /* Do Nothing */ }
-
-static void
-ev_job_load_dispose (GObject *object)
-{
- EvJobLoad *job;
-
- job = EV_JOB_LOAD (object);
-
- if (job->uri) {
- g_free (job->uri);
- job->uri = NULL;
- }
-
- if (job->error) {
- g_error_free (job->error);
- job->error = NULL;
- }
-
- (* G_OBJECT_CLASS (ev_job_load_parent_class)->dispose) (object);
-}
-
-static void
-ev_job_load_class_init (EvJobLoadClass *class)
-{
- GObjectClass *oclass;
-
- oclass = G_OBJECT_CLASS (class);
-
- oclass->dispose = ev_job_load_dispose;
-}
-
/* Public functions */
void
ev_job_finished (EvJob *job)
@@ -355,68 +330,125 @@ ev_job_thumbnail_run (EvJobThumbnail *job)
ev_document_doc_mutex_unlock ();
}
+static void ev_job_fonts_init (EvJobFonts *job) { /* Do Nothing */ }
+
+static void ev_job_fonts_class_init (EvJobFontsClass *class) { /* Do Nothing */ }
+
EvJob *
-ev_job_load_new (EvDocument *document,
- const gchar *uri)
+ev_job_fonts_new (EvDocument *document)
{
- EvJobLoad *job;
+ EvJobFonts *job;
- job = g_object_new (EV_TYPE_JOB_LOAD, NULL);
+ job = g_object_new (EV_TYPE_JOB_FONTS, NULL);
EV_JOB (job)->document = g_object_ref (document);
- job->uri = g_strdup (uri);
return EV_JOB (job);
}
void
-ev_job_load_run (EvJobLoad *job)
+ev_job_fonts_run (EvJobFonts *job)
{
- g_return_if_fail (EV_IS_JOB_LOAD (job));
+ EvDocumentFonts *fonts;
+
+ g_return_if_fail (EV_IS_JOB_FONTS (job));
ev_document_doc_mutex_lock ();
- if (job->error) {
- g_error_free (job->error);
- job->error = NULL;
- }
-
- ev_document_load (EV_JOB(job)->document, job->uri, &job->error);
+ fonts = EV_DOCUMENT_FONTS (EV_JOB (job)->document);
+ job->scan_completed = !ev_document_fonts_scan (fonts, 20);
EV_JOB (job)->finished = TRUE;
ev_document_doc_mutex_unlock ();
}
-static void ev_job_fonts_init (EvJobFonts *job) { /* Do Nothing */ }
+static void ev_job_xfer_init (EvJobXfer *job) { /* Do Nothing */ }
+
+static void
+ev_job_xfer_dispose (GObject *object)
+{
+ EvJobXfer *job = EV_JOB_XFER (object);
+
+ if (job->uri) {
+ g_free (job->uri);
+ job->uri = NULL;
+ }
+
+ if (job->local_uri) {
+ g_free (job->local_uri);
+ job->local_uri = NULL;
+ }
+
+ if (job->error) {
+ g_error_free (job->error);
+ job->error = NULL;
+ }
+
+ (* G_OBJECT_CLASS (ev_job_xfer_parent_class)->dispose) (object);
+}
+
+static void
+ev_job_xfer_class_init (EvJobXferClass *class)
+{
+ GObjectClass *oclass;
+
+ oclass = G_OBJECT_CLASS (class);
+
+ oclass->dispose = ev_job_xfer_dispose;
+}
-static void ev_job_fonts_class_init (EvJobFontsClass *class) { /* Do Nothing */ }
EvJob *
-ev_job_fonts_new (EvDocument *document)
+ev_job_xfer_new (const gchar *uri)
{
- EvJobFonts *job;
+ EvJobXfer *job;
- job = g_object_new (EV_TYPE_JOB_FONTS, NULL);
+ job = g_object_new (EV_TYPE_JOB_XFER, NULL);
- EV_JOB (job)->document = g_object_ref (document);
+ job->uri = g_strdup (uri);
return EV_JOB (job);
}
void
-ev_job_fonts_run (EvJobFonts *job)
+ev_job_xfer_run (EvJobXfer *job)
{
- EvDocumentFonts *fonts;
-
- g_return_if_fail (EV_IS_JOB_FONTS (job));
+ GnomeVFSURI *source_uri;
+ GnomeVFSURI *target_uri;
- ev_document_doc_mutex_lock ();
-
- fonts = EV_DOCUMENT_FONTS (EV_JOB (job)->document);
- job->scan_completed = !ev_document_fonts_scan (fonts, 20);
+ g_return_if_fail (EV_IS_JOB_XFER (job));
+ if (job->error) {
+ g_error_free (job->error);
+ job->error = NULL;
+ }
+
+ source_uri = gnome_vfs_uri_new (job->uri);
+ if (!gnome_vfs_uri_is_local (source_uri) && !job->local_uri) {
+ char *tmp_name;
+ char *base_name;
+
+ tmp_name = ev_tmp_filename ();
+ base_name = g_path_get_basename (job->uri);
+ job->local_uri = g_strconcat ("file:", tmp_name, base_name, NULL);
+ g_free (tmp_name);
+
+ target_uri = gnome_vfs_uri_new (job->local_uri);
+
+ gnome_vfs_xfer_uri (source_uri, target_uri,
+ GNOME_VFS_XFER_DEFAULT | GNOME_VFS_XFER_FOLLOW_LINKS,
+ GNOME_VFS_XFER_ERROR_MODE_ABORT,
+ GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
+ NULL,
+ job);
+ gnome_vfs_uri_unref (target_uri);
+ }
+ gnome_vfs_uri_unref (source_uri);
+
+ EV_JOB(job)->document = ev_document_factory_get_document (job->local_uri ? job->local_uri : job->uri, &job->error);
EV_JOB (job)->finished = TRUE;
- ev_document_doc_mutex_unlock ();
+ return;
}
+
diff --git a/shell/ev-jobs.h b/shell/ev-jobs.h
index a0ef3f4..a7f6e82 100644
--- a/shell/ev-jobs.h
+++ b/shell/ev-jobs.h
@@ -37,12 +37,12 @@ typedef struct _EvJobThumbnailClass EvJobThumbnailClass;
typedef struct _EvJobLinks EvJobLinks;
typedef struct _EvJobLinksClass EvJobLinksClass;
-typedef struct _EvJobLoad EvJobLoad;
-typedef struct _EvJobLoadClass EvJobLoadClass;
-
typedef struct _EvJobFonts EvJobFonts;
typedef struct _EvJobFontsClass EvJobFontsClass;
+typedef struct _EvJobXfer EvJobXfer;
+typedef struct _EvJobXferClass EvJobXferClass;
+
#define EV_TYPE_JOB (ev_job_get_type())
#define EV_JOB(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB, EvJob))
#define EV_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB, EvJobClass))
@@ -63,16 +63,16 @@ typedef struct _EvJobFontsClass EvJobFontsClass;
#define EV_JOB_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_THUMBNAIL, EvJobThumbnailClass))
#define EV_IS_JOB_THUMBNAIL(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_THUMBNAIL))
-#define EV_TYPE_JOB_LOAD (ev_job_load_get_type())
-#define EV_JOB_LOAD(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_LOAD, EvJobLoad))
-#define EV_JOB_LOAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_LOAD, EvJobLoadClass))
-#define EV_IS_JOB_LOAD(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_LOAD))
-
#define EV_TYPE_JOB_FONTS (ev_job_fonts_get_type())
#define EV_JOB_FONTS(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_FONTS, EvJobFonts))
#define EV_JOB_FONTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_JOB_FONTS, EvJobFontsClass))
#define EV_IS_JOB_FONTS(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_FONTS))
+#define EV_TYPE_JOB_XFER (ev_job_xfer_get_type())
+#define EV_JOB_XFER(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_JOB_XFER, EvJobXfer))
+#define EV_JOB_XFER_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass), EV_TYPE_JOB_XFER, EvJobXferClass))
+#define EV_IS_JOB_XFER(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_JOB_XFER))
+
typedef enum {
EV_JOB_PRIORITY_LOW,
EV_JOB_PRIORITY_HIGH,
@@ -148,27 +148,28 @@ struct _EvJobThumbnailClass
EvJobClass parent_class;
};
-struct _EvJobLoad
+struct _EvJobFonts
{
EvJob parent;
- GError *error;
- gchar *uri;
+ gboolean scan_completed;
};
-struct _EvJobLoadClass
+struct _EvJobFontsClass
{
- EvJobClass parent_class;
+ EvJobClass parent_class;
};
-struct _EvJobFonts
+struct _EvJobXfer
{
EvJob parent;
- gboolean scan_completed;
+ GError *error;
+ char *uri;
+ char *local_uri;
};
-struct _EvJobFontsClass
+struct _EvJobXferClass
{
- EvJobClass parent_class;
+ EvJobClass parent_class;
};
/* Base job class */
@@ -202,17 +203,16 @@ EvJob *ev_job_thumbnail_new (EvDocument *document,
gint requested_width);
void ev_job_thumbnail_run (EvJobThumbnail *thumbnail);
-/* EvJobLoad */
-GType ev_job_load_get_type (void);
-EvJob *ev_job_load_new (EvDocument *document,
- const gchar *uri);
-void ev_job_load_run (EvJobLoad *load);
-
/* EvJobFonts */
GType ev_job_fonts_get_type (void);
EvJob *ev_job_fonts_new (EvDocument *document);
void ev_job_fonts_run (EvJobFonts *fonts);
+/* EvJobXfer */
+GType ev_job_xfer_get_type (void);
+EvJob *ev_job_xfer_new (const gchar *uri);
+void ev_job_xfer_run (EvJobXfer *xfer);
+
G_END_DECLS
#endif /* __EV_JOBS_H__ */
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 460fce0..aefda98 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -141,9 +141,7 @@ struct _EvWindowPrivate {
EvWindowTitle *title;
EggRecentViewUIManager *recent_view;
- /* Job used to load document */
EvJob *xfer_job;
- EvJob *load_job;
#ifdef WITH_GNOME_PRINT
GnomePrintJob *print_job;
#endif
@@ -177,8 +175,6 @@ static void ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_si
EvWindow *ev_window);
static void ev_window_set_page_mode (EvWindow *window,
EvWindowPageMode page_mode);
-static void ev_window_load_job_cb (EvJobLoad *job,
- gpointer data);
static void ev_window_xfer_job_cb (EvJobXfer *job,
gpointer data);
static void ev_window_sizing_mode_changed_cb (EvView *view,
@@ -500,84 +496,6 @@ update_sizing_buttons (EvWindow *window)
}
}
-static void
-ev_window_cmd_focus_page_selector (GtkAction *act, EvWindow *window)
-{
- GtkAction *action;
-
- update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, TRUE);
- ev_window_set_action_sensitive (window, "ViewToolbar", FALSE);
-
- action = gtk_action_group_get_action (window->priv->action_group,
- PAGE_SELECTOR_ACTION);
- ev_page_action_grab_focus (EV_PAGE_ACTION (action));
-}
-
-static void
-ev_window_cmd_scroll_forward (GtkAction *action, EvWindow *window)
-{
- ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_FORWARD, FALSE);
-}
-
-static void
-ev_window_cmd_scroll_backward (GtkAction *action, EvWindow *window)
-{
- ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_BACKWARD, FALSE);
-}
-
-static void
-ev_window_cmd_continuous (GtkAction *action, EvWindow *ev_window)
-{
- gboolean continuous;
-
- ev_window_stop_presentation (ev_window);
- continuous = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- g_object_set (G_OBJECT (ev_window->priv->view),
- "continuous", continuous,
- NULL);
- ev_window_update_actions (ev_window);
-}
-
-static void
-ev_window_cmd_dual (GtkAction *action, EvWindow *ev_window)
-{
- gboolean dual_page;
-
- ev_window_stop_presentation (ev_window);
- dual_page = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- g_object_set (G_OBJECT (ev_window->priv->view),
- "dual-page", dual_page,
- NULL);
- ev_window_update_actions (ev_window);
-}
-
-static void
-ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
-{
- ev_window_stop_presentation (ev_window);
-
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
- ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_BEST_FIT);
- } else {
- ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
- }
- ev_window_update_actions (ev_window);
-}
-
-static void
-ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
-{
- ev_window_stop_presentation (ev_window);
-
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
- ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FIT_WIDTH);
- } else {
- ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
- }
- ev_window_update_actions (ev_window);
-}
-
-
void
ev_window_open_page_label (EvWindow *ev_window,
const char *label)
@@ -594,7 +512,6 @@ ev_window_is_empty (const EvWindow *ev_window)
g_return_val_if_fail (EV_IS_WINDOW (ev_window), FALSE);
return (ev_window->priv->document == NULL) &&
- (ev_window->priv->load_job == NULL) &&
(ev_window->priv->xfer_job == NULL);
}
@@ -898,7 +815,7 @@ password_dialog_response (GtkWidget *password_dialog,
ev_window->priv->password_document = NULL;
ev_window_title_set_type (ev_window->priv->title, EV_WINDOW_TITLE_DOCUMENT);
- ev_job_queue_add_job (ev_window->priv->load_job, EV_JOB_PRIORITY_HIGH);
+ ev_job_queue_add_job (ev_window->priv->xfer_job, EV_JOB_PRIORITY_HIGH);
gtk_widget_destroy (password_dialog);
@@ -909,7 +826,7 @@ password_dialog_response (GtkWidget *password_dialog,
gtk_widget_destroy (password_dialog);
}
-/* Called either by ev_window_load_job_cb or by the "unlock" callback on the
+/* Called either by ev_window_xfer_job_cb or by the "unlock" callback on the
* password_view page. It assumes that ev_window->priv->password_* has been set
* correctly. These are cleared by password_dialog_response() */
@@ -941,18 +858,8 @@ ev_window_popup_password_dialog (EvWindow *ev_window)
}
static void
-ev_window_clear_jobs (EvWindow *ev_window)
+ev_window_clear_xfer_job (EvWindow *ev_window)
{
- if (ev_window->priv->load_job != NULL) {
-
- if (!ev_window->priv->load_job->finished)
- ev_job_queue_remove_job (ev_window->priv->load_job);
-
- g_signal_handlers_disconnect_by_func (ev_window->priv->load_job, ev_window_load_job_cb, ev_window);
- g_object_unref (ev_window->priv->load_job);
- ev_window->priv->load_job = NULL;
- }
-
if (ev_window->priv->xfer_job != NULL) {
if (!ev_window->priv->xfer_job->finished)
@@ -989,14 +896,12 @@ ev_window_clear_local_uri (EvWindow *ev_window)
* function should _not_ necessarily expect those to exist after being
* called. */
static void
-ev_window_load_job_cb (EvJobLoad *job,
+ev_window_xfer_job_cb (EvJobXfer *job,
gpointer data)
{
EvWindow *ev_window = EV_WINDOW (data);
EvDocument *document = EV_JOB (job)->document;
- g_assert (document);
- g_assert (document != ev_window->priv->document);
g_assert (job->uri);
ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
@@ -1008,6 +913,16 @@ ev_window_load_job_cb (EvJobLoad *job,
/* Success! */
if (job->error == NULL) {
+
+ g_free (ev_window->priv->uri);
+ ev_window->priv->uri = g_strdup (job->uri);
+ setup_view_from_metadata (ev_window);
+
+ if (job->local_uri) {
+ ev_window->priv->local_uri = g_strdup (job->local_uri);
+ } else {
+ ev_window->priv->local_uri = NULL;
+ }
if (ev_window->priv->document)
g_object_unref (ev_window->priv->document);
@@ -1015,7 +930,7 @@ ev_window_load_job_cb (EvJobLoad *job,
ev_window_setup_document (ev_window);
ev_window_add_recent (ev_window, ev_window->priv->uri);
- ev_window_clear_jobs (ev_window);
+ ev_window_clear_xfer_job (ev_window);
return;
}
@@ -1024,6 +939,10 @@ ev_window_load_job_cb (EvJobLoad *job,
job->error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
gchar *base_name, *file_name;
+ g_free (ev_window->priv->uri);
+ ev_window->priv->uri = g_strdup (job->uri);
+ setup_view_from_metadata (ev_window);
+
ev_window->priv->password_document = g_object_ref (document);
file_name = gnome_vfs_format_uri_for_display (job->uri);
@@ -1037,48 +956,12 @@ ev_window_load_job_cb (EvJobLoad *job,
ev_window_popup_password_dialog (ev_window);
} else {
unable_to_load (ev_window, job->error->message);
+ ev_window_clear_xfer_job (ev_window);
}
return;
}
-static void
-ev_window_xfer_job_cb (EvJobXfer *job,
- gpointer data)
-{
- EvWindow *ev_window = EV_WINDOW (data);
-
-
-
- if (job->error != NULL) {
- unable_to_load (ev_window, job->error->message);
- ev_window_clear_jobs (ev_window);
- ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
- } else {
- char *uri;
-
- EvDocument *document = g_object_ref (EV_JOB (job)->document);
-
- if (job->local_uri) {
- ev_window->priv->local_uri = g_strdup (job->local_uri);
- uri = ev_window->priv->local_uri;
- } else {
- ev_window->priv->local_uri = NULL;
- uri = ev_window->priv->uri;
- }
-
- ev_window_clear_jobs (ev_window);
-
- ev_window->priv->load_job = ev_job_load_new (document, uri);
- g_signal_connect (ev_window->priv->load_job,
- "finished",
- G_CALLBACK (ev_window_load_job_cb),
- ev_window);
- ev_job_queue_add_job (ev_window->priv->load_job, EV_JOB_PRIORITY_HIGH);
- g_object_unref (document);
- }
-}
-
const char *
ev_window_get_uri (EvWindow *ev_window)
{
@@ -1109,14 +992,11 @@ ev_window_close_dialogs (EvWindow *ev_window)
void
ev_window_open_uri (EvWindow *ev_window, const char *uri)
{
-
g_free (ev_window->priv->uri);
- ev_window->priv->uri = g_strdup (uri);
-
- setup_view_from_metadata (ev_window);
+ ev_window->priv->uri = NULL;
ev_window_close_dialogs (ev_window);
- ev_window_clear_jobs (ev_window);
+ ev_window_clear_xfer_job (ev_window);
ev_window_clear_local_uri (ev_window);
ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE);
@@ -1454,6 +1334,84 @@ ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window)
}
static void
+ev_window_cmd_focus_page_selector (GtkAction *act, EvWindow *window)
+{
+ GtkAction *action;
+
+ update_chrome_flag (window, EV_CHROME_RAISE_TOOLBAR, TRUE);
+ ev_window_set_action_sensitive (window, "ViewToolbar", FALSE);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ PAGE_SELECTOR_ACTION);
+ ev_page_action_grab_focus (EV_PAGE_ACTION (action));
+}
+
+static void
+ev_window_cmd_scroll_forward (GtkAction *action, EvWindow *window)
+{
+ ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_FORWARD, FALSE);
+}
+
+static void
+ev_window_cmd_scroll_backward (GtkAction *action, EvWindow *window)
+{
+ ev_view_scroll (EV_VIEW (window->priv->view), EV_SCROLL_PAGE_BACKWARD, FALSE);
+}
+
+static void
+ev_window_cmd_continuous (GtkAction *action, EvWindow *ev_window)
+{
+ gboolean continuous;
+
+ ev_window_stop_presentation (ev_window);
+ continuous = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_object_set (G_OBJECT (ev_window->priv->view),
+ "continuous", continuous,
+ NULL);
+ ev_window_update_actions (ev_window);
+}
+
+static void
+ev_window_cmd_dual (GtkAction *action, EvWindow *ev_window)
+{
+ gboolean dual_page;
+
+ ev_window_stop_presentation (ev_window);
+ dual_page = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_object_set (G_OBJECT (ev_window->priv->view),
+ "dual-page", dual_page,
+ NULL);
+ ev_window_update_actions (ev_window);
+}
+
+static void
+ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
+{
+ ev_window_stop_presentation (ev_window);
+
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_BEST_FIT);
+ } else {
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
+ }
+ ev_window_update_actions (ev_window);
+}
+
+static void
+ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
+{
+ ev_window_stop_presentation (ev_window);
+
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FIT_WIDTH);
+ } else {
+ ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
+ }
+ ev_window_update_actions (ev_window);
+}
+
+
+static void
ev_window_cmd_edit_select_all (GtkAction *action, EvWindow *ev_window)
{
g_return_if_fail (EV_IS_WINDOW (ev_window));
@@ -2745,8 +2703,8 @@ ev_window_dispose (GObject *object)
priv->view = NULL;
}
- if (priv->load_job || priv->xfer_job) {
- ev_window_clear_jobs (window);
+ if (priv->xfer_job) {
+ ev_window_clear_xfer_job (window);
}
if (priv->local_uri) {
diff --git a/thumbnailer/evince-thumbnailer.c b/thumbnailer/evince-thumbnailer.c
index 8c79ae9..1c0ba0b 100644
--- a/thumbnailer/evince-thumbnailer.c
+++ b/thumbnailer/evince-thumbnailer.c
@@ -36,22 +36,23 @@ evince_thumbnail_pngenc_get (const char *uri, const char *thumbnail, int size)
EvDocument *document = NULL;
GError *error = NULL;
GdkPixbuf *pixbuf;
- char *mime_type = NULL;
- document = ev_document_factory_get_document (uri, &mime_type, &error);
+ document = ev_document_factory_get_document (uri, &error);
- if (document == NULL || error) {
- return FALSE;
- }
-
- if (!ev_document_load (document, uri, &error)) {
+ if (error) {
if (error->domain == EV_DOCUMENT_ERROR &&
- error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
+ error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
/* FIXME: Create a thumb for cryp docs */
+ g_error_free (error);
+ return FALSE;
}
g_error_free (error);
return FALSE;
}
+
+ if (document == NULL) {
+ return FALSE;
+ }
if (!EV_IS_DOCUMENT_THUMBNAILS (document)) {
return FALSE;