X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=inline;f=shell%2Fev-sidebar-attachments.c;h=44c027f5baa63bb22981fdefb900a9eea2c05623;hb=63e5b30126ea0dc16cf1e85193aacd294854c87f;hp=1b2be06d79a30f58789c16170b3439f4ed97cf70;hpb=75d6ca169171f642ba7438e648b4529638bf90c3;p=evince.git diff --git a/shell/ev-sidebar-attachments.c b/shell/ev-sidebar-attachments.c index 1b2be06d..44c027f5 100644 --- a/shell/ev-sidebar-attachments.c +++ b/shell/ev-sidebar-attachments.c @@ -31,6 +31,8 @@ #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" @@ -293,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); @@ -613,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; @@ -656,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