コード例 #1
0
ファイル: deskmenu.c プロジェクト: pombredanne/NetSurf
static void __CDECL menu_open_file(short item, short title, void *data)
{

	LOG(("%s", __FUNCTION__));

	const char * filename = file_select(messages_get("OpenFile"), "");
	if( filename != NULL ){
		char * urltxt = local_file_to_url( filename );
		if( urltxt ){
			nsurl *url;
			nserror error;

			error = nsurl_create(urltxt, &url);
			if (error == NSERROR_OK) {
				error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
							      BROWSER_WINDOW_HISTORY,
							      url,
							      NULL,
							      NULL,
							      NULL);
				nsurl_unref(url);
				
			}
			if (error != NSERROR_OK) {
				warn_user(messages_get_errorcode(error), 0);
			}
			free( urltxt );
		}
	}
}
コード例 #2
0
ファイル: global_evnt.c プロジェクト: pcwalton/NetSurf
static void __CDECL menu_open_file(WINDOW *win, int item, int title, void *data)
{
	struct gui_window * gw;
	struct browser_window * bw ;

	LOG(("%s", __FUNCTION__));

	const char * filename = file_select( messages_get("OpenFile"), "" );
	if( filename != NULL ){
		char * url = local_file_to_url( filename );
		if( url ){
			bw = browser_window_create(url, NULL, NULL, true, false);
			free( url );
		}
	}
}
コード例 #3
0
ファイル: gui.c プロジェクト: mmuman/NetSurf
/**
 * Entry point from OS.
 *
 * /param argc The number of arguments in the string vector.
 * /param argv The argument string vector.
 * /return The return code to the OS
 */
int main(int argc, char** argv)
{
    char messages[PATH_MAX];
    char store[PATH_MAX];
    const char *addr;
    char * file_url = NULL;
    struct stat stat_buf;
    nsurl *url;
    nserror ret;

    struct netsurf_table atari_table = {
	.misc = &atari_misc_table,
	.window = &atari_window_table,
	.clipboard = &atari_clipboard_table,
	.download = atari_download_table,
	.fetch = &atari_fetch_table,
	.file = atari_file_table,
	.utf8 = atari_utf8_table,
	.search = atari_search_table,
	.llcache = filesystem_llcache_table,
	.bitmap = atari_bitmap_table,
	.layout = atari_layout_table
    };

    ret = netsurf_register(&atari_table);
    if (ret != NSERROR_OK) {
	die("NetSurf operation table failed registration");
    }

    /** @todo logging file descriptor update belongs in a nslog_init callback */
    setbuf(stderr, NULL);
    setbuf(stdout, NULL);
#ifdef WITH_DBG_LOGFILE
    freopen("stdout.log", "a+", stdout);
    freopen("stderr.log", "a+", stderr);
#endif

    graf_mouse(BUSY_BEE, NULL);

    init_app(NULL);

    init_os_info();

    atari_find_resource((char*)&messages, "messages", "res/messages");
    atari_find_resource((char*)&options, "Choices", "Choices");
    atari_find_resource((char*)&store, "cache", "res/cache");

    /* initialise logging - not fatal if it fails but not much we can
     * do about it
     */
    nslog_init(NULL, &argc, argv);

    /* user options setup */
    ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
    if (ret != NSERROR_OK) {
	die("Options failed to initialise");
    }
    nsoption_read(options, NULL);
    nsoption_commandline(&argc, argv, NULL);

    ret = messages_add_from_file(messages);

    /* common initialisation */
    LOG("Initialising core...");
    ret = netsurf_init(store);
    if (ret != NSERROR_OK) {
	die("NetSurf failed to initialise");
    }

    LOG("Initializing GUI...");
    gui_init(argc, argv);

    graf_mouse( ARROW , NULL);

    LOG("Creating initial browser window...");
    addr = option_homepage_url;
    if (strncmp(addr, "file://", 7) && strncmp(addr, "http://", 7)) {
	if (stat(addr, &stat_buf) == 0) {
	    file_url = local_file_to_url(addr);
	    addr = file_url;
	}
    }

    /* create an initial browser window */
    ret = nsurl_create(addr, &url);
    if (ret == NSERROR_OK) {
	ret = browser_window_create(BW_CREATE_HISTORY,
				    url,
				    NULL,
				    NULL,
				    NULL);
	nsurl_unref(url);
    }
    if (ret != NSERROR_OK) {
	atari_warn_user(messages_get_errorcode(ret), 0);
    } else {
	LOG("Entering Atari event mainloop...");
	while (!atari_quit) {
	    atari_poll();
	}
    }

    netsurf_exit();

    free(file_url);

#ifdef WITH_DBG_LOGFILE
    fclose(stdout);
    fclose(stderr);
#endif
    LOG("exit_gem");
    exit_gem();

    return 0;
}