summaryrefslogtreecommitdiff
path: root/plugins/Clist_nicer
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-07-20 14:24:37 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-07-20 14:24:37 +0300
commitb811e80675707d996c7b8d8e9179d5c318648443 (patch)
treec5408fc8296c095a315ce15c4559aba3cf07b4fa /plugins/Clist_nicer
parentf34a7a0e3a3ea516827909c36d2758fc85d37b73 (diff)
Clist_Nicer part of #3591
Diffstat (limited to 'plugins/Clist_nicer')
-rw-r--r--plugins/Clist_nicer/src/clc.h2
-rw-r--r--plugins/Clist_nicer/src/clcutils.cpp62
-rw-r--r--plugins/Clist_nicer/src/extBackg.cpp32
3 files changed, 13 insertions, 83 deletions
diff --git a/plugins/Clist_nicer/src/clc.h b/plugins/Clist_nicer/src/clc.h
index e6ab80b103..8e138f374b 100644
--- a/plugins/Clist_nicer/src/clc.h
+++ b/plugins/Clist_nicer/src/clc.h
@@ -378,8 +378,6 @@ void BeginRenameSelection(HWND hwnd, struct ClcData *dat);
int HitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, ClcContact **contact, ClcGroup **group, uint32_t *flags);
void ScrollTo(HWND hwnd, struct ClcData *dat, int desty, int noSmooth);
void RecalcScrollBar(HWND hwnd, struct ClcData *dat);
-size_t MY_pathToRelative(const wchar_t *pSrc, wchar_t *pOut);
-size_t MY_pathToAbsolute(const wchar_t *pSrc, wchar_t *pOut);
int GetDropTargetInformation(HWND hwnd, struct ClcData *dat, POINT pt);
void LoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst);
diff --git a/plugins/Clist_nicer/src/clcutils.cpp b/plugins/Clist_nicer/src/clcutils.cpp
index 5be75febe9..1ea0c9f1e2 100644
--- a/plugins/Clist_nicer/src/clcutils.cpp
+++ b/plugins/Clist_nicer/src/clcutils.cpp
@@ -35,68 +35,6 @@ extern int /*g_isConnecting,*/ during_sizing;
extern void ( *saveRecalcScrollBar )(HWND hwnd, struct ClcData *dat);
-static int MY_pathIsAbsolute(const wchar_t *path)
-{
- if (!path || !(mir_wstrlen(path) > 2))
- return 0;
-
- if ((path[1] == ':' && path[2] == '\\') || (path[0] == '\\' && path[1] == '\\'))
- return 1;
-
- return 0;
-}
-
-size_t MY_pathToRelative(const wchar_t *pSrc, wchar_t *pOut)
-{
- size_t dwSrcLen, dwProfilePathLen;
-
- if (!pSrc || !pOut)
- return 0;
- dwSrcLen = mir_wstrlen(pSrc);
- if (!dwSrcLen || dwSrcLen > (MAX_PATH - 1))
- return 0;
- if (!MY_pathIsAbsolute(pSrc))
- goto path_not_abs;
-
- wchar_t szTmp[MAX_PATH];
- memcpy(szTmp, pSrc, (dwSrcLen * sizeof(wchar_t)));
- szTmp[dwSrcLen] = 0;
- wcslwr(szTmp);
- if (wcsstr(szTmp, cfg::dat.tszProfilePath)) {
- dwProfilePathLen = mir_wstrlen(cfg::dat.tszProfilePath);
- memcpy(pOut, (pSrc + (dwProfilePathLen - 1)), ((dwSrcLen - (dwProfilePathLen - 1)) * sizeof(wchar_t)));
- pOut[0] = '.';
- pOut[dwSrcLen] = 0;
- return (dwSrcLen - (dwProfilePathLen - 1));
- }
-
-path_not_abs:
- memcpy(pOut, pSrc, (dwSrcLen * sizeof(wchar_t)));
- pOut[dwSrcLen] = 0;
- return dwSrcLen;
-}
-
-size_t MY_pathToAbsolute(const wchar_t *pSrc, wchar_t *pOut)
-{
- size_t dwSrcLen;
-
- if (!pSrc || !pOut)
- return 0;
- dwSrcLen = mir_wstrlen(pSrc);
- if (!dwSrcLen || dwSrcLen > (MAX_PATH - 1))
- return 0;
-
- if (MY_pathIsAbsolute(pSrc) && pSrc[0] != '.') {
- memcpy(pOut, pSrc, (dwSrcLen * sizeof(wchar_t)));
- pOut[dwSrcLen] = 0;
- return dwSrcLen;
- }
- if (pSrc[0] == '.')
- return (mir_snwprintf(pOut, MAX_PATH, L"%s\\%s", cfg::dat.tszProfilePath, pSrc));
-
- return 0;
-}
-
/*
* performs hit-testing for reversed (mirrored) contact rows when using RTL
* shares all the init stuff with HitTest()
diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp
index 08e02c72d2..c087148136 100644
--- a/plugins/Clist_nicer/src/extBackg.cpp
+++ b/plugins/Clist_nicer/src/extBackg.cpp
@@ -1219,7 +1219,7 @@ void IMG_LoadItems()
return;
wchar_t tszFileName[MAX_PATH];
- MY_pathToAbsolute(dbv.pwszVal, tszFileName);
+ PathToAbsoluteW(dbv.pwszVal, tszFileName);
// TODO: rewrite the skin loading in wchar_t manner
char szFileName[MAX_PATH];
@@ -1489,11 +1489,11 @@ void extbk_import(char *file, HWND hwndDlg)
static void ApplyCLUISkin()
{
DBVARIANT dbv = { 0 };
- wchar_t tszFinalName[MAX_PATH];
- char szFinalName[MAX_PATH];
if (!db_get_ws(0, "CLC", "AdvancedSkin", &dbv)) {
- MY_pathToAbsolute(dbv.pwszVal, tszFinalName);
+ wchar_t tszFinalName[MAX_PATH];
+ PathToAbsoluteW(dbv.pwszVal, tszFinalName);
+ char szFinalName[MAX_PATH];
WideCharToMultiByte(CP_ACP, 0, tszFinalName, MAX_PATH, szFinalName, MAX_PATH, nullptr, nullptr);
if (db_get_b(0, "CLUI", "skin_changed", 0)) {
@@ -1565,13 +1565,14 @@ static INT_PTR CALLBACK DlgProcSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
db_delete_module(0, "CLC");
db_delete_module(0, "CLCExt");
IMG_DeleteItems();
+
LoadExtBkSettingsFromDB();
+ IMG_LoadItems();
ReloadThemedOptions();
ReloadSkinItemsToCache();
db_set_b(0, "CLUI", "useskin", 0);
- IMG_LoadItems();
ConfigureFrame();
SetButtonStates();
@@ -1600,20 +1601,13 @@ static INT_PTR CALLBACK DlgProcSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
ofn.lpstrDefExt = L"";
if (!GetOpenFileName(&ofn))
break;
- MY_pathToRelative(str, final_path);
- if (PathFileExists(str)) {
- int skinChanged = 0;
- DBVARIANT dbv = { 0 };
-
- if (!db_get_ws(0, "CLC", "AdvancedSkin", &dbv)) {
- if (mir_wstrcmp(dbv.pwszVal, final_path))
- skinChanged = TRUE;
- db_free(&dbv);
- }
- else
- skinChanged = TRUE;
+
+ PathToRelativeW(str, final_path);
+ if (PathFileExistsW(str)) {
+ auto wszOld = db_get_wsm(0, "CLC", "AdvancedSkin");
+
db_set_ws(0, "CLC", "AdvancedSkin", final_path);
- db_set_b(0, "CLUI", "skin_changed", (uint8_t)skinChanged);
+ db_set_b(0, "CLUI", "skin_changed", wszOld != final_path);
SetDlgItemText(hwndDlg, IDC_SKINFILENAME, final_path);
}
}
@@ -1628,7 +1622,7 @@ static INT_PTR CALLBACK DlgProcSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
wchar_t tszFilename[MAX_PATH], tszFinalPath[MAX_PATH];
GetDlgItemText(hwndDlg, IDC_SKINFILE, tszFilename, _countof(tszFilename));
tszFilename[MAX_PATH - 1] = 0;
- MY_pathToAbsolute(tszFilename, tszFinalPath);
+ PathToAbsoluteW(tszFilename, tszFinalPath);
if (PathFileExists(tszFinalPath)) {
LoadPerContactSkins(tszFinalPath);
ReloadSkinItemsToCache();