]> www.fi.muni.cz Git - evince.git/blob - shell/ev-bookmark-action.c
[shell] initial dualscreen support
[evince.git] / shell / ev-bookmark-action.c
1 /* ev-bookmark-action.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20
21 #include "config.h"
22
23 #include "ev-bookmark-action.h"
24
25 enum {
26         PROP_0,
27         PROP_PAGE
28 };
29
30 struct _EvBookmarkAction {
31         GtkAction base;
32
33         guint     page;
34 };
35
36 struct _EvBookmarkActionClass {
37         GtkActionClass base_class;
38 };
39
40 G_DEFINE_TYPE (EvBookmarkAction, ev_bookmark_action, GTK_TYPE_ACTION)
41
42 static void
43 ev_bookmark_action_init (EvBookmarkAction *action)
44 {
45 }
46
47 static void
48 ev_bookmark_action_set_property (GObject      *object,
49                                  guint         prop_id,
50                                  const GValue *value,
51                                  GParamSpec   *pspec)
52 {
53         EvBookmarkAction *action = EV_BOOKMARK_ACTION (object);
54
55         switch (prop_id) {
56         case PROP_PAGE:
57                 action->page = g_value_get_uint (value);
58                 break;
59         default:
60                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
61         }
62 }
63
64 static void
65 ev_bookmark_action_class_init (EvBookmarkActionClass *klass)
66 {
67         GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
68
69         gobject_class->set_property = ev_bookmark_action_set_property;
70
71         g_object_class_install_property (gobject_class,
72                                          PROP_PAGE,
73                                          g_param_spec_uint ("page",
74                                                             "Page",
75                                                             "The bookmark page",
76                                                             0, G_MAXUINT, 0,
77                                                             G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
78 }
79
80 GtkAction *
81 ev_bookmark_action_new (EvBookmark *bookmark)
82 {
83         GtkAction *action;
84         gchar *name;
85
86         g_return_val_if_fail (bookmark->title != NULL, NULL);
87
88         name = g_strdup_printf ("EvBookmark%u", bookmark->page);
89         action = GTK_ACTION (g_object_new (EV_TYPE_BOOKMARK_ACTION,
90                                            "name", name,
91                                            "label", bookmark->title,
92                                            "page", bookmark->page,
93                                            NULL));
94         g_free (name);
95
96         return action;
97 }
98
99 guint
100 ev_bookmark_action_get_page (EvBookmarkAction *action)
101 {
102         g_return_val_if_fail (EV_IS_BOOKMARK_ACTION (action), 0);
103
104         return action->page;
105 }