From 4f38af21d106fe759a31c2fe360ce9170119ad66 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 21 Nov 2023 15:22:44 +0300 Subject: Clist_Modern: fix for a translation issue in Options - Skins --- plugins/Clist_modern/src/modern_clc.cpp | 8 ++-- plugins/Clist_modern/src/modern_clc.h | 2 - plugins/Clist_modern/src/modern_clcopts.cpp | 50 ++++++++++++------------- plugins/Clist_modern/src/modern_clistevents.cpp | 2 +- plugins/Clist_modern/src/modern_toolbar.cpp | 2 +- plugins/Clist_modern/src/modern_viewmodebar.cpp | 2 +- plugins/Clist_modern/src/stdafx.h | 10 ----- 7 files changed, 31 insertions(+), 45 deletions(-) (limited to 'plugins/Clist_modern/src') diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index 4d92425f45..69ecf3ad18 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -1615,10 +1615,10 @@ static int clcHookModulesLoaded(WPARAM, LPARAM) for (auto &hContact : Contacts()) SetRateExtraIcon(hContact, -1, FALSE); - CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)(LPGEN("List background")"/CLC"), 0); - CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)(LPGEN("Menu background")"/Menu"), 0); - CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)(LPGEN("Status bar background")"/StatusBar"), 0); - CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)(LPGEN("Frames title bar background")"/FrameTitleBar"), 0); + BackgroundConfig_Register(LPGEN("List background")"/CLC"); + BackgroundConfig_Register(LPGEN("Menu background")"/Menu"); + BackgroundConfig_Register(LPGEN("Status bar background")"/StatusBar"); + BackgroundConfig_Register(LPGEN("Frames title bar background")"/FrameTitleBar"); HookEvent(ME_BACKGROUNDCONFIG_CHANGED, clcHookBkgndConfigChanged); HookEvent(ME_BACKGROUNDCONFIG_CHANGED, BgStatusBarChange); diff --git a/plugins/Clist_modern/src/modern_clc.h b/plugins/Clist_modern/src/modern_clc.h index c0956ee8cd..4d06174025 100644 --- a/plugins/Clist_modern/src/modern_clc.h +++ b/plugins/Clist_modern/src/modern_clc.h @@ -57,8 +57,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define INTM_AVATARCHANGED (WM_USER+28) #define INTM_TIMEZONECHANGED (WM_USER+29) -#define CLBF_TILEVTOROWHEIGHT 0x0100 - #define TIMERID_SUBEXPAND 21 #define TIMERID_INVALIDATE 22 #define TIMERID_RECALCSCROLLBAR 26 diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp index 33f7ef7972..f10ff33484 100644 --- a/plugins/Clist_modern/src/modern_clcopts.cpp +++ b/plugins/Clist_modern/src/modern_clcopts.cpp @@ -1168,8 +1168,14 @@ static INT_PTR CALLBACK DlgProcClistWindowOpts(HWND hwndDlg, UINT msg, WPARAM wP #define DEFAULT_BKBMPUSE CLB_STRETCH #define DEFAULT_SELBKCOLOUR GetSysColor(COLOR_HIGHLIGHT) -char **bkgrList = nullptr; -int bkgrCount = 0; +struct BkgrInternal +{ + ptrW wszDescr; + ptrA szModule; + HPLUGIN hPlugin; +}; + +static OBJLIST g_arBkrg(1); #define M_BKGR_UPDATE (WM_USER+10) #define M_BKGR_SETSTATE (WM_USER+11) @@ -1195,6 +1201,7 @@ struct BkgrItem uint16_t flags; uint8_t useWinColours; }; + struct BkgrData { struct BkgrItem *item; @@ -1214,11 +1221,11 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, dat = (struct BkgrData*)mir_alloc(sizeof(struct BkgrData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - dat->count = bkgrCount; + dat->count = g_arBkrg.getCount(); dat->item = (struct BkgrItem*)mir_alloc(sizeof(struct BkgrItem)*dat->count); dat->indx = CB_ERR; for (indx = 0; indx < dat->count; indx++) { - char *module = bkgrList[indx] + mir_strlen(bkgrList[indx]) + 1; + char *module = g_arBkrg[indx].szModule; int jndx; dat->item[indx].changed = FALSE; @@ -1237,7 +1244,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, else *dat->item[indx].filename = 0; dat->item[indx].flags = db_get_w(0, module, "BkBmpUse", DEFAULT_BKBMPUSE); - jndx = SendMessageA(hList, CB_ADDSTRING, 0, (LPARAM)Translate(bkgrList[indx])); + jndx = SendMessageW(hList, CB_ADDSTRING, 0, (LPARAM)TranslateW_LP(g_arBkrg[indx].wszDescr, g_arBkrg[indx].hPlugin)); SendMessage(hList, CB_SETITEMDATA, jndx, indx); } SendMessage(hList, CB_SETCURSEL, 0, 0); @@ -1383,7 +1390,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, if (!p.changed) continue; - char *module = bkgrList[indx] + mir_strlen(bkgrList[indx]) + 1; + char *module = g_arBkrg[indx].szModule; db_set_b(0, module, "UseBitmap", (uint8_t)p.useBitmap); COLORREF col; @@ -1420,38 +1427,29 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, static INT_PTR BkgrCfg_Register(WPARAM wParam, LPARAM lParam) { - char *szSetting = (char*)wParam; - size_t len = mir_strlen(szSetting) + 1; - - char *value = (char *)mir_alloc(len + 4); // add room for flags (uint32_t) - memcpy(value, szSetting, len); - char *tok = strchr(value, '/'); - if (tok == nullptr) { - mir_free(value); + char *szSetting = NEWSTR_ALLOCA((char *)wParam); + char *tok = strchr(szSetting, '/'); + if (tok == nullptr) return 1; - } - *tok = 0; - *(uint32_t*)(value + len) = lParam; - bkgrList = (char **)mir_realloc(bkgrList, sizeof(char*)*(bkgrCount + 1)); - bkgrList[bkgrCount] = value; - bkgrCount++; + *tok = 0; + auto *pNew = new BkgrInternal(); + pNew->wszDescr = mir_a2u(szSetting); + pNew->szModule = mir_strdup(tok + 1); + pNew->hPlugin = (HPLUGIN)lParam; + g_arBkrg.insert(pNew); return 0; } HRESULT BackgroundsLoadModule() { - CreateServiceFunction(MS_BACKGROUNDCONFIG_REGISTER, BkgrCfg_Register); + CreateServiceFunction("ModernBkgrCfg/Register", BkgrCfg_Register); return S_OK; } int BackgroundsUnloadModule(void) { - if (bkgrList != nullptr) { - for (int indx = 0; indx < bkgrCount; indx++) - mir_free(bkgrList[indx]); - mir_free(bkgrList); - } + g_arBkrg.destroy(); DestroyHookableEvent(g_CluiData.hEventBkgrChanged); g_CluiData.hEventBkgrChanged = nullptr; return 0; diff --git a/plugins/Clist_modern/src/modern_clistevents.cpp b/plugins/Clist_modern/src/modern_clistevents.cpp index a578a69a29..403fc548de 100644 --- a/plugins/Clist_modern/src/modern_clistevents.cpp +++ b/plugins/Clist_modern/src/modern_clistevents.cpp @@ -455,7 +455,7 @@ static LRESULT CALLBACK EventArea_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LP int EventArea_Create(HWND hCluiWnd) { - CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)(LPGEN("Event area background")"/EventArea"), 0); + BackgroundConfig_Register(LPGEN("Event area background")"/EventArea"); HookEvent(ME_BACKGROUNDCONFIG_CHANGED, ehhEventAreaBackgroundSettingsChanged); ehhEventAreaBackgroundSettingsChanged(0, 0); diff --git a/plugins/Clist_modern/src/modern_toolbar.cpp b/plugins/Clist_modern/src/modern_toolbar.cpp index fc5ab73936..774e10335a 100644 --- a/plugins/Clist_modern/src/modern_toolbar.cpp +++ b/plugins/Clist_modern/src/modern_toolbar.cpp @@ -321,7 +321,7 @@ static int Toolbar_ModuleReloaded(WPARAM wParam, LPARAM) static int Toolbar_ModulesLoaded(WPARAM, LPARAM) { - CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)(LPGEN("Toolbar background")"/ToolBar"), 0); + BackgroundConfig_Register(LPGEN("Toolbar background")"/ToolBar"); HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ehhToolBarSettingsChanged); diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp index a6239a2a5a..e267f41c2d 100644 --- a/plugins/Clist_modern/src/modern_viewmodebar.cpp +++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp @@ -1190,7 +1190,7 @@ static int ViewModePaintCallbackProc(HWND hWnd, HDC hDC, RECT *, HRGN, uint32_t, void CreateViewModeFrame() { - CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)(LPGEN("View mode background")"/ViewMode"), 0); + BackgroundConfig_Register(LPGEN("View mode background")"/ViewMode"); HookEvent(ME_BACKGROUNDCONFIG_CHANGED, ehhViewModeBackgroundSettingsChanged); ehhViewModeBackgroundSettingsChanged(0, 0); diff --git a/plugins/Clist_modern/src/stdafx.h b/plugins/Clist_modern/src/stdafx.h index e00671a124..cc2ce1371c 100644 --- a/plugins/Clist_modern/src/stdafx.h +++ b/plugins/Clist_modern/src/stdafx.h @@ -161,16 +161,6 @@ extern wchar_t SkinsFolder[MAX_PATH]; char* __cdecl strstri(char *a, const char *b); -// Register of plugin's user -// -// wParam = (WPARAM)szSetting - string that describes a user -// format: Category/ModuleName, -// eg: "Contact list background/CLUI", -// "Status bar background/StatusBar" -// lParam = (LPARAM)dwFlags -// -#define MS_BACKGROUNDCONFIG_REGISTER "ModernBkgrCfg/Register" - // // Notification about changed background // wParam = ModuleName -- cgit v1.2.3