1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
2 /* this file is part of evince, a gnome document viewer
4 * Copyright (C) 2005 Red Hat, Inc.
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.
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.
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.
25 #include "ev-bookmark.h"
34 struct _EvBookmarkPrivate {
40 static GObjectClass *parent_class = NULL;
42 G_DEFINE_TYPE (EvBookmark, ev_bookmark, G_TYPE_OBJECT)
44 #define EV_BOOKMARK_GET_PRIVATE(object) \
45 (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_BOOKMARK, EvBookmarkPrivate))
48 ev_bookmark_type_get_type (void)
50 static GType type = 0;
52 if (G_UNLIKELY (type == 0)) {
53 static const GEnumValue values[] = {
54 { EV_BOOKMARK_TYPE_TITLE, "EV_BOOKMARK_TYPE_TITLE", "title" },
55 { EV_BOOKMARK_TYPE_LINK, "EV_BOOKMARK_TYPE_LINK", "link" },
56 { EV_BOOKMARK_TYPE_EXTERNAL_URI, "EV_BOOKMARK_TYPE_EXTERNAL_URI", "external" },
60 type = g_enum_register_static ("EvBookmarkType", values);
67 ev_bookmark_get_title (EvBookmark *self)
69 g_return_val_if_fail (EV_IS_BOOKMARK (self), NULL);
71 return self->priv->title;
75 ev_bookmark_set_title (EvBookmark* self, const char *title)
77 g_assert (EV_IS_BOOKMARK (self));
78 g_assert (title != NULL);
80 if (self->priv->title != NULL) {
81 g_free (self->priv->title);
84 self->priv->title = g_strdup (title);
86 g_object_notify (G_OBJECT (self), "title");
90 ev_bookmark_get_bookmark_type (EvBookmark *self)
92 g_return_val_if_fail (EV_IS_BOOKMARK (self), 0);
94 return self->priv->type;
98 ev_bookmark_set_bookmark_type (EvBookmark* self, EvBookmarkType type)
100 g_assert (EV_IS_BOOKMARK (self));
102 self->priv->type = type;
104 g_object_notify (G_OBJECT (self), "type");
108 ev_bookmark_get_page (EvBookmark *self)
110 g_return_val_if_fail (EV_IS_BOOKMARK (self), 0);
112 return self->priv->page;
116 ev_bookmark_set_page (EvBookmark* self, int page)
118 g_assert (EV_IS_BOOKMARK (self));
120 self->priv->page = page;
122 g_object_notify (G_OBJECT (self), "page");
126 ev_bookmark_get_property (GObject *object, guint prop_id, GValue *value,
127 GParamSpec *param_spec)
131 self = EV_BOOKMARK (object);
135 g_value_set_string (value, self->priv->title);
138 g_value_set_enum (value, self->priv->type);
141 g_value_set_int (value, self->priv->page);
144 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
152 ev_bookmark_set_property (GObject *object, guint prop_id, const GValue *value,
153 GParamSpec *param_spec)
157 self = EV_BOOKMARK (object);
161 ev_bookmark_set_title (self, g_value_get_string (value));
164 ev_bookmark_set_bookmark_type (self, g_value_get_enum (value));
167 ev_bookmark_set_page (self, g_value_get_int (value));
170 G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
178 ev_window_dispose (GObject *object)
180 EvBookmarkPrivate *priv;
182 g_return_if_fail (EV_IS_BOOKMARK (object));
184 priv = EV_BOOKMARK (object)->priv;
187 g_free (priv->title);
191 G_OBJECT_CLASS (parent_class)->dispose (object);
195 ev_bookmark_init (EvBookmark *ev_bookmark)
197 ev_bookmark->priv = EV_BOOKMARK_GET_PRIVATE (ev_bookmark);
199 ev_bookmark->priv->type = EV_BOOKMARK_TYPE_TITLE;
203 ev_bookmark_class_init (EvBookmarkClass *ev_window_class)
205 GObjectClass *g_object_class;
207 parent_class = g_type_class_peek_parent (ev_window_class);
209 g_object_class = G_OBJECT_CLASS (ev_window_class);
210 g_object_class->dispose = ev_window_dispose;
211 g_object_class->set_property = ev_bookmark_set_property;
212 g_object_class->get_property = ev_bookmark_get_property;
214 g_type_class_add_private (g_object_class, sizeof (EvBookmarkPrivate));
216 g_object_class_install_property (g_object_class,
218 g_param_spec_string ("title",
220 "The bookmark title",
224 g_object_class_install_property (g_object_class,
226 g_param_spec_enum ("type",
229 EV_TYPE_BOOKMARK_TYPE,
230 EV_BOOKMARK_TYPE_TITLE,
233 g_object_class_install_property (g_object_class,
235 g_param_spec_int ("page",
245 ev_bookmark_new (const char *title,
249 return EV_BOOKMARK (g_object_new (EV_TYPE_BOOKMARK,