[gnome-builder/document-manager] GbDevhelpView: wire up uri to webview upon gproperty notify
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/document-manager] GbDevhelpView: wire up uri to webview upon gproperty notify
- Date: Wed, 10 Dec 2014 01:39:14 +0000 (UTC)
commit 830b4ce3ce1c79906121dd012c3a6c8d3f1ecdf8
Author: Christian Hergert <christian hergert me>
Date: Tue Dec 9 17:38:48 2014 -0800
GbDevhelpView: wire up uri to webview upon gproperty notify
src/devhelp/gb-devhelp-view.c | 43 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/src/devhelp/gb-devhelp-view.c b/src/devhelp/gb-devhelp-view.c
index 364aa06..55bbad8 100644
--- a/src/devhelp/gb-devhelp-view.c
+++ b/src/devhelp/gb-devhelp-view.c
@@ -60,10 +60,53 @@ gb_devhelp_view_get_document (GbDocumentView *view)
}
static void
+gb_devhelp_view_notify_uri (GbDevhelpView *view,
+ GParamSpec *pspec,
+ GbDevhelpDocument *document)
+{
+ const gchar *uri;
+
+ g_return_if_fail (GB_IS_DEVHELP_VIEW (view));
+ g_return_if_fail (GB_IS_DEVHELP_DOCUMENT (document));
+
+ uri = gb_devhelp_document_get_uri (document);
+ if (uri)
+ webkit_web_view_load_uri (view->priv->web_view, uri);
+}
+
+static void
gb_devhelp_view_set_document (GbDevhelpView *view,
GbDevhelpDocument *document)
{
+ GbDevhelpViewPrivate *priv;
+
g_return_if_fail (GB_IS_DEVHELP_VIEW (view));
+
+ priv = view->priv;
+
+ if (priv->document != document)
+ {
+ if (priv->document)
+ {
+ g_signal_handlers_disconnect_by_func (priv->document,
+ G_CALLBACK (gb_devhelp_view_notify_uri),
+ view);
+ g_clear_object (&priv->document);
+ }
+
+ if (document)
+ {
+ priv->document = g_object_ref (document);
+ g_signal_connect_object (priv->document,
+ "notify::uri",
+ G_CALLBACK (gb_devhelp_view_notify_uri),
+ view,
+ G_CONNECT_SWAPPED);
+ }
+
+ gb_devhelp_view_notify_uri (view, NULL, document);
+ g_object_notify (G_OBJECT (view), "document");
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]