Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/ev-sidebar-attachments.c
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2008-08-22 09:59:16 (GMT)
committer Carlos Garcia Campos <carlosgc@src.gnome.org>2008-08-22 09:59:16 (GMT)
commit27dce4e648c04fc784527610af77c30cf1318111 (patch)
tree184ed8835fab88c7bfbc1a7bd4263f3e9fc3d993 /shell/ev-sidebar-attachments.c
parent614124da1fe2cff8e085faad88320d0dcf4269ad (diff)
Add a new job to get the attachments in a thread with the document lock
2008-08-22 Carlos Garcia Campos <carlosgc@gnome.org> * shell/ev-jobs.[ch]: (ev_job_attachments_init), (ev_job_attachments_dispose), (ev_job_attachments_run), (ev_job_attachments_class_init), (ev_job_attachments_new): * shell/ev-sidebar-attachments.c: (ev_sidebar_attachments_set_document): Add a new job to get the attachments in a thread with the document lock held. Fixes bug #548653. svn path=/trunk/; revision=3116
Diffstat (limited to 'shell/ev-sidebar-attachments.c')
-rw-r--r--shell/ev-sidebar-attachments.c64
1 files changed, 39 insertions, 25 deletions
diff --git a/shell/ev-sidebar-attachments.c b/shell/ev-sidebar-attachments.c
index 1b2be06..fa64fbc 100644
--- a/shell/ev-sidebar-attachments.c
+++ b/shell/ev-sidebar-attachments.c
@@ -31,6 +31,8 @@
#include <glib/gstdio.h>
#include <gtk/gtk.h>
+#include "ev-jobs.h"
+#include "ev-job-scheduler.h"
#include "ev-file-helpers.h"
#include "ev-sidebar-attachments.h"
#include "ev-sidebar-page.h"
@@ -613,32 +615,12 @@ ev_sidebar_attachments_new (void)
}
static void
-ev_sidebar_attachments_set_document (EvSidebarPage *page,
- EvDocument *document)
+job_finished_callback (EvJobAttachments *job,
+ EvSidebarAttachments *ev_attachbar)
{
- EvSidebarAttachments *ev_attachbar = EV_SIDEBAR_ATTACHMENTS (page);
- GList *attachments = NULL;
GList *l;
- if (!ev_document_has_attachments (document))
- return;
-
- if (!ev_attachbar->priv->icon_theme) {
- GdkScreen *screen;
-
- screen = gtk_widget_get_screen (GTK_WIDGET (ev_attachbar));
- ev_attachbar->priv->icon_theme = gtk_icon_theme_get_for_screen (screen);
- g_signal_connect_swapped (G_OBJECT (ev_attachbar->priv->icon_theme),
- "changed",
- G_CALLBACK (ev_sidebar_attachments_update_icons),
- (gpointer) ev_attachbar);
- }
-
- attachments = ev_document_get_attachments (document);
-
- gtk_list_store_clear (ev_attachbar->priv->model);
-
- for (l = attachments; l && l->data; l = g_list_next (l)) {
+ for (l = job->attachments; l && l->data; l = g_list_next (l)) {
EvAttachment *attachment;
GtkTreeIter iter;
GdkPixbuf *pixbuf = NULL;
@@ -656,11 +638,43 @@ ev_sidebar_attachments_set_document (EvSidebarPage *page,
COLUMN_ICON, pixbuf,
COLUMN_ATTACHMENT, attachment,
-1);
+ }
- g_object_unref (attachment);
+ g_object_unref (job);
+}
+
+static void
+ev_sidebar_attachments_set_document (EvSidebarPage *page,
+ EvDocument *document)
+{
+ EvSidebarAttachments *ev_attachbar = EV_SIDEBAR_ATTACHMENTS (page);
+ EvJob *job;
+
+ if (!ev_document_has_attachments (document))
+ return;
+
+ if (!ev_attachbar->priv->icon_theme) {
+ GdkScreen *screen;
+
+ screen = gtk_widget_get_screen (GTK_WIDGET (ev_attachbar));
+ ev_attachbar->priv->icon_theme = gtk_icon_theme_get_for_screen (screen);
+ g_signal_connect_swapped (G_OBJECT (ev_attachbar->priv->icon_theme),
+ "changed",
+ G_CALLBACK (ev_sidebar_attachments_update_icons),
+ (gpointer) ev_attachbar);
}
+
+ gtk_list_store_clear (ev_attachbar->priv->model);
- g_list_free (attachments);
+ job = ev_job_attachments_new (document);
+ g_signal_connect (job, "finished",
+ G_CALLBACK (job_finished_callback),
+ ev_attachbar);
+ g_signal_connect (job, "cancelled",
+ G_CALLBACK (g_object_unref),
+ NULL);
+ /* The priority doesn't matter for this job */
+ ev_job_scheduler_push_job (job, EV_JOB_PRIORITY_NONE);
}
static gboolean