void grab_feeds_finished(GObject *, GAsyncResult *, gpointer);
void hover_web_view(WebKitWebView *, WebKitHitTestResult *, guint, gpointer);
void icon_location(GtkEntry *, GtkEntryIconPosition, GdkEvent *, gpointer);
+void init_default_web_context(void);
gboolean key_common(GtkWidget *, GdkEvent *, gpointer);
gboolean key_downloadmanager(GtkWidget *, GdkEvent *, gpointer);
gboolean key_location(GtkWidget *, GdkEvent *, gpointer);
gdouble global_zoom = 1.0;
gchar *history_file = NULL;
gchar *home_uri = "about:blank";
-gboolean initial_wc_setup_done = FALSE;
gchar *search_text = NULL;
GtkPositionType tab_pos = GTK_POS_TOP;
gint tab_width_chars = 20;
gboolean focus_tab)
{
struct Client *c;
- WebKitWebContext *wc;
gchar *f;
GtkWidget *evbox, *tabbox;
c->web_view = webkit_web_view_new();
else
c->web_view = webkit_web_view_new_with_related_view(related_wv);
- wc = webkit_web_view_get_context(WEBKIT_WEB_VIEW(c->web_view));
webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(c->web_view), global_zoom);
g_signal_connect(G_OBJECT(c->web_view), "notify::favicon",
g_signal_connect(G_OBJECT(c->web_view), "web-process-crashed",
G_CALLBACK(crashed_web_view), c);
- if (!initial_wc_setup_done)
- {
- if (accepted_language[0] != NULL)
- webkit_web_context_set_preferred_languages(wc, accepted_language);
-
- g_signal_connect(G_OBJECT(wc), "download-started",
- G_CALLBACK(download_handle_start), NULL);
-
- trust_user_certs(wc);
-
- webkit_web_context_set_favicon_database_directory(wc, NULL);
-
- initial_wc_setup_done = TRUE;
- }
-
if (user_agent != NULL)
g_object_set(G_OBJECT(webkit_web_view_get_settings(WEBKIT_WEB_VIEW(c->web_view))),
"user-agent", user_agent, NULL);
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);
!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);
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
}
}
+void
+init_default_web_context(void)
+{
+ gchar *p;
+ WebKitWebContext *wc;
+
+ wc = webkit_web_context_get_default();
+
+ p = g_build_filename(g_get_user_config_dir(), __NAME__, "adblock", NULL);
+ webkit_web_context_set_sandbox_enabled(wc, TRUE);
+ webkit_web_context_add_path_to_sandbox(wc, p, TRUE);
+ g_free(p);
+
+ webkit_web_context_set_process_model(wc,
+ WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
+
+ p = g_build_filename(g_get_user_config_dir(), __NAME__, "web_extensions",
+ NULL);
+ webkit_web_context_set_web_extensions_directory(wc, p);
+ g_free(p);
+
+ if (accepted_language[0] != NULL)
+ webkit_web_context_set_preferred_languages(wc, accepted_language);
+
+ g_signal_connect(G_OBJECT(wc), "download-started",
+ G_CALLBACK(download_handle_start), NULL);
+
+ trust_user_certs(wc);
+
+ webkit_web_context_set_favicon_database_directory(wc, NULL);
+}
+
gboolean
key_common(GtkWidget *widget, GdkEvent *event, gpointer data)
{
int
main(int argc, char **argv)
{
- gchar *c;
int opt, i;
gtk_init(&argc, &argv);
- webkit_web_context_set_process_model(webkit_web_context_get_default(),
- WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
-
grab_environment_configuration();
while ((opt = getopt(argc, argv, "C")) != -1)
if (cooperative_instances)
cooperation_setup();
- downloadmanager_setup();
-
- mainwindow_setup();
if (!cooperative_instances || cooperative_alone)
- {
- c = g_build_filename(g_get_user_config_dir(), __NAME__, "web_extensions",
- NULL);
- webkit_web_context_set_web_extensions_directory(
- webkit_web_context_get_default(), c
- );
- }
+ init_default_web_context();
+
+ downloadmanager_setup();
+ mainwindow_setup();
if (optind >= argc)
client_new(home_uri, NULL, TRUE, TRUE);
if (!cooperative_instances || cooperative_alone)
gtk_main();
+
exit(EXIT_SUCCESS);
}