summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tab-chrome.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/src/tab-chrome.c b/src/tab-chrome.c
index 3fc8674..6a4c77c 100644
--- a/src/tab-chrome.c
+++ b/src/tab-chrome.c
@@ -20,6 +20,7 @@
*/
#include <stdlib.h>
+#include <string.h>
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
@@ -524,16 +525,36 @@ mq_tab_chrome_get_container(MqTabChrome *chrome)
return chrome->container;
}
+static gchar *
+web_view_get_uri(WebKitWebView *web_view)
+{
+ const gchar *uri;
+ gchar *rw_uri;
+
+ uri = webkit_web_view_get_uri(web_view);
+
+ if (g_str_has_prefix(uri, "mq-about:")) {
+ rw_uri = g_strconcat("about:", uri + strlen("mq-about:"), NULL);
+ } else {
+ rw_uri = g_strdup(uri);
+ }
+
+ return rw_uri;
+}
+
static void
load_changed_cb(WebKitWebView *web_view, WebKitLoadEvent load_event,
MqTabChrome *chrome)
{
+ gchar *uri;
+
switch (load_event) {
case WEBKIT_LOAD_STARTED:
case WEBKIT_LOAD_REDIRECTED:
case WEBKIT_LOAD_COMMITTED:
- gtk_entry_set_text(GTK_ENTRY(chrome->uri_entry),
- webkit_web_view_get_uri(web_view));
+ uri = web_view_get_uri(web_view);
+ gtk_entry_set_text(GTK_ENTRY(chrome->uri_entry), uri);
+ g_free(uri);
gtk_entry_set_attributes(GTK_ENTRY(chrome->uri_entry),
NULL);
break;
@@ -567,6 +588,9 @@ mouse_target_changed_cb(WebKitWebView __attribute__((unused)) *web_view,
guint __attribute__((unused)) modifiers,
MqTabChrome *chrome)
{
+ gchar *uri;
+
+ uri = web_view_get_uri(web_view);
if (webkit_hit_test_result_context_is_link(hit_test_result)) {
if (gtk_widget_has_focus(chrome->uri_entry)) {
} else if (chrome->hovered_link_uri &&
@@ -576,8 +600,8 @@ mouse_target_changed_cb(WebKitWebView __attribute__((unused)) *web_view,
/* The user has edited the hovered link URI in the URI
* bar. */
} else if (g_strcmp0(gtk_entry_get_text(
- GTK_ENTRY(chrome->uri_entry)),
- webkit_web_view_get_uri(web_view)) == 0) {
+ GTK_ENTRY(chrome->uri_entry)), uri) ==
+ 0) {
g_free(chrome->hovered_link_uri);
chrome->hovered_link_uri = g_strdup(
webkit_hit_test_result_get_link_uri(
@@ -609,12 +633,13 @@ mouse_target_changed_cb(WebKitWebView __attribute__((unused)) *web_view,
* URI bar. */
g_free(chrome->hovered_link_uri);
chrome->hovered_link_uri = NULL;
- gtk_entry_set_text(GTK_ENTRY(chrome->uri_entry),
- webkit_web_view_get_uri(web_view));
+ gtk_entry_set_text(GTK_ENTRY(chrome->uri_entry), uri);
gtk_entry_set_attributes(GTK_ENTRY(chrome->uri_entry),
NULL);
}
}
+
+ g_free(uri);
}
static void
@@ -640,8 +665,11 @@ static void
uri_cb(WebKitWebView *web_view, GParamSpec __attribute__((unused)) *paramspec,
MqTabChrome *chrome)
{
- gtk_entry_set_text(GTK_ENTRY(chrome->uri_entry),
- webkit_web_view_get_uri(web_view));
+ gchar *uri;
+
+ uri = web_view_get_uri(web_view);
+ gtk_entry_set_text(GTK_ENTRY(chrome->uri_entry), uri);
+ g_free(uri);
gtk_entry_set_attributes(GTK_ENTRY(chrome->uri_entry), NULL);
}