[devhelp] WebView: add get_devhelp_title()



commit 3be27c9e62c6a8b228e731474adac65f7595b30d
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Feb 11 13:28:05 2018 +0100

    WebView: add get_devhelp_title()
    
    DhWebView is a subclass of WebKitWebView, so if later DhWebView is added
    to the libdevhelp, the method name must not conflict with its parent
    classes (for GObject Introspection support). There is already
    webkit_web_view_get_title().
    
    dh_web_view_get_devhelp_title() will also be used for the tab label. To
    avoid code duplication.

 src/dh-web-view.c |   16 ++++++++++++++++
 src/dh-web-view.h |    2 ++
 src/dh-window.c   |   10 ++++------
 3 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/src/dh-web-view.c b/src/dh-web-view.c
index ec9cb82..1769dc3 100644
--- a/src/dh-web-view.c
+++ b/src/dh-web-view.c
@@ -18,6 +18,7 @@
 
 #include "dh-web-view.h"
 #include <math.h>
+#include <glib/gi18n.h>
 
 struct _DhWebViewPrivate {
         gchar *search_text;
@@ -187,6 +188,21 @@ dh_web_view_new (void)
         return g_object_new (DH_TYPE_WEB_VIEW, NULL);
 }
 
+const gchar *
+dh_web_view_get_devhelp_title (DhWebView *view)
+{
+        const gchar *title;
+
+        g_return_val_if_fail (DH_IS_WEB_VIEW (view), NULL);
+
+        title = webkit_web_view_get_title (WEBKIT_WEB_VIEW (view));
+
+        if (title == NULL || title[0] == '\0')
+                title = _("Empty Page");
+
+        return title;
+}
+
 /*
  * dh_web_view_set_search_text:
  * @view: a #DhWebView.
diff --git a/src/dh-web-view.h b/src/dh-web-view.h
index 10cbeee..ae1e9c8 100644
--- a/src/dh-web-view.h
+++ b/src/dh-web-view.h
@@ -51,6 +51,8 @@ GType           dh_web_view_get_type            (void);
 
 DhWebView *     dh_web_view_new                 (void);
 
+const gchar *   dh_web_view_get_devhelp_title   (DhWebView *view);
+
 void            dh_web_view_set_search_text     (DhWebView   *view,
                                                  const gchar *search_text);
 
diff --git a/src/dh-window.c b/src/dh-window.c
index 269334d..f8bba4e 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -139,15 +139,13 @@ update_window_title (DhWindow *window)
 {
         DhWindowPrivate *priv = dh_window_get_instance_private (window);
         DhWebView *web_view;
-        const gchar *title = NULL;
+        const gchar *title;
 
         web_view = get_active_web_view (window);
-        if (web_view != NULL)
-                title = webkit_web_view_get_title (WEBKIT_WEB_VIEW (web_view));
-
-        if (title == NULL || title[0] == '\0')
-                title = _("Empty Page");
+        if (web_view == NULL)
+                return;
 
+        title = dh_web_view_get_devhelp_title (web_view);
         gtk_header_bar_set_title (priv->header_bar, title);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]