summaryrefslogtreecommitdiff
path: root/libyelp/yelp-bookmarks.c
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2010-08-10 12:03:39 -0400
committerShaun McCance <shaunm@gnome.org>2010-08-10 12:03:39 -0400
commitc799c996a8a679631d45c0a08e8a7c8d73e279e5 (patch)
tree5f2688e243fcea17802ebbb8eb726b25db54adff /libyelp/yelp-bookmarks.c
parent089eb3a88501b1ad420f3fe137b2ee223e5d827e (diff)
downloadyelp-c799c996a8a679631d45c0a08e8a7c8d73e279e5.tar.gz
[libyelp] Show bookmarks in location entry with YelpBookmarks
The bookmarks are managed by the application, not libyelp, so we need a way for the application to tell libyelp about bookmarks. Add a YelpBookmarks interface, which is implemented by YelpApplication. Then we can pass a YelpBookmarks to any libyelp class that needs it. Still need to hook up the bookmarks-changed signal and do something useful when the bookmark-new icon is clicked.
Diffstat (limited to 'libyelp/yelp-bookmarks.c')
-rw-r--r--libyelp/yelp-bookmarks.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/libyelp/yelp-bookmarks.c b/libyelp/yelp-bookmarks.c
new file mode 100644
index 00000000..e68d8a8f
--- /dev/null
+++ b/libyelp/yelp-bookmarks.c
@@ -0,0 +1,86 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2010 Shaun McCance <shaunm@gnome.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Shaun McCance <shaunm@gnome.org>
+ */
+
+#include "yelp-bookmarks.h"
+
+enum {
+ BOOKMARKS_CHANGED,
+ LAST_SIGNAL
+};
+
+G_DEFINE_INTERFACE (YelpBookmarks, yelp_bookmarks, G_TYPE_OBJECT)
+
+static void
+yelp_bookmarks_default_init (YelpBookmarksInterface *iface)
+{
+}
+
+void
+yelp_bookmarks_add_bookmark (YelpBookmarks *bookmarks,
+ const gchar *doc_uri,
+ const gchar *page_id,
+ const gchar *icon,
+ const gchar *title)
+{
+ YelpBookmarksInterface *iface;
+
+ g_return_if_fail (YELP_IS_BOOKMARKS (bookmarks));
+
+ iface = YELP_BOOKMARKS_GET_INTERFACE (bookmarks);
+
+ if (iface->add_bookmark)
+ (* iface->add_bookmark) (bookmarks,
+ doc_uri, page_id,
+ icon, title);
+}
+
+void
+yelp_bookmarks_remove_bookmark (YelpBookmarks *bookmarks,
+ const gchar *doc_uri,
+ const gchar *page_id)
+{
+ YelpBookmarksInterface *iface;
+
+ g_return_if_fail (YELP_IS_BOOKMARKS (bookmarks));
+
+ iface = YELP_BOOKMARKS_GET_INTERFACE (bookmarks);
+
+ if (iface->remove_bookmark)
+ (* iface->remove_bookmark) (bookmarks, doc_uri, page_id);
+}
+
+gboolean
+yelp_bookmarks_is_bookmarked (YelpBookmarks *bookmarks,
+ const gchar *doc_uri,
+ const gchar *page_id)
+{
+ YelpBookmarksInterface *iface;
+
+ g_return_if_fail (YELP_IS_BOOKMARKS (bookmarks));
+
+ iface = YELP_BOOKMARKS_GET_INTERFACE (bookmarks);
+
+ if (iface->is_bookmarked)
+ return (* iface->is_bookmarked) (bookmarks, doc_uri, page_id);
+ else
+ return FALSE;
+}