status_t
ThemeInterfaceView::AddScreenshot()
{
	status_t err;
	ThemeManager* tman = GetThemeManager();
	int32 id;
	ThemeItem *item;
	BMessage theme;
	// find selected theme
	id = fThemeList->CurrentSelection(0);
	if (id < 0)
		return B_OK;
	item = dynamic_cast<ThemeItem *>(fThemeList->ItemAt(id));
	if (!item)
		return AError(__FUNCTION__, ENOENT);
	id = item->ThemeId();
	if (id < 0)
		return AError(__FUNCTION__, ENOENT);
	// then apply
	err = tman->MakeThemeScreenShot(id);
	if (err)
		return AError(__FUNCTION__, err);
	err = tman->SaveTheme(id);
	if (err)
		return AError(__FUNCTION__, err);
	ThemeSelected(); // force reload of description for selected theme.
	return err;
}
status_t
ThemeInterfaceView::DeleteSelected()
{
	status_t err;
	ThemeManager* tman = GetThemeManager();
	int32 id;
	ThemeItem *item;
	BMessage theme;
	// find selected theme
	id = fThemeList->CurrentSelection(0);
	if (id < 0)
		return B_OK;
	item = dynamic_cast<ThemeItem *>(fThemeList->ItemAt(id));
	if (!item)
		return AError(__FUNCTION__, ENOENT);
	if (item->IsReadOnly())
		return AError(__FUNCTION__, B_READ_ONLY_DEVICE);
	id = item->ThemeId();
	if (id < 0)
		return AError(__FUNCTION__, ENOENT);
	// then apply
	err = tman->DeleteTheme(id);
	if (err)
		return AError(__FUNCTION__, err);
	fThemeList->RemoveItem(item);
	delete item;
	//err = tman->ApplyTheme(theme);
	return err;
}
Пример #3
0
AError ACommandExecutor::executeCommand(const std::string & cmd_text, std::string & answer)
{
	error_messenger()->printMessage("Executing command: " + cmd_text);

	AUtilityPlugin * plug = getPluginForCommand(cmd_text);
	if(plug == nullptr)
	{
		answer = "Command not found: '" + cmd_text + "'.";
		return AError(AT_ERROR_COMMAND_NOT_FOUND);
	}
	
	AError res = plug->executeCommand(cmd_text, answer);

	error_messenger()->printMessage("Result: " + answer);
	return res;
}