From 24e3a405c4362f3311b66d61936855018782c171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Fri, 25 Jan 2008 13:52:22 +0000 Subject: [PATCH] Add proper checks of flags for apply/save. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23732 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../themes/addons/BackgroundsAddon.cpp | 4 +- 3rdparty/mmu_man/themes/addons/BeIDEAddon.cpp | 5 +-- .../themes/addons/DanoUISettingsAddon.cpp | 12 ++++-- .../themes/addons/DanoWindowDecorAddon.cpp | 4 +- .../mmu_man/themes/addons/DeskbarAddon.cpp | 4 +- 3rdparty/mmu_man/themes/addons/EddieAddon.cpp | 4 +- .../themes/addons/HaikuUISettingsAddon.cpp | 4 +- .../themes/addons/HaikuWindowDecorAddon.cpp | 4 +- 3rdparty/mmu_man/themes/addons/PeAddon.cpp | 6 +-- .../themes/addons/ScreensaverAddon.cpp | 4 +- .../themes/addons/SoundplayColorAddon.cpp | 39 +++++++++++-------- .../mmu_man/themes/addons/SoundsAddon.cpp | 4 +- .../mmu_man/themes/addons/TerminalAddon.cpp | 15 ++++--- .../mmu_man/themes/addons/WinampSkinAddon.cpp | 4 +- 14 files changed, 69 insertions(+), 44 deletions(-) diff --git a/3rdparty/mmu_man/themes/addons/BackgroundsAddon.cpp b/3rdparty/mmu_man/themes/addons/BackgroundsAddon.cpp index 033bbecd8b..2f684e7118 100644 --- a/3rdparty/mmu_man/themes/addons/BackgroundsAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/BackgroundsAddon.cpp @@ -124,7 +124,9 @@ status_t BackgroundThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) ssize_t flatSize; 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); if (err) return err; diff --git a/3rdparty/mmu_man/themes/addons/BeIDEAddon.cpp b/3rdparty/mmu_man/themes/addons/BeIDEAddon.cpp index 5d3ade39ab..d1a430d11f 100644 --- a/3rdparty/mmu_man/themes/addons/BeIDEAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/BeIDEAddon.cpp @@ -99,7 +99,6 @@ status_t BeIDEThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) BPath beideSPath; rgb_color col; - (void)flags; err = theme.FindMessage(Z_THEME_UI_SETTINGS, &uisettings); if (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) 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, 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; app_info ainfo; int32 count, i; diff --git a/3rdparty/mmu_man/themes/addons/DanoUISettingsAddon.cpp b/3rdparty/mmu_man/themes/addons/DanoUISettingsAddon.cpp index 16222aaf11..437a082ee8 100644 --- a/3rdparty/mmu_man/themes/addons/DanoUISettingsAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/DanoUISettingsAddon.cpp @@ -118,12 +118,20 @@ status_t UISettingsThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) BMessage uisettings; BFont fnt; status_t err; + uint32 uiflags = 0; (void)flags; err = MyMessage(theme, uisettings); if (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 err = uisettings.FindFlat("be:f:be_plain_font", &fnt); 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"); if (err == B_OK) BFont::SetStandardFont(B_FIXED_FONT, &fnt); - - - update_ui_settings(uisettings); + update_ui_settings(uisettings, uiflags); return B_OK; } diff --git a/3rdparty/mmu_man/themes/addons/DanoWindowDecorAddon.cpp b/3rdparty/mmu_man/themes/addons/DanoWindowDecorAddon.cpp index 2996fabf98..63b5886fe3 100644 --- a/3rdparty/mmu_man/themes/addons/DanoWindowDecorAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/DanoWindowDecorAddon.cpp @@ -97,7 +97,9 @@ status_t DecorThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) BString decorName; 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); if (err) return err; diff --git a/3rdparty/mmu_man/themes/addons/DeskbarAddon.cpp b/3rdparty/mmu_man/themes/addons/DeskbarAddon.cpp index 64481eb56a..b553ba217e 100644 --- a/3rdparty/mmu_man/themes/addons/DeskbarAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/DeskbarAddon.cpp @@ -99,7 +99,9 @@ status_t DeskbarThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) bool expanded = true; 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); if (err) return err; diff --git a/3rdparty/mmu_man/themes/addons/EddieAddon.cpp b/3rdparty/mmu_man/themes/addons/EddieAddon.cpp index 0704189c9d..f412f66b85 100644 --- a/3rdparty/mmu_man/themes/addons/EddieAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/EddieAddon.cpp @@ -110,12 +110,12 @@ status_t EddieThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) BFile EddieSettings(EddieSPath.Path(), B_WRITE_ONLY|B_OPEN_AT_END); if (EddieSettings.InitCheck() < B_OK) 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) 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; diff --git a/3rdparty/mmu_man/themes/addons/HaikuUISettingsAddon.cpp b/3rdparty/mmu_man/themes/addons/HaikuUISettingsAddon.cpp index 6dac974d11..2bf4a06d7a 100644 --- a/3rdparty/mmu_man/themes/addons/HaikuUISettingsAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/HaikuUISettingsAddon.cpp @@ -187,7 +187,9 @@ status_t UISettingsThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) int i; FENTRY; - (void)flags; + if (!(flags & UI_THEME_SETTINGS_SET_ALL) || !(AddonFlags() & Z_THEME_ADDON_DO_SET_ALL)) + return B_OK; + err = MyMessage(theme, uisettings); DERR(err); if (err) diff --git a/3rdparty/mmu_man/themes/addons/HaikuWindowDecorAddon.cpp b/3rdparty/mmu_man/themes/addons/HaikuWindowDecorAddon.cpp index 2cb81021f1..cf24038149 100644 --- a/3rdparty/mmu_man/themes/addons/HaikuWindowDecorAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/HaikuWindowDecorAddon.cpp @@ -124,7 +124,9 @@ status_t DecorThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) BString decorName; 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); DERR(err); if (err) diff --git a/3rdparty/mmu_man/themes/addons/PeAddon.cpp b/3rdparty/mmu_man/themes/addons/PeAddon.cpp index b5432c3551..19238c9305 100644 --- a/3rdparty/mmu_man/themes/addons/PeAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/PeAddon.cpp @@ -83,7 +83,6 @@ status_t PeThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) BString text; char buffer[10]; - (void)flags; err = theme.FindMessage(Z_THEME_UI_SETTINGS, &uisettings); if (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); if (PeSettings.InitCheck() < B_OK) 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) 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; diff --git a/3rdparty/mmu_man/themes/addons/ScreensaverAddon.cpp b/3rdparty/mmu_man/themes/addons/ScreensaverAddon.cpp index 078ff17609..b31639172d 100644 --- a/3rdparty/mmu_man/themes/addons/ScreensaverAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/ScreensaverAddon.cpp @@ -104,7 +104,9 @@ status_t ScreensaverThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) BMessage settings; 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); if (err) return err; diff --git a/3rdparty/mmu_man/themes/addons/SoundplayColorAddon.cpp b/3rdparty/mmu_man/themes/addons/SoundplayColorAddon.cpp index 431bd2df53..2b5ff8fcaf 100644 --- a/3rdparty/mmu_man/themes/addons/SoundplayColorAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/SoundplayColorAddon.cpp @@ -76,7 +76,6 @@ status_t SoundplayThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) rgb_color panelcol; int32 wincnt = 1; - (void)flags; err = theme.FindMessage(Z_THEME_UI_SETTINGS, &uisettings); if (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) panelcol = make_color(216,216,216,255); - BMessenger msgr("application/x-vnd.marcone-soundplay"); - BMessage command(B_COUNT_PROPERTIES); - 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; + if (flags & UI_THEME_SETTINGS_SAVE && AddonFlags() & Z_THEME_ADDON_DO_SAVE) { + // WRITEME } - 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); + + if (flags & UI_THEME_SETTINGS_APPLY && AddonFlags() & Z_THEME_ADDON_DO_APPLY) { + BMessenger msgr("application/x-vnd.marcone-soundplay"); + BMessage command(B_COUNT_PROPERTIES); + 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); + 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; diff --git a/3rdparty/mmu_man/themes/addons/SoundsAddon.cpp b/3rdparty/mmu_man/themes/addons/SoundsAddon.cpp index c48854da7c..1518df4b37 100644 --- a/3rdparty/mmu_man/themes/addons/SoundsAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/SoundsAddon.cpp @@ -112,7 +112,9 @@ status_t SoundsThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) int32 field_count; 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); if (err) return err; diff --git a/3rdparty/mmu_man/themes/addons/TerminalAddon.cpp b/3rdparty/mmu_man/themes/addons/TerminalAddon.cpp index 8a1dd9bb2b..c1f37dd4e7 100644 --- a/3rdparty/mmu_man/themes/addons/TerminalAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/TerminalAddon.cpp @@ -258,7 +258,6 @@ status_t TerminalThemesAddon::ApplyThemeR5(BMessage &theme, uint32 flags) status_t err; struct termprefs tp; - (void)flags; err = MyMessage(theme, termpref); if (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) 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; if (find_directory(B_USER_SETTINGS_DIRECTORY, &pTermPref) < B_OK) return EINVAL; @@ -317,7 +316,8 @@ status_t TerminalThemesAddon::ApplyThemeR5(BMessage &theme, uint32 flags) if (ni.InitCheck() == B_OK) 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; app_info ainfo; int32 count, i; @@ -404,7 +404,6 @@ status_t TerminalThemesAddon::ApplyThemeHaiku(BMessage &theme, uint32 flags) rgb_color color; BString s; - (void)flags; err = MyMessage(theme, termpref); if (err) return err; @@ -479,7 +478,7 @@ status_t TerminalThemesAddon::ApplyThemeHaiku(BMessage &theme, uint32 flags) s << color.red << ", " << color.green << ", " << color.blue; 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) @@ -489,11 +488,11 @@ status_t TerminalThemesAddon::ApplyThemeHaiku(BMessage &theme, uint32 flags) //XXX: shouldn't really be touched... //lines.AddString(, s.String()); - - if (flags & UI_THEME_SETTINGS_SAVE) { + if (flags & UI_THEME_SETTINGS_SAVE && AddonFlags() & Z_THEME_ADDON_DO_SAVE) { SaveHaikuTerminalSettings(lines); } - if (flags & UI_THEME_SETTINGS_APPLY) { + + if (flags & UI_THEME_SETTINGS_APPLY && AddonFlags() & Z_THEME_ADDON_DO_APPLY) { BList teamList; app_info ainfo; int32 count, i; diff --git a/3rdparty/mmu_man/themes/addons/WinampSkinAddon.cpp b/3rdparty/mmu_man/themes/addons/WinampSkinAddon.cpp index 8ffa8cf53c..3b00446128 100644 --- a/3rdparty/mmu_man/themes/addons/WinampSkinAddon.cpp +++ b/3rdparty/mmu_man/themes/addons/WinampSkinAddon.cpp @@ -99,7 +99,9 @@ status_t WinampSkinThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) BString name; 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); if (err) return err;