* Fix use of FindData(), now we can find colors and fonts!

* Implemented a text input box to name a new theme.
* Made loading of themes asynchronous in a thread, controls are disabled but at least the window appears ASAP.
* fixed app sig
* Implemented setting colors and fonts on Haiku.
* Implemented setting the window decor, but doesn't work as we don't have any decorator installed.
* Enable all addons.
TODO: forbid quitting while themes are loading!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23508 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2008-01-14 02:00:42 +00:00
parent f9e760ccaa
commit d1854cb931
12 changed files with 362 additions and 118 deletions

View File

@ -2,6 +2,7 @@ SubDir HAIKU_TOP 3rdparty mmu_man themes ;
SetSubDirSupportedPlatformsBeOSCompatible ;
#SubDirC++Flags -DSINGLE_BINARY -DDEBUG=1 ;
SubDirC++Flags -DSINGLE_BINARY ;
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) 3rdparty mmu_man themes addons ] ;

View File

@ -1,5 +1,12 @@
//HACK :P
#define private public
#include <Alert.h>
#undef private
#include "TextInputAlert.h"
#define TEXT_HEIGHT 25
TextInputAlert::TextInputAlert(const char *title,
const char *text,
@ -11,6 +18,17 @@ TextInputAlert::TextInputAlert(const char *title,
alert_type type)
: BAlert(title, text, button0Label, button1Label, button2Label, widthStyle, type)
{
ResizeBy(0,TEXT_HEIGHT);
BRect f = Bounds();
f.InsetBySelf(TEXT_HEIGHT, f.Height()/4 - TEXT_HEIGHT/2);
f.left *= 3;
fText = new BTextControl(f, "text", "Name:", initial, NULL);
fText->SetDivider(f.Width()/3);
ChildAt(0)->AddChild(fText);
TextView()->Hide();
fText->SetViewColor(ChildAt(0)->ViewColor());
fText->SetLowColor(ChildAt(0)->LowColor());
fText->TextView()->SelectAll();
}
@ -19,3 +37,10 @@ TextInputAlert::~TextInputAlert()
}
void
TextInputAlert::Show()
{
BAlert::Show();
}

View File

@ -2,6 +2,7 @@
#define TEXT_INPUT_ALERT_H
#include <Alert.h>
#include <TextControl.h>
class TextInputAlert : public BAlert {
public:
@ -14,7 +15,14 @@ class TextInputAlert : public BAlert {
button_width widthStyle = B_WIDTH_AS_USUAL,
alert_type type = B_INFO_ALERT);
virtual ~TextInputAlert();
virtual void Show();
const char *Text() const { return fText->Text(); };
BTextControl *TextControl() const { return fText; };
private:
BTextControl *fText;
};
#endif /* TEXT_INPUT_ALERT_H */

View File

@ -76,6 +76,49 @@ filter_result refs_filter(BMessage *message, BHandler **handler, BMessageFilter
return B_DISPATCH_MESSAGE;
}
// ------------------------------------------------------------------------------
class MyInvoker : public BInvoker {
public:
MyInvoker(BMessage* message, const BHandler* handler, const BLooper* looper = NULL);
virtual ~MyInvoker();
virtual status_t Invoke(BMessage* message = NULL);
void SetOwner(TextInputAlert *alert);
private:
TextInputAlert *fOwner;
};
MyInvoker::MyInvoker(BMessage* message, const BHandler* handler, const BLooper* looper = NULL)
: BInvoker(message, handler, looper)
{
}
MyInvoker::~MyInvoker()
{
}
status_t
MyInvoker::Invoke(BMessage* message)
{
BMessage *out = Message();
if (out) {
if (out->ReplaceString("text", fOwner->TextControl()->TextView()->Text()) == B_OK ||
out->AddString("text", fOwner->TextControl()->TextView()->Text()) == B_OK)
return BInvoker::Invoke();
}
return EINVAL;
}
void
MyInvoker::SetOwner(TextInputAlert *alert)
{
fOwner = alert;
}
// ------------------------------------------------------------------------------
//extern "C" BView *get_pref_view(const BRect& Bounds)
extern "C" BView *themes_pref(const BRect& Bounds)
@ -113,7 +156,7 @@ ThemeInterfaceView::AllAttached()
{
BView::AllAttached();
fPopupInvoker = new BInvoker(new BMessage(kReallyCreateTheme), this);
fPopupInvoker = new MyInvoker(new BMessage(kReallyCreateTheme), this);
#ifdef B_BEOS_VERSION_DANO
SetViewUIColor(B_UI_PANEL_BACKGROUND_COLOR);
#else
@ -121,7 +164,6 @@ ThemeInterfaceView::AllAttached()
#endif
fThemeManager = new ThemeManager;
fThemeManager->LoadThemes();
BRect frame = Bounds();
frame.InsetBy(10.0, 10.0);
@ -233,8 +275,8 @@ ThemeInterfaceView::AllAttached()
fAddonList->SetTarget(this);
fAddonListSV->Hide();
PopulateThemeList();
PopulateAddonList();
PopulateThemeList();
}
// ------------------------------------------------------------------------------
@ -269,7 +311,8 @@ ThemeInterfaceView::MessageReceived(BMessage *_msg)
case kCreateThemeBtn:
{
TextInputAlert *alert = new TextInputAlert("New name", "New Theme Name", "", "Ok", "Cancel");
TextInputAlert *alert = new TextInputAlert("New name", "New Theme Name", "My Theme", "Ok");
fPopupInvoker->SetOwner(alert);
alert->Go(fPopupInvoker);
break;
}
@ -426,23 +469,61 @@ bool ThemeInterfaceView::IsScreenshotPaneHidden()
// ------------------------------------------------------------------------------
void ThemeInterfaceView::PopulateThemeList()
{
int i;
BControl *c;
for (i = 0; ChildAt(i); i++) {
c = dynamic_cast<BControl *>(ChildAt(i));
if (c)
c->SetEnabled(false);
}
thread_id tid = spawn_thread(_ThemeListPopulatorTh, "", B_LOW_PRIORITY, this);
resume_thread(tid);
}
// ------------------------------------------------------------------------------
int32 ThemeInterfaceView::_ThemeListPopulatorTh(void *arg)
{
ThemeInterfaceView *_this = (ThemeInterfaceView *)arg;
_this->_ThemeListPopulator();
return 0;
}
// ------------------------------------------------------------------------------
void ThemeInterfaceView::_ThemeListPopulator()
{
status_t err;
int32 i, count;
BString name;
ThemeItem *ti;
bool isro;
ThemeManager* tman = GetThemeManager();
tman->LoadThemes();
count = tman->CountThemes();
LockLooper();
fThemeList->MakeEmpty();
UnlockLooper();
for (i = 0; i < count; i++) {
err = tman->ThemeName(i, name);
isro = tman->ThemeIsReadOnly(i);
if (err)
continue;
ti = new ThemeItem(i, name.String(), isro);
LockLooper();
fThemeList->AddItem(ti);
UnlockLooper();
}
BControl *c;
LockLooper();
for (i = 0; ChildAt(i); i++) {
c = dynamic_cast<BControl *>(ChildAt(i));
if (c)
c->SetEnabled(true);
}
UnlockLooper();
}
// ------------------------------------------------------------------------------

View File

@ -16,7 +16,7 @@ class BScrollView;
class BTextView;
class BMessage;
class BStringView;
class BInvoker;
class MyInvoker;
class ThemeInterfaceView : public BView
{
@ -49,12 +49,14 @@ class ThemeInterfaceView : public BView
status_t AError(const char *func, status_t err);
private:
static int32 _ThemeListPopulatorTh(void *arg);
void _ThemeListPopulator();
ThemeManager* fThemeManager;
bool fScreenshotPaneHidden;
bool fHasScreenshot;
BInvoker* fPopupInvoker;
MyInvoker* fPopupInvoker;
BScrollView* fThemeListSV;
BListView* fThemeList;
BButton* fApplyBtn;

View File

@ -30,8 +30,10 @@
extern status_t MakeScreenshot(BBitmap **here);
// addons used in the prefs in Zeta (some were disabled)
//#define ZETA_ADDONS
#define DEBUG_TM
//#define DEBUG_TM
#ifdef DEBUG_TM
#define FENTRY PRINT(("ThemeManager::%s()\n", __FUNCTION__))
#else
@ -161,48 +163,43 @@ status_t ThemeManager::LoadAddons()
//if (err) return err;
}
#else
#define ADDA(a) \
if (ta) { \
fAddonList.AddItem((void *)ta); \
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName())); \
}
ta = instanciate_themes_addon_backgrounds();
fAddonList.AddItem((void *)ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
ADDA(ta);
ta = instanciate_themes_addon_beide();
fAddonList.AddItem((void *)ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
ADDA(ta);
ta = instanciate_themes_addon_deskbar();
fAddonList.AddItem((void *)ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
#if 0
ADDA(ta);
#ifndef ZETA_ADDONS
ta = instanciate_themes_addon_eddie();
fAddonList.AddItem((void *)ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
ADDA(ta);
#endif
ta = instanciate_themes_addon_pe();
fAddonList.AddItem((void *)ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
ADDA(ta);
ta = instanciate_themes_addon_screensaver();
fAddonList.AddItem((void *)ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
#if 0
ADDA(ta);
#ifndef ZETA_ADDONS
ta = instanciate_themes_addon_soundplay();
fAddonList.AddItem((void *)ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
ADDA(ta);
#endif
ta = instanciate_themes_addon_sounds();
fAddonList.AddItem((void *)ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
ta = instanciate_themes_addon_terminal();
fAddonList.AddItem((void *)ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
ADDA(ta);
ta = instanciate_themes_addon_ui_settings();
fAddonList.AddItem((void *)ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
#if 0
ADDA(ta);
#ifndef ZETA_ADDONS
ta = instanciate_themes_addon_winamp_skin();
fAddonList.AddItem((void *)ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
ADDA(ta);
#endif
ta = instanciate_themes_addon_window_decor();
fAddonList.AddItem((void *)ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
ADDA(ta);
#endif
//if (err) return err;
fAddonCount = fAddonList.CountItems();

View File

@ -1,5 +1,5 @@
resource(1, "BEOS:APP_SIG") #'MIMS' "application/x-vnd.mmu_man.Themes";
resource(1, "BEOS:APP_SIG") #'MIMS' "application/x-vnd.mmu_man-Themes";
resource app_version {
major = 0,

View File

@ -113,14 +113,17 @@ status_t ThemesAddon::MyMessage(BMessage &theme, BMessage &mine)
{
FENTRY;
BMessage msg;
status_t err;
status_t err = B_NAME_NOT_FOUND;
if (!MessageName())
return B_NAME_NOT_FOUND;
goto error;
err = theme.FindMessage(MessageName(), &msg);
if (err)
return err;
goto error;
mine = msg;
return B_OK;
error:
return err;
}
status_t ThemesAddon::SetMyMessage(BMessage &theme, BMessage &mine)

View File

@ -25,7 +25,7 @@ void
ThemesApp::ReadyToRun()
{
BScreen s;
BRect frame(0, 0, 500, 300);
BRect frame(0, 0, 550, 300);
frame.OffsetBySelf(s.Frame().Width()/2 - frame.Width()/2,
s.Frame().Height()/2 - frame.Height()/2);
BWindow *w = new BWindow(frame, "Themes", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_QUIT_ON_WINDOW_CLOSE);

View File

@ -286,7 +286,7 @@ FindRGBColor(BMessage &message, const char *name, int32 index, rgb_color *c)
const void *data;
ssize_t len;
status_t err;
err = message.FindData(name, index, &data, &len);
err = message.FindData(name, B_RGB_COLOR_TYPE, index, &data, &len);
if (err < B_OK)
return err;
if (len > (ssize_t)sizeof(*c))
@ -317,7 +317,8 @@ FindFont(BMessage &message, const char *name, int32 index, BFont *f)
#else
const void *data;
ssize_t len;
status_t err = message.FindData(name, index, &data, &len);
status_t err = message.FindData(name, 'FONt', index, &data, &len);
#define DERR(e) { PRINT(("%s: err: %s\n", __FUNCTION__, strerror(e))); }
if (err < B_OK)
return err;
if (len > (ssize_t)sizeof(*f))

View File

@ -12,26 +12,35 @@
#include <Font.h>
#include <Message.h>
#include <Roster.h>
#include <Debug.h>
#include <stdio.h>
#include <string.h>
#include "ThemesAddon.h"
#include "UITheme.h"
#include "Utils.h"
#ifdef SINGLE_BINARY
#define instanciate_themes_addon instanciate_themes_addon_ui_settings
#endif
//XXX: FIXME
ThemesAddon *instanciate_themes_addon()
{
return NULL;
}
#define DEBUG_TA
#ifdef DEBUG_TA
#define FENTRY PRINT(("*ThemesAddon[%s]::%s()\n", Name(), __FUNCTION__))
#else
#define FENTRY
#endif
#define DERR(e) { PRINT(("%s: err: %s\n", __FUNCTION__, strerror(e))); }
// private font API
extern void _set_system_font_(const char *which, font_family family,
font_style style, float size);
extern status_t _get_system_default_font_(const char* which,
font_family family, font_style style, float* _size);
#if 0 // DANO...
//#define A_NAME "UI Settings"
#define A_NAME "System Colors and Fonts"
#define A_MSGNAME Z_THEME_UI_SETTINGS
#define A_DESCRIPTION "System colors, fonts and other goodies"
@ -53,13 +62,45 @@ status_t MakeTheme(BMessage &theme, uint32 flags=0L);
status_t ApplyDefaultTheme(uint32 flags=0L);
};
struct ui_color_map {
const char *name;
color_which id;
} gUIColorMap[] = {
{ B_UI_PANEL_BACKGROUND_COLOR, B_PANEL_BACKGROUND_COLOR },
{ B_UI_PANEL_TEXT_COLOR, B_PANEL_TEXT_COLOR },
// { B_UI_PANEL_LINK_COLOR, B_PANEL_LINK_COLOR },
{ B_UI_DOCUMENT_BACKGROUND_COLOR, B_DOCUMENT_BACKGROUND_COLOR },
{ B_UI_DOCUMENT_TEXT_COLOR, B_DOCUMENT_TEXT_COLOR },
// { B_UI_DOCUMENT_LINK_COLOR, B_DOCUMENT_LINK_COLOR },
{ B_UI_CONTROL_BACKGROUND_COLOR, B_CONTROL_BACKGROUND_COLOR },
{ B_UI_CONTROL_TEXT_COLOR, B_CONTROL_TEXT_COLOR },
{ B_UI_CONTROL_BORDER_COLOR, B_CONTROL_BORDER_COLOR },
{ B_UI_CONTROL_HIGHLIGHT_COLOR, B_CONTROL_HIGHLIGHT_COLOR },
{ B_UI_NAVIGATION_BASE_COLOR, B_NAVIGATION_BASE_COLOR },
{ B_UI_NAVIGATION_PULSE_COLOR, B_NAVIGATION_PULSE_COLOR },
{ B_UI_SHINE_COLOR, B_SHINE_COLOR },
{ B_UI_SHADOW_COLOR, B_SHADOW_COLOR },
{ B_UI_TOOLTIP_BACKGROUND_COLOR, B_TOOLTIP_BACKGROUND_COLOR },
{ B_UI_TOOLTIP_TEXT_COLOR, B_TOOLTIP_TEXT_COLOR },
{ B_UI_MENU_BACKGROUND_COLOR, B_MENU_BACKGROUND_COLOR },
{ B_UI_MENU_SELECTED_BACKGROUND_COLOR, B_MENU_SELECTED_BACKGROUND_COLOR },
{ B_UI_MENU_ITEM_TEXT_COLOR, B_MENU_ITEM_TEXT_COLOR },
{ B_UI_MENU_SELECTED_ITEM_TEXT_COLOR, B_MENU_SELECTED_ITEM_TEXT_COLOR },
{ B_UI_MENU_SELECTED_BORDER_COLOR, B_MENU_SELECTED_BORDER_COLOR },
{ B_UI_SUCCESS_COLOR, B_SUCCESS_COLOR },
{ B_UI_FAILURE_COLOR, B_FAILURE_COLOR },
{ NULL, (color_which)-1 }
};
UISettingsThemesAddon::UISettingsThemesAddon()
: ThemesAddon(A_NAME, A_MSGNAME)
{
FENTRY;
}
UISettingsThemesAddon::~UISettingsThemesAddon()
{
FENTRY;
}
const char *UISettingsThemesAddon::Description()
@ -72,6 +113,7 @@ status_t UISettingsThemesAddon::RunPreferencesPanel()
status_t err = B_OK;
entry_ref ref;
BEntry ent;
FENTRY;
/*
err = ent.SetTo("/boot/beos/preferences/Colors");
if (!err) {
@ -83,16 +125,11 @@ status_t UISettingsThemesAddon::RunPreferencesPanel()
*/
if (!err)
return B_OK;
err = ent.SetTo("/system/add-ons/Preferences/Appearance");
err = ent.SetTo("/boot/beos/preferences/Appearance");
if (!err) {
err = ent.GetRef(&ref);
if (!err) {
err = be_roster->Launch(&ref);
if (err) {
BMessage msg(B_REFS_RECEIVED);
msg.AddRef("refs", &ref);
be_app_messenger.SendMessage(&msg);
}
}
}
return err;
@ -100,24 +137,45 @@ status_t UISettingsThemesAddon::RunPreferencesPanel()
status_t UISettingsThemesAddon::AddNames(BMessage &names)
{
BMessage uisettings;
BMessage uinames;
status_t err;
const char *str, *value;
type_code code;
int32 i;
FENTRY;
err = get_ui_settings(&uisettings, &uinames);
if (err)
return err;
names.AddString(Z_THEME_UI_SETTINGS, "UI Settings");
// hack for legacy fonts
// Haiku doesn't know about them, wo add them
//XXX: use symbolic names.
names.AddString("be:c:PanBg", "Panel Background");
names.AddString("be:c:PanTx", "Panel Text");
names.AddString("be:c:PanLn", "Panel Link");
names.AddString("be:c:DocBg", "Document Background");
names.AddString("be:c:DocTx", "Document Text");
names.AddString("be:c:DocLn", "Document Link");
names.AddString("be:c:CtlBg", "Control Background");
names.AddString("be:c:CtlTx", "Control Text");
names.AddString("be:c:CtlBr", "Control Border");
names.AddString("be:c:CtlHg", "Control Highlight");
names.AddString("be:c:NavBs", "Navigation Base");
names.AddString("be:c:NavPl", "Navigation Pulse");
names.AddString("be:c:Shine", "Shine");
names.AddString("be:c:Shadow", "Shadow");
names.AddString("be:c:TipBg", "ToolTip Background");
names.AddString("be:c:TipTx", "ToolTip Text");
names.AddString("be:c:MenBg", "Menu Background");
names.AddString("be:c:MenSBg", "Menu Selected Background");
names.AddString("be:c:MenTx", "Menu Item Text");
names.AddString("be:c:MenSTx", "Menu Selected Item Text");
names.AddString("be:c:MenSBr", "Menu Selected Border");
names.AddString("be:c:Success", "Success");
names.AddString("be:c:Failure", "Failure");
names.AddString("be:f:MenTx", "Menu Item Text");
names.AddString("be:MenSep", "Menu Separator");
names.AddString("be:MenTrig", "Show Menu Triggers");
names.AddString("be:MenZSnake", "Menu ZSnake");
names.AddString("be:f:Tip", "ToolTip");
names.AddString("be:f:be_plain_font", "System Plain");
names.AddString("be:f:be_bold_font", "System Bold");
names.AddString("be:f:be_fixed_font", "System Fixed");
for (i = 0; uinames.GetInfo(B_STRING_TYPE, i, &str, &code) == B_OK;i++)
if (uinames.FindString(str, &value) == B_OK)
names.AddString(str, value);
return B_OK;
}
@ -126,30 +184,50 @@ status_t UISettingsThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
BMessage uisettings;
BFont fnt;
status_t err;
int i;
FENTRY;
(void)flags;
err = MyMessage(theme, uisettings);
DERR(err);
if (err)
return err;
// hack for legacy fonts
err = uisettings.FindFlat("be:f:be_plain_font", &fnt);
font_family family;
font_style style;
err = FindFont(uisettings, "be:f:be_plain_font", 0, &fnt);
uisettings.RemoveName("be:f:be_plain_font");
if (err == B_OK)
BFont::SetStandardFont(B_PLAIN_FONT, &fnt);
DERR(err);
if (err == B_OK) {
fnt.GetFamilyAndStyle(&family, &style);
_set_system_font_("plain", family, style, fnt.Size());
}
err = uisettings.FindFlat("be:f:be_bold_font", &fnt);
err = FindFont(uisettings, "be:f:be_bold_font", 0, &fnt);
DERR(err);
uisettings.RemoveName("be:f:be_bold_font");
if (err == B_OK)
BFont::SetStandardFont(B_BOLD_FONT, &fnt);
if (err == B_OK) {
fnt.GetFamilyAndStyle(&family, &style);
_set_system_font_("bold", family, style, fnt.Size());
}
err = uisettings.FindFlat("be:f:be_fixed_font", &fnt);
err = FindFont(uisettings, "be:f:be_fixed_font", 0, &fnt);
DERR(err);
uisettings.RemoveName("be:f:be_fixed_font");
if (err == B_OK)
BFont::SetStandardFont(B_FIXED_FONT, &fnt);
if (err == B_OK) {
fnt.GetFamilyAndStyle(&family, &style);
_set_system_font_("fixed", family, style, fnt.Size());
}
update_ui_settings(uisettings);
for (i = 0; gUIColorMap[i].name; i++) {
rgb_color c;
if (FindRGBColor(uisettings, gUIColorMap[i].name, 0, &c) == B_OK) {
set_ui_color(gUIColorMap[i].id, c);
fprintf(stderr, "set_ui_color(%d, #%02x%02x%02x)\n",
gUIColorMap[i].id, c.red, c.green, c.blue);
}
}
return B_OK;
@ -161,23 +239,23 @@ status_t UISettingsThemesAddon::MakeTheme(BMessage &theme, uint32 flags)
BMessage names;
BFont fnt;
status_t err;
int i;
FENTRY;
(void)flags;
err = MyMessage(theme, uisettings);
if (err)
uisettings.MakeEmpty();
err = get_ui_settings(&uisettings, &names);
if (err)
return err;
for (i = 0; gUIColorMap[i].name; i++) {
rgb_color c = ui_color(gUIColorMap[i].id);
AddRGBColor(uisettings, gUIColorMap[i].name, c);
}
// hack for legacy fonts
err = BFont::GetStandardFont(B_PLAIN_FONT, &fnt);
uisettings.AddFlat("be:f:be_plain_font", &fnt);
err = BFont::GetStandardFont(B_BOLD_FONT, &fnt);
uisettings.AddFlat("be:f:be_bold_font", &fnt);
err = BFont::GetStandardFont(B_FIXED_FONT, &fnt);
uisettings.AddFlat("be:f:be_fixed_font", &fnt);
AddFont(uisettings, "be:f:be_plain_font", (BFont *)be_plain_font);
AddFont(uisettings, "be:f:be_bold_font", (BFont *)be_bold_font);
AddFont(uisettings, "be:f:be_fixed_font", (BFont *)be_fixed_font);
err = SetMyMessage(theme, uisettings);
return err;
@ -189,18 +267,35 @@ status_t UISettingsThemesAddon::ApplyDefaultTheme(uint32 flags)
BMessage uisettings;
BFont fnt;
status_t err;
FENTRY;
/*
err = get_default_settings(&uisettings);
if (err)
return err;
*/
// hack for legacy fonts
err = BFont::GetStandardFont((font_which)(B_PLAIN_FONT-100), &fnt);
uisettings.AddFlat("be:f:be_plain_font", &fnt);
err = BFont::GetStandardFont((font_which)(B_BOLD_FONT-100), &fnt);
uisettings.AddFlat("be:f:be_bold_font", &fnt);
err = BFont::GetStandardFont((font_which)(B_FIXED_FONT-100), &fnt);
uisettings.AddFlat("be:f:be_fixed_font", &fnt);
font_family family;
font_style style;
float size;
BFont f;
if (_get_system_default_font_("plain", family, style, &size) != B_OK)
return B_ERROR;
f.SetFamilyAndStyle(family, style);
f.SetSize(size);
AddFont(uisettings, "be:f:be_plain_font", &f);
if (_get_system_default_font_(Name(), family, style, &size) != B_OK)
return B_ERROR;
f.SetFamilyAndStyle(family, style);
f.SetSize(size);
AddFont(uisettings, "be:f:be_plain_font", &f);
if (_get_system_default_font_(Name(), family, style, &size) != B_OK)
return B_ERROR;
f.SetFamilyAndStyle(family, style);
f.SetSize(size);
AddFont(uisettings, "be:f:be_plain_font", &f);
theme.AddMessage(A_MSGNAME, &uisettings);
return ApplyTheme(theme, flags);
@ -212,6 +307,4 @@ ThemesAddon *instanciate_themes_addon()
return (ThemesAddon *) new UISettingsThemesAddon;
}
#endif
#endif /* B_BEOS_VERSION_DANO */

View File

@ -16,6 +16,7 @@
#include <Path.h>
#include <Roster.h>
#include <String.h>
#include <Debug.h>
#include <stdio.h>
#include <string.h>
@ -27,13 +28,36 @@
#define instanciate_themes_addon instanciate_themes_addon_window_decor
#endif
//XXX: FIXME
ThemesAddon *instanciate_themes_addon()
{
return NULL;
#define DERR(e) { PRINT(("%s: err: %s\n", __FUNCTION__, strerror(e))); }
namespace BPrivate {
int32 count_decorators(void);
int32 get_decorator(void);
status_t get_decorator_name(const int32 &index, BString &name);
status_t get_decorator_preview(const int32 &index, BBitmap *bitmap);
status_t set_decorator(const int32 &index);
}
#if 0 // DANO...
using namespace BPrivate;
status_t set_decorator(const char *name)
{
BString n;
status_t err;
int i = count_decorators() - 1;
for (; i > -1; i--) {
err = get_decorator_name(i, n);
DERR(err);
if (err < B_OK)
continue;
if (n == name) {
err = set_decorator(i);
DERR(err);
return err;
}
}
return ENOENT;
}
#define A_NAME "Window Decor"
#define A_MSGNAME Z_THEME_WINDOW_DECORATIONS
@ -75,16 +99,11 @@ status_t DecorThemesAddon::RunPreferencesPanel()
status_t err;
entry_ref ref;
BEntry ent;
err = ent.SetTo("/system/add-ons/Preferences/Appearance");
err = ent.SetTo("/boot/beos/references/Appearance");
if (!err) {
err = ent.GetRef(&ref);
if (!err) {
err = be_roster->Launch(&ref);
if (err) {
BMessage msg(B_REFS_RECEIVED);
msg.AddRef("refs", &ref);
be_app_messenger.SendMessage(&msg);
}
}
}
return err;
@ -107,9 +126,13 @@ status_t DecorThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
(void)flags;
err = MyMessage(theme, window_decor);
DERR(err);
if (err)
return err;
if (window_decor.FindString("window:decor", &decorName) == B_OK)
set_decorator(decorName.String());
#if 0
#ifdef B_BEOS_VERSION_DANO
if (window_decor.FindString("window:decor", &decorName) == B_OK)
set_window_decor(decorName.String(),
@ -119,6 +142,7 @@ extern void __set_window_decor(int32 theme);
int32 decorNr = 0;
if (window_decor.FindInt32("window:R5:decor", &decorNr) == B_OK)
__set_window_decor(decorNr);
#endif
#endif
// XXX: add colors à la WindowShade ?
@ -134,20 +158,31 @@ status_t DecorThemesAddon::MakeTheme(BMessage &theme, uint32 flags)
(void)flags;
err = MyMessage(theme, window_decor);
DERR(err);
if (err)
window_decor.MakeEmpty();
err = get_decorator_name(get_decorator(), decorName);
DERR(err);
if (err == B_OK) {
window_decor.AddString("window:decor", decorName.String());
window_decor.AddMessage("window:decor_globals", &globals);
}
#if 0
#ifdef B_BEOS_VERSION_DANO
err = get_window_decor(&decorName, &globals);
DERR(err);
if (err == B_OK) {
window_decor.AddString("window:decor", decorName.String());
window_decor.AddMessage("window:decor_globals", &globals);
}
#else
window_decor.AddInt32("window:R5:decor", 0);
#endif
#endif
err = SetMyMessage(theme, window_decor);
DERR(err);
return err;
}
@ -167,6 +202,4 @@ ThemesAddon *instanciate_themes_addon()
return (ThemesAddon *) new DecorThemesAddon;
}
#endif
#endif /* B_BEOS_VERSION_DANO */