diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tab-chrome.c | 33 | ||||
-rw-r--r-- | src/tab-chrome.h | 1 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/tab-chrome.c b/src/tab-chrome.c index ea168dd..1b07236 100644 --- a/src/tab-chrome.c +++ b/src/tab-chrome.c @@ -117,6 +117,11 @@ navigation_toolbar_new(MqTabChrome *chrome, gchar *uri) gtk_tool_item_set_expand(uri_toolitem, TRUE); gtk_toolbar_insert(navigation_toolbar, uri_toolitem, -1); + /* URI bar hovered link style */ + chrome->hovered_link_style = pango_attr_list_new(); + pango_attr_list_insert(chrome->hovered_link_style, + pango_attr_style_new(PANGO_STYLE_ITALIC)); + gtk_widget_set_hexpand(GTK_WIDGET(navigation_toolbar), TRUE); chrome->load_failed = FALSE; @@ -203,6 +208,32 @@ load_failed_cb(WebKitWebView __attribute__((unused)) *web_view, } static void +mouse_target_changed_cb(WebKitWebView __attribute__((unused)) *web_view, + WebKitHitTestResult *hit_test_result, + guint __attribute__((unused)) modifiers, + MqTabChrome *chrome) +{ + if (webkit_hit_test_result_context_is_link(hit_test_result)) { + if (g_strcmp0(gtk_entry_get_text(GTK_ENTRY(chrome->uri_entry)), + webkit_web_view_get_uri(web_view)) == 0) { + gtk_entry_set_text(GTK_ENTRY(chrome->uri_entry), + webkit_hit_test_result_get_link_uri( + hit_test_result)); + gtk_entry_set_attributes(GTK_ENTRY(chrome->uri_entry), + chrome->hovered_link_style); + } + } else { + if (gtk_entry_get_attributes(GTK_ENTRY(chrome->uri_entry)) == + chrome->hovered_link_style) { + gtk_entry_set_text(GTK_ENTRY(chrome->uri_entry), + webkit_web_view_get_uri(web_view)); + gtk_entry_set_attributes(GTK_ENTRY(chrome->uri_entry), + NULL); + } + } +} + +static void load_progress_cb(WebKitWebView *web_view, GParamSpec __attribute__((unused)) *paramspec, MqTabChrome *chrome) { @@ -276,6 +307,8 @@ connect_web_view(MqTabChrome *chrome) G_CALLBACK(load_changed_cb), chrome); g_signal_connect(chrome->web_view, "load-failed", G_CALLBACK(load_failed_cb), chrome); + g_signal_connect(chrome->web_view, "mouse-target-changed", + G_CALLBACK(mouse_target_changed_cb), chrome); g_signal_connect(chrome->web_view, "notify::estimated-load-progress", G_CALLBACK(load_progress_cb), chrome); g_signal_connect(chrome->web_view, "notify::uri", diff --git a/src/tab-chrome.h b/src/tab-chrome.h index aef59f9..61fc069 100644 --- a/src/tab-chrome.h +++ b/src/tab-chrome.h @@ -36,6 +36,7 @@ typedef struct { GtkWidget *reload_icon; GtkToolItem *stop_reload_button; GtkWidget *uri_entry; + PangoAttrList *hovered_link_style; WebKitWebView *web_view; gboolean load_failed; } MqTabChrome; |