Exemplo n.º 1
0
nserror theme_install_callback(hlcache_handle *handle,
		const hlcache_event *event, void *pw)
{
	char buffer[256];
	int author_indent = 0;

	switch (event->type) {

	case CONTENT_MSG_DONE:
	{
		const char *source_data;
		unsigned long source_size;

		theme_install_content = handle;

		source_data = content_get_source_data(handle, &source_size);

		if (!theme_install_read(source_data, source_size)) {
			warn_user("ThemeInvalid", 0);
			theme_install_close(dialog_theme_install);
			break;
		}

		/* remove '© ' from the start of the data */
		if (theme_install_descriptor.author[0] == '©')
			author_indent++;
		while (theme_install_descriptor.author[author_indent] == ' ')
			author_indent++;
		snprintf(buffer, sizeof buffer, messages_get("ThemeInstall"),
				theme_install_descriptor.name,
				&theme_install_descriptor.author[author_indent]);
		buffer[sizeof buffer - 1] = '\0';
		ro_gui_set_icon_string(dialog_theme_install,
				ICON_THEME_INSTALL_MESSAGE,
				buffer, true);
		ro_gui_set_icon_shaded_state(dialog_theme_install,
				ICON_THEME_INSTALL_INSTALL, false);
	}
		break;

	case CONTENT_MSG_ERROR:
		theme_install_close(dialog_theme_install);
		warn_user(event->data.error, 0);
		break;

	default:
		break;
	}

	return NSERROR_OK;
}
Exemplo n.º 2
0
static nserror
theme_install_callback(hlcache_handle *c,
		const hlcache_event *event, void *pw)
{
	switch (event->type) {
	case CONTENT_MSG_READY:
		break;

	case CONTENT_MSG_DONE:
	{
		const char *source_data;
		unsigned long source_size;

		source_data = content_get_source_data(c, &source_size);

		if (!theme_install_read(source_data, source_size))
			warn_user("ThemeInvalid", 0);

		hlcache_handle_release(c);
	}
	break;

	case CONTENT_MSG_ERROR:
		warn_user(event->data.error, 0);
		break;

	case CONTENT_MSG_STATUS:
		break;

	case CONTENT_MSG_LOADING:
	case CONTENT_MSG_REFORMAT:
	case CONTENT_MSG_REDRAW:
	default:
		assert(0);
		break;
	}

	return NSERROR_OK;
}