[epiphany/wip/exalm/newtab-dark] Stop using about:blank for new tabs
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/exalm/newtab-dark] Stop using about:blank for new tabs
- Date: Tue, 23 Nov 2021 21:19:23 +0000 (UTC)
commit be5025b4336ee1330f941590a90926529f14fbf4
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Nov 24 02:15:46 2021 +0500
Stop using about:blank for new tabs
about:blank is still white even when the app is using dark style.
Go with the same approach as Safari and introduce a new page for new tab
instead: about:newtab. As a bonus, we can give it a proper title instead
of "blank page".
Fixes https://gitlab.gnome.org/GNOME/epiphany/-/issues/1555
embed/ephy-about-handler.c | 19 +++++++++++++++++++
embed/ephy-embed-utils.c | 2 ++
src/ephy-action-bar-start.c | 2 +-
src/ephy-desktop-utils.c | 2 ++
src/preferences/prefs-general-page.c | 6 +++---
src/window-commands.c | 2 +-
6 files changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/embed/ephy-about-handler.c b/embed/ephy-about-handler.c
index 43d91adaa..8766d757b 100644
--- a/embed/ephy-about-handler.c
+++ b/embed/ephy-about-handler.c
@@ -440,6 +440,23 @@ out:
g_object_unref (request);
}
+static gboolean
+ephy_about_handler_handle_newtab (EphyAboutHandler *handler,
+ WebKitURISchemeRequest *request)
+{
+ char *data;
+
+ data = g_strdup_printf ("<html><head><title>%s</title>"
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
+ "</head><body style=\"color-scheme: light dark;\">"
+ "</body></html>",
+ _("New Tab"));
+
+ ephy_about_handler_finish_request (request, data, -1);
+
+ return TRUE;
+}
+
EphyHistoryQuery *
ephy_history_query_new_for_overview (void)
{
@@ -543,6 +560,8 @@ ephy_about_handler_handle_request (EphyAboutHandler *handler,
handled = ephy_about_handler_handle_epiphany (handler, request);
else if (!g_strcmp0 (path, "applications") && !ephy_is_running_inside_flatpak ())
handled = ephy_about_handler_handle_applications (handler, request);
+ else if (!g_strcmp0 (path, "newtab"))
+ handled = ephy_about_handler_handle_newtab (handler, request);
else if (!g_strcmp0 (path, "overview"))
handled = ephy_about_handler_handle_html_overview (handler, request);
else if (!g_strcmp0 (path, "incognito"))
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index e6cc8dd79..0ccfaf535 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -375,6 +375,7 @@ ephy_embed_utils_url_is_empty (const char *location)
return (location == NULL ||
location[0] == '\0' ||
strcmp (location, "about:blank") == 0 ||
+ strcmp (location, "ephy-about:newtab") == 0 ||
strcmp (location, "ephy-about:overview") == 0 ||
strcmp (location, "ephy-about:incognito") == 0);
}
@@ -383,6 +384,7 @@ ephy_embed_utils_url_is_empty (const char *location)
* window's location entry. */
static const char *do_not_show_address[] = {
"about:blank",
+ "ephy-about:newtab",
"ephy-about:incognito",
"ephy-about:overview",
NULL
diff --git a/src/ephy-action-bar-start.c b/src/ephy-action-bar-start.c
index 2cb1955d9..feac717fe 100644
--- a/src/ephy-action-bar-start.c
+++ b/src/ephy-action-bar-start.c
@@ -475,7 +475,7 @@ homepage_url_changed (GSettings *settings,
setting = g_settings_get_string (settings, key);
if (setting && setting[0])
- show_button = g_strcmp0 (setting, "about:blank") != 0;
+ show_button = g_strcmp0 (setting, "about:newtab") != 0;
else
show_button = is_desktop_pantheon ();
diff --git a/src/ephy-desktop-utils.c b/src/ephy-desktop-utils.c
index 5f52bb784..732f72ac2 100644
--- a/src/ephy-desktop-utils.c
+++ b/src/ephy-desktop-utils.c
@@ -62,6 +62,8 @@ ephy_get_fallback_favicon_name (const char *uri,
if (uri) {
if (g_str_has_prefix (uri, "ephy-about:overview") || g_str_has_prefix (uri, "about:overview"))
return type == EPHY_FAVICON_TYPE_SHOW_MISSING_PLACEHOLDER ? "view-grid-symbolic" : NULL;
+ else if (g_str_has_prefix (uri, "ephy-about:newtab") || g_str_has_prefix (uri, "about:newtab"))
+ return NULL;
else if (g_str_has_prefix (uri, "ephy-about:") || g_str_has_prefix (uri, "about:"))
return "web-browser-symbolic";
}
diff --git a/src/preferences/prefs-general-page.c b/src/preferences/prefs-general-page.c
index b17241edc..4bae44c72 100644
--- a/src/preferences/prefs-general-page.c
+++ b/src/preferences/prefs-general-page.c
@@ -960,7 +960,7 @@ blank_homepage_get_mapping (GValue *value,
const char *setting;
setting = g_variant_get_string (variant, NULL);
- if (g_strcmp0 (setting, "about:blank") == 0)
+ if (g_strcmp0 (setting, "about:newtab") == 0)
g_value_set_boolean (value, TRUE);
return TRUE;
@@ -978,7 +978,7 @@ blank_homepage_set_mapping (const GValue *value,
gtk_entry_set_text (GTK_ENTRY (general_page->custom_homepage_entry), "");
- return g_variant_new_string ("about:blank");
+ return g_variant_new_string ("about:newtab");
}
static gboolean
@@ -989,7 +989,7 @@ custom_homepage_get_mapping (GValue *value,
const char *setting;
setting = g_variant_get_string (variant, NULL);
- if (setting && setting[0] != '\0' && g_strcmp0 (setting, "about:blank") != 0)
+ if (setting && setting[0] != '\0' && g_strcmp0 (setting, "about:newtab") != 0)
g_value_set_boolean (value, TRUE);
return TRUE;
}
diff --git a/src/window-commands.c b/src/window-commands.c
index 8744ae10f..a6bc16b6b 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -1309,7 +1309,7 @@ window_cmd_new_tab (GSimpleAction *action,
char *url;
url = g_settings_get_string (EPHY_SETTINGS_MAIN, EPHY_PREFS_HOMEPAGE_URL);
- if (g_strcmp0 (url, "about:blank") != 0) {
+ if (g_strcmp0 (url, "about:newtab") != 0) {
g_free (url);
url = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]