diff --git a/3rdparty/mmu_man/themes/Jamfile b/3rdparty/mmu_man/themes/Jamfile index 668241dc4b..4e89c5ad78 100644 --- a/3rdparty/mmu_man/themes/Jamfile +++ b/3rdparty/mmu_man/themes/Jamfile @@ -26,6 +26,7 @@ addonSources = ; Application <3rdparty>Themes : + BeThemeImporter.cpp CompareMessages.cpp DumpMessage.cpp MakeScreenshot.cpp @@ -33,6 +34,7 @@ Application <3rdparty>Themes : TextInputAlert.cpp ThemeAddonItem.cpp ThemesApp.cpp + ThemeImporter.cpp ThemeInterfaceView.cpp ThemeItem.cpp ThemeManager.cpp diff --git a/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp b/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp index 569ee61c77..c1d5f19736 100644 --- a/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp +++ b/3rdparty/mmu_man/themes/ThemeInterfaceView.cpp @@ -494,6 +494,7 @@ void ThemeInterfaceView::_ThemeListPopulator() { status_t err; int32 i, count; + int32 importer; BString name; ThemeItem *ti; bool isro; @@ -502,9 +503,12 @@ void ThemeInterfaceView::_ThemeListPopulator() tman->LoadThemes(); count = tman->CountThemes(); + LockLooper(); fThemeList->MakeEmpty(); UnlockLooper(); + + // native themes for (i = 0; i < count; i++) { err = tman->ThemeName(i, name); isro = tman->ThemeIsReadOnly(i); @@ -516,6 +520,36 @@ void ThemeInterfaceView::_ThemeListPopulator() UnlockLooper(); } + // for each importer + for (importer = 0; importer < tman->CountThemeImporters(); importer++) { + err = tman->ImportThemesFor(importer); + if (err < 0) + continue; + PRINT(("Imports for %s: %d\n", tman->ThemeImporterAt(importer), (tman->CountThemes() - count))); + if (tman->CountThemes() == count) + continue; // nothing found + // separator item + name = "Imported ("; + name << tman->ThemeImporterAt(importer) << ")"; + BStringItem *si = new BStringItem(name.String()); + si->SetEnabled(false); + LockLooper(); + fThemeList->AddItem(si); + UnlockLooper(); + // add new themes + count = tman->CountThemes(); + for (; i < count; i++) { + err = tman->ThemeName(i, name); + isro = true;//tman->ThemeIsReadOnly(i); + if (err) + continue; + ti = new ThemeItem(i, name.String(), isro); + LockLooper(); + fThemeList->AddItem(ti); + UnlockLooper(); + } + } + // enable controls again BControl *c; LockLooper(); for (i = 0; ChildAt(i); i++) { diff --git a/3rdparty/mmu_man/themes/ThemeManager.cpp b/3rdparty/mmu_man/themes/ThemeManager.cpp index 8e908bf4eb..fbf192798f 100644 --- a/3rdparty/mmu_man/themes/ThemeManager.cpp +++ b/3rdparty/mmu_man/themes/ThemeManager.cpp @@ -21,9 +21,11 @@ #include #include +#include "UITheme.h" #include "ThemeManager.h" #include "ThemesAddon.h" -#include "UITheme.h" +#include "ThemeImporter.h" +#include "BeThemeImporter.h" #include "ParseMessage.h" #include "DumpMessage.h" @@ -54,6 +56,8 @@ ThemeManager::ThemeManager() AddNames(fNames); LoadSettings(); + // XXX: add more + fThemeImporters.AddItem(new BeThemeImporter()); // XXX test /* @@ -952,6 +956,48 @@ status_t ThemeManager::LoadTheme(const char *path, BMessage **to) return err; } +int32 ThemeManager::CountThemeImporters() +{ + FENTRY; + return fThemeImporters.CountItems(); +} + +const char * ThemeManager::ThemeImporterAt(int32 index) +{ + FENTRY; + ThemeImporter *importer; + importer = static_cast(fThemeImporters.ItemAt(index)); + if (!importer) + return NULL; + return importer->Name(); +} + +status_t ThemeManager::ImportThemesFor(int32 index, const char *path) +{ + FENTRY; + status_t err; + int32 count; + BString m; + int32 i; + ThemeImporter *importer; + BMessage msg; + BMessage *theme; + + importer = static_cast(fThemeImporters.ItemAt(index)); + if (!importer) + return ENOENT; + + err = importer->FetchThemes(); + if (err < 0) + return err; + while ((importer->ImportNextTheme(&theme)) >= 0) { + AddTheme(theme); + } + importer->EndImports(); + + return B_OK; +} + bool ThemeManager::ThemeHasInfoFor(int32 id, BString &module) { FENTRY; @@ -1025,10 +1071,18 @@ bool ThemeManager::ThemeIsReadOnly(int32 id) FENTRY; status_t err; BString s; + BMessage *theme; if (id < 0) return true; + theme = (BMessage *)fThemeList.ItemAt(id); + if (!theme) + return true; + // imported themes are always RO for now + if (theme->FindString(Z_THEME_IMPORTER, &s) >= B_OK) + return true; + err = ThemeLocation(id, s); if (err) return true; diff --git a/3rdparty/mmu_man/themes/ThemeManager.h b/3rdparty/mmu_man/themes/ThemeManager.h index 4a5f769116..36bc656398 100644 --- a/3rdparty/mmu_man/themes/ThemeManager.h +++ b/3rdparty/mmu_man/themes/ThemeManager.h @@ -91,6 +91,11 @@ status_t PackageTheme(BMessage &theme); /* load from disk (zip / folder) */ status_t LoadTheme(const char *path, BMessage **to=NULL); + /* Theme importation */ +int32 CountThemeImporters(); +const char *ThemeImporterAt(int32 index); +status_t ImportThemesFor(int32 index, const char *path=NULL); + /* Theme properties */ bool ThemeHasInfoFor(int32 id, BString &module); @@ -123,6 +128,7 @@ private: int32 fAddonCount; BList fThemeList; BMessage fNames; /* pretty names for fields */ + BList fThemeImporters; }; } // ns ThemeManager diff --git a/3rdparty/mmu_man/themes/ThemesAddon.h b/3rdparty/mmu_man/themes/ThemesAddon.h index 24c0c6373a..b477e5cb2b 100644 --- a/3rdparty/mmu_man/themes/ThemesAddon.h +++ b/3rdparty/mmu_man/themes/ThemesAddon.h @@ -1,3 +1,5 @@ +#ifndef _THEMES_ADDON_H +#define _THEMES_ADDON_H /* * ThemesAddon class header */ @@ -95,3 +97,4 @@ extern "C" Z::ThemeManager::ThemesAddon *instantiate_themes_addon_window_decor() using namespace Z::ThemeManager; +#endif /* _THEMES_ADDON_H */ diff --git a/3rdparty/mmu_man/themes/UITheme.h b/3rdparty/mmu_man/themes/UITheme.h index 21c5f48e67..ee1dc9a7bb 100644 --- a/3rdparty/mmu_man/themes/UITheme.h +++ b/3rdparty/mmu_man/themes/UITheme.h @@ -13,6 +13,8 @@ #define Z_THEME_LOCATION "z:theme:location" // identifies a module this theme has info for. #define Z_THEME_MODULE_TAG "z:theme:moduletag" + // if the theme is imported, where from +#define Z_THEME_IMPORTER "z:theme:importer" // the names of the global BMessages #define Z_THEME_INFO_MESSAGE "z:theme:infos"