diff options
author | Xan Lopez <xan@igalia.com> | 2012-03-15 16:42:13 +0800 |
---|---|---|
committer | Xan Lopez <xan@igalia.com> | 2012-03-15 16:42:13 +0800 |
commit | 0ddce1562e5712c098358ab99eccded7a327dd0c (patch) | |
tree | 8b4e4b0bc86529b23e342710904cc02215591b2a | |
parent | 3060de2a0ceeb976c1da6b79f3b3a4c7ed7848d2 (diff) | |
download | gsoc2013-epiphany-0ddce1562e5712c098358ab99eccded7a327dd0c.tar.gz gsoc2013-epiphany-0ddce1562e5712c098358ab99eccded7a327dd0c.tar.zst gsoc2013-epiphany-0ddce1562e5712c098358ab99eccded7a327dd0c.zip |
ephy-web-view: do not duplicate code for the uri->title fallback
-rw-r--r-- | embed/ephy-web-view.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index 3b29e9f01..48dfd225a 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -1126,6 +1126,17 @@ ephy_web_view_finalize (GObject *object) G_OBJECT_CLASS (ephy_web_view_parent_class)->finalize (object); } +static char* +get_title_from_address (const char *address) +{ + if (g_str_has_prefix (address, "file://")) + return g_strdup (address + 7); + else if (!strcmp (address, EPHY_ABOUT_SCHEME":plugins")) + return g_strdup (_("Plugins")); + else + return ephy_string_get_host_name (address); +} + static void title_changed_cb (WebKitWebView *web_view, GParamSpec *spec, @@ -1141,13 +1152,10 @@ title_changed_cb (WebKitWebView *web_view, g_object_get (web_view, "title", &title, NULL); - /* Fallback to the URI as title if it's NULL. */ - if ((title == NULL || g_str_equal (title, "")) && uri != NULL) { - g_free (title); - title = g_strdup (uri); - } - ephy_web_view_set_title (EPHY_WEB_VIEW (web_view), title); + + if (!title && uri) + title = get_title_from_address (uri); if (uri && title) ephy_history_service_set_url_title (history, uri, title, NULL, NULL, NULL); @@ -2699,17 +2707,6 @@ ephy_web_view_set_address (EphyWebView *view, g_object_notify (object, "address"); } -static char* -get_title_from_address (const char *address) -{ - if (g_str_has_prefix (address, "file://")) - return g_strdup (address + 7); - else if (!strcmp (address, EPHY_ABOUT_SCHEME":plugins")) - return g_strdup (_("Plugins")); - else - return ephy_string_get_host_name (address); -} - /** * ephy_web_view_set_title: * @view: an #EphyWebView |