[yelp] [yelp-window] Make 'Add Bookmark' unsensitive on bookmarked pages
- From: Shaun McCance <shaunm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp] [yelp-window] Make 'Add Bookmark' unsensitive on bookmarked pages
- Date: Mon, 10 May 2010 20:12:05 +0000 (UTC)
commit 2f08ce90f7b41d405a4983eabbc775594337ad50
Author: Shaun McCance <shaunm gnome org>
Date: Mon May 10 15:11:33 2010 -0500
[yelp-window] Make 'Add Bookmark' unsensitive on bookmarked pages
src/yelp-window.c | 66 ++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 45 insertions(+), 21 deletions(-)
---
diff --git a/src/yelp-window.c b/src/yelp-window.c
index 20bc172..8885d73 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -76,6 +76,7 @@ static void app_bookmarks_changed (YelpApplication *app,
YelpWindow *window);
static void window_set_bookmarks (YelpWindow *window,
const gchar *doc_uri);
+static void window_set_bookmark_action (YelpWindow *window);
static void window_set_bookmark_icons (YelpWindow *window);
static gboolean find_animate_open (YelpWindow *window);
static gboolean find_animate_close (YelpWindow *window);
@@ -115,9 +116,6 @@ static void view_loaded (YelpView *view,
static void view_uri_selected (YelpView *view,
GParamSpec *pspec,
YelpWindow *window);
-static void view_page_id (YelpView *view,
- GParamSpec *pspec,
- YelpWindow *window);
static void view_root_title (YelpView *view,
GParamSpec *pspec,
YelpWindow *window);
@@ -564,7 +562,8 @@ window_construct (YelpWindow *window)
g_signal_connect (priv->view, "external-uri", G_CALLBACK (view_external_uri), window);
g_signal_connect (priv->view, "loaded", G_CALLBACK (view_loaded), window);
g_signal_connect (priv->view, "notify::yelp-uri", G_CALLBACK (view_uri_selected), window);
- g_signal_connect (priv->view, "notify::page-id", G_CALLBACK (view_page_id), window);
+ g_signal_connect_swapped (priv->view, "notify::page-id",
+ G_CALLBACK (window_set_bookmark_action), window);
g_signal_connect (priv->view, "notify::root-title", G_CALLBACK (view_root_title), window);
g_signal_connect (priv->view, "notify::page-title", G_CALLBACK (view_page_title), window);
g_signal_connect (priv->view, "notify::page-desc", G_CALLBACK (view_page_desc), window);
@@ -808,6 +807,48 @@ window_set_bookmarks (YelpWindow *window,
}
static void
+window_set_bookmark_action (YelpWindow *window)
+{
+ YelpUri *uri;
+ gchar *doc_uri, *page_id;
+ gchar *curpage;
+ GVariant *value;
+ GVariantIter *viter;
+ GtkAction *action;
+ YelpWindowPrivate *priv = GET_PRIV (window);
+
+ action = gtk_action_group_get_action (priv->action_group, "AddBookmark");
+
+ g_object_get (priv->view,
+ "yelp-uri", &uri,
+ "page-id", &page_id,
+ NULL);
+ if (page_id == NULL) {
+ gtk_action_set_sensitive (action, FALSE);
+ if (uri)
+ g_object_unref (uri);
+ return;
+ }
+ gtk_action_set_sensitive (action, TRUE);
+
+ doc_uri = yelp_uri_get_document_uri (uri);
+ value = yelp_application_get_bookmarks (priv->application, doc_uri);
+ g_variant_get (value, "a(sss)", &viter);
+ while (g_variant_iter_loop (viter, "(&s&s&s)", &curpage, NULL, NULL)) {
+ if (g_str_equal (page_id, curpage)) {
+ gtk_action_set_sensitive (action, FALSE);
+ break;
+ }
+ }
+ g_variant_iter_free (viter);
+ g_variant_unref (value);
+
+ g_free (page_id);
+ g_free (doc_uri);
+ g_object_unref (uri);
+}
+
+static void
window_set_bookmark_icons (YelpWindow *window)
{
YelpUri *uri;
@@ -1455,23 +1496,6 @@ view_uri_selected (YelpView *view,
}
static void
-view_page_id (YelpView *view,
- GParamSpec *pspec,
- YelpWindow *window)
-{
- GtkAction *action;
- gchar *page_id;
- YelpWindowPrivate *priv = GET_PRIV (window);
-
- g_object_get (view, "page-id", &page_id, NULL);
-
- action = gtk_action_group_get_action (priv->action_group, "AddBookmark");
- gtk_action_set_sensitive (action, page_id != NULL);
-
- g_free (page_id);
-}
-
-static void
view_root_title (YelpView *view,
GParamSpec *pspec,
YelpWindow *window)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]