]> www.fi.muni.cz Git - evince.git/blob - shell/ev-sidebar-bookmarks.c
[dualscreen] fix crash on ctrl+w and fix control window closing
[evince.git] / shell / ev-sidebar-bookmarks.c
1 /* ev-sidebar-bookmarks.c
2  *  this file is part of evince, a gnome document viewer
3  *
4  * Copyright (C) 2010 Carlos Garcia Campos  <carlosgc@gnome.org>
5  *
6  * Evince is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * Evince is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #include "config.h"
22
23 #include <glib/gi18n.h>
24
25 #include "ev-sidebar-bookmarks.h"
26
27 #include "ev-document.h"
28 #include "ev-sidebar-page.h"
29 #include "ev-utils.h"
30
31 enum {
32         PROP_0,
33         PROP_WIDGET
34 };
35
36 enum {
37         COLUMN_MARKUP,
38         COLUMN_PAGE,
39         N_COLUMNS
40 };
41
42 enum {
43         ADD_BOOKMARK,
44         N_SIGNALS
45 };
46
47 struct _EvSidebarBookmarksPrivate {
48         EvDocumentModel *model;
49         EvBookmarks     *bookmarks;
50
51         GtkWidget       *tree_view;
52         GtkWidget       *del_button;
53         GtkWidget       *add_button;
54
55         /* Popup menu */
56         GtkWidget       *popup;
57         GtkUIManager    *ui_manager;
58         GtkActionGroup  *action_group;
59 };
60
61 static void ev_sidebar_bookmarks_page_iface_init (EvSidebarPageInterface *iface);
62
63 G_DEFINE_TYPE_EXTENDED (EvSidebarBookmarks,
64                         ev_sidebar_bookmarks,
65                         GTK_TYPE_VBOX,
66                         0,
67                         G_IMPLEMENT_INTERFACE (EV_TYPE_SIDEBAR_PAGE,
68                                                ev_sidebar_bookmarks_page_iface_init))
69
70 static guint signals[N_SIGNALS];
71
72 static const gchar popup_menu_ui[] =
73         "<popup name=\"BookmarksPopup\" action=\"BookmarksPopupAction\">\n"
74         "  <menuitem name=\"OpenBookmark\" action=\"OpenBookmark\"/>\n"
75         "  <separator/>\n"
76         "  <menuitem name=\"RenameBookmark\" action=\"RenameBookmark\"/>\n"
77         "  <menuitem name=\"RemoveBookmark\" action=\"RemoveBookmark\"/>\n"
78         "</popup>\n";
79
80 static gint
81 ev_sidebar_bookmarks_get_selected_page (EvSidebarBookmarks *sidebar_bookmarks,
82                                         GtkTreeSelection   *selection)
83 {
84         GtkTreeModel *model;
85         GtkTreeIter   iter;
86
87         if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
88                 guint page;
89
90                 gtk_tree_model_get (model, &iter,
91                                     COLUMN_PAGE, &page,
92                                     -1);
93                 return page;
94         }
95
96         return -1;
97 }
98
99 static void
100 ev_bookmarks_popup_cmd_open_bookmark (GtkAction          *action,
101                                       EvSidebarBookmarks *sidebar_bookmarks)
102 {
103         EvSidebarBookmarksPrivate *priv = sidebar_bookmarks->priv;
104         GtkTreeSelection          *selection;
105         gint                       page;
106
107         selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
108         page = ev_sidebar_bookmarks_get_selected_page (sidebar_bookmarks, selection);
109         ev_document_model_set_page (priv->model, page);
110 }
111
112 static void
113 ev_bookmarks_popup_cmd_rename_bookmark (GtkAction          *action,
114                                         EvSidebarBookmarks *sidebar_bookmarks)
115 {
116         EvSidebarBookmarksPrivate *priv = sidebar_bookmarks->priv;
117         GtkTreeView               *tree_view = GTK_TREE_VIEW (priv->tree_view);
118         GtkTreeSelection          *selection;
119         GtkTreeModel              *model;
120         GtkTreeIter                iter;
121
122
123         selection = gtk_tree_view_get_selection (tree_view);
124         if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
125                 GtkTreePath *path;
126
127                 path = gtk_tree_model_get_path (model, &iter);
128                 gtk_tree_view_set_cursor (tree_view, path,
129                                           gtk_tree_view_get_column (tree_view, 0),
130                                           TRUE);
131                 gtk_tree_path_free (path);
132         }
133 }
134
135 static void
136 ev_bookmarks_popup_cmd_remove_bookmark (GtkAction          *action,
137                                         EvSidebarBookmarks *sidebar_bookmarks)
138 {
139         EvSidebarBookmarksPrivate *priv = sidebar_bookmarks->priv;
140         GtkTreeSelection          *selection;
141         gint                       page;
142         EvBookmark                 bm;
143
144         selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
145         page = ev_sidebar_bookmarks_get_selected_page (sidebar_bookmarks, selection);
146         bm.page = page;
147         bm.title = NULL;
148         ev_bookmarks_delete (priv->bookmarks, &bm);
149 }
150
151 static const GtkActionEntry popup_entries[] = {
152         { "OpenBookmark", GTK_STOCK_OPEN, N_("_Open Bookmark"), NULL,
153           NULL, G_CALLBACK (ev_bookmarks_popup_cmd_open_bookmark) },
154         { "RenameBookmark", NULL, N_("_Rename Bookmark"), NULL,
155           NULL, G_CALLBACK (ev_bookmarks_popup_cmd_rename_bookmark) },
156         { "RemoveBookmark", NULL, N_("_Remove Bookmark"), NULL,
157           NULL, G_CALLBACK (ev_bookmarks_popup_cmd_remove_bookmark) }
158 };
159
160 static gint
161 compare_bookmarks (EvBookmark *a,
162                    EvBookmark *b)
163 {
164         if (a->page < b->page)
165                 return -1;
166         if (a->page > b->page)
167                 return 1;
168         return 0;
169 }
170
171 static void
172 ev_sidebar_bookmarks_update (EvSidebarBookmarks *sidebar_bookmarks)
173 {
174         EvSidebarBookmarksPrivate *priv = sidebar_bookmarks->priv;
175         GtkListStore              *model;
176         GList                     *items, *l;
177         GtkTreeIter                iter;
178
179         model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (priv->tree_view)));
180         gtk_list_store_clear (model);
181
182         if (!priv->bookmarks) {
183                 g_object_set (priv->tree_view, "has-tooltip", FALSE, NULL);
184                 return;
185         }
186
187         items = ev_bookmarks_get_bookmarks (priv->bookmarks);
188         items = g_list_sort (items, (GCompareFunc)compare_bookmarks);
189         for (l = items; l; l = g_list_next (l)) {
190                 EvBookmark *bm = (EvBookmark *)l->data;
191
192                 gtk_list_store_append (model, &iter);
193                 gtk_list_store_set (model, &iter,
194                                     COLUMN_MARKUP, bm->title,
195                                     COLUMN_PAGE, bm->page,
196                                     -1);
197         }
198         g_list_free (items);
199         g_object_set (priv->tree_view, "has-tooltip", TRUE, NULL);
200 }
201
202 static void
203 ev_sidebar_bookmarks_changed (EvBookmarks        *bookmarks,
204                               EvSidebarBookmarks *sidebar_bookmarks)
205 {
206         ev_sidebar_bookmarks_update (sidebar_bookmarks);
207 }
208
209 static void
210 ev_sidebar_bookmarks_selection_changed (GtkTreeSelection   *selection,
211                                         EvSidebarBookmarks *sidebar_bookmarks)
212 {
213         EvSidebarBookmarksPrivate *priv = sidebar_bookmarks->priv;
214         gint                       page;
215
216         page = ev_sidebar_bookmarks_get_selected_page (sidebar_bookmarks, selection);
217         if (page >= 0) {
218                 ev_document_model_set_page (priv->model, page);
219                 gtk_widget_set_sensitive (priv->del_button, TRUE);
220         } else {
221                 gtk_widget_set_sensitive (priv->del_button, FALSE);
222         }
223 }
224
225 static void
226 ev_sidebar_bookmarks_add_clicked (GtkWidget          *button,
227                                   EvSidebarBookmarks *sidebar_bookmarks)
228 {
229         /* Let the window add the bookmark since
230          * since we don't know the page title
231          */
232         g_signal_emit (sidebar_bookmarks, signals[ADD_BOOKMARK], 0);
233 }
234
235 static void
236 ev_sidebar_bookmarks_del_clicked (GtkWidget          *button,
237                                   EvSidebarBookmarks *sidebar_bookmarks)
238 {
239         EvSidebarBookmarksPrivate *priv = sidebar_bookmarks->priv;
240         GtkTreeSelection          *selection;
241         gint                       page;
242         EvBookmark                 bm;
243
244         selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
245         page = ev_sidebar_bookmarks_get_selected_page (sidebar_bookmarks, selection);
246         if (page < 0)
247                 return;
248
249         bm.page = page;
250         bm.title = NULL;
251         ev_bookmarks_delete (priv->bookmarks, &bm);
252 }
253
254 static void
255 ev_sidebar_bookmarks_bookmark_renamed (GtkCellRendererText *renderer,
256                                        const gchar         *path_string,
257                                        const gchar         *new_text,
258                                        EvSidebarBookmarks  *sidebar_bookmarks)
259 {
260         EvSidebarBookmarksPrivate *priv = sidebar_bookmarks->priv;
261         GtkTreePath               *path = gtk_tree_path_new_from_string (path_string);
262         GtkTreeModel              *model;
263         GtkTreeIter                iter;
264         guint                      page;
265         EvBookmark                 bm;
266
267         if (!new_text || new_text[0] == '\0')
268                 return;
269
270         model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->tree_view));
271         gtk_tree_model_get_iter (model, &iter, path);
272         gtk_tree_model_get (model, &iter,
273                             COLUMN_PAGE, &page,
274                             -1);
275         gtk_tree_path_free (path);
276
277         bm.page = page;
278         bm.title = g_strdup (new_text);
279         ev_bookmarks_update (priv->bookmarks, &bm);
280 }
281
282 static gboolean
283 ev_sidebar_bookmarks_query_tooltip (GtkWidget          *widget,
284                                     gint                x,
285                                     gint                y,
286                                     gboolean            keyboard_tip,
287                                     GtkTooltip         *tooltip,
288                                     EvSidebarBookmarks *sidebar_bookmarks)
289 {
290         EvSidebarBookmarksPrivate *priv = sidebar_bookmarks->priv;
291         GtkTreeModel              *model;
292         GtkTreeIter                iter;
293         GtkTreePath               *path = NULL;
294         EvDocument                *document;
295         guint                      page;
296         gchar                     *page_label;
297         gchar                     *text;
298
299         model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->tree_view));
300         if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (priv->tree_view),
301                                                 &x, &y, keyboard_tip,
302                                                 &model, &path, &iter))
303                 return FALSE;
304
305         gtk_tree_model_get (model, &iter,
306                             COLUMN_PAGE, &page,
307                             -1);
308
309         document = ev_document_model_get_document (priv->model);
310         page_label = ev_document_get_page_label (document, page);
311         text = g_strdup_printf (_("Page %s"), page_label);
312         gtk_tooltip_set_text (tooltip, text);
313         g_free (text);
314         g_free (page_label);
315
316         gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (priv->tree_view),
317                                        tooltip, path);
318         gtk_tree_path_free (path);
319
320         return TRUE;
321 }
322
323 static gboolean
324 ev_sidebar_bookmarks_popup_menu_show (EvSidebarBookmarks *sidebar_bookmarks,
325                                       gint                x,
326                                       gint                y,
327                                       gboolean            keyboard_mode)
328 {
329         EvSidebarBookmarksPrivate *priv = sidebar_bookmarks->priv;
330         GtkTreeView               *tree_view = GTK_TREE_VIEW (sidebar_bookmarks->priv->tree_view);
331         GtkTreeSelection          *selection = gtk_tree_view_get_selection (tree_view);
332
333         if (keyboard_mode) {
334                 if (!gtk_tree_selection_get_selected (selection, NULL, NULL))
335                         return FALSE;
336         } else {
337                 GtkTreePath *path;
338
339                 if (!gtk_tree_view_get_path_at_pos (tree_view, x, y, &path, NULL, NULL, NULL))
340                         return FALSE;
341
342                 g_signal_handlers_block_by_func (selection,
343                                                  ev_sidebar_bookmarks_selection_changed,
344                                                  sidebar_bookmarks);
345                 gtk_tree_view_set_cursor (tree_view, path, NULL, FALSE);
346                 g_signal_handlers_unblock_by_func (selection,
347                                                    ev_sidebar_bookmarks_selection_changed,
348                                                    sidebar_bookmarks);
349                 gtk_tree_path_free (path);
350         }
351
352         if (!priv->popup)
353                 priv->popup = gtk_ui_manager_get_widget (priv->ui_manager, "/BookmarksPopup");
354
355         gtk_menu_popup (GTK_MENU (priv->popup),
356                         NULL, NULL,
357                         keyboard_mode ? ev_gui_menu_position_tree_selection : NULL,
358                         keyboard_mode ? tree_view : NULL,
359                         keyboard_mode ? 0 : 3,
360                         gtk_get_current_event_time ());
361         return TRUE;
362 }
363
364 static gboolean
365 ev_sidebar_bookmarks_button_press (GtkWidget          *widget,
366                                    GdkEventButton     *event,
367                                    EvSidebarBookmarks *sidebar_bookmarks)
368 {
369         if (event->button != 3)
370                 return FALSE;
371
372         return ev_sidebar_bookmarks_popup_menu_show (sidebar_bookmarks, event->x, event->y, FALSE);
373 }
374
375 static gboolean
376 ev_sidebar_bookmarks_popup_menu (GtkWidget *widget)
377 {
378         EvSidebarBookmarks *sidebar_bookmarks = EV_SIDEBAR_BOOKMARKS (widget);
379         gint                x, y;
380
381         gtk_widget_get_pointer (widget, &x, &y);
382         return ev_sidebar_bookmarks_popup_menu_show (sidebar_bookmarks, x, y, TRUE);
383 }
384
385 static void
386 ev_sidebar_bookmarks_dispose (GObject *object)
387 {
388         EvSidebarBookmarks *sidebar_bookmarks = EV_SIDEBAR_BOOKMARKS (object);
389         EvSidebarBookmarksPrivate *priv = sidebar_bookmarks->priv;
390
391         if (priv->model) {
392                 g_object_unref (priv->model);
393                 priv->model = NULL;
394         }
395
396         if (priv->bookmarks) {
397                 g_object_unref (priv->bookmarks);
398                 priv->bookmarks = NULL;
399         }
400
401         if (priv->action_group) {
402                 g_object_unref (priv->action_group);
403                 priv->action_group = NULL;
404         }
405
406         if (priv->ui_manager) {
407                 g_object_unref (priv->ui_manager);
408                 priv->ui_manager = NULL;
409         }
410
411         G_OBJECT_CLASS (ev_sidebar_bookmarks_parent_class)->dispose (object);
412 }
413
414 static void
415 ev_sidebar_bookmarks_init (EvSidebarBookmarks *sidebar_bookmarks)
416 {
417         EvSidebarBookmarksPrivate *priv;
418         GtkWidget                 *swindow;
419         GtkWidget                 *hbox;
420         GtkListStore              *model;
421         GtkCellRenderer           *renderer;
422         GtkTreeSelection          *selection;
423
424         sidebar_bookmarks->priv = G_TYPE_INSTANCE_GET_PRIVATE (sidebar_bookmarks,
425                                                                EV_TYPE_SIDEBAR_BOOKMARKS,
426                                                                EvSidebarBookmarksPrivate);
427         priv = sidebar_bookmarks->priv;
428
429         gtk_box_set_spacing (GTK_BOX (sidebar_bookmarks), 6);
430
431         swindow = gtk_scrolled_window_new (NULL, NULL);
432         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
433                                         GTK_POLICY_AUTOMATIC,
434                                         GTK_POLICY_AUTOMATIC);
435         gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swindow),
436                                              GTK_SHADOW_IN);
437         gtk_box_pack_start (GTK_BOX (sidebar_bookmarks), swindow, TRUE, TRUE, 0);
438         gtk_widget_show (swindow);
439
440         model = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_UINT);
441         priv->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
442         g_object_unref (model);
443         g_signal_connect (priv->tree_view, "query-tooltip",
444                           G_CALLBACK (ev_sidebar_bookmarks_query_tooltip),
445                           sidebar_bookmarks);
446         g_signal_connect (priv->tree_view,
447                           "button-press-event",
448                           G_CALLBACK (ev_sidebar_bookmarks_button_press),
449                           sidebar_bookmarks);
450         gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->tree_view), FALSE);
451         selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
452         g_signal_connect (selection, "changed",
453                           G_CALLBACK (ev_sidebar_bookmarks_selection_changed),
454                           sidebar_bookmarks);
455
456         renderer = gtk_cell_renderer_text_new ();
457         g_object_set (renderer,
458                       "ellipsize", PANGO_ELLIPSIZE_END,
459                       "editable", TRUE,
460                       NULL);
461         g_signal_connect (renderer, "edited",
462                           G_CALLBACK (ev_sidebar_bookmarks_bookmark_renamed),
463                           sidebar_bookmarks);
464         gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->tree_view),
465                                                      0, NULL, renderer,
466                                                      "markup", COLUMN_MARKUP,
467                                                      NULL);
468         gtk_container_add (GTK_CONTAINER (swindow), priv->tree_view);
469         gtk_widget_show (priv->tree_view);
470
471         hbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
472
473         priv->add_button = gtk_button_new_from_stock (GTK_STOCK_ADD);
474         g_signal_connect (priv->add_button, "clicked",
475                           G_CALLBACK (ev_sidebar_bookmarks_add_clicked),
476                           sidebar_bookmarks);
477         gtk_widget_set_sensitive (priv->add_button, FALSE);
478         gtk_box_pack_start (GTK_BOX (hbox), priv->add_button, TRUE, TRUE, 6);
479         gtk_widget_show (priv->add_button);
480
481         priv->del_button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
482         g_signal_connect (priv->del_button, "clicked",
483                           G_CALLBACK (ev_sidebar_bookmarks_del_clicked),
484                           sidebar_bookmarks);
485         gtk_widget_set_sensitive (priv->del_button, FALSE);
486         gtk_box_pack_start (GTK_BOX (hbox), priv->del_button, TRUE, TRUE, 6);
487         gtk_widget_show (priv->del_button);
488
489         gtk_box_pack_end (GTK_BOX (sidebar_bookmarks), hbox, FALSE, TRUE, 0);
490         gtk_widget_show (hbox);
491         gtk_widget_show (GTK_WIDGET (sidebar_bookmarks));
492
493         /* Popup menu */
494         priv->action_group = gtk_action_group_new ("BookmarsPopupActions");
495         gtk_action_group_set_translation_domain (priv->action_group, NULL);
496         gtk_action_group_add_actions (priv->action_group, popup_entries,
497                                       G_N_ELEMENTS (popup_entries),
498                                       sidebar_bookmarks);
499         priv->ui_manager = gtk_ui_manager_new ();
500         gtk_ui_manager_insert_action_group (priv->ui_manager,
501                                             priv->action_group, 0);
502         gtk_ui_manager_add_ui_from_string (priv->ui_manager, popup_menu_ui, -1, NULL);
503 }
504
505 static void
506 ev_sidebar_bookmarks_get_property (GObject    *object,
507                                    guint       prop_id,
508                                    GValue     *value,
509                                    GParamSpec *pspec)
510 {
511         EvSidebarBookmarks *sidebar_bookmarks;
512
513         sidebar_bookmarks = EV_SIDEBAR_BOOKMARKS (object);
514
515         switch (prop_id) {
516         case PROP_WIDGET:
517                 g_value_set_object (value, sidebar_bookmarks->priv->tree_view);
518                 break;
519         default:
520                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
521                 break;
522         }
523 }
524
525 static void
526 ev_sidebar_bookmarks_class_init (EvSidebarBookmarksClass *klass)
527 {
528         GObjectClass   *g_object_class = G_OBJECT_CLASS (klass);
529         GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
530
531         g_object_class->get_property = ev_sidebar_bookmarks_get_property;
532         g_object_class->dispose = ev_sidebar_bookmarks_dispose;
533
534         widget_class->popup_menu = ev_sidebar_bookmarks_popup_menu;
535
536         g_type_class_add_private (g_object_class, sizeof (EvSidebarBookmarksPrivate));
537
538         g_object_class_override_property (g_object_class, PROP_WIDGET, "main-widget");
539
540         signals[ADD_BOOKMARK] =
541                 g_signal_new ("add-bookmark",
542                               G_TYPE_FROM_CLASS (g_object_class),
543                               G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
544                               G_STRUCT_OFFSET (EvSidebarBookmarksClass, add_bookmark),
545                               NULL, NULL,
546                               g_cclosure_marshal_VOID__VOID,
547                               G_TYPE_NONE, 0,
548                               G_TYPE_NONE);
549 }
550
551 GtkWidget *
552 ev_sidebar_bookmarks_new (void)
553 {
554         return GTK_WIDGET (g_object_new (EV_TYPE_SIDEBAR_BOOKMARKS, NULL));
555 }
556
557 void
558 ev_sidebar_bookmarks_set_bookmarks (EvSidebarBookmarks *sidebar_bookmarks,
559                                     EvBookmarks        *bookmarks)
560 {
561         EvSidebarBookmarksPrivate *priv = sidebar_bookmarks->priv;
562
563         g_return_if_fail (EV_IS_BOOKMARKS (bookmarks));
564
565         if (priv->bookmarks == bookmarks)
566                 return;
567
568         if (priv->bookmarks)
569                 g_object_unref (priv->bookmarks);
570         priv->bookmarks = g_object_ref (bookmarks);
571         g_signal_connect (priv->bookmarks, "changed",
572                           G_CALLBACK (ev_sidebar_bookmarks_changed),
573                           sidebar_bookmarks);
574
575         gtk_widget_set_sensitive (priv->add_button, TRUE);
576         ev_sidebar_bookmarks_update (sidebar_bookmarks);
577 }
578
579 /* EvSidebarPageIface */
580 static void
581 ev_sidebar_bookmarks_set_model (EvSidebarPage   *sidebar_page,
582                                 EvDocumentModel *model)
583 {
584         EvSidebarBookmarks *sidebar_bookmarks = EV_SIDEBAR_BOOKMARKS (sidebar_page);
585         EvSidebarBookmarksPrivate *priv = sidebar_bookmarks->priv;
586
587         if (priv->model == model)
588                 return;
589
590         if (priv->model)
591                 g_object_unref (priv->model);
592         priv->model = g_object_ref (model);
593 }
594
595 static gboolean
596 ev_sidebar_bookmarks_support_document (EvSidebarPage *sidebar_page,
597                                        EvDocument    *document)
598 {
599         return TRUE;
600 }
601
602 static const gchar *
603 ev_sidebar_bookmarks_get_label (EvSidebarPage *sidebar_page)
604 {
605         return _("Bookmarks");
606 }
607
608 static void
609 ev_sidebar_bookmarks_page_iface_init (EvSidebarPageInterface *iface)
610 {
611         iface->support_document = ev_sidebar_bookmarks_support_document;
612         iface->set_model = ev_sidebar_bookmarks_set_model;
613         iface->get_label = ev_sidebar_bookmarks_get_label;
614 }