]> git.armaanb.net Git - chorizo.git/blobdiff - browser.c
Focus c->web_view on new tabs
[chorizo.git] / browser.c
index 0185daa1b67e454e5b6951e8e2ce59075df8bd82..2ebcaff6de0a084bf823076649b4942bfdbcfd52 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -203,6 +203,7 @@ client_new(const gchar *uri, WebKitWebView *related_wv, gboolean show,
     c->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
     gtk_box_pack_start(GTK_BOX(c->vbox), c->location, FALSE, FALSE, 0);
     gtk_box_pack_start(GTK_BOX(c->vbox), c->web_view, TRUE, TRUE, 0);
+    gtk_container_set_focus_child(GTK_CONTAINER(c->vbox), c->web_view);
 
     c->tabicon = gtk_image_new_from_icon_name("text-html", GTK_ICON_SIZE_SMALL_TOOLBAR);
 
@@ -632,7 +633,8 @@ ensure_uri_scheme(const gchar *t)
         !g_str_has_prefix(f, "https:") &&
         !g_str_has_prefix(f, "file:") &&
         !g_str_has_prefix(f, "about:") &&
-        !g_str_has_prefix(f, "data:"))
+        !g_str_has_prefix(f, "data:") &&
+        !g_str_has_prefix(f, "webkit:"))
     {
         g_free(f);
         fabs = realpath(t, NULL);
@@ -766,28 +768,23 @@ hover_web_view(WebKitWebView *web_view, WebKitHitTestResult *ht, guint modifiers
                gpointer data)
 {
     struct Client *c = (struct Client *)data;
+    const char *to_show;
 
-    if (!gtk_widget_is_focus(c->location))
-    {
-        if (webkit_hit_test_result_context_is_link(ht))
-        {
-            gtk_entry_set_text(GTK_ENTRY(c->location),
-                               webkit_hit_test_result_get_link_uri(ht));
-
-            if (c->hover_uri != NULL)
-                g_free(c->hover_uri);
-            c->hover_uri = g_strdup(webkit_hit_test_result_get_link_uri(ht));
-        }
-        else
-        {
-            gtk_entry_set_text(GTK_ENTRY(c->location),
-                               webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view)));
+    g_free(c->hover_uri);
 
-            if (c->hover_uri != NULL)
-                g_free(c->hover_uri);
-            c->hover_uri = NULL;
-        }
+    if (webkit_hit_test_result_context_is_link(ht))
+    {
+        to_show = webkit_hit_test_result_get_link_uri(ht);
+        c->hover_uri = g_strdup(to_show);
     }
+    else
+    {
+        to_show = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
+        c->hover_uri = NULL;
+    }
+
+    if (!gtk_widget_is_focus(c->location))
+        gtk_entry_set_text(GTK_ENTRY(c->location), to_show);
 }
 
 void