* 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
+1
View File
@@ -2,6 +2,7 @@ SubDir HAIKU_TOP 3rdparty mmu_man themes ;
SetSubDirSupportedPlatformsBeOSCompatible ; SetSubDirSupportedPlatformsBeOSCompatible ;
#SubDirC++Flags -DSINGLE_BINARY -DDEBUG=1 ;
SubDirC++Flags -DSINGLE_BINARY ; SubDirC++Flags -DSINGLE_BINARY ;
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) 3rdparty mmu_man themes addons ] ; SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) 3rdparty mmu_man themes addons ] ;
+25
View File
@@ -1,5 +1,12 @@
//HACK :P
#define private public
#include <Alert.h>
#undef private
#include "TextInputAlert.h" #include "TextInputAlert.h"
#define TEXT_HEIGHT 25
TextInputAlert::TextInputAlert(const char *title, TextInputAlert::TextInputAlert(const char *title,
const char *text, const char *text,
@@ -11,6 +18,17 @@ TextInputAlert::TextInputAlert(const char *title,
alert_type type) alert_type type)
: BAlert(title, text, button0Label, button1Label, button2Label, widthStyle, 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();
}
+8
View File
@@ -2,6 +2,7 @@
#define TEXT_INPUT_ALERT_H #define TEXT_INPUT_ALERT_H
#include <Alert.h> #include <Alert.h>
#include <TextControl.h>
class TextInputAlert : public BAlert { class TextInputAlert : public BAlert {
public: public:
@@ -14,7 +15,14 @@ class TextInputAlert : public BAlert {
button_width widthStyle = B_WIDTH_AS_USUAL, button_width widthStyle = B_WIDTH_AS_USUAL,
alert_type type = B_INFO_ALERT); alert_type type = B_INFO_ALERT);
virtual ~TextInputAlert(); 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 */ #endif /* TEXT_INPUT_ALERT_H */
+85 -4
View File
@@ -76,6 +76,49 @@ filter_result refs_filter(BMessage *message, BHandler **handler, BMessageFilter
return B_DISPATCH_MESSAGE; 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 *get_pref_view(const BRect& Bounds)
extern "C" BView *themes_pref(const BRect& Bounds) extern "C" BView *themes_pref(const BRect& Bounds)
@@ -113,7 +156,7 @@ ThemeInterfaceView::AllAttached()
{ {
BView::AllAttached(); BView::AllAttached();
fPopupInvoker = new BInvoker(new BMessage(kReallyCreateTheme), this); fPopupInvoker = new MyInvoker(new BMessage(kReallyCreateTheme), this);
#ifdef B_BEOS_VERSION_DANO #ifdef B_BEOS_VERSION_DANO
SetViewUIColor(B_UI_PANEL_BACKGROUND_COLOR); SetViewUIColor(B_UI_PANEL_BACKGROUND_COLOR);
#else #else
@@ -121,7 +164,6 @@ ThemeInterfaceView::AllAttached()
#endif #endif
fThemeManager = new ThemeManager; fThemeManager = new ThemeManager;
fThemeManager->LoadThemes();
BRect frame = Bounds(); BRect frame = Bounds();
frame.InsetBy(10.0, 10.0); frame.InsetBy(10.0, 10.0);
@@ -233,8 +275,8 @@ ThemeInterfaceView::AllAttached()
fAddonList->SetTarget(this); fAddonList->SetTarget(this);
fAddonListSV->Hide(); fAddonListSV->Hide();
PopulateThemeList();
PopulateAddonList(); PopulateAddonList();
PopulateThemeList();
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
@@ -269,7 +311,8 @@ ThemeInterfaceView::MessageReceived(BMessage *_msg)
case kCreateThemeBtn: 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); alert->Go(fPopupInvoker);
break; break;
} }
@@ -426,23 +469,61 @@ bool ThemeInterfaceView::IsScreenshotPaneHidden()
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
void ThemeInterfaceView::PopulateThemeList() 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; status_t err;
int32 i, count; int32 i, count;
BString name; BString name;
ThemeItem *ti; ThemeItem *ti;
bool isro; bool isro;
ThemeManager* tman = GetThemeManager(); ThemeManager* tman = GetThemeManager();
tman->LoadThemes();
count = tman->CountThemes(); count = tman->CountThemes();
LockLooper();
fThemeList->MakeEmpty(); fThemeList->MakeEmpty();
UnlockLooper();
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
err = tman->ThemeName(i, name); err = tman->ThemeName(i, name);
isro = tman->ThemeIsReadOnly(i); isro = tman->ThemeIsReadOnly(i);
if (err) if (err)
continue; continue;
ti = new ThemeItem(i, name.String(), isro); ti = new ThemeItem(i, name.String(), isro);
LockLooper();
fThemeList->AddItem(ti); 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();
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
+5 -3
View File
@@ -16,7 +16,7 @@ class BScrollView;
class BTextView; class BTextView;
class BMessage; class BMessage;
class BStringView; class BStringView;
class BInvoker; class MyInvoker;
class ThemeInterfaceView : public BView class ThemeInterfaceView : public BView
{ {
@@ -49,12 +49,14 @@ class ThemeInterfaceView : public BView
status_t AError(const char *func, status_t err); status_t AError(const char *func, status_t err);
private: private:
static int32 _ThemeListPopulatorTh(void *arg);
void _ThemeListPopulator();
ThemeManager* fThemeManager; ThemeManager* fThemeManager;
bool fScreenshotPaneHidden; bool fScreenshotPaneHidden;
bool fHasScreenshot; bool fHasScreenshot;
BInvoker* fPopupInvoker; MyInvoker* fPopupInvoker;
BScrollView* fThemeListSV; BScrollView* fThemeListSV;
BListView* fThemeList; BListView* fThemeList;
BButton* fApplyBtn; BButton* fApplyBtn;
+25 -28
View File
@@ -30,8 +30,10 @@
extern status_t MakeScreenshot(BBitmap **here); 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 #ifdef DEBUG_TM
#define FENTRY PRINT(("ThemeManager::%s()\n", __FUNCTION__)) #define FENTRY PRINT(("ThemeManager::%s()\n", __FUNCTION__))
#else #else
@@ -161,48 +163,43 @@ status_t ThemeManager::LoadAddons()
//if (err) return err; //if (err) return err;
} }
#else #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(); ta = instanciate_themes_addon_backgrounds();
fAddonList.AddItem((void *)ta); ADDA(ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
ta = instanciate_themes_addon_beide(); ta = instanciate_themes_addon_beide();
fAddonList.AddItem((void *)ta); ADDA(ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
ta = instanciate_themes_addon_deskbar(); ta = instanciate_themes_addon_deskbar();
fAddonList.AddItem((void *)ta); ADDA(ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName())); #ifndef ZETA_ADDONS
#if 0
ta = instanciate_themes_addon_eddie(); ta = instanciate_themes_addon_eddie();
fAddonList.AddItem((void *)ta); ADDA(ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
#endif #endif
ta = instanciate_themes_addon_pe(); ta = instanciate_themes_addon_pe();
fAddonList.AddItem((void *)ta); ADDA(ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
ta = instanciate_themes_addon_screensaver(); ta = instanciate_themes_addon_screensaver();
fAddonList.AddItem((void *)ta); ADDA(ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName())); #ifndef ZETA_ADDONS
#if 0
ta = instanciate_themes_addon_soundplay(); ta = instanciate_themes_addon_soundplay();
fAddonList.AddItem((void *)ta); ADDA(ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
#endif #endif
ta = instanciate_themes_addon_sounds(); 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(); ta = instanciate_themes_addon_terminal();
fAddonList.AddItem((void *)ta); ADDA(ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
ta = instanciate_themes_addon_ui_settings(); ta = instanciate_themes_addon_ui_settings();
fAddonList.AddItem((void *)ta); ADDA(ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName())); #ifndef ZETA_ADDONS
#if 0
ta = instanciate_themes_addon_winamp_skin(); ta = instanciate_themes_addon_winamp_skin();
fAddonList.AddItem((void *)ta); ADDA(ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
#endif #endif
ta = instanciate_themes_addon_window_decor(); ta = instanciate_themes_addon_window_decor();
fAddonList.AddItem((void *)ta); ADDA(ta);
PRINT(("ThemeManager: Added addon %ld '%s', msgname '%s'\n", ta->ImageId(), ta->Name(), ta->MessageName()));
#endif #endif
//if (err) return err; //if (err) return err;
fAddonCount = fAddonList.CountItems(); fAddonCount = fAddonList.CountItems();
+1 -1
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 { resource app_version {
major = 0, major = 0,
+6 -3
View File
@@ -113,14 +113,17 @@ status_t ThemesAddon::MyMessage(BMessage &theme, BMessage &mine)
{ {
FENTRY; FENTRY;
BMessage msg; BMessage msg;
status_t err; status_t err = B_NAME_NOT_FOUND;
if (!MessageName()) if (!MessageName())
return B_NAME_NOT_FOUND; goto error;
err = theme.FindMessage(MessageName(), &msg); err = theme.FindMessage(MessageName(), &msg);
if (err) if (err)
return err; goto error;
mine = msg; mine = msg;
return B_OK; return B_OK;
error:
return err;
} }
status_t ThemesAddon::SetMyMessage(BMessage &theme, BMessage &mine) status_t ThemesAddon::SetMyMessage(BMessage &theme, BMessage &mine)
+1 -1
View File
@@ -25,7 +25,7 @@ void
ThemesApp::ReadyToRun() ThemesApp::ReadyToRun()
{ {
BScreen s; BScreen s;
BRect frame(0, 0, 500, 300); BRect frame(0, 0, 550, 300);
frame.OffsetBySelf(s.Frame().Width()/2 - frame.Width()/2, frame.OffsetBySelf(s.Frame().Width()/2 - frame.Width()/2,
s.Frame().Height()/2 - frame.Height()/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); BWindow *w = new BWindow(frame, "Themes", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_QUIT_ON_WINDOW_CLOSE);
+3 -2
View File
@@ -286,7 +286,7 @@ FindRGBColor(BMessage &message, const char *name, int32 index, rgb_color *c)
const void *data; const void *data;
ssize_t len; ssize_t len;
status_t err; 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) if (err < B_OK)
return err; return err;
if (len > (ssize_t)sizeof(*c)) if (len > (ssize_t)sizeof(*c))
@@ -317,7 +317,8 @@ FindFont(BMessage &message, const char *name, int32 index, BFont *f)
#else #else
const void *data; const void *data;
ssize_t len; 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) if (err < B_OK)
return err; return err;
if (len > (ssize_t)sizeof(*f)) if (len > (ssize_t)sizeof(*f))
+153 -60
View File
@@ -12,26 +12,35 @@
#include <Font.h> #include <Font.h>
#include <Message.h> #include <Message.h>
#include <Roster.h> #include <Roster.h>
#include <Debug.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "ThemesAddon.h" #include "ThemesAddon.h"
#include "UITheme.h" #include "UITheme.h"
#include "Utils.h"
#ifdef SINGLE_BINARY #ifdef SINGLE_BINARY
#define instanciate_themes_addon instanciate_themes_addon_ui_settings #define instanciate_themes_addon instanciate_themes_addon_ui_settings
#endif #endif
//XXX: FIXME #define DEBUG_TA
ThemesAddon *instanciate_themes_addon() #ifdef DEBUG_TA
{ #define FENTRY PRINT(("*ThemesAddon[%s]::%s()\n", Name(), __FUNCTION__))
return NULL; #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_NAME "System Colors and Fonts"
#define A_MSGNAME Z_THEME_UI_SETTINGS #define A_MSGNAME Z_THEME_UI_SETTINGS
#define A_DESCRIPTION "System colors, fonts and other goodies" #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); 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() UISettingsThemesAddon::UISettingsThemesAddon()
: ThemesAddon(A_NAME, A_MSGNAME) : ThemesAddon(A_NAME, A_MSGNAME)
{ {
FENTRY;
} }
UISettingsThemesAddon::~UISettingsThemesAddon() UISettingsThemesAddon::~UISettingsThemesAddon()
{ {
FENTRY;
} }
const char *UISettingsThemesAddon::Description() const char *UISettingsThemesAddon::Description()
@@ -72,6 +113,7 @@ status_t UISettingsThemesAddon::RunPreferencesPanel()
status_t err = B_OK; status_t err = B_OK;
entry_ref ref; entry_ref ref;
BEntry ent; BEntry ent;
FENTRY;
/* /*
err = ent.SetTo("/boot/beos/preferences/Colors"); err = ent.SetTo("/boot/beos/preferences/Colors");
if (!err) { if (!err) {
@@ -83,16 +125,11 @@ status_t UISettingsThemesAddon::RunPreferencesPanel()
*/ */
if (!err) if (!err)
return B_OK; return B_OK;
err = ent.SetTo("/system/add-ons/Preferences/Appearance"); err = ent.SetTo("/boot/beos/preferences/Appearance");
if (!err) { if (!err) {
err = ent.GetRef(&ref); err = ent.GetRef(&ref);
if (!err) { if (!err) {
err = be_roster->Launch(&ref); err = be_roster->Launch(&ref);
if (err) {
BMessage msg(B_REFS_RECEIVED);
msg.AddRef("refs", &ref);
be_app_messenger.SendMessage(&msg);
}
} }
} }
return err; return err;
@@ -100,24 +137,45 @@ status_t UISettingsThemesAddon::RunPreferencesPanel()
status_t UISettingsThemesAddon::AddNames(BMessage &names) status_t UISettingsThemesAddon::AddNames(BMessage &names)
{ {
BMessage uisettings;
BMessage uinames;
status_t err;
const char *str, *value; const char *str, *value;
type_code code; type_code code;
int32 i; int32 i;
FENTRY;
err = get_ui_settings(&uisettings, &uinames);
if (err)
return err;
names.AddString(Z_THEME_UI_SETTINGS, "UI Settings"); 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_plain_font", "System Plain");
names.AddString("be:f:be_bold_font", "System Bold"); names.AddString("be:f:be_bold_font", "System Bold");
names.AddString("be:f:be_fixed_font", "System Fixed"); 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; return B_OK;
} }
@@ -126,30 +184,50 @@ status_t UISettingsThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
BMessage uisettings; BMessage uisettings;
BFont fnt; BFont fnt;
status_t err; status_t err;
int i;
FENTRY;
(void)flags; (void)flags;
err = MyMessage(theme, uisettings); err = MyMessage(theme, uisettings);
DERR(err);
if (err) if (err)
return err; return err;
// hack for legacy fonts font_family family;
err = uisettings.FindFlat("be:f:be_plain_font", &fnt); font_style style;
uisettings.RemoveName("be:f:be_plain_font");
if (err == B_OK)
BFont::SetStandardFont(B_PLAIN_FONT, &fnt);
err = uisettings.FindFlat("be:f:be_bold_font", &fnt);
uisettings.RemoveName("be:f:be_bold_font");
if (err == B_OK)
BFont::SetStandardFont(B_BOLD_FONT, &fnt);
err = uisettings.FindFlat("be:f:be_fixed_font", &fnt);
uisettings.RemoveName("be:f:be_fixed_font");
if (err == B_OK)
BFont::SetStandardFont(B_FIXED_FONT, &fnt);
update_ui_settings(uisettings); err = FindFont(uisettings, "be:f:be_plain_font", 0, &fnt);
uisettings.RemoveName("be:f:be_plain_font");
DERR(err);
if (err == B_OK) {
fnt.GetFamilyAndStyle(&family, &style);
_set_system_font_("plain", family, style, fnt.Size());
}
err = FindFont(uisettings, "be:f:be_bold_font", 0, &fnt);
DERR(err);
uisettings.RemoveName("be:f:be_bold_font");
if (err == B_OK) {
fnt.GetFamilyAndStyle(&family, &style);
_set_system_font_("bold", family, style, fnt.Size());
}
err = FindFont(uisettings, "be:f:be_fixed_font", 0, &fnt);
DERR(err);
uisettings.RemoveName("be:f:be_fixed_font");
if (err == B_OK) {
fnt.GetFamilyAndStyle(&family, &style);
_set_system_font_("fixed", family, style, fnt.Size());
}
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; return B_OK;
@@ -161,23 +239,23 @@ status_t UISettingsThemesAddon::MakeTheme(BMessage &theme, uint32 flags)
BMessage names; BMessage names;
BFont fnt; BFont fnt;
status_t err; status_t err;
int i;
FENTRY;
(void)flags; (void)flags;
err = MyMessage(theme, uisettings); err = MyMessage(theme, uisettings);
if (err) if (err)
uisettings.MakeEmpty(); uisettings.MakeEmpty();
err = get_ui_settings(&uisettings, &names); for (i = 0; gUIColorMap[i].name; i++) {
if (err) rgb_color c = ui_color(gUIColorMap[i].id);
return err; AddRGBColor(uisettings, gUIColorMap[i].name, c);
}
// hack for legacy fonts // hack for legacy fonts
err = BFont::GetStandardFont(B_PLAIN_FONT, &fnt); AddFont(uisettings, "be:f:be_plain_font", (BFont *)be_plain_font);
uisettings.AddFlat("be:f:be_plain_font", &fnt); AddFont(uisettings, "be:f:be_bold_font", (BFont *)be_bold_font);
err = BFont::GetStandardFont(B_BOLD_FONT, &fnt); AddFont(uisettings, "be:f:be_fixed_font", (BFont *)be_fixed_font);
uisettings.AddFlat("be:f:be_bold_font", &fnt);
err = BFont::GetStandardFont(B_FIXED_FONT, &fnt);
uisettings.AddFlat("be:f:be_fixed_font", &fnt);
err = SetMyMessage(theme, uisettings); err = SetMyMessage(theme, uisettings);
return err; return err;
@@ -189,18 +267,35 @@ status_t UISettingsThemesAddon::ApplyDefaultTheme(uint32 flags)
BMessage uisettings; BMessage uisettings;
BFont fnt; BFont fnt;
status_t err; status_t err;
FENTRY;
/*
err = get_default_settings(&uisettings); err = get_default_settings(&uisettings);
if (err) if (err)
return err; return err;
*/
// hack for legacy fonts
err = BFont::GetStandardFont((font_which)(B_PLAIN_FONT-100), &fnt); font_family family;
uisettings.AddFlat("be:f:be_plain_font", &fnt); font_style style;
err = BFont::GetStandardFont((font_which)(B_BOLD_FONT-100), &fnt); float size;
uisettings.AddFlat("be:f:be_bold_font", &fnt); BFont f;
err = BFont::GetStandardFont((font_which)(B_FIXED_FONT-100), &fnt); if (_get_system_default_font_("plain", family, style, &size) != B_OK)
uisettings.AddFlat("be:f:be_fixed_font", &fnt); 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); theme.AddMessage(A_MSGNAME, &uisettings);
return ApplyTheme(theme, flags); return ApplyTheme(theme, flags);
@@ -212,6 +307,4 @@ ThemesAddon *instanciate_themes_addon()
return (ThemesAddon *) new UISettingsThemesAddon; return (ThemesAddon *) new UISettingsThemesAddon;
} }
#endif #endif /* B_BEOS_VERSION_DANO */
#endif /* B_BEOS_VERSION_DANO */
+49 -16
View File
@@ -16,6 +16,7 @@
#include <Path.h> #include <Path.h>
#include <Roster.h> #include <Roster.h>
#include <String.h> #include <String.h>
#include <Debug.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -27,13 +28,36 @@
#define instanciate_themes_addon instanciate_themes_addon_window_decor #define instanciate_themes_addon instanciate_themes_addon_window_decor
#endif #endif
//XXX: FIXME #define DERR(e) { PRINT(("%s: err: %s\n", __FUNCTION__, strerror(e))); }
ThemesAddon *instanciate_themes_addon()
{
return NULL;
}
#if 0 // DANO... 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);
}
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_NAME "Window Decor"
#define A_MSGNAME Z_THEME_WINDOW_DECORATIONS #define A_MSGNAME Z_THEME_WINDOW_DECORATIONS
@@ -75,16 +99,11 @@ status_t DecorThemesAddon::RunPreferencesPanel()
status_t err; status_t err;
entry_ref ref; entry_ref ref;
BEntry ent; BEntry ent;
err = ent.SetTo("/system/add-ons/Preferences/Appearance"); err = ent.SetTo("/boot/beos/references/Appearance");
if (!err) { if (!err) {
err = ent.GetRef(&ref); err = ent.GetRef(&ref);
if (!err) { if (!err) {
err = be_roster->Launch(&ref); err = be_roster->Launch(&ref);
if (err) {
BMessage msg(B_REFS_RECEIVED);
msg.AddRef("refs", &ref);
be_app_messenger.SendMessage(&msg);
}
} }
} }
return err; return err;
@@ -107,9 +126,13 @@ status_t DecorThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
(void)flags; (void)flags;
err = MyMessage(theme, window_decor); err = MyMessage(theme, window_decor);
DERR(err);
if (err) if (err)
return err; return err;
if (window_decor.FindString("window:decor", &decorName) == B_OK)
set_decorator(decorName.String());
#if 0
#ifdef B_BEOS_VERSION_DANO #ifdef B_BEOS_VERSION_DANO
if (window_decor.FindString("window:decor", &decorName) == B_OK) if (window_decor.FindString("window:decor", &decorName) == B_OK)
set_window_decor(decorName.String(), set_window_decor(decorName.String(),
@@ -119,6 +142,7 @@ extern void __set_window_decor(int32 theme);
int32 decorNr = 0; int32 decorNr = 0;
if (window_decor.FindInt32("window:R5:decor", &decorNr) == B_OK) if (window_decor.FindInt32("window:R5:decor", &decorNr) == B_OK)
__set_window_decor(decorNr); __set_window_decor(decorNr);
#endif
#endif #endif
// XXX: add colors à la WindowShade ? // XXX: add colors à la WindowShade ?
@@ -134,20 +158,31 @@ status_t DecorThemesAddon::MakeTheme(BMessage &theme, uint32 flags)
(void)flags; (void)flags;
err = MyMessage(theme, window_decor); err = MyMessage(theme, window_decor);
DERR(err);
if (err) if (err)
window_decor.MakeEmpty(); 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 #ifdef B_BEOS_VERSION_DANO
err = get_window_decor(&decorName, &globals); err = get_window_decor(&decorName, &globals);
DERR(err);
if (err == B_OK) { if (err == B_OK) {
window_decor.AddString("window:decor", decorName.String()); window_decor.AddString("window:decor", decorName.String());
window_decor.AddMessage("window:decor_globals", &globals); window_decor.AddMessage("window:decor_globals", &globals);
} }
#else #else
window_decor.AddInt32("window:R5:decor", 0); window_decor.AddInt32("window:R5:decor", 0);
#endif
#endif #endif
err = SetMyMessage(theme, window_decor); err = SetMyMessage(theme, window_decor);
DERR(err);
return err; return err;
} }
@@ -167,6 +202,4 @@ ThemesAddon *instanciate_themes_addon()
return (ThemesAddon *) new DecorThemesAddon; return (ThemesAddon *) new DecorThemesAddon;
} }
#endif
#endif /* B_BEOS_VERSION_DANO */ #endif /* B_BEOS_VERSION_DANO */