Added BeTheme importer. Oops, missing a file :)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23802 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Vendored
+2
@@ -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
|
||||
|
||||
+34
@@ -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++) {
|
||||
|
||||
+55
-1
@@ -21,9 +21,11 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#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<ThemeImporter *>(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<ThemeImporter *>(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;
|
||||
|
||||
+6
@@ -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
|
||||
|
||||
+3
@@ -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 */
|
||||
|
||||
Vendored
+2
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user