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);
gboolean key_tablabel(GtkWidget *, GdkEvent *, gpointer);
gboolean key_web_view(GtkWidget *, GdkEvent *, gpointer);
void mainwindow_setup(void);
+void mainwindow_title(gint);
+void notebook_switch_page(GtkNotebook *, GtkWidget *, guint, gpointer);
gboolean quit_if_nothing_active(void);
gboolean remote_msg(GIOChannel *, GIOCondition, gpointer);
void run_user_scripts(WebKitWebView *);
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);
g_signal_connect(G_OBJECT(evbox), "scroll-event",
G_CALLBACK(key_tablabel), c);
+ /* For easy access, store a reference to our label. */
+ g_object_set_data(G_OBJECT(evbox), "lariza-tab-label", c->tablabel);
+
/* This only shows the event box and the label inside, nothing else.
* Needed because the evbox/label is "internal" to the notebook and
* not part of the normal "widget tree" (IIUC). */
gtk_label_set_text(GTK_LABEL(c->tablabel), t);
gtk_widget_set_tooltip_text(c->tablabel, t);
+ mainwindow_title(gtk_notebook_get_current_page(GTK_NOTEBOOK(mw.notebook)));
}
void
!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);
}
}
+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.black", 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)
{
gtk_notebook_set_scrollable(GTK_NOTEBOOK(mw.notebook), TRUE);
gtk_notebook_set_tab_pos(GTK_NOTEBOOK(mw.notebook), tab_pos);
gtk_container_add(GTK_CONTAINER(mw.win), mw.notebook);
+ g_signal_connect(G_OBJECT(mw.notebook), "switch-page",
+ G_CALLBACK(notebook_switch_page), NULL);
+}
+
+void
+mainwindow_title(gint idx)
+{
+ GtkWidget *child, *widg, *tablabel;
+ const gchar *text;
+
+ child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(mw.notebook), idx);
+ if (child == NULL)
+ return;
+
+ widg = gtk_notebook_get_tab_label(GTK_NOTEBOOK(mw.notebook), child);
+ tablabel = (GtkWidget *)g_object_get_data(G_OBJECT(widg), "lariza-tab-label");
+ text = gtk_label_get_text(GTK_LABEL(tablabel));
+ gtk_window_set_title(GTK_WINDOW(mw.win), text);
+}
+
+void
+notebook_switch_page(GtkNotebook *nb, GtkWidget *p, guint idx, gpointer data)
+{
+ mainwindow_title(idx);
}
gboolean
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);
}