Пример #1
0
/* exported interface documented in gtk/resources.h */
GdkCursor *nsgtk_create_menu_cursor(void)
{
	GdkCursor *cursor = NULL;
	GdkPixbuf *pixbuf;
	nserror res;

	res = nsgdk_pixbuf_new_from_resname("menu_cursor.png", &pixbuf);
	if (res == NSERROR_OK) {
		cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(),
						    pixbuf, 0, 3);
		g_object_unref(pixbuf);
	}

	return cursor;
}
Пример #2
0
/**
 * Initialize GTK interface.
 */
static nserror nsgtk_init(int argc, char** argv, char **respath)
{
	char buf[PATH_MAX];
	char *resource_filename;
	char *addr = NULL;
	nsurl *url;
	nserror error;

	error = nsgtk_builder_new_from_resname("warning", &warning_builder);
	if (error != NSERROR_OK) {
		LOG("Unable to initialise warning dialog");
		return error;
	}

	gtk_builder_connect_signals(warning_builder, NULL);

	/* set default icon if its available */
	error = nsgdk_pixbuf_new_from_resname("netsurf.xpm",
					      &win_default_icon_pixbuf);
	if (error == NSERROR_OK) {
		LOG("Seting default window icon");
		gtk_window_set_default_icon(win_default_icon_pixbuf);
	}

	/* Search engine sources */
	resource_filename = filepath_find(respath, "SearchEngines");
	search_web_init(resource_filename);
	if (resource_filename != NULL) {
		LOG("Using '%s' as Search Engines file", resource_filename);
		free(resource_filename);
	}

	/* Default favicon */
	error = nsgdk_pixbuf_new_from_resname("favicon.png", &favicon_pixbuf);
	if (error != NSERROR_OK) {
		favicon_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
						false, 8, 16, 16);
	}

	/* arrow down icon */
	error = nsgdk_pixbuf_new_from_resname("arrow_down_8x32.png",
					      &arrow_down_pixbuf);
	if (error != NSERROR_OK) {
		arrow_down_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
						   false, 8, 8, 32);
	}

	/* initialise throbber */
	error = nsgtk_throbber_init();
	if (error != NSERROR_OK) {
		LOG("Unable to initialise throbber.");
		return error;
	}

	/* Initialise completions - cannot fail */
	nsgtk_completion_init();

	filepath_sfinddef(respath, buf, "mime.types", "/etc/");
	gtk_fetch_filetype_init(buf);

	save_complete_init();

	urldb_load(nsoption_charp(url_file));
	urldb_load_cookies(nsoption_charp(cookie_file));

	/* The tree view system needs to know the screen's DPI, so we
	 * find that out here, rather than when we create a first browser
	 * window.
	 */
	browser_set_dpi(gdk_screen_get_resolution(gdk_screen_get_default()));
	LOG("Set CSS DPI to %d", browser_get_dpi());

	/* Initialise top level UI elements */
	error = nsgtk_download_init();
	if (error != NSERROR_OK) {
		LOG("Unable to initialise download window.");
		return error;
	}

	/* If there is a url specified on the command line use it */
	if (argc > 1) {
		struct stat fs;
		if (stat(argv[1], &fs) == 0) {
			size_t addrlen;
			char *rp = realpath(argv[1], NULL);
			assert(rp != NULL);

			/* calculate file url length including terminator */
			addrlen = SLEN("file://") + strlen(rp) + 1;
			addr = malloc(addrlen);
			assert(addr != NULL);
			snprintf(addr, addrlen, "file://%s", rp);
			free(rp);
		} else {
			addr = strdup(argv[1]);
		}
	}
	if (addr != NULL) {
		/* managed to set up based on local launch */
	} else if (nsoption_charp(homepage_url) != NULL) {
		addr = strdup(nsoption_charp(homepage_url));
	} else {
		addr = strdup(NETSURF_HOMEPAGE);
	}

	/* create an initial browser window */
	error = nsurl_create(addr, &url);
	if (error == NSERROR_OK) {
		error = browser_window_create(BW_CREATE_HISTORY,
					      url,
					      NULL,
					      NULL,
					      NULL);
		nsurl_unref(url);
	}

	free(addr);

	return error;
}