]> www.fi.muni.cz Git - evince.git/blob - shell/ev-sidebar-attachments.c
Translation updated.
[evince.git] / shell / ev-sidebar-attachments.c
1 /* ev-sidebar-attachments.c
2  *  this file is part of evince, a gnome document viewer
3  *
4  * Copyright (C) 2006 Carlos Garcia Campos
5  *
6  * Author:
7  *   Carlos Garcia Campos <carlosgc@gnome.org>
8  *
9  * Evince is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Evince is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  */
23
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28 #include <glib/gi18n.h>
29 #include <glib/gstdio.h>
30 #include <gtk/gtk.h>
31 #include <string.h>
32 #include <libgnomeui/gnome-icon-lookup.h>
33
34 #include "ev-sidebar-attachments.h"
35 #include "ev-sidebar-page.h"
36
37 enum {
38         COLUMN_ICON,
39         COLUMN_NAME,
40         COLUMN_DESCRIPTION,
41         COLUMN_ATTACHMENT,
42         N_COLS
43 };
44
45 enum {
46         PROP_0,
47         PROP_WIDGET,
48 };
49
50 enum {
51         SIGNAL_POPUP_MENU,
52         N_SIGNALS
53 };
54
55 static const GtkTargetEntry drag_targets[] = {
56         { "text/uri-list", 0, 0 }
57 };
58
59 static guint signals[N_SIGNALS];
60
61 struct _EvSidebarAttachmentsPrivate {
62         GtkWidget      *icon_view;
63         GtkListStore   *model;
64
65         /* Icons */
66         GtkIconTheme   *icon_theme;
67         GHashTable     *icon_cache;
68 };
69
70 static void ev_sidebar_attachments_page_iface_init (EvSidebarPageIface *iface);
71
72 G_DEFINE_TYPE_EXTENDED (EvSidebarAttachments,
73                         ev_sidebar_attachments,
74                         GTK_TYPE_VBOX,
75                         0, 
76                         G_IMPLEMENT_INTERFACE (EV_TYPE_SIDEBAR_PAGE, 
77                                                ev_sidebar_attachments_page_iface_init))
78
79 #define EV_SIDEBAR_ATTACHMENTS_GET_PRIVATE(object) \
80                 (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR_ATTACHMENTS, EvSidebarAttachmentsPrivate))
81
82 /* Icon cache */
83 static void
84 ev_sidebar_attachments_icon_cache_add (EvSidebarAttachments *ev_attachbar,
85                                        const gchar          *mime_type,
86                                        const GdkPixbuf      *pixbuf)
87 {
88         g_assert (mime_type != NULL);
89         g_assert (GDK_IS_PIXBUF (pixbuf));
90
91         g_hash_table_insert (ev_attachbar->priv->icon_cache,
92                              (gpointer)g_strdup (mime_type),
93                              (gpointer)pixbuf);
94                              
95 }
96
97 static GdkPixbuf *
98 icon_theme_get_pixbuf_from_mime_type (GtkIconTheme *icon_theme,
99                                       const gchar  *mime_type)
100 {
101         GdkPixbuf *pixbuf = NULL;
102         gchar     *icon;
103
104         icon = gnome_icon_lookup (icon_theme,
105                                   NULL, NULL,
106                                   NULL, NULL,
107                                   mime_type,
108                                   GNOME_ICON_LOOKUP_FLAGS_NONE,
109                                   NULL);
110
111         pixbuf = gtk_icon_theme_load_icon (icon_theme,
112                                            icon, 48, 0, NULL);
113         g_free (icon);
114
115         return pixbuf;
116 }
117
118 static GdkPixbuf *
119 ev_sidebar_attachments_icon_cache_get (EvSidebarAttachments *ev_attachbar,
120                                        const gchar          *mime_type)
121 {
122         GdkPixbuf *pixbuf = NULL;
123         
124         g_assert (mime_type != NULL);
125
126         pixbuf = g_hash_table_lookup (ev_attachbar->priv->icon_cache,
127                                       mime_type);
128
129         if (GDK_IS_PIXBUF (pixbuf))
130                 return pixbuf;
131
132         pixbuf = icon_theme_get_pixbuf_from_mime_type (ev_attachbar->priv->icon_theme,
133                                                        mime_type);
134
135         if (GDK_IS_PIXBUF (pixbuf))
136                 ev_sidebar_attachments_icon_cache_add (ev_attachbar,
137                                                        mime_type,
138                                                        pixbuf);
139
140         return pixbuf;
141 }
142
143 static gboolean
144 icon_cache_update_icon (gchar                *key,
145                         GdkPixbuf            *value,
146                         EvSidebarAttachments *ev_attachbar)
147 {
148         GdkPixbuf *pixbuf = NULL;
149
150         pixbuf = icon_theme_get_pixbuf_from_mime_type (ev_attachbar->priv->icon_theme,
151                                                        key);
152
153         ev_sidebar_attachments_icon_cache_add (ev_attachbar,
154                                                key,
155                                                pixbuf);
156         
157         return FALSE;
158 }
159
160 static void
161 ev_sidebar_attachments_icon_cache_refresh (EvSidebarAttachments *ev_attachbar)
162 {
163         g_hash_table_foreach_remove (ev_attachbar->priv->icon_cache,
164                                      (GHRFunc) icon_cache_update_icon,
165                                      ev_attachbar);
166 }
167
168 static EvAttachment *
169 ev_sidebar_attachments_get_attachment_at_pos (EvSidebarAttachments *ev_attachbar,
170                                               gint                  x,
171                                               gint                  y)
172 {
173         GtkTreePath  *path = NULL;
174         GtkTreeIter   iter;
175         EvAttachment *attachment = NULL;
176
177         path = gtk_icon_view_get_path_at_pos (GTK_ICON_VIEW (ev_attachbar->priv->icon_view),
178                                               x, y);
179         if (!path) {
180                 return NULL;
181         }
182
183         gtk_tree_model_get_iter (GTK_TREE_MODEL (ev_attachbar->priv->model),
184                                  &iter, path);
185         gtk_tree_model_get (GTK_TREE_MODEL (ev_attachbar->priv->model), &iter,
186                             COLUMN_ATTACHMENT, &attachment,
187                             -1);
188
189         gtk_icon_view_select_path (GTK_ICON_VIEW (ev_attachbar->priv->icon_view),
190                                    path);
191         
192         gtk_tree_path_free (path);
193
194         return attachment;
195 }
196
197 static gboolean
198 ev_sidebar_attachments_popup_menu_show (EvSidebarAttachments *ev_attachbar,
199                                         gint                  x,
200                                         gint                  y)
201 {
202         GtkIconView *icon_view;
203         GtkTreePath *path;
204         GList       *selected = NULL, *l;
205         GList       *attach_list = NULL;
206
207         icon_view = GTK_ICON_VIEW (ev_attachbar->priv->icon_view);
208         
209         path = gtk_icon_view_get_path_at_pos (icon_view, x, y);
210         if (!path)
211                 return FALSE;
212
213         if (!gtk_icon_view_path_is_selected (icon_view, path)) {
214                 gtk_icon_view_unselect_all (icon_view);
215                 gtk_icon_view_select_path (icon_view, path);
216         }
217
218         gtk_tree_path_free (path);
219         
220         selected = gtk_icon_view_get_selected_items (icon_view);
221         if (!selected)
222                 return FALSE;
223
224         for (l = selected; l && l->data; l = g_list_next (l)) {
225                 GtkTreeIter   iter;
226                 EvAttachment *attachment = NULL;
227
228                 path = (GtkTreePath *) l->data;
229
230                 gtk_tree_model_get_iter (GTK_TREE_MODEL (ev_attachbar->priv->model),
231                                          &iter, path);
232                 gtk_tree_model_get (GTK_TREE_MODEL (ev_attachbar->priv->model), &iter,
233                                     COLUMN_ATTACHMENT, &attachment,
234                                     -1);
235
236                 if (attachment)
237                         attach_list = g_list_prepend (attach_list, attachment);
238
239                 gtk_tree_path_free (path);
240         }
241
242         g_list_free (selected);
243
244         if (!attach_list)
245                 return FALSE;
246
247         g_signal_emit (ev_attachbar, signals[SIGNAL_POPUP_MENU], 0, attach_list);
248
249         return TRUE;
250 }
251
252 static gboolean
253 ev_sidebar_attachments_popup_menu (GtkWidget *widget)
254 {
255         EvSidebarAttachments *ev_attachbar = EV_SIDEBAR_ATTACHMENTS (widget);
256         gint                  x, y;
257
258         gtk_widget_get_pointer (widget, &x, &y);
259
260         return ev_sidebar_attachments_popup_menu_show (ev_attachbar, x, y);
261 }
262
263 static gboolean
264 ev_sidebar_attachments_button_press (EvSidebarAttachments *ev_attachbar,
265                                      GdkEventButton       *event,
266                                      GtkWidget            *icon_view)
267 {
268         if (!GTK_WIDGET_HAS_FOCUS (icon_view)) {
269                 gtk_widget_grab_focus (icon_view);
270         }
271         
272         if (event->button == 2)
273                 return FALSE;
274
275         switch (event->button) {
276                 case 1:
277                         if (event->type == GDK_2BUTTON_PRESS) {
278                                 GError *error = NULL;
279                                 EvAttachment *attachment;
280                                 
281                                 attachment = ev_sidebar_attachments_get_attachment_at_pos (ev_attachbar,
282                                                                                            event->x,
283                                                                                            event->y);
284                                 if (!attachment)
285                                         return FALSE;
286                                 
287                                 ev_attachment_open (attachment, &error);
288                                 
289                                 if (error) {
290                                         g_warning (error->message);
291                                         g_error_free (error);
292                                 }
293                                 
294                                 g_object_unref (attachment);
295                                 
296                                 return TRUE;
297                         }
298                         break;
299                 case 3: 
300                         return ev_sidebar_attachments_popup_menu_show (ev_attachbar, event->x, event->y);
301         }
302
303         return FALSE;
304 }
305
306 static void
307 ev_sidebar_attachments_update_icons (EvSidebarAttachments *ev_attachbar,
308                                      gpointer              user_data)
309 {
310         GtkTreeIter iter;
311         gboolean    valid;
312
313         ev_sidebar_attachments_icon_cache_refresh (ev_attachbar);
314         
315         valid = gtk_tree_model_get_iter_first (
316                 GTK_TREE_MODEL (ev_attachbar->priv->model),
317                 &iter);
318
319         while (valid) {
320                 EvAttachment *attachment = NULL;
321                 GdkPixbuf    *pixbuf = NULL;
322                 const gchar  *mime_type;
323
324                 gtk_tree_model_get (GTK_TREE_MODEL (ev_attachbar->priv->model), &iter,
325                                     COLUMN_ATTACHMENT, &attachment,
326                                     -1);
327
328                 mime_type = ev_attachment_get_mime_type (attachment);
329
330                 if (attachment)
331                         g_object_unref (attachment);
332
333                 pixbuf = ev_sidebar_attachments_icon_cache_get (ev_attachbar,
334                                                                 mime_type);
335
336                 gtk_list_store_set (ev_attachbar->priv->model, &iter,
337                                     COLUMN_ICON, pixbuf,
338                                     -1);
339
340                 valid = gtk_tree_model_iter_next (
341                         GTK_TREE_MODEL (ev_attachbar->priv->model),
342                         &iter);
343         }
344 }
345
346 static void
347 ev_sidebar_attachments_screen_changed (GtkWidget *widget,
348                                        GdkScreen *old_screen)
349 {
350         EvSidebarAttachments *ev_attachbar = EV_SIDEBAR_ATTACHMENTS (widget);
351         GdkScreen            *screen;
352
353         if (!ev_attachbar->priv->icon_theme)
354                 return;
355         
356         screen = gtk_widget_get_screen (widget);
357         if (screen == old_screen)
358                 return;
359
360         if (old_screen) {
361                 g_signal_handlers_disconnect_by_func (
362                         gtk_icon_theme_get_for_screen (old_screen),
363                         G_CALLBACK (ev_sidebar_attachments_update_icons),
364                         ev_attachbar);
365         }
366
367         ev_attachbar->priv->icon_theme = gtk_icon_theme_get_for_screen (screen);
368         g_signal_connect_swapped (ev_attachbar->priv->icon_theme,
369                                   "changed",
370                                   G_CALLBACK (ev_sidebar_attachments_update_icons),
371                                   (gpointer) ev_attachbar);
372
373         if (GTK_WIDGET_CLASS (ev_sidebar_attachments_parent_class)->screen_changed) {
374                 GTK_WIDGET_CLASS (ev_sidebar_attachments_parent_class)->screen_changed (widget, old_screen);
375         }
376 }
377
378 static void
379 ev_sidebar_attachments_drag_data_get (GtkWidget        *widget,
380                                       GdkDragContext   *drag_context,
381                                       GtkSelectionData *data,
382                                       guint             info,
383                                       guint             time,
384                                       gpointer          user_data)
385 {
386         EvSidebarAttachments *ev_attachbar = EV_SIDEBAR_ATTACHMENTS (user_data);
387         GString              *uri_list;
388         gchar                *uris = NULL;
389         GList                *selected = NULL, *l;
390
391         selected = gtk_icon_view_get_selected_items (GTK_ICON_VIEW (ev_attachbar->priv->icon_view));
392         if (!selected)
393                 return;
394
395         uri_list = g_string_new (NULL);
396         
397         for (l = selected; l && l->data; l = g_list_next (l)) {
398                 EvAttachment *attachment;
399                 GtkTreePath  *path;
400                 GtkTreeIter   iter;
401                 gchar        *uri, *filename;
402                 GError       *error = NULL;
403                 
404                 path = (GtkTreePath *) l->data;
405
406                 gtk_tree_model_get_iter (GTK_TREE_MODEL (ev_attachbar->priv->model),
407                                          &iter, path);
408                 gtk_tree_model_get (GTK_TREE_MODEL (ev_attachbar->priv->model), &iter,
409                                     COLUMN_ATTACHMENT, &attachment,
410                                     -1);
411
412                 filename = g_build_filename (g_get_tmp_dir (),
413                                              ev_attachment_get_name (attachment),
414                                              NULL);
415                 
416                 uri = g_filename_to_uri (filename, NULL, NULL);
417
418                 if (ev_attachment_save (attachment, filename, &error)) {
419                         g_string_append (uri_list, uri);
420                         g_string_append_c (uri_list, '\n');
421                 }
422         
423                 if (error) {
424                         g_warning (error->message);
425                         g_error_free (error);
426                 }
427
428                 g_free (uri);
429                 gtk_tree_path_free (path);
430                 g_object_unref (attachment);
431         }
432
433         uris = g_string_free (uri_list, FALSE);
434
435         if (uris) {
436                 gtk_selection_data_set (data,
437                                         data->target,
438                                         8,
439                                         (guchar *)uris,
440                                         strlen (uris));
441         }
442
443         g_list_free (selected);
444 }
445
446 static void
447 ev_sidebar_attachments_get_property (GObject    *object,
448                                      guint       prop_id,
449                                      GValue     *value,
450                                      GParamSpec *pspec)
451 {
452         EvSidebarAttachments *ev_sidebar_attachments;
453   
454         ev_sidebar_attachments = EV_SIDEBAR_ATTACHMENTS (object);
455
456         switch (prop_id) {
457                 case PROP_WIDGET:
458                         g_value_set_object (value, ev_sidebar_attachments->priv->icon_view);
459                         break;
460                 default:
461                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
462                         break;
463         }
464 }
465
466 static void
467 ev_sidebar_attachments_destroy (GtkObject *object)
468 {
469         EvSidebarAttachments *ev_attachbar = EV_SIDEBAR_ATTACHMENTS (object);
470
471         if (ev_attachbar->priv->icon_theme) {
472                 g_signal_handlers_disconnect_by_func (
473                         ev_attachbar->priv->icon_theme, 
474                         G_CALLBACK (ev_sidebar_attachments_update_icons),
475                         ev_attachbar);
476                 ev_attachbar->priv->icon_theme = NULL;
477         }
478         
479         if (ev_attachbar->priv->model) {
480                 g_object_unref (ev_attachbar->priv->model);
481                 ev_attachbar->priv->model = NULL;
482         }
483
484         if (ev_attachbar->priv->icon_cache) {
485                 g_hash_table_destroy (ev_attachbar->priv->icon_cache);
486                 ev_attachbar->priv->icon_cache = NULL;
487         }
488
489         (* GTK_OBJECT_CLASS (ev_sidebar_attachments_parent_class)->destroy) (object);
490 }
491
492 static void
493 ev_sidebar_attachments_class_init (EvSidebarAttachmentsClass *ev_attachbar_class)
494 {
495         GObjectClass   *g_object_class;
496         GtkObjectClass *gtk_object_class;
497         GtkWidgetClass *gtk_widget_class;
498
499         g_object_class = G_OBJECT_CLASS (ev_attachbar_class);
500         gtk_object_class = GTK_OBJECT_CLASS (ev_attachbar_class);
501         gtk_widget_class = GTK_WIDGET_CLASS (ev_attachbar_class);
502
503         g_object_class->get_property = ev_sidebar_attachments_get_property;
504         gtk_object_class->destroy = ev_sidebar_attachments_destroy;
505         gtk_widget_class->popup_menu = ev_sidebar_attachments_popup_menu;
506         gtk_widget_class->screen_changed = ev_sidebar_attachments_screen_changed;
507
508         g_type_class_add_private (g_object_class, sizeof (EvSidebarAttachmentsPrivate));
509
510         /* Signals */
511         signals[SIGNAL_POPUP_MENU] =
512                 g_signal_new ("popup",
513                               G_TYPE_FROM_CLASS (g_object_class),
514                               G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
515                               G_STRUCT_OFFSET (EvSidebarAttachmentsClass, popup_menu),
516                               NULL, NULL,
517                               g_cclosure_marshal_VOID__POINTER,
518                               G_TYPE_NONE, 1,
519                               G_TYPE_POINTER);
520
521         g_object_class_override_property (g_object_class,
522                                           PROP_WIDGET,
523                                           "main-widget");
524 }
525
526 static void
527 ev_sidebar_attachments_init (EvSidebarAttachments *ev_attachbar)
528 {
529         GtkWidget *swindow;
530         
531         ev_attachbar->priv = EV_SIDEBAR_ATTACHMENTS_GET_PRIVATE (ev_attachbar);
532
533         swindow = gtk_scrolled_window_new (NULL, NULL);
534         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
535                                         GTK_POLICY_NEVER,
536                                         GTK_POLICY_AUTOMATIC);
537         gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swindow),
538                                              GTK_SHADOW_IN);
539         /* Data Model */
540         ev_attachbar->priv->model = gtk_list_store_new (N_COLS,
541                                                         GDK_TYPE_PIXBUF, 
542                                                         G_TYPE_STRING,  
543                                                         G_TYPE_STRING,
544                                                         EV_TYPE_ATTACHMENT);
545
546         /* Icon View */
547         ev_attachbar->priv->icon_view =
548                 gtk_icon_view_new_with_model (GTK_TREE_MODEL (ev_attachbar->priv->model));
549         gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (ev_attachbar->priv->icon_view),
550                                           GTK_SELECTION_MULTIPLE);
551         gtk_icon_view_set_columns (GTK_ICON_VIEW (ev_attachbar->priv->icon_view), -1);
552         g_object_set (G_OBJECT (ev_attachbar->priv->icon_view),
553                       "text-column", COLUMN_NAME,
554                       "pixbuf-column", COLUMN_ICON,
555                       NULL);
556         g_signal_connect_swapped (G_OBJECT (ev_attachbar->priv->icon_view),
557                                   "button-press-event",
558                                   G_CALLBACK (ev_sidebar_attachments_button_press),
559                                   (gpointer) ev_attachbar);
560
561         gtk_container_add (GTK_CONTAINER (swindow),
562                            ev_attachbar->priv->icon_view);
563
564         gtk_container_add (GTK_CONTAINER (ev_attachbar),
565                            swindow);
566         gtk_widget_show_all (GTK_WIDGET (ev_attachbar));
567
568         /* Icon Theme */
569         ev_attachbar->priv->icon_theme = NULL;
570
571         /* Icon Cache */
572         ev_attachbar->priv->icon_cache = g_hash_table_new_full (g_str_hash,
573                                                                 g_str_equal,
574                                                                 g_free,
575                                                                 g_object_unref);
576
577         /* Drag and Drop */
578         gtk_icon_view_enable_model_drag_source (
579                 GTK_ICON_VIEW (ev_attachbar->priv->icon_view),
580                 GDK_BUTTON1_MASK,
581                 drag_targets,
582                 G_N_ELEMENTS (drag_targets),
583                 GDK_ACTION_COPY);
584
585         g_signal_connect (G_OBJECT (ev_attachbar->priv->icon_view),
586                           "drag-data-get",
587                           G_CALLBACK (ev_sidebar_attachments_drag_data_get),
588                           (gpointer) ev_attachbar);     
589 }
590
591 GtkWidget *
592 ev_sidebar_attachments_new (void)
593 {
594         GtkWidget *ev_attachbar;
595
596         ev_attachbar = g_object_new (EV_TYPE_SIDEBAR_ATTACHMENTS, NULL);
597
598         return ev_attachbar;
599 }
600
601 static void
602 ev_sidebar_attachments_set_document (EvSidebarPage   *page,
603                                      EvDocument      *document)
604 {
605         EvSidebarAttachments *ev_attachbar = EV_SIDEBAR_ATTACHMENTS (page);
606         GList *attachments = NULL;
607         GList *l;
608         
609         if (!ev_document_has_attachments (document))
610                 return;
611
612         if (!ev_attachbar->priv->icon_theme) {
613                 GdkScreen *screen;
614
615                 screen = gtk_widget_get_screen (GTK_WIDGET (ev_attachbar));
616                 ev_attachbar->priv->icon_theme = gtk_icon_theme_get_for_screen (screen);
617                 g_signal_connect_swapped (G_OBJECT (ev_attachbar->priv->icon_theme),
618                                           "changed",
619                                           G_CALLBACK (ev_sidebar_attachments_update_icons),
620                                           (gpointer) ev_attachbar);
621         }
622                 
623         attachments = ev_document_get_attachments (document);
624
625         gtk_list_store_clear (ev_attachbar->priv->model);
626                                            
627         for (l = attachments; l && l->data; l = g_list_next (l)) {
628                 EvAttachment *attachment;
629                 GtkTreeIter   iter;
630                 GdkPixbuf    *pixbuf = NULL;
631                 const gchar  *mime_type;
632
633                 attachment = EV_ATTACHMENT (l->data);
634
635                 mime_type = ev_attachment_get_mime_type (attachment);
636                 pixbuf = ev_sidebar_attachments_icon_cache_get (ev_attachbar,
637                                                                 mime_type);
638
639                 gtk_list_store_append (ev_attachbar->priv->model, &iter);
640                 gtk_list_store_set (ev_attachbar->priv->model, &iter,
641                                     COLUMN_NAME, ev_attachment_get_name (attachment),
642                                     COLUMN_ICON, pixbuf,
643                                     COLUMN_ATTACHMENT, attachment, 
644                                     -1);
645
646                 g_object_unref (attachment);
647         }
648
649         g_list_free (attachments);
650 }
651
652 static gboolean
653 ev_sidebar_attachments_support_document (EvSidebarPage   *sidebar_page,
654                                          EvDocument      *document)
655 {
656         return ev_document_has_attachments (document);
657 }
658
659 static const gchar*
660 ev_sidebar_attachments_get_label (EvSidebarPage *sidebar_page)
661 {
662         return _("Attachments");
663 }
664
665 static void
666 ev_sidebar_attachments_page_iface_init (EvSidebarPageIface *iface)
667 {
668         iface->support_document = ev_sidebar_attachments_support_document;
669         iface->set_document = ev_sidebar_attachments_set_document;
670         iface->get_label = ev_sidebar_attachments_get_label;
671 }
672