X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-sidebar-attachments.c;h=44c027f5baa63bb22981fdefb900a9eea2c05623;hb=63e5b30126ea0dc16cf1e85193aacd294854c87f;hp=11305334fb93ba1a200bc7cb68bc69cea8892134;hpb=3e7d5f82187c7fc0d8515c1706aeab0bd0b44dfd;p=evince.git diff --git a/shell/ev-sidebar-attachments.c b/shell/ev-sidebar-attachments.c index 11305334..44c027f5 100644 --- a/shell/ev-sidebar-attachments.c +++ b/shell/ev-sidebar-attachments.c @@ -26,10 +26,13 @@ #endif #include + #include #include #include +#include "ev-jobs.h" +#include "ev-job-scheduler.h" #include "ev-file-helpers.h" #include "ev-sidebar-attachments.h" #include "ev-sidebar-page.h" @@ -292,7 +295,10 @@ ev_sidebar_attachments_button_press (EvSidebarAttachments *ev_attachbar, if (!attachment) return FALSE; - ev_attachment_open (attachment, &error); + ev_attachment_open (attachment, + gtk_widget_get_screen (GTK_WIDGET (ev_attachbar)), + event->time, + &error); if (error) { g_warning ("%s", error->message); @@ -612,32 +618,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; @@ -655,11 +641,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