[yelp] Expose the real page ID in YelpView, use for bookmarks in YelpWindow
- From: Shaun McCance <shaunm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp] Expose the real page ID in YelpView, use for bookmarks in YelpWindow
- Date: Fri, 30 Apr 2010 14:21:56 +0000 (UTC)
commit 7ec578b6bef629c7feb1b3987cfec683298dee81
Author: Shaun McCance <shaunm gnome org>
Date: Fri Apr 30 09:21:04 2010 -0500
Expose the real page ID in YelpView, use for bookmarks in YelpWindow
libyelp/yelp-view.c | 50 +++++++++++++++++++++++++++++++++++++----------
src/yelp-application.c | 9 +------
src/yelp-application.h | 3 +-
src/yelp-window.c | 29 +++++++++++++++++++++++++-
4 files changed, 70 insertions(+), 21 deletions(-)
---
diff --git a/libyelp/yelp-view.c b/libyelp/yelp-view.c
index da2beba..c991dd6 100644
--- a/libyelp/yelp-view.c
+++ b/libyelp/yelp-view.c
@@ -114,6 +114,7 @@ enum {
PROP_0,
PROP_URI,
PROP_STATE,
+ PROP_PAGE_ID,
PROP_ROOT_TITLE,
PROP_PAGE_TITLE,
PROP_PAGE_DESC,
@@ -160,6 +161,7 @@ struct _YelpViewPrivate {
YelpViewState state;
+ gchar *page_id;
gchar *root_title;
gchar *page_title;
gchar *page_desc;
@@ -242,6 +244,7 @@ yelp_view_finalize (GObject *object)
{
YelpViewPrivate *priv = GET_PRIV (object);
+ g_free (priv->page_id);
g_free (priv->root_title);
g_free (priv->page_title);
g_free (priv->page_desc);
@@ -321,6 +324,15 @@ yelp_view_class_init (YelpViewClass *klass)
G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
g_object_class_install_property (object_class,
+ PROP_PAGE_ID,
+ g_param_spec_string ("page-id",
+ N_("Page ID"),
+ N_("The ID of the root page of the page being viewew"),
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property (object_class,
PROP_ROOT_TITLE,
g_param_spec_string ("root-title",
N_("Root Title"),
@@ -370,6 +382,9 @@ yelp_view_get_property (GObject *object,
case PROP_URI:
g_value_set_object (value, priv->uri);
break;
+ case PROP_PAGE_ID:
+ g_value_set_string (value, priv->page_id);
+ break;
case PROP_ROOT_TITLE:
g_value_set_string (value, priv->root_title);
break;
@@ -442,14 +457,17 @@ yelp_view_load_uri (YelpView *view,
view_clear_load (view);
g_object_set (view, "state", YELP_VIEW_STATE_LOADING, NULL);
+ g_free (priv->page_id);
g_free (priv->root_title);
g_free (priv->page_title);
g_free (priv->page_desc);
g_free (priv->page_icon);
+ priv->page_id = NULL;
priv->root_title = NULL;
priv->page_title = NULL;
priv->page_desc = NULL;
priv->page_icon = NULL;
+ g_signal_emit_by_name (view, "notify::page-id", 0);
g_signal_emit_by_name (view, "notify::root-title", 0);
g_signal_emit_by_name (view, "notify::page-title", 0);
g_signal_emit_by_name (view, "notify::page-desc", 0);
@@ -681,7 +699,6 @@ view_load_page (YelpView *view)
priv->cancellable,
(YelpDocumentCallback) document_callback,
view);
-
g_free (page_id);
}
@@ -927,6 +944,10 @@ uri_resolved (YelpUri *uri,
g_signal_emit_by_name (view, "notify::yelp-uri", 0);
+ g_free (priv->page_id);
+ priv->page_id = yelp_uri_get_page_id (priv->uri);
+ g_signal_emit_by_name (view, "notify::page-id", 0);
+
view_load_page (view);
}
@@ -941,20 +962,29 @@ document_callback (YelpDocument *document,
debug_print (DB_FUNCTION, "entering\n");
if (signal == YELP_DOCUMENT_SIGNAL_INFO) {
- gchar *page_id, *prev_id, *next_id;
+ gchar *prev_id, *next_id, *real_id;
GtkAction *action;
YelpBackEntry *back = NULL;
- page_id = yelp_uri_get_page_id (priv->uri);
+
+ real_id = yelp_document_get_page_id (document, priv->page_id);
+ if (priv->page_id && g_str_equal (real_id, priv->page_id)) {
+ g_free (real_id);
+ }
+ else {
+ g_free (priv->page_id);
+ priv->page_id = real_id;
+ g_signal_emit_by_name (view, "notify::page-id", 0);
+ }
g_free (priv->root_title);
g_free (priv->page_title);
g_free (priv->page_desc);
g_free (priv->page_icon);
- priv->root_title = yelp_document_get_root_title (document, page_id);
- priv->page_title = yelp_document_get_page_title (document, page_id);
- priv->page_desc = yelp_document_get_page_desc (document, page_id);
- priv->page_icon = yelp_document_get_page_icon (document, page_id);
+ priv->root_title = yelp_document_get_root_title (document, priv->page_id);
+ priv->page_title = yelp_document_get_page_title (document, priv->page_id);
+ priv->page_desc = yelp_document_get_page_desc (document, priv->page_id);
+ priv->page_icon = yelp_document_get_page_icon (document, priv->page_id);
if (priv->back_cur)
back = priv->back_cur->data;
@@ -965,12 +995,12 @@ document_callback (YelpDocument *document,
back->desc = g_strdup (priv->page_desc);
}
- prev_id = yelp_document_get_prev_id (document, page_id);
+ prev_id = yelp_document_get_prev_id (document, priv->page_id);
action = gtk_action_group_get_action (priv->action_group, "YelpViewGoPrevious");
gtk_action_set_sensitive (action, prev_id != NULL);
g_free (prev_id);
- next_id = yelp_document_get_next_id (document, page_id);
+ next_id = yelp_document_get_next_id (document, priv->page_id);
action = gtk_action_group_get_action (priv->action_group, "YelpViewGoNext");
gtk_action_set_sensitive (action, next_id != NULL);
g_free (next_id);
@@ -979,8 +1009,6 @@ document_callback (YelpDocument *document,
g_signal_emit_by_name (view, "notify::page-title", 0);
g_signal_emit_by_name (view, "notify::page-desc", 0);
g_signal_emit_by_name (view, "notify::page-icon", 0);
-
- g_free (page_id);
}
else if (signal == YELP_DOCUMENT_SIGNAL_CONTENTS) {
const gchar *contents;
diff --git a/src/yelp-application.c b/src/yelp-application.c
index f239292..d6f81fb 100644
--- a/src/yelp-application.c
+++ b/src/yelp-application.c
@@ -564,16 +564,14 @@ packages_installed (DBusGProxy *proxy,
void
yelp_application_add_bookmark (YelpApplication *app,
- YelpUri *uri,
+ const gchar *doc_uri,
+ const gchar *page_id,
const gchar *icon,
const gchar *title)
{
GSettings *settings;
- gchar *doc_uri, *page_id;
YelpApplicationPrivate *priv = GET_PRIV (app);
- doc_uri = yelp_uri_get_document_uri (uri);
- page_id = yelp_uri_get_page_id (uri);
settings = application_get_doc_settings (app, doc_uri);
if (settings) {
@@ -602,9 +600,6 @@ yelp_application_add_bookmark (YelpApplication *app,
g_signal_emit (app, signals[BOOKMARKS_CHANGED], 0, doc_uri, 0);
}
}
-
- g_free (doc_uri);
- g_free (page_id);
}
GVariant *
diff --git a/src/yelp-application.h b/src/yelp-application.h
index 9ae9d1c..cda9969 100644
--- a/src/yelp-application.h
+++ b/src/yelp-application.h
@@ -59,7 +59,8 @@ void yelp_application_new_window (YelpApplication *app,
const gchar *uri);
GtkActionGroup * yelp_application_get_action_group (YelpApplication *app);
void yelp_application_add_bookmark (YelpApplication *app,
- YelpUri *uri,
+ const gchar *doc_uri,
+ const gchar *page_id,
const gchar *icon,
const gchar *title);
GVariant * yelp_application_get_bookmarks (YelpApplication *app,
diff --git a/src/yelp-window.c b/src/yelp-window.c
index 872f702..a8e4eff 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -93,6 +93,9 @@ 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);
@@ -470,6 +473,7 @@ 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 (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);
@@ -574,15 +578,19 @@ window_add_bookmark (GtkAction *action,
YelpWindow *window)
{
YelpUri *uri;
- gchar *icon, *title;
+ gchar *doc_uri, *page_id, *icon, *title;
YelpWindowPrivate *priv = GET_PRIV (window);
g_object_get (priv->view,
"yelp-uri", &uri,
+ "page-id", &page_id,
"page-icon", &icon,
"page-title", &title,
NULL);
- yelp_application_add_bookmark (priv->application, uri, icon, title);
+ doc_uri = yelp_uri_get_document_uri (uri);
+ yelp_application_add_bookmark (priv->application, doc_uri, page_id, icon, title);
+ g_free (doc_uri);
+ g_free (page_id);
g_free (icon);
g_free (title);
g_object_unref (uri);
@@ -949,6 +957,23 @@ 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]