Add proper checks of flags for apply/save.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23732 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2008-01-25 13:52:22 +00:00
parent 2f3f3d79b5
commit 24e3a405c4
14 changed files with 69 additions and 44 deletions

View File

@ -124,7 +124,9 @@ status_t BackgroundThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
ssize_t flatSize; ssize_t flatSize;
char *pAttr; char *pAttr;
(void)flags; if (!(flags & UI_THEME_SETTINGS_SET_ALL) || !(AddonFlags() & Z_THEME_ADDON_DO_SET_ALL))
return B_OK;
err = MyMessage(theme, backgrounds); err = MyMessage(theme, backgrounds);
if (err) if (err)
return err; return err;

View File

@ -99,7 +99,6 @@ status_t BeIDEThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
BPath beideSPath; BPath beideSPath;
rgb_color col; rgb_color col;
(void)flags;
err = theme.FindMessage(Z_THEME_UI_SETTINGS, &uisettings); err = theme.FindMessage(Z_THEME_UI_SETTINGS, &uisettings);
if (err) if (err)
return err; return err;
@ -118,11 +117,11 @@ status_t BeIDEThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
if (FindRGBColor(uisettings, B_UI_MENU_SELECTED_BACKGROUND_COLOR, 0, &col) >= B_OK) if (FindRGBColor(uisettings, B_UI_MENU_SELECTED_BACKGROUND_COLOR, 0, &col) >= B_OK)
bp.selbg = col; bp.selbg = col;
if (true/* || flags & UI_THEME_SETTINGS_SAVE*/) { if (flags & UI_THEME_SETTINGS_SAVE && AddonFlags() & Z_THEME_ADDON_DO_SAVE) {
err = beideSettings.WriteAttr("AppEditorPrefs", 'rPWM', 0LL, &bp, err = beideSettings.WriteAttr("AppEditorPrefs", 'rPWM', 0LL, &bp,
sizeof(struct beide_editor_pref)); sizeof(struct beide_editor_pref));
} }
if (true/* || flags & UI_THEME_SETTINGS_APPLY*/) { if (flags & UI_THEME_SETTINGS_APPLY && AddonFlags() & Z_THEME_ADDON_DO_APPLY) {
BList teamList; BList teamList;
app_info ainfo; app_info ainfo;
int32 count, i; int32 count, i;

View File

@ -118,12 +118,20 @@ status_t UISettingsThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
BMessage uisettings; BMessage uisettings;
BFont fnt; BFont fnt;
status_t err; status_t err;
uint32 uiflags = 0;
(void)flags; (void)flags;
err = MyMessage(theme, uisettings); err = MyMessage(theme, uisettings);
if (err) if (err)
return err; return err;
if (flags & UI_THEME_SETTINGS_SAVE && AddonFlags() & Z_THEME_ADDON_DO_SAVE)
uiflags |= B_SAVE_UI_SETTINGS;
if (flags & UI_THEME_SETTINGS_APPLY && AddonFlags() & Z_THEME_ADDON_DO_APPLY)
uiflags |= B_APPLY_UI_SETTINGS;
if (!uiflags)
return B_OK;
// hack for legacy fonts // hack for legacy fonts
err = uisettings.FindFlat("be:f:be_plain_font", &fnt); err = uisettings.FindFlat("be:f:be_plain_font", &fnt);
uisettings.RemoveName("be:f:be_plain_font"); uisettings.RemoveName("be:f:be_plain_font");
@ -139,10 +147,8 @@ status_t UISettingsThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
uisettings.RemoveName("be:f:be_fixed_font"); uisettings.RemoveName("be:f:be_fixed_font");
if (err == B_OK) if (err == B_OK)
BFont::SetStandardFont(B_FIXED_FONT, &fnt); BFont::SetStandardFont(B_FIXED_FONT, &fnt);
update_ui_settings(uisettings);
update_ui_settings(uisettings, uiflags);
return B_OK; return B_OK;
} }

View File

@ -97,7 +97,9 @@ status_t DecorThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
BString decorName; BString decorName;
status_t err; status_t err;
(void)flags; if (!(flags & UI_THEME_SETTINGS_SET_ALL) || !(AddonFlags() & Z_THEME_ADDON_DO_SET_ALL))
return B_OK;
err = MyMessage(theme, window_decor); err = MyMessage(theme, window_decor);
if (err) if (err)
return err; return err;

View File

@ -99,7 +99,9 @@ status_t DeskbarThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
bool expanded = true; bool expanded = true;
BDeskbar db; BDeskbar db;
(void)flags; if (!(flags & UI_THEME_SETTINGS_SET_ALL) || !(AddonFlags() & Z_THEME_ADDON_DO_SET_ALL))
return B_OK;
err = MyMessage(theme, deskbar); err = MyMessage(theme, deskbar);
if (err) if (err)
return err; return err;

View File

@ -110,12 +110,12 @@ status_t EddieThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
BFile EddieSettings(EddieSPath.Path(), B_WRITE_ONLY|B_OPEN_AT_END); BFile EddieSettings(EddieSPath.Path(), B_WRITE_ONLY|B_OPEN_AT_END);
if (EddieSettings.InitCheck() < B_OK) if (EddieSettings.InitCheck() < B_OK)
return EddieSettings.InitCheck(); return EddieSettings.InitCheck();
if (true/* || flags & UI_THEME_SETTINGS_SAVE*/) { if (flags & UI_THEME_SETTINGS_SAVE && AddonFlags() & Z_THEME_ADDON_DO_SAVE) {
if (EddieSettings.Write(text.String(), strlen(text.String())) < B_OK) if (EddieSettings.Write(text.String(), strlen(text.String())) < B_OK)
return B_ERROR; return B_ERROR;
} }
if (true/* || flags & UI_THEME_SETTINGS_APPLY*/) { if (flags & UI_THEME_SETTINGS_APPLY && AddonFlags() & Z_THEME_ADDON_DO_APPLY) {
} }
return B_OK; return B_OK;

View File

@ -187,7 +187,9 @@ status_t UISettingsThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
int i; int i;
FENTRY; FENTRY;
(void)flags; if (!(flags & UI_THEME_SETTINGS_SET_ALL) || !(AddonFlags() & Z_THEME_ADDON_DO_SET_ALL))
return B_OK;
err = MyMessage(theme, uisettings); err = MyMessage(theme, uisettings);
DERR(err); DERR(err);
if (err) if (err)

View File

@ -124,7 +124,9 @@ status_t DecorThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
BString decorName; BString decorName;
status_t err; status_t err;
(void)flags; if (!(flags & UI_THEME_SETTINGS_SET_ALL) || !(AddonFlags() & Z_THEME_ADDON_DO_SET_ALL))
return B_OK;
err = MyMessage(theme, window_decor); err = MyMessage(theme, window_decor);
DERR(err); DERR(err);
if (err) if (err)

View File

@ -83,7 +83,6 @@ status_t PeThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
BString text; BString text;
char buffer[10]; char buffer[10];
(void)flags;
err = theme.FindMessage(Z_THEME_UI_SETTINGS, &uisettings); err = theme.FindMessage(Z_THEME_UI_SETTINGS, &uisettings);
if (err) if (err)
return err; return err;
@ -110,12 +109,13 @@ status_t PeThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
BFile PeSettings(PeSPath.Path(), B_WRITE_ONLY|B_OPEN_AT_END); BFile PeSettings(PeSPath.Path(), B_WRITE_ONLY|B_OPEN_AT_END);
if (PeSettings.InitCheck() < B_OK) if (PeSettings.InitCheck() < B_OK)
return PeSettings.InitCheck(); return PeSettings.InitCheck();
if (true/* || flags & UI_THEME_SETTINGS_SAVE*/) {
if (flags & UI_THEME_SETTINGS_SAVE && AddonFlags() & Z_THEME_ADDON_DO_SAVE) {
if (PeSettings.Write(text.String(), strlen(text.String())) < B_OK) if (PeSettings.Write(text.String(), strlen(text.String())) < B_OK)
return B_ERROR; return B_ERROR;
} }
if (true/* || flags & UI_THEME_SETTINGS_APPLY*/) { if (flags & UI_THEME_SETTINGS_APPLY && AddonFlags() & Z_THEME_ADDON_DO_APPLY) {
} }
return B_OK; return B_OK;

View File

@ -104,7 +104,9 @@ status_t ScreensaverThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
BMessage settings; BMessage settings;
BMessage modsettings; BMessage modsettings;
(void)flags; if (!(flags & UI_THEME_SETTINGS_SET_ALL) || !(AddonFlags() & Z_THEME_ADDON_DO_SET_ALL))
return B_OK;
err = MyMessage(theme, screensaver); err = MyMessage(theme, screensaver);
if (err) if (err)
return err; return err;

View File

@ -76,7 +76,6 @@ status_t SoundplayThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
rgb_color panelcol; rgb_color panelcol;
int32 wincnt = 1; int32 wincnt = 1;
(void)flags;
err = theme.FindMessage(Z_THEME_UI_SETTINGS, &uisettings); err = theme.FindMessage(Z_THEME_UI_SETTINGS, &uisettings);
if (err) if (err)
return err; return err;
@ -84,23 +83,29 @@ status_t SoundplayThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
if (FindRGBColor(uisettings, B_UI_PANEL_BACKGROUND_COLOR, 0, &panelcol) < B_OK) if (FindRGBColor(uisettings, B_UI_PANEL_BACKGROUND_COLOR, 0, &panelcol) < B_OK)
panelcol = make_color(216,216,216,255); panelcol = make_color(216,216,216,255);
BMessenger msgr("application/x-vnd.marcone-soundplay"); if (flags & UI_THEME_SETTINGS_SAVE && AddonFlags() & Z_THEME_ADDON_DO_SAVE) {
BMessage command(B_COUNT_PROPERTIES); // WRITEME
BMessage answer;
command.AddSpecifier("Window");
err = msgr.SendMessage(&command, &answer,2000000LL,2000000LL);
if(B_OK == err) {
if (answer.FindInt32("result", &wincnt) != B_OK)
wincnt = 1;
} }
BMessage msg(B_PASTE);
AddRGBColor(msg, "RGBColor", panelcol); if (flags & UI_THEME_SETTINGS_APPLY && AddonFlags() & Z_THEME_ADDON_DO_APPLY) {
msg.AddPoint("_drop_point_", BPoint(0,0)); BMessenger msgr("application/x-vnd.marcone-soundplay");
// send to every window (the Playlist window needs it too) BMessage command(B_COUNT_PROPERTIES);
for (int32 i = 0; i < wincnt; i++) { BMessage answer;
BMessage wmsg(msg); command.AddSpecifier("Window");
wmsg.AddSpecifier("Window", i); err = msgr.SendMessage(&command, &answer,2000000LL,2000000LL);
msgr.SendMessage(&wmsg, (BHandler *)NULL, 2000000LL); if(B_OK == err) {
if (answer.FindInt32("result", &wincnt) != B_OK)
wincnt = 1;
}
BMessage msg(B_PASTE);
AddRGBColor(msg, "RGBColor", panelcol);
msg.AddPoint("_drop_point_", BPoint(0,0));
// send to every window (the Playlist window needs it too)
for (int32 i = 0; i < wincnt; i++) {
BMessage wmsg(msg);
wmsg.AddSpecifier("Window", i);
msgr.SendMessage(&wmsg, (BHandler *)NULL, 2000000LL);
}
} }
return B_OK; return B_OK;

View File

@ -112,7 +112,9 @@ status_t SoundsThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
int32 field_count; int32 field_count;
BMessage msg; BMessage msg;
(void)flags; if (!(flags & UI_THEME_SETTINGS_SET_ALL) || !(AddonFlags() & Z_THEME_ADDON_DO_SET_ALL))
return B_OK;
err = MyMessage(theme, sounds); err = MyMessage(theme, sounds);
if (err) if (err)
return err; return err;

View File

@ -258,7 +258,6 @@ status_t TerminalThemesAddon::ApplyThemeR5(BMessage &theme, uint32 flags)
status_t err; status_t err;
struct termprefs tp; struct termprefs tp;
(void)flags;
err = MyMessage(theme, termpref); err = MyMessage(theme, termpref);
if (err) if (err)
return err; return err;
@ -303,7 +302,7 @@ status_t TerminalThemesAddon::ApplyThemeR5(BMessage &theme, uint32 flags)
if (termpref.FindInt32(TP_ENCODING, (int32 *)&tp.p.encoding) != B_OK) if (termpref.FindInt32(TP_ENCODING, (int32 *)&tp.p.encoding) != B_OK)
tp.p.encoding = 0; // UTF-8 tp.p.encoding = 0; // UTF-8
if (flags & UI_THEME_SETTINGS_SAVE) { if (flags & UI_THEME_SETTINGS_SAVE && AddonFlags() & Z_THEME_ADDON_DO_SAVE) {
BPath pTermPref; BPath pTermPref;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &pTermPref) < B_OK) if (find_directory(B_USER_SETTINGS_DIRECTORY, &pTermPref) < B_OK)
return EINVAL; return EINVAL;
@ -317,7 +316,8 @@ status_t TerminalThemesAddon::ApplyThemeR5(BMessage &theme, uint32 flags)
if (ni.InitCheck() == B_OK) if (ni.InitCheck() == B_OK)
ni.SetType("application/x-vnd.Be-pref"); ni.SetType("application/x-vnd.Be-pref");
} }
if (flags & UI_THEME_SETTINGS_APPLY) {
if (flags & UI_THEME_SETTINGS_APPLY && AddonFlags() & Z_THEME_ADDON_DO_APPLY) {
BList teamList; BList teamList;
app_info ainfo; app_info ainfo;
int32 count, i; int32 count, i;
@ -404,7 +404,6 @@ status_t TerminalThemesAddon::ApplyThemeHaiku(BMessage &theme, uint32 flags)
rgb_color color; rgb_color color;
BString s; BString s;
(void)flags;
err = MyMessage(theme, termpref); err = MyMessage(theme, termpref);
if (err) if (err)
return err; return err;
@ -479,7 +478,7 @@ status_t TerminalThemesAddon::ApplyThemeHaiku(BMessage &theme, uint32 flags)
s << color.red << ", " << color.green << ", " << color.blue; s << color.red << ", " << color.green << ", " << color.blue;
lines.AddString(PREF_SELECT_FORE_COLOR, s.String()); lines.AddString(PREF_SELECT_FORE_COLOR, s.String());
/* XXX: handle PREF_IM_FORE_COLOR PREF_IM_BACK_COLOR PREF_IM_SELECT_COLOR */ /* XXX: handle PREF_IM_FORE_COLOR PREF_IM_BACK_COLOR PREF_IM_SELECT_COLOR */
if (termpref.FindInt32(TP_ENCODING, &ival) != B_OK) if (termpref.FindInt32(TP_ENCODING, &ival) != B_OK)
@ -489,11 +488,11 @@ status_t TerminalThemesAddon::ApplyThemeHaiku(BMessage &theme, uint32 flags)
//XXX: shouldn't really be touched... //XXX: shouldn't really be touched...
//lines.AddString(, s.String()); //lines.AddString(, s.String());
if (flags & UI_THEME_SETTINGS_SAVE && AddonFlags() & Z_THEME_ADDON_DO_SAVE) {
if (flags & UI_THEME_SETTINGS_SAVE) {
SaveHaikuTerminalSettings(lines); SaveHaikuTerminalSettings(lines);
} }
if (flags & UI_THEME_SETTINGS_APPLY) {
if (flags & UI_THEME_SETTINGS_APPLY && AddonFlags() & Z_THEME_ADDON_DO_APPLY) {
BList teamList; BList teamList;
app_info ainfo; app_info ainfo;
int32 count, i; int32 count, i;

View File

@ -99,7 +99,9 @@ status_t WinampSkinThemesAddon::ApplyTheme(BMessage &theme, uint32 flags)
BString name; BString name;
status_t err; status_t err;
(void)flags; if (!(flags & UI_THEME_SETTINGS_SET_ALL) || !(AddonFlags() & Z_THEME_ADDON_DO_SET_ALL))
return B_OK;
err = MyMessage(theme, skin); err = MyMessage(theme, skin);
if (err) if (err)
return err; return err;