Example #1
0
int initGUI()
{
	int len;
	char dirspec[256];

	

#ifdef EMBED_THEME

	config_file_t *embedded = &bootInfo->themeDefault;

	// build xml dictionary for embedded theme.plist
	ParseXMLFile( (char *) __theme_plist, &embedded->dictionary);

	// determine screen params form edid
	getResolution(&screen_params[0], &screen_params[1], &screen_params[2]);


	
#else

	/*
	 * Return Error since GUI can't run when embedtheme is not used.
	 */
	
	return 1;
	
#endif

  // Initalizing GUI strucutre.
  bzero(&gui, sizeof(gui_t));
	
	
	// find theme name in boot.plist
	getValueForKey( "Theme", &theme_name, &len, &bootInfo->bootConfig );
	
	sprintf(dirspec, "/Extra/Themes/%s/theme.plist", theme_name);

	loadConfigFile(dirspec, &bootInfo->themeConfig);


	// find best matching vesa mode for our requested width & height
	getGraphicModeParams(screen_params);

	// set our screen structure with the mode width & height
	gui.screen.width = screen_params[0];	
	gui.screen.height = screen_params[1];
	
	// load graphics otherwise fail and return
	if( !loadGraphics() )
	{
		// set embedded theme.plist as defaults
		loadThemeValues(&bootInfo->themeDefault, YES);
		
		// set user overides
		loadThemeValues(&bootInfo->themeConfig, NO);
		
		colorFont(&font_small,   gui.screen.font_small_color);
		colorFont(&font_console, gui.screen.font_console_color);
		
		// create the screen & window buffers
		if( !createBackBuffer( &gui.screen ) )
			if( !createWindowBuffer( &gui.screen ) )
				if( !createWindowBuffer( &gui.devicelist ) )
					if( !createWindowBuffer( &gui.bootprompt ) )
						if( !createWindowBuffer( &gui.infobox ) )
							if( !createWindowBuffer( &gui.menu ) ) 
							{							
								drawBackground();

								// lets copy the screen into the back buffer
								memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );

								setVideoMode( GRAPHICS_MODE, 0 );
								
								gui.initialised = YES;
									
								return 0;
							}	
	}

	// something went wrong
	return 1;
}
Example #2
0
File: gui.c Project: JrCs/Chameleon
int initGUI(void)
{
	int		val;
#ifdef EMBED_THEME
	config_file_t	*config;
	
	config = &bootInfo->themeConfig;
	if (ParseXMLFile((char *)__theme_plist, &config->dictionary) != 0) {
		return 1;
	}
#else
	int	len;
	char	dirspec[256];

	getValueForKey( "Theme", &theme_name, &len, &bootInfo->bootConfig );
	if ((strlen(theme_name) + 27) > sizeof(dirspec)) {
		return 1;
	}
	sprintf(dirspec, "/Extra/Themes/%s/theme.plist", theme_name);
	if (loadConfigFile(dirspec, &bootInfo->themeConfig) != 0) {
		return 1;
	}
#endif
	// parse display size parameters
	if (getIntForKey("screen_width", &val, &bootInfo->themeConfig)) {
		screen_params[0] = val;
	}
	if (getIntForKey("screen_height", &val, &bootInfo->themeConfig)) {
		screen_params[1] = val;
	}
	screen_params[2] = 32;

	// Initalizing GUI strucutre.
	bzero(&gui, sizeof(gui_t));
	
	// find best matching vesa mode for our requested width & height
	getGraphicModeParams(screen_params);

	// set our screen structure with the mode width & height
	gui.screen.width = screen_params[0];	
	gui.screen.height = screen_params[1];

	// load graphics otherwise fail and return
	if (loadGraphics() == 0) {
		loadThemeValues(&bootInfo->themeConfig, true);
		colorFont(&font_small, gui.screen.font_small_color);
		colorFont(&font_console, gui.screen.font_console_color);

		// create the screen & window buffers
		if (createBackBuffer(&gui.screen) == 0) {
			if (createWindowBuffer(&gui.screen) == 0) {
				if (createWindowBuffer(&gui.devicelist) == 0) {
					if (createWindowBuffer(&gui.bootprompt) == 0) {
						if (createWindowBuffer(&gui.infobox) == 0) {
							if (createWindowBuffer(&gui.menu) == 0) {							
								drawBackground();
								// lets copy the screen into the back buffer
								memcpy( gui.backbuffer->pixels, gui.screen.pixmap->pixels, gui.backbuffer->width * gui.backbuffer->height * 4 );
								setVideoMode( GRAPHICS_MODE, 0 );
								gui.initialised = true;
								return 0;
							}
						}
					}
				}
			}
		}
	}
	return 1;
}