[libyelp/yelp-mallard-document] Support for Mallard Facets extension
[yelp.git] / libyelp / yelp-bookmarks.c
blob670650d990222603796ca88169b36bd708cc609d
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * Copyright (C) 2010 Shaun McCance <shaunm@gnome.org>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Shaun McCance <shaunm@gnome.org>
23 #include "yelp-bookmarks.h"
25 enum {
26 BOOKMARKS_CHANGED,
27 LAST_SIGNAL
29 static gint signals[LAST_SIGNAL] = { 0 };
31 G_DEFINE_INTERFACE (YelpBookmarks, yelp_bookmarks, G_TYPE_OBJECT)
33 static void
34 yelp_bookmarks_default_init (YelpBookmarksInterface *iface)
36 signals[BOOKMARKS_CHANGED] =
37 g_signal_new ("bookmarks-changed",
38 G_TYPE_FROM_INTERFACE (iface),
39 G_SIGNAL_RUN_LAST,
40 0, NULL, NULL,
41 g_cclosure_marshal_VOID__STRING,
42 G_TYPE_NONE, 1, G_TYPE_STRING);
45 void
46 yelp_bookmarks_add_bookmark (YelpBookmarks *bookmarks,
47 const gchar *doc_uri,
48 const gchar *page_id,
49 const gchar *icon,
50 const gchar *title)
52 YelpBookmarksInterface *iface;
54 g_return_if_fail (YELP_IS_BOOKMARKS (bookmarks));
56 iface = YELP_BOOKMARKS_GET_INTERFACE (bookmarks);
58 if (iface->add_bookmark)
59 (* iface->add_bookmark) (bookmarks,
60 doc_uri, page_id,
61 icon, title);
64 void
65 yelp_bookmarks_remove_bookmark (YelpBookmarks *bookmarks,
66 const gchar *doc_uri,
67 const gchar *page_id)
69 YelpBookmarksInterface *iface;
71 g_return_if_fail (YELP_IS_BOOKMARKS (bookmarks));
73 iface = YELP_BOOKMARKS_GET_INTERFACE (bookmarks);
75 if (iface->remove_bookmark)
76 (* iface->remove_bookmark) (bookmarks, doc_uri, page_id);
79 gboolean
80 yelp_bookmarks_is_bookmarked (YelpBookmarks *bookmarks,
81 const gchar *doc_uri,
82 const gchar *page_id)
84 YelpBookmarksInterface *iface;
86 g_return_if_fail (YELP_IS_BOOKMARKS (bookmarks));
88 iface = YELP_BOOKMARKS_GET_INTERFACE (bookmarks);
90 if (iface->is_bookmarked)
91 return (* iface->is_bookmarked) (bookmarks, doc_uri, page_id);
92 else
93 return FALSE;