10 #include <gdk/gdkkeysyms.h>
12 #include <webkit/webkit.h>
15 static void adblock(WebKitWebView *, WebKitWebFrame *, WebKitWebResource *,
16 WebKitNetworkRequest *, WebKitNetworkResponse *, gpointer);
17 static void adblock_load(void);
18 static void client_destroy(GtkWidget *obj, gpointer data);
19 static gboolean client_destroy_request(WebKitWebView *, gpointer);
20 static WebKitWebView *client_new(const gchar *uri);
21 static WebKitWebView *client_new_request(WebKitWebView *, WebKitWebFrame *,
23 static void cooperation_setup(void);
24 static void changed_load_progress(GObject *obj, GParamSpec *pspec,
26 static void changed_title(GObject *, GParamSpec *, gpointer);
27 static void changed_uri(GObject *, GParamSpec *, gpointer);
28 static gboolean download_handle(WebKitWebView *, WebKitDownload *, gpointer);
29 static gboolean download_reset_indicator(gpointer);
30 static gboolean download_request(WebKitWebView *, WebKitWebFrame *,
31 WebKitNetworkRequest *, gchar *,
32 WebKitWebPolicyDecision *, gpointer);
33 static void downloadmanager_cancel(GtkToolButton *, gpointer data);
34 static void downloadmanager_progress(GObject *obj, GParamSpec *pspec,
36 static void downloadmanager_setup(void);
37 static gchar *ensure_url_scheme(const gchar *);
38 static void grab_environment_configuration(void);
39 static void hover_web_view(WebKitWebView *, gchar *, gchar *, gpointer);
40 static gboolean key_downloadmanager(GtkWidget *, GdkEvent *, gpointer);
41 static gboolean key_location(GtkWidget *, GdkEvent *, gpointer);
42 static gboolean key_web_view(GtkWidget *, GdkEvent *, gpointer);
43 static void keywords_load(void);
44 static gboolean keywords_try_search(WebKitWebView *, const gchar *);
45 static gboolean remote_msg(GIOChannel *, GIOCondition, gpointer);
46 static void search(gpointer, gint);
47 static Window tabbed_launch(void);
48 static void usage(void);
63 struct DownloadManager
71 static gchar *accepted_language = "en-US";
72 static GSList *adblock_patterns = NULL;
73 static gint clients = 0;
74 static gboolean cooperative_alone = TRUE;
75 static gboolean cooperative_instances = TRUE;
76 static int cooperative_pipe_fp = 0;
77 static gchar *download_dir = "/tmp";
78 static gint downloads_indicated = 0;
79 static Window embed = 0;
80 static gchar *first_uri = NULL;
81 static gdouble global_zoom = 1.0;
82 static GHashTable *keywords = NULL;
83 static gboolean language_is_set = FALSE;
84 static gchar *search_text = NULL;
85 static gboolean show_all_requests = FALSE;
86 static gboolean tabbed_automagic = TRUE;
90 adblock(WebKitWebView *web_view, WebKitWebFrame *frame,
91 WebKitWebResource *resource, WebKitNetworkRequest *request,
92 WebKitNetworkResponse *response, gpointer data)
94 GSList *it = adblock_patterns;
103 uri = webkit_network_request_get_uri(request);
104 if (show_all_requests)
105 fprintf(stderr, " -> %s\n", uri);
109 if (g_regex_match((GRegex *)(it->data), uri, 0, NULL))
111 webkit_network_request_set_uri(request, "about:blank");
112 if (show_all_requests)
113 fprintf(stderr, " BLOCKED!\n");
116 it = g_slist_next(it);
125 GIOChannel *channel = NULL;
129 path = g_build_filename(g_get_user_config_dir(), __NAME__, "adblock.black",
131 channel = g_io_channel_new_file(path, "r", &err);
134 while (g_io_channel_read_line(channel, &buf, NULL, NULL, NULL)
135 == G_IO_STATUS_NORMAL)
138 re = g_regex_new(buf,
139 G_REGEX_CASELESS | G_REGEX_OPTIMIZE,
140 G_REGEX_MATCH_PARTIAL, &err);
143 fprintf(stderr, __NAME__": Could not compile regex: %s\n", buf);
147 adblock_patterns = g_slist_append(adblock_patterns, re);
152 g_io_channel_shutdown(channel, FALSE, NULL);
157 client_destroy(GtkWidget *obj, gpointer data)
159 struct Client *c = (struct Client *)data;
172 client_destroy_request(WebKitWebView *web_view, gpointer data)
174 struct Client *c = (struct Client *)data;
178 gtk_widget_destroy(c->win);
184 client_new(const gchar *uri)
189 if (uri != NULL && cooperative_instances && !cooperative_alone)
191 write(cooperative_pipe_fp, uri, strlen(uri));
192 write(cooperative_pipe_fp, "\n", 1);
196 c = malloc(sizeof(struct Client));
199 fprintf(stderr, __NAME__": fatal: malloc failed\n");
206 c->win = gtk_plug_new(embed);
207 if (!gtk_plug_get_embedded(GTK_PLUG(c->win)))
209 fprintf(stderr, __NAME__": Can't plug-in to XID %ld.\n", embed);
210 gtk_widget_destroy(c->win);
218 c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
219 gtk_window_set_wmclass(GTK_WINDOW(c->win), __NAME__, __NAME_CAPITALIZED__);
222 /* When using Gtk2, it only shows a white area when run in suckless'
223 * tabbed. It appears we need to set a default window size for this
224 * to work. This is not needed when using Gtk3. */
225 gtk_window_set_default_size(GTK_WINDOW(c->win), 1024, 768);
227 g_signal_connect(G_OBJECT(c->win), "destroy", G_CALLBACK(client_destroy), c);
228 gtk_window_set_title(GTK_WINDOW(c->win), __NAME__);
230 c->web_view = webkit_web_view_new();
232 /* XXX I really do want to enable this option. However, I get
233 * reproducable crashes with it enabled. I've seen bug reports from
234 * 2010 about this... WebKit crashes in libpixman, so maybe it's not
236 * Yeah, well. I'll turn it off for now. */
237 /*webkit_web_view_set_full_content_zoom(WEBKIT_WEB_VIEW(c->web_view), TRUE);*/
239 webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(c->web_view), global_zoom);
240 g_signal_connect(G_OBJECT(c->web_view), "notify::title",
241 G_CALLBACK(changed_title), c);
242 g_signal_connect(G_OBJECT(c->web_view), "notify::uri",
243 G_CALLBACK(changed_uri), c);
244 g_signal_connect(G_OBJECT(c->web_view), "notify::progress",
245 G_CALLBACK(changed_load_progress), c);
246 g_signal_connect(G_OBJECT(c->web_view), "create-web-view",
247 G_CALLBACK(client_new_request), NULL);
248 g_signal_connect(G_OBJECT(c->web_view), "close-web-view",
249 G_CALLBACK(client_destroy_request), c);
250 g_signal_connect(G_OBJECT(c->web_view),
251 "mime-type-policy-decision-requested",
252 G_CALLBACK(download_request), NULL);
253 g_signal_connect(G_OBJECT(c->web_view), "download-requested",
254 G_CALLBACK(download_handle), c);
255 g_signal_connect(G_OBJECT(c->web_view), "key-press-event",
256 G_CALLBACK(key_web_view), c);
257 g_signal_connect(G_OBJECT(c->web_view), "button-press-event",
258 G_CALLBACK(key_web_view), c);
259 g_signal_connect(G_OBJECT(c->web_view), "hovering-over-link",
260 G_CALLBACK(hover_web_view), c);
261 g_signal_connect(G_OBJECT(c->web_view), "resource-request-starting",
262 G_CALLBACK(adblock), NULL);
264 if (!language_is_set)
266 g_object_set(webkit_get_default_session(), "accept-language",
267 accepted_language, NULL);
268 language_is_set = TRUE;
271 c->scroll = gtk_scrolled_window_new(NULL, NULL);
273 gtk_container_add(GTK_CONTAINER(c->scroll), c->web_view);
275 c->location = gtk_entry_new();
276 g_signal_connect(G_OBJECT(c->location), "key-press-event",
277 G_CALLBACK(key_location), c);
279 c->progress = gtk_progress_bar_new();
280 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(c->progress), 0);
282 c->status = gtk_progress_bar_new();
283 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(c->status), 0);
284 gtk_widget_set_size_request(c->status, 20, -1);
286 c->top_box = gtk_hbox_new(FALSE, 0);
287 gtk_box_pack_start(GTK_BOX(c->top_box), c->status, FALSE, FALSE, 2);
288 gtk_box_pack_start(GTK_BOX(c->top_box), c->location, TRUE, TRUE, 0);
289 gtk_box_pack_end(GTK_BOX(c->top_box), c->progress, FALSE, TRUE, 2);
291 c->vbox = gtk_vbox_new(FALSE, 0);
292 gtk_box_pack_start(GTK_BOX(c->vbox), c->top_box, FALSE, FALSE, 2);
293 gtk_container_add(GTK_CONTAINER(c->vbox), c->scroll);
295 gtk_container_add(GTK_CONTAINER(c->win), c->vbox);
297 gtk_widget_grab_focus(c->web_view);
298 gtk_widget_show_all(c->win);
302 f = ensure_url_scheme(uri);
303 if (show_all_requests)
304 fprintf(stderr, "====> %s\n", uri);
305 webkit_web_view_load_uri(WEBKIT_WEB_VIEW(c->web_view), f);
311 return WEBKIT_WEB_VIEW(c->web_view);
315 client_new_request(WebKitWebView *web_view, WebKitWebFrame *frame, gpointer data)
321 return client_new(NULL);
325 cooperation_setup(void)
330 fifopath = g_build_filename(g_get_user_runtime_dir(), __NAME__".fifo", NULL);
332 if (!g_file_test(fifopath, G_FILE_TEST_EXISTS))
333 mkfifo(fifopath, 0600);
335 cooperative_pipe_fp = open(fifopath, O_WRONLY | O_NONBLOCK);
336 if (!cooperative_pipe_fp)
338 fprintf(stderr, __NAME__": Can't open FIFO at all.\n");
342 if (write(cooperative_pipe_fp, "", 0) == -1)
344 /* Could not do an empty write to the FIFO which means there's
345 * no one listening. */
346 close(cooperative_pipe_fp);
347 towatch = g_io_channel_new_file(fifopath, "r+", NULL);
348 g_io_add_watch(towatch, G_IO_IN, (GIOFunc)remote_msg, NULL);
351 cooperative_alone = FALSE;
358 changed_load_progress(GObject *obj, GParamSpec *pspec, gpointer data)
360 struct Client *c = (struct Client *)data;
366 p = webkit_web_view_get_progress(WEBKIT_WEB_VIEW(c->web_view));
367 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(c->progress), p);
371 changed_title(GObject *obj, GParamSpec *pspec, gpointer data)
374 struct Client *c = (struct Client *)data;
379 t = webkit_web_view_get_title(WEBKIT_WEB_VIEW(c->web_view));
380 gtk_window_set_title(GTK_WINDOW(c->win), (t == NULL ? __NAME__ : t));
384 changed_uri(GObject *obj, GParamSpec *pspec, gpointer data)
387 struct Client *c = (struct Client *)data;
392 t = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
393 gtk_entry_set_text(GTK_ENTRY(c->location), (t == NULL ? __NAME__ : t));
397 download_handle(WebKitWebView *web_view, WebKitDownload *download, gpointer data)
399 struct Client *c = (struct Client *)data;
400 gchar *path, *path2 = NULL, *uri;
408 path = g_build_filename(download_dir,
409 webkit_download_get_suggested_filename(download),
411 path2 = g_strdup(path);
412 while (g_file_test(path2, G_FILE_TEST_EXISTS) && suffix < 1000)
416 path2 = g_strdup_printf("%s.%d", path, suffix);
422 fprintf(stderr, __NAME__": Suffix reached limit for download.\n");
427 uri = g_filename_to_uri(path2, NULL, NULL);
428 webkit_download_set_destination_uri(download, uri);
432 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(c->status), 1);
433 downloads_indicated++;
434 g_timeout_add(500, download_reset_indicator, c);
436 tb = gtk_tool_button_new_from_stock(GTK_STOCK_DELETE);
437 gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb),
438 webkit_download_get_suggested_filename(download));
439 gtk_toolbar_insert(GTK_TOOLBAR(dm.toolbar), tb, 0);
440 gtk_widget_show_all(dm.toolbar);
442 g_signal_connect(G_OBJECT(download), "notify::progress",
443 G_CALLBACK(downloadmanager_progress), tb);
445 g_object_ref(download);
446 g_signal_connect(G_OBJECT(tb), "clicked",
447 G_CALLBACK(downloadmanager_cancel), download);
457 download_reset_indicator(gpointer data)
459 struct Client *c = (struct Client *)data;
461 downloads_indicated--;
462 if (downloads_indicated == 0)
463 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(c->status), 0);
469 download_request(WebKitWebView *web_view, WebKitWebFrame *frame,
470 WebKitNetworkRequest *request, gchar *mime_type,
471 WebKitWebPolicyDecision *policy_decision, gpointer data)
477 if (!webkit_web_view_can_show_mime_type(web_view, mime_type))
479 webkit_web_policy_decision_download(policy_decision);
486 downloadmanager_cancel(GtkToolButton *tb, gpointer data)
488 WebKitDownload *download = WEBKIT_DOWNLOAD(data);
490 webkit_download_cancel(download);
491 g_object_unref(download);
493 gtk_widget_destroy(GTK_WIDGET(tb));
497 downloadmanager_progress(GObject *obj, GParamSpec *pspec, gpointer data)
499 WebKitDownload *download = WEBKIT_DOWNLOAD(obj);
500 GtkToolItem *tb = GTK_TOOL_ITEM(data);
506 p = webkit_download_get_progress(download) * 100;
507 t = g_strdup_printf("%s (%.0f%%)",
508 webkit_download_get_suggested_filename(download),
510 gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), t);
515 downloadmanager_setup(void)
517 dm.win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
518 gtk_window_set_type_hint(GTK_WINDOW(dm.win), GDK_WINDOW_TYPE_HINT_DIALOG);
519 gtk_window_set_default_size(GTK_WINDOW(dm.win), 500, 250);
520 gtk_window_set_title(GTK_WINDOW(dm.win), __NAME__" - Download Manager");
521 g_signal_connect(G_OBJECT(dm.win), "delete-event",
522 G_CALLBACK(gtk_widget_hide_on_delete), NULL);
523 g_signal_connect(G_OBJECT(dm.win), "key-press-event",
524 G_CALLBACK(key_downloadmanager), NULL);
526 dm.toolbar = gtk_toolbar_new();
527 gtk_orientable_set_orientation(GTK_ORIENTABLE(dm.toolbar),
528 GTK_ORIENTATION_VERTICAL);
529 gtk_toolbar_set_style(GTK_TOOLBAR(dm.toolbar), GTK_TOOLBAR_BOTH_HORIZ);
530 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(dm.toolbar), FALSE);
532 dm.scroll = gtk_scrolled_window_new(NULL, NULL);
533 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(dm.scroll),
534 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
535 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(dm.scroll),
538 gtk_container_add(GTK_CONTAINER(dm.win), dm.scroll);
542 ensure_url_scheme(const gchar *t)
546 f = g_ascii_strdown(t, -1);
547 if (!g_str_has_prefix(f, "http:") &&
548 !g_str_has_prefix(f, "https:") &&
549 !g_str_has_prefix(f, "file:") &&
550 !g_str_has_prefix(f, "about:"))
553 f = g_strdup_printf("http://%s", t);
561 grab_environment_configuration(void)
565 e = g_getenv(__NAME_UPPERCASE__"_ACCEPTED_LANGUAGE");
567 accepted_language = g_strdup(e);
569 e = g_getenv(__NAME_UPPERCASE__"_DOWNLOAD_DIR");
571 download_dir = g_strdup(e);
573 e = g_getenv(__NAME_UPPERCASE__"_ZOOM");
575 global_zoom = atof(e);
579 hover_web_view(WebKitWebView *web_view, gchar *title, gchar *uri, gpointer data)
581 struct Client *c = (struct Client *)data;
586 if (!gtk_widget_is_focus(c->location))
589 gtk_entry_set_text(GTK_ENTRY(c->location),
590 webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view)));
592 gtk_entry_set_text(GTK_ENTRY(c->location), uri);
597 key_downloadmanager(GtkWidget *widget, GdkEvent *event, gpointer data)
602 if (event->type == GDK_KEY_PRESS)
604 if (((GdkEventKey *)event)->state & GDK_MOD1_MASK)
606 switch (((GdkEventKey *)event)->keyval)
608 case GDK_KEY_q: /* close window (left hand) */
609 gtk_widget_hide(dm.win);
619 key_location(GtkWidget *widget, GdkEvent *event, gpointer data)
621 struct Client *c = (struct Client *)data;
627 if (event->type == GDK_KEY_PRESS)
629 if (((GdkEventKey *)event)->state & GDK_MOD1_MASK)
631 switch (((GdkEventKey *)event)->keyval)
633 case GDK_KEY_q: /* close window (left hand) */
634 gtk_widget_destroy(c->win);
636 case GDK_KEY_d: /* download manager (left hand) */
637 gtk_widget_show_all(dm.win);
639 case GDK_KEY_r: /* reload (left hand) */
640 webkit_web_view_reload_bypass_cache(WEBKIT_WEB_VIEW(
643 case GDK_KEY_k: /* initiate search (BOTH hands) */
644 gtk_entry_set_text(GTK_ENTRY(c->location), "/");
645 gtk_editable_set_position(GTK_EDITABLE(c->location), -1);
651 switch (((GdkEventKey *)event)->keyval)
654 gtk_widget_grab_focus(c->web_view);
655 t = gtk_entry_get_text(GTK_ENTRY(c->location));
656 if (t != NULL && t[0] == '/')
658 if (search_text != NULL)
660 search_text = g_strdup(t + 1); /* XXX whacky */
663 else if (!keywords_try_search(WEBKIT_WEB_VIEW(c->web_view), t))
665 f = ensure_url_scheme(t);
666 if (show_all_requests)
667 fprintf(stderr, "====> %s\n", f);
668 webkit_web_view_load_uri(WEBKIT_WEB_VIEW(c->web_view), f);
673 t = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
674 gtk_entry_set_text(GTK_ENTRY(c->location),
675 (t == NULL ? __NAME__ : t));
685 key_web_view(GtkWidget *widget, GdkEvent *event, gpointer data)
687 struct Client *c = (struct Client *)data;
688 WebKitHitTestResultContext ht_context;
689 WebKitHitTestResult *ht_result = NULL;
690 gchar *ht_uri = NULL, *f;
694 if (event->type == GDK_KEY_PRESS)
696 if (((GdkEventKey *)event)->state & GDK_MOD1_MASK)
698 switch (((GdkEventKey *)event)->keyval)
700 case GDK_KEY_q: /* close window (left hand) */
701 gtk_widget_destroy(c->win);
703 case GDK_KEY_w: /* home (left hand) */
704 f = ensure_url_scheme(first_uri);
705 if (show_all_requests)
706 fprintf(stderr, "====> %s\n", f);
707 webkit_web_view_load_uri(WEBKIT_WEB_VIEW(c->web_view), f);
710 case GDK_KEY_e: /* new tab (left hand) */
711 f = ensure_url_scheme(first_uri);
712 if (show_all_requests)
713 fprintf(stderr, "====> %s\n", f);
717 case GDK_KEY_r: /* reload (left hand) */
718 webkit_web_view_reload_bypass_cache(WEBKIT_WEB_VIEW(
721 case GDK_KEY_d: /* download manager (left hand) */
722 gtk_widget_show_all(dm.win);
724 case GDK_KEY_2: /* search forward (left hand) */
725 case GDK_KEY_n: /* search forward (maybe both hands) */
728 case GDK_KEY_3: /* search backward (left hand) */
731 case GDK_KEY_l: /* location (BOTH hands) */
732 gtk_widget_grab_focus(c->location);
734 case GDK_KEY_k: /* initiate search (BOTH hands) */
735 gtk_widget_grab_focus(c->location);
736 gtk_entry_set_text(GTK_ENTRY(c->location), "/");
737 gtk_editable_set_position(GTK_EDITABLE(c->location), -1);
741 else if (((GdkEventKey *)event)->keyval == GDK_KEY_Escape)
743 webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(c->web_view));
744 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(c->progress), 0);
747 else if (event->type == GDK_BUTTON_PRESS)
749 switch (((GdkEventButton *)event)->button)
752 ht_result = webkit_web_view_get_hit_test_result(
753 WEBKIT_WEB_VIEW(c->web_view),
754 (GdkEventButton *)event);
755 g_object_get(ht_result, "context", &ht_context, NULL);
756 if (ht_context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
758 g_object_get(ht_result, "link-uri", &ht_uri, NULL);
760 g_object_unref(ht_result);
763 g_object_unref(ht_result);
766 webkit_web_view_go_back(WEBKIT_WEB_VIEW(c->web_view));
769 webkit_web_view_go_forward(WEBKIT_WEB_VIEW(c->web_view));
781 GIOChannel *channel = NULL;
784 gchar **tokens = NULL;
786 keywords = g_hash_table_new(g_str_hash, g_str_equal);
788 path = g_build_filename(g_get_user_config_dir(), __NAME__, "keywordsearch",
790 channel = g_io_channel_new_file(path, "r", &err);
793 while (g_io_channel_read_line(channel, &buf, NULL, NULL, NULL)
794 == G_IO_STATUS_NORMAL)
799 tokens = g_strsplit(buf, " ", 2);
800 if (tokens[0] != NULL && tokens[1] != NULL)
801 g_hash_table_insert(keywords, tokens[0], tokens[1]);
808 g_io_channel_shutdown(channel, FALSE, NULL);
813 keywords_try_search(WebKitWebView *web_view, const gchar *t)
815 gboolean ret = FALSE;
816 gchar **tokens = NULL;
820 tokens = g_strsplit(t, " ", 2);
821 if (tokens[0] != NULL && tokens[1] != NULL)
823 val = g_hash_table_lookup(keywords, tokens[0]);
826 uri = g_strdup_printf((gchar *)val, tokens[1]);
827 if (show_all_requests)
828 fprintf(stderr, "====> %s\n", uri);
829 webkit_web_view_load_uri(web_view, uri);
840 remote_msg(GIOChannel *channel, GIOCondition condition, gpointer data)
847 g_io_channel_read_line(channel, &uri, NULL, NULL, NULL);
858 search(gpointer data, gint direction)
860 struct Client *c = (struct Client *)data;
862 if (search_text == NULL)
865 webkit_web_view_search_text(WEBKIT_WEB_VIEW(c->web_view), search_text,
866 FALSE, direction == 1, TRUE);
873 GIOChannel *tabbed_stdout_channel;
875 gchar *output = NULL;
876 char *argv[] = { "tabbed", "-c", "-d", "-p", "s1", "-n", __NAME__, NULL };
879 if (!g_spawn_async_with_pipes(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL,
880 NULL, NULL, NULL, &tabbed_stdout, NULL,
883 fprintf(stderr, __NAME__": Could not launch tabbed: %s\n", err->message);
888 tabbed_stdout_channel = g_io_channel_unix_new(tabbed_stdout);
889 g_io_channel_read_line(tabbed_stdout_channel, &output, NULL, NULL, NULL);
892 fprintf(stderr, __NAME__": Could not read XID from tabbed\n");
896 g_io_channel_shutdown(tabbed_stdout_channel, FALSE, NULL);
899 plug_into = strtol(output, NULL, 16);
907 fprintf(stderr, "Usage: "__NAME__" [OPTION]... <URI>...\n");
913 main(int argc, char **argv)
917 gtk_init(&argc, &argv);
919 grab_environment_configuration();
921 while ((opt = getopt(argc, argv, "e:rCT")) != -1)
926 embed = atol(optarg);
927 tabbed_automagic = FALSE;
930 show_all_requests = TRUE;
933 cooperative_instances = FALSE;
936 tabbed_automagic = FALSE;
949 downloadmanager_setup();
951 if (tabbed_automagic && !(cooperative_instances && !cooperative_alone))
952 embed = tabbed_launch();
954 first_uri = g_strdup(argv[optind]);
955 for (i = optind; i < argc; i++)
957 if (!cooperative_instances || cooperative_alone)