Exemplo n.º 1
0
bool ro_gui_options_theme_ok(wimp_w w)
{
	struct toolbar_display *toolbar;
	struct theme_descriptor *theme_new = NULL;

	/* find the current selection */
	for (toolbar = toolbars; toolbar; toolbar = toolbar->next) {
		if (ro_gui_get_icon_selected_state(theme_pane, toolbar->icon_number)) {
			theme_new = toolbar->descriptor;
		  	break;
		}
	}

	/* set the options */
	if (option_theme)
		free(option_theme);
	if (theme_new) {
		option_theme = strdup(theme_new->leafname);
		ro_gui_theme_apply(theme_new);
	} else
		option_theme = NULL;
	ro_gui_save_options();

	/* store the pane status */
	ro_gui_wimp_event_memorise(theme_pane);
	return true;
}
Exemplo n.º 2
0
bool ro_gui_theme_install_apply(wimp_w w)
{
	char theme_save[256];
	char *theme_file;
	struct theme_descriptor *theme_install;
	os_error *error;
	char *fix;
	const char *source_data;
	unsigned long source_size;

	assert(theme_install_content);

	/* convert spaces to hard spaces */
	theme_file = strdup(theme_install_descriptor.name);
	if (!theme_file) {
	  	LOG(("malloc failed"));
	  	warn_user("NoMemory", 0);
		return false;
	}
	for (fix = theme_file; *fix != '\0'; fix++)
		if (*fix == ' ')
			*fix = 160;	/* hard space */

	/* simply overwrite previous theme versions */
	snprintf(theme_save, sizeof theme_save, "%s.%s",
                 nsoption_charp(theme_save), theme_file);

	theme_save[sizeof theme_save - 1] = '\0';

	source_data = content_get_source_data(theme_install_content, 
			&source_size);

	error = xosfile_save_stamped(theme_save, 0xffd,
			(byte *) source_data,
			(byte *) source_data + source_size);
	if (error) {
		LOG(("xosfile_save_stamped: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("ThemeInstallErr", 0);
		free(theme_file);
		return false;
	}

	/* apply the new theme */
	ro_gui_theme_get_available();
	theme_install = ro_gui_theme_find(theme_file);
	if (!theme_install || !ro_gui_theme_apply(theme_install)) {
		warn_user("ThemeApplyErr", 0);
	} else {
            nsoption_set_charp(theme, strdup(theme_install->leafname));
	}
	free(theme_file);
	ro_gui_save_options();
	return true;
}