~ubuntu-branches/ubuntu/oneiric/evince/oneiric-updates

« back to all changes in this revision

Viewing changes to shell/ev-sidebar-attachments.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette, Josselin Mouette, Marc 'HE' Brockschmidt
  • Date: 2008-12-31 16:41:58 UTC
  • mfrom: (1.1.36 upstream)
  • mto: (1.5.1 sid)
  • mto: This revision was merged to the branch mainline in revision 109.
  • Revision ID: james.westby@ubuntu.com-20081231164158-xnobl1sokvvc6ho8
Tags: 2.24.2-1
[ Josselin Mouette ]
* README.Debian: document that you need to install poppler-data.
  Closes: #506836.

[ Marc 'HE' Brockschmidt ]
* debian/control: Make the Gnome team maintainer. I'm not doing the job
   anyway.

[ Josselin Mouette ]
* New upstream release.
* Require nautilus 2.22 to build the extension for the correct 
  version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "config.h"
26
26
#endif
27
27
 
 
28
#include <string.h>
 
29
 
28
30
#include <glib/gi18n.h>
29
31
#include <glib/gstdio.h>
30
32
#include <gtk/gtk.h>
31
 
#include <string.h>
32
33
 
 
34
#include "ev-jobs.h"
 
35
#include "ev-job-scheduler.h"
33
36
#include "ev-file-helpers.h"
34
37
#include "ev-sidebar-attachments.h"
35
38
#include "ev-sidebar-page.h"
292
295
                                if (!attachment)
293
296
                                        return FALSE;
294
297
                                
295
 
                                ev_attachment_open (attachment, &error);
 
298
                                ev_attachment_open (attachment,
 
299
                                                    gtk_widget_get_screen (GTK_WIDGET (ev_attachbar)),
 
300
                                                    event->time,
 
301
                                                    &error);
296
302
                                
297
303
                                if (error) {
298
 
                                        g_warning (error->message);
 
304
                                        g_warning ("%s", error->message);
299
305
                                        g_error_free (error);
300
306
                                }
301
307
                                
434
440
                }
435
441
        
436
442
                if (error) {
437
 
                        g_warning (error->message);
 
443
                        g_warning ("%s", error->message);
438
444
                        g_error_free (error);
439
445
                }
440
446
 
612
618
}
613
619
 
614
620
static void
 
621
job_finished_callback (EvJobAttachments     *job,
 
622
                       EvSidebarAttachments *ev_attachbar)
 
623
{
 
624
        GList *l;
 
625
        
 
626
        for (l = job->attachments; l && l->data; l = g_list_next (l)) {
 
627
                EvAttachment *attachment;
 
628
                GtkTreeIter   iter;
 
629
                GdkPixbuf    *pixbuf = NULL;
 
630
                const gchar  *mime_type;
 
631
 
 
632
                attachment = EV_ATTACHMENT (l->data);
 
633
 
 
634
                mime_type = ev_attachment_get_mime_type (attachment);
 
635
                pixbuf = ev_sidebar_attachments_icon_cache_get (ev_attachbar,
 
636
                                                                mime_type);
 
637
 
 
638
                gtk_list_store_append (ev_attachbar->priv->model, &iter);
 
639
                gtk_list_store_set (ev_attachbar->priv->model, &iter,
 
640
                                    COLUMN_NAME, ev_attachment_get_name (attachment),
 
641
                                    COLUMN_ICON, pixbuf,
 
642
                                    COLUMN_ATTACHMENT, attachment, 
 
643
                                    -1);
 
644
        }
 
645
 
 
646
        g_object_unref (job);
 
647
}
 
648
 
 
649
static void
615
650
ev_sidebar_attachments_set_document (EvSidebarPage   *page,
616
651
                                     EvDocument      *document)
617
652
{
618
653
        EvSidebarAttachments *ev_attachbar = EV_SIDEBAR_ATTACHMENTS (page);
619
 
        GList *attachments = NULL;
620
 
        GList *l;
 
654
        EvJob *job;
621
655
        
622
656
        if (!ev_document_has_attachments (document))
623
657
                return;
633
667
                                          (gpointer) ev_attachbar);
634
668
        }
635
669
                
636
 
        attachments = ev_document_get_attachments (document);
637
 
 
638
670
        gtk_list_store_clear (ev_attachbar->priv->model);
639
 
                                           
640
 
        for (l = attachments; l && l->data; l = g_list_next (l)) {
641
 
                EvAttachment *attachment;
642
 
                GtkTreeIter   iter;
643
 
                GdkPixbuf    *pixbuf = NULL;
644
 
                const gchar  *mime_type;
645
 
 
646
 
                attachment = EV_ATTACHMENT (l->data);
647
 
 
648
 
                mime_type = ev_attachment_get_mime_type (attachment);
649
 
                pixbuf = ev_sidebar_attachments_icon_cache_get (ev_attachbar,
650
 
                                                                mime_type);
651
 
 
652
 
                gtk_list_store_append (ev_attachbar->priv->model, &iter);
653
 
                gtk_list_store_set (ev_attachbar->priv->model, &iter,
654
 
                                    COLUMN_NAME, ev_attachment_get_name (attachment),
655
 
                                    COLUMN_ICON, pixbuf,
656
 
                                    COLUMN_ATTACHMENT, attachment, 
657
 
                                    -1);
658
 
 
659
 
                g_object_unref (attachment);
660
 
        }
661
 
 
662
 
        g_list_free (attachments);
 
671
 
 
672
        job = ev_job_attachments_new (document);
 
673
        g_signal_connect (job, "finished",
 
674
                          G_CALLBACK (job_finished_callback),
 
675
                          ev_attachbar);
 
676
        g_signal_connect (job, "cancelled",
 
677
                          G_CALLBACK (g_object_unref),
 
678
                          NULL);
 
679
        /* The priority doesn't matter for this job */
 
680
        ev_job_scheduler_push_job (job, EV_JOB_PRIORITY_NONE);
663
681
}
664
682
 
665
683
static gboolean