[gnome-builder/wip/gtk4-port: 1335/1774] libide/webkit: add fallback title
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1335/1774] libide/webkit: add fallback title
- Date: Mon, 11 Jul 2022 22:31:42 +0000 (UTC)
commit b1b7623cd0283bc897981516e8d67df16fed49e9
Author: Christian Hergert <chergert redhat com>
Date: Fri Jun 3 14:29:29 2022 -0700
libide/webkit: add fallback title
src/libide/webkit/ide-webkit-page.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/webkit/ide-webkit-page.c b/src/libide/webkit/ide-webkit-page.c
index 3b6a5b201..e06e0de6d 100644
--- a/src/libide/webkit/ide-webkit-page.c
+++ b/src/libide/webkit/ide-webkit-page.c
@@ -44,6 +44,28 @@ G_DEFINE_TYPE_WITH_PRIVATE (IdeWebkitPage, ide_webkit_page, IDE_TYPE_PAGE)
static GParamSpec *properties [N_PROPS];
+static gboolean
+transform_title_with_fallback (GBinding *binding,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data)
+{
+ IdeWebkitPage *self = user_data;
+ IdeWebkitPagePrivate *priv = ide_webkit_page_get_instance_private (self);
+ const char *title;
+
+ g_assert (G_IS_BINDING (binding));
+ g_assert (G_VALUE_HOLDS_STRING (from_value));
+ g_assert (G_VALUE_HOLDS_STRING (to_value));
+ g_assert (IDE_IS_WEBKIT_PAGE (self));
+
+ title = g_value_get_string (from_value);
+ if (ide_str_empty0 (title))
+ title = webkit_web_view_get_uri (priv->web_view);
+ g_value_set_string (to_value, title);
+ return TRUE;
+}
+
static gboolean
transform_cairo_surface_to_gicon (GBinding *binding,
const GValue *from_value,
@@ -196,7 +218,9 @@ ide_webkit_page_init (IdeWebkitPage *self)
gtk_widget_init_template (GTK_WIDGET (self));
- g_object_bind_property (priv->web_view, "title", self, "title", 0);
+ g_object_bind_property_full (priv->web_view, "title", self, "title", 0,
+ transform_title_with_fallback,
+ NULL, self, NULL);
g_object_bind_property_full (priv->web_view, "favicon", self, "icon", 0,
transform_cairo_surface_to_gicon,
NULL, self, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]