コード例 #1
0
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;
}
コード例 #2
0
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;
}
コード例 #3
0
status_t
ThemeInterfaceView::ThemeSelected()
{
	status_t err;
	ThemeManager* tman = GetThemeManager();
	int32 id;
	ThemeItem *item;
	BString desc;
	BBitmap *sshot = NULL;
	// find selected theme
	id = fThemeList->CurrentSelection(0);
	if (id < 0)
	{
		fScreenshotPane->ClearViewBitmap();
		fScreenshotPane->Invalidate(fScreenshotPane->Bounds());
		
		while(true == fScreenshotText->IsHidden())
			fScreenshotText->Show();
			
		fScreenshotText->SetText(B_TRANSLATE("No theme selected"));
		return ENOENT;
	}
	
	item = dynamic_cast<ThemeItem *>(fThemeList->ItemAt(id));
	if (!item)
		return ENOENT;
	id = item->ThemeId();
	if (id < 0)
		return ENOENT;
	// then apply
	
	err = tman->ThemeScreenShot(id, &sshot);
	if (err)
		sshot = NULL;
	if (sshot == NULL) 
	{
		SetScreenshot(NULL);
		fprintf(stderr, "ThemeManager: no screenshot; error 0x%08lx\n", err);

		while(true == fScreenshotText->IsHidden())
			fScreenshotText->Show();

		fScreenshotText->SetText(B_TRANSLATE("No screenshot"));
		return err;
	}

	SetScreenshot(sshot);
	while(false == fScreenshotText->IsHidden())
			fScreenshotText->Hide();

	//err = tman->ApplyTheme(theme);
	return err;
}
コード例 #4
0
status_t
ThemeInterfaceView::ApplySelected()
{
	status_t err;
	ThemeManager* tman = GetThemeManager();
	int32 id;
	ThemeItem *item;
	// find selected theme
	id = fThemeList->CurrentSelection(0);
	if (id < 0)
		return ENOENT;
	item = dynamic_cast<ThemeItem *>(fThemeList->ItemAt(id));
	if (!item)
		return ENOENT;
	id = item->ThemeId();
	if (id < 0)
		return ENOENT;
	SetIsRevertable();
	err = tman->ApplyTheme(id);
	return err;
}