Author: gadamopoulos
Date: Tue May 9 08:13:49 2017
New Revision: 74511
URL:
http://svn.reactos.org/svn/reactos?rev=74511&view=rev
Log:
[DESK.CPL] -Addendum to 74506 which was a bit rushed. Make it possible to apply a theme
that was opened by double click. Also add the active theme in the list of themes if it was
not enumerated in the themes directory.
Modified:
trunk/reactos/dll/cpl/desk/appearance.c
trunk/reactos/dll/cpl/desk/appearance.h
trunk/reactos/dll/cpl/desk/theme.c
Modified: trunk/reactos/dll/cpl/desk/appearance.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/appearance.c?…
==============================================================================
--- trunk/reactos/dll/cpl/desk/appearance.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/desk/appearance.c [iso-8859-1] Tue May 9 08:13:49 2017
@@ -117,40 +117,27 @@
g->pThemes = LoadThemes();
if (g->pThemes)
{
- PTHEME pLoadedTheme = NULL;
-
+ BOOL bLoadedTheme = FALSE;
+
if (g_GlobalData.pwszAction &&
g_GlobalData.pwszFile &&
wcscmp(g_GlobalData.pwszAction, L"OpenMSTheme") == 0)
{
- /* Check if the theme specified was already loaded */
- for (pTheme = g->pThemes; pTheme; pTheme = pTheme->NextTheme)
- {
- if (pTheme->ThemeFileName && wcsicmp(pTheme->ThemeFileName,
g_GlobalData.pwszFile) == 0)
- {
- pLoadedTheme = pTheme;
- break;
- }
-
- if (!pTheme->NextTheme)
- break;
- }
-
- if (!pLoadedTheme)
- {
- /* Load it now and insert it in the list */
- pLoadedTheme = LoadTheme(g_GlobalData.pwszFile, g_GlobalData.pwszFile);
- if (pLoadedTheme)
- pTheme->NextTheme = pLoadedTheme;
- }
- }
-
- if (pLoadedTheme)
- {
- g->ActiveTheme.ThemeActive = TRUE;
- g->ActiveTheme.Theme = pLoadedTheme;
- g->ActiveTheme.Color = pLoadedTheme->ColoursList;
- g->ActiveTheme.Size = pLoadedTheme->SizesList;
+ bLoadedTheme = FindOrAppendTheme(g->pThemes,
+ g_GlobalData.pwszFile,
+ NULL,
+ NULL,
+ &g->ActiveTheme);
+ }
+
+ if (bLoadedTheme)
+ {
+ g->bThemeChanged = TRUE;
+ g->bSchemeChanged = TRUE;
+
+ PostMessageW(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
+
+ AppearancePage_LoadSelectedScheme(hwndDlg, g);
}
else
{
Modified: trunk/reactos/dll/cpl/desk/appearance.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/appearance.h?…
==============================================================================
--- trunk/reactos/dll/cpl/desk/appearance.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/desk/appearance.h [iso-8859-1] Tue May 9 08:13:49 2017
@@ -137,6 +137,7 @@
PLOGFONTW SchemeGetFont(COLOR_SCHEME *scheme, int id);
PTHEME LoadTheme(IN LPCWSTR pszThemeFileName,IN LPCWSTR pszThemeName);
PTHEME LoadThemes(VOID);
+BOOL FindOrAppendTheme(IN PTHEME pThemeList, IN LPCWSTR pwszThemeFileName, IN LPCWSTR
pwszColorBuff, IN LPCWSTR pwszSizeBuff, OUT PTHEME_SELECTION pSelectedTheme);
BOOL GetActiveTheme(PTHEME pThemeList, PTHEME_SELECTION pSelectedTheme);
BOOL GetActiveClassicTheme(PTHEME pThemeList, PTHEME_SELECTION pSelectedTheme);
BOOL LoadCurrentScheme(PCOLOR_SCHEME scheme);
Modified: trunk/reactos/dll/cpl/desk/theme.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/theme.c?rev=7…
==============================================================================
--- trunk/reactos/dll/cpl/desk/theme.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/desk/theme.c [iso-8859-1] Tue May 9 08:13:49 2017
@@ -784,8 +784,61 @@
}
/*
+ * FindSelectedTheme: Finds the specified theme in the list of themes
+ * or loads it if it was not loaded already.
+ */
+BOOL
+FindOrAppendTheme(IN PTHEME pThemeList,
+ IN LPCWSTR pwszThemeFileName,
+ IN LPCWSTR pwszColorBuff,
+ IN LPCWSTR pwszSizeBuff,
+ OUT PTHEME_SELECTION pSelectedTheme)
+{
+ PTHEME pTheme;
+ PTHEME pFoundTheme = NULL;
+
+ ZeroMemory(pSelectedTheme, sizeof(THEME_SELECTION));
+
+ for (pTheme = pThemeList; pTheme; pTheme = pTheme->NextTheme)
+ {
+ if (pTheme->ThemeFileName &&
+ _wcsicmp(pTheme->ThemeFileName, pwszThemeFileName) == 0)
+ {
+ pFoundTheme = pTheme;
+ break;
+ }
+
+ if (pTheme->NextTheme == NULL)
+ break;
+ }
+
+ if (!pFoundTheme)
+ {
+ pFoundTheme = LoadTheme(pwszThemeFileName, pwszThemeFileName);
+ if (!pFoundTheme)
+ return FALSE;
+
+ pTheme->NextTheme = pFoundTheme;
+ }
+
+ pSelectedTheme->ThemeActive = TRUE;
+ pSelectedTheme->Theme = pFoundTheme;
+ if (pwszColorBuff)
+ pSelectedTheme->Color = FindStyle(pFoundTheme->ColoursList,
pwszColorBuff);
+ else
+ pSelectedTheme->Color = pFoundTheme->ColoursList;
+
+ if (pwszSizeBuff)
+ pSelectedTheme->Size = FindStyle(pFoundTheme->SizesList, pwszSizeBuff);
+ else
+ pSelectedTheme->Size = pFoundTheme->SizesList;
+
+ return TRUE;
+}
+
+/*
* GetActiveTheme: Gets the active theme and populates pSelectedTheme
- * with entries from the list of loaded themes
+ * with entries from the list of loaded themes.
*/
BOOL
GetActiveTheme(IN PTHEME pThemeList, OUT PTHEME_SELECTION pSelectedTheme)
@@ -793,10 +846,7 @@
WCHAR szThemeFileName[MAX_PATH];
WCHAR szColorBuff[MAX_PATH];
WCHAR szSizeBuff[MAX_PATH];
- PTHEME pTheme;
HRESULT hret;
-
- ZeroMemory(pSelectedTheme, sizeof(THEME_SELECTION));
/* Retrieve the name of the current theme */
hret = GetCurrentThemeName(szThemeFileName,
@@ -805,25 +855,10 @@
MAX_PATH,
szSizeBuff,
MAX_PATH);
- if (FAILED(hret)) return FALSE;
-
- for (pTheme = pThemeList; pTheme; pTheme = pTheme->NextTheme)
- {
- if (pTheme->ThemeFileName &&
- _wcsicmp(pTheme->ThemeFileName, szThemeFileName) == 0)
- {
- break;
- }
- }
-
- if (pTheme == NULL) return FALSE;
-
- pSelectedTheme->ThemeActive = TRUE;
- pSelectedTheme->Theme = pTheme;
- pSelectedTheme->Color = FindStyle(pTheme->ColoursList, szColorBuff);
- pSelectedTheme->Size = FindStyle(pTheme->SizesList, szSizeBuff);
-
- return TRUE;
+ if (FAILED(hret))
+ return FALSE;
+
+ return FindOrAppendTheme(pThemeList, szThemeFileName, szColorBuff, szSizeBuff,
pSelectedTheme);
}
/*