From 9f015335c0c516fe16e804b1ce35f25e9ba32165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sun, 6 Jun 2010 20:40:52 +0000 Subject: [PATCH] Unfinished Themes addon to set Pulse color. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37042 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- 3rdparty/mmu_man/themes/addons/PulseAddon.cpp | 152 ++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 3rdparty/mmu_man/themes/addons/PulseAddon.cpp diff --git a/3rdparty/mmu_man/themes/addons/PulseAddon.cpp b/3rdparty/mmu_man/themes/addons/PulseAddon.cpp new file mode 100644 index 0000000000..c4af5f1191 --- /dev/null +++ b/3rdparty/mmu_man/themes/addons/PulseAddon.cpp @@ -0,0 +1,152 @@ +/* + * Pulse colors ThemesAddon class + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "ThemesAddon.h" +#include "UITheme.h" + +#ifdef SINGLE_BINARY +#define instantiate_themes_addon instantiate_themes_addon_pulse +#endif + +#define A_NAME "Pulse" +#define A_MSGNAME Z_THEME_PULSE_SETTINGS +#define A_DESCRIPTION "Pulse colors" + +class PulseThemesAddon : public ThemesAddon { +public: + PulseThemesAddon(); + ~PulseThemesAddon(); + +const char *Description(); + +status_t RunPreferencesPanel(); + +status_t AddNames(BMessage &names); + +status_t ApplyTheme(BMessage &theme, uint32 flags=0L); +status_t MakeTheme(BMessage &theme, uint32 flags=0L); + +status_t ApplyDefaultTheme(uint32 flags=0L); +}; + +PulseThemesAddon::PulseThemesAddon() + : ThemesAddon(A_NAME, A_MSGNAME) +{ +} + +PulseThemesAddon::~PulseThemesAddon() +{ +} + +const char *PulseThemesAddon::Description() +{ + return A_DESCRIPTION; +} + +status_t PulseThemesAddon::RunPreferencesPanel() +{ + status_t err; + entry_ref ref; + BEntry ent; + err = ent.SetTo("/boot/beos/preferences/Pulse"); + if (!err) { + err = ent.GetRef(&ref); + if (!err) { + err = be_roster->Launch(&ref); + } + } + if (!err) + return B_OK; + err = ent.SetTo("/system/add-ons/Preferences/Pulse"); + 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; +} + +status_t PulseThemesAddon::AddNames(BMessage &names) +{ + names.AddString(Z_THEME_PULSE_SETTINGS, "Pulse colors"); + //names.AddString("db:location", "Pulse on-screen position"); + //names.AddString("db:expanded", "Pulse is expanded"); + return B_OK; +} + +status_t PulseThemesAddon::ApplyTheme(BMessage &theme, uint32 flags) +{ + BMessage deskbar; + status_t err; + int32 loc = 5; + bool expanded = true; + BPulse db; + + 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; + + if (deskbar.FindInt32("db:location", &loc) != B_OK) + return ENOENT; + deskbar.FindBool("db:expanded", &expanded); + return db.SetLocation((deskbar_location)loc, expanded); +} + +status_t PulseThemesAddon::MakeTheme(BMessage &theme, uint32 flags) +{ + BMessage deskbar; + status_t err; + + (void)flags; + err = MyMessage(theme, deskbar); + if (err) + deskbar.MakeEmpty(); + + deskbar_location loc; + bool expanded; + BPulse db; + + loc = db.Location(&expanded); + deskbar.AddInt32("db:location", (int32)loc); + deskbar.AddBool("db:expanded", expanded); + + err = SetMyMessage(theme, deskbar); + return err; +} + +status_t PulseThemesAddon::ApplyDefaultTheme(uint32 flags) +{ + BMessage theme; + BMessage deskbar; + deskbar_location loc = B_DESKBAR_RIGHT_TOP; + bool expanded = true; + deskbar.AddInt32("db:location", (int32)loc); + deskbar.AddBool("db:expanded", expanded); + theme.AddMessage(A_MSGNAME, &deskbar); + return ApplyTheme(theme, flags); +} + + +ThemesAddon *instantiate_themes_addon() +{ + return (ThemesAddon *) new PulseThemesAddon; +}