Beispiel #1
0
/* browserwindow_new */
BrowserWindow * browserwindow_new(String const * directory)
{
	BrowserWindow * browser;
	GtkAccelGroup * group;
	GtkWidget * vbox;
#ifndef EMBEDDED
	GtkWidget * tb_menubar;
#endif

	if((browser = malloc(sizeof(*browser))) == NULL)
	{
		browser_error(NULL, (directory != NULL) ? directory : ".", 1);
		return NULL;
	}
	browser->window = NULL;

	/* window */
	group = gtk_accel_group_new();
	browser->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_add_accel_group(GTK_WINDOW(browser->window), group);
	g_object_unref(group);
	gtk_window_set_default_size(GTK_WINDOW(browser->window), 720, 480);
#if GTK_CHECK_VERSION(2, 6, 0)
	gtk_window_set_icon_name(GTK_WINDOW(browser->window), ICON_NAME);
#endif
	gtk_window_set_title(GTK_WINDOW(browser->window), _("File manager"));
	g_signal_connect_swapped(browser->window, "delete-event", G_CALLBACK(
				_browserwindow_on_closex), browser);

	/* browser */
	browser_window_cnt++;
	if((browser->browser = browser_new(browser->window, group, directory))
			== NULL)
	{
		browserwindow_delete(browser);
		return NULL;
	}

	/* widgets */
#if GTK_CHECK_VERSION(3, 0, 0)
	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
	vbox = gtk_vbox_new(FALSE, 0);
#endif
	/* menubar */
#ifndef EMBEDDED
	tb_menubar = desktop_menubar_create(_browserwindow_menubar, browser,
			group);
	gtk_box_pack_start(GTK_BOX(vbox), tb_menubar, FALSE, FALSE, 0);
#endif
	desktop_accel_create(_browserwindow_accel, browser, group);
	gtk_box_pack_start(GTK_BOX(vbox), browser_get_widget(browser->browser),
			TRUE, TRUE, 0);

	gtk_container_add(GTK_CONTAINER(browser->window), vbox);
	gtk_widget_show_all(browser->window);
	return browser;
}
Beispiel #2
0
gboolean cmd_winopen(Browser *b, int argc, char **argv)
{
	Browser *n = browser_new();
	char *uri;

	uri = strjoinv(argv, " ");
	browser_load_uri(n, uri);

	free(uri);

	return TRUE;
}
Beispiel #3
0
/* main entry-point */
int main(int argc, char *argv[])
{
	gboolean version = FALSE;
	gboolean fullscreen = FALSE;
	char *geometry = NULL;
	char **uris = NULL;
	GError *error = NULL;

	GOptionEntry entries[] = {
		{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Print version number", NULL },
		{ "fullscreen", 0, 0, G_OPTION_ARG_NONE, &fullscreen, "Fullscreen mode", NULL },
		{ "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry, "X geometry specification", "GEOMETRY" },
		{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &uris, "Addresses", NULL },
		{ NULL }
	};

	/* initialize GTK and parse commandline options */
	if (!gtk_init_with_args(&argc, &argv, "[addresses]", entries, NULL, &error)) {
		die("%s\n", error->message);
	}

	if (version) {
		printf("hydra %s, 2014 David Luco\n", VERSION);
		exit(EXIT_SUCCESS);
	}

	/* create top level Hydra struct */
	hydra = g_new0(Hydra, 1);

	/* create first browser and add to browsers list */
	Browser *b = browser_new();
	hydra->browsers = g_list_append(hydra->browsers, b);

	if (fullscreen) {
		gtk_window_fullscreen(GTK_WINDOW(b->window));
	}
	
	if (uris) {
		/* load first uri in first tab (already created) */
		tab_load_uri(browser_get_current_tab(b), *uris++);
		/* load other uris (if any) in new tabs */
		while (uris && *uris) {
			tab_load_uri(tab_new(b, "Loading..."), *uris++);
		}
	} else {
		/* load homepage on startup */
		tab_load_uri(browser_get_current_tab(b), DEFAULT_HOME);
	}

	gtk_main();

	return 0;
}
Beispiel #4
0
/* main */
int main(int argc, char * argv[])
{
	int o;
	int i;

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
	gtk_init(&argc, &argv);
	while((o = getopt(argc, argv, "")) != -1)
		switch(o)
		{
			default:
				return _usage();
		}
	if(optind == argc)
		browser_new(NULL);
	else
		for(i = optind; i < argc; i++)
			browser_new(argv[i]);
	gtk_main();
	return 0;
}
Beispiel #5
0
int main(int argc, char *argv[])
{
	Browser *b;
	char **arg, *uri = NULL;

	gtk_init(&argc, &argv);

	for (arg = argv+1; *arg; arg++) {
		if (strcmp_s(*arg, "-p") == 0) {
			private_browsing = TRUE;
		} else {
			uri = *arg;
			break;
		}
	}

	/* init toplevel struct */
	ripcurl = emalloc(sizeof *ripcurl);
	ripcurl_init();
	ripcurl_settings();
	ripcurl_style();
	
	load_data();

	/* init first browser window */
	b = browser_new();

	if (uri) {
		browser_load_uri(b, uri);
	} else {
		browser_load_uri(b, home_page);
	}

	/* start GTK+ main loop */
	gtk_main();

	cleanup();

	return 0;
}
Beispiel #6
0
WebKitWebView *cb_wv_create_web_view(WebKitWebView *v, WebKitWebFrame *f, Browser *b)
{
	Browser *n = browser_new();

	return n->UI.view;
}