diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-02 13:47:14 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-02 13:47:14 +0000 |
commit | c5392f2ac487b9c2bd525bc13a33fcf13f66ee5d (patch) | |
tree | 4a2fcef4e1b9f9468f58c41de7d85db3bfc1bc43 | |
parent | 899c95607b3add967778bb75015fde65060f2e5c (diff) |
fixed extra icons related hell in CountryFlags
git-svn-id: http://svn.miranda-ng.org/main/trunk@7456 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/CountryFlags/src/extraimg.cpp | 50 | ||||
-rw-r--r-- | plugins/CountryFlags/src/flags.h | 3 | ||||
-rw-r--r-- | plugins/CountryFlags/src/main.cpp | 7 | ||||
-rw-r--r-- | plugins/CountryFlags/src/options.cpp | 43 |
4 files changed, 43 insertions, 60 deletions
diff --git a/plugins/CountryFlags/src/extraimg.cpp b/plugins/CountryFlags/src/extraimg.cpp index 9310c8e4c5..b816872a73 100644 --- a/plugins/CountryFlags/src/extraimg.cpp +++ b/plugins/CountryFlags/src/extraimg.cpp @@ -74,7 +74,7 @@ static void EnsureExtraImages(void) SetExtraImage(hContact);
}
-static void CALLBACK UpdateExtraImages(LPARAM lParam)
+void UpdateExtraImages()
{
if (bShowExtraIcon)
EnsureExtraImages();
@@ -82,13 +82,6 @@ static void CALLBACK UpdateExtraImages(LPARAM lParam) RemoveExtraImages();
}
-static int ExtraImageApply(WPARAM wParam,LPARAM lParam)
-{
- if (bShowExtraIcon)
- SetExtraImage((HANDLE)wParam); /* unbuffered */
- return 0;
-}
-
/************************* Status Icon ****************************/
#define STATUSICON_REFRESHDELAY 100 /* time for which setting changes are buffered */
@@ -140,7 +133,7 @@ static int MsgWndEvent(WPARAM wParam,LPARAM lParam) return 0;
}
-static void CALLBACK UpdateStatusIcons(LPARAM lParam)
+void CALLBACK UpdateStatusIcons(LPARAM)
{
MessageWindowInputData msgwi = { sizeof(msgwi) };
msgwi.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
@@ -169,33 +162,17 @@ static int StatusIconsChanged(WPARAM wParam,LPARAM lParam) static int ExtraImgSettingChanged(WPARAM wParam,LPARAM lParam)
{
- DBCONTACTWRITESETTING *dbcws=(DBCONTACTWRITESETTING*)lParam;
- if ((HANDLE)wParam == NULL) {
- if (!lstrcmpA(dbcws->szModule,MODULENAME)) {
+ DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING*)lParam;
+ if (wParam != NULL) {
+ /* user details update */
+ if (!lstrcmpA(dbcws->szSetting,"RealIP") || !lstrcmpA(dbcws->szSetting,"Country") || !lstrcmpA(dbcws->szSetting,"CompanyCountry")) {
/* Extra Image */
- if (!lstrcmpA(dbcws->szSetting,"ShowExtraImgFlag") ||
- !lstrcmpA(dbcws->szSetting,"ExtraImgFlagColumn") ||
- !lstrcmpA(dbcws->szSetting,"UseUnknownFlag") ||
- !lstrcmpA(dbcws->szSetting,"UseIpToCountry"))
- CallFunctionBuffered(UpdateExtraImages,0,FALSE,EXTRAIMAGE_REFRESHDELAY);
+ SetExtraImage((HANDLE)wParam);
/* Status Icon */
- if (!lstrcmpA(dbcws->szSetting,"ShowStatusIconFlag") ||
- !lstrcmpA(dbcws->szSetting,"UseUnknownFlag") ||
- !lstrcmpA(dbcws->szSetting,"UseIpToCountry"))
- if (ServiceExists(MS_MSG_REMOVEICON))
- CallFunctionBuffered(UpdateStatusIcons,0,FALSE,STATUSICON_REFRESHDELAY);
+ if (ServiceExists(MS_MSG_REMOVEICON))
+ CallFunctionBuffered(UpdateStatusIcons,0,FALSE,STATUSICON_REFRESHDELAY);
}
}
- /* user details update */
- else if (!lstrcmpA(dbcws->szSetting,"RealIP") ||
- !lstrcmpA(dbcws->szSetting,"Country") ||
- !lstrcmpA(dbcws->szSetting,"CompanyCountry")) {
- /* Extra Image */
- SetExtraImage((HANDLE)wParam);
- /* Status Icon */
- if (ServiceExists(MS_MSG_REMOVEICON))
- CallFunctionBuffered(UpdateStatusIcons,0,FALSE,STATUSICON_REFRESHDELAY);
- }
return 0;
}
@@ -203,10 +180,6 @@ static int ExtraImgSettingChanged(WPARAM wParam,LPARAM lParam) static int ExtraImgModulesLoaded(WPARAM wParam,LPARAM lParam)
{
- /* Extra Image */
- hExtraIcon = ExtraIcon_Register("flags_extra", LPGEN("Country flag"));
- HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY,ExtraImageApply);
-
/* Status Icon */
StatusIconData sid = { sizeof(sid) };
sid.szModule = MODULENAME; // dwID = 0
@@ -225,4 +198,9 @@ void InitExtraImg(void) HookEvent(ME_SKIN2_ICONSCHANGED, StatusIconsChanged);
HookEvent(ME_OPT_INITIALISE, OnOptionsInit);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ExtraImgSettingChanged);
+
+ /* Extra Image */
+ hExtraIcon = ExtraIcon_Register("flags_extra", LPGEN("Country flag"));
+ if (bShowExtraIcon)
+ EnsureExtraImages();
}
diff --git a/plugins/CountryFlags/src/flags.h b/plugins/CountryFlags/src/flags.h index d8a0a9cc79..b3707233f2 100644 --- a/plugins/CountryFlags/src/flags.h +++ b/plugins/CountryFlags/src/flags.h @@ -63,6 +63,8 @@ void UninitIpToCountry(void); /* extraimg.c */
void InitExtraImg(void);
+void UpdateExtraImages(void);
+void CALLBACK UpdateStatusIcons(LPARAM);
/* utils.c */
typedef void (CALLBACK *BUFFEREDPROC)(LPARAM lParam);
@@ -78,5 +80,4 @@ void KillBufferedFunctions(void); /* options.c */
extern bool bUseUnknown, bShowStatusIcon, bShowExtraIcon, bUseIpToCountry;
-void LoadOptions(void);
int OnOptionsInit(WPARAM wParam,LPARAM lParam);
diff --git a/plugins/CountryFlags/src/main.cpp b/plugins/CountryFlags/src/main.cpp index b68b14bd02..216595c441 100644 --- a/plugins/CountryFlags/src/main.cpp +++ b/plugins/CountryFlags/src/main.cpp @@ -57,10 +57,15 @@ extern "C" __declspec(dllexport) int Load(void) PrepareBufferedFunctions();
if ( CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&nCountriesCount, (LPARAM)&countries))
nCountriesCount = 0;
+
+ bShowStatusIcon = db_get_b(NULL, MODULENAME, "ShowStatusIconFlag", SETTING_SHOWSTATUSICONFLAG_DEFAULT) != 0;
+ bShowExtraIcon = db_get_b(NULL, MODULENAME, "ShowExtraImgFlag", SETTING_SHOWEXTRAIMGFLAG_DEFAULT) != 0;
+ bUseUnknown = db_get_b(NULL, MODULENAME, "UseUnknownFlag", SETTING_USEUNKNOWNFLAG_DEFAULT) != 0;
+ bUseIpToCountry = db_get_b(NULL, MODULENAME, "UseIpToCountry", SETTING_USEIPTOCOUNTRY_DEFAULT) != 0;
+
InitIcons();
InitIpToCountry();
InitExtraImg();
- LoadOptions();
return 0;
}
diff --git a/plugins/CountryFlags/src/options.cpp b/plugins/CountryFlags/src/options.cpp index 628dc04551..273857029a 100644 --- a/plugins/CountryFlags/src/options.cpp +++ b/plugins/CountryFlags/src/options.cpp @@ -21,14 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. bool bUseUnknown, bShowStatusIcon, bShowExtraIcon, bUseIpToCountry;
-void LoadOptions()
-{
- bShowStatusIcon = db_get_b(NULL, MODULENAME, "ShowStatusIconFlag", SETTING_SHOWSTATUSICONFLAG_DEFAULT) != 0;
- bShowExtraIcon = db_get_b(NULL, MODULENAME, "ShowExtraImgFlag", SETTING_SHOWEXTRAIMGFLAG_DEFAULT) != 0;
- bUseUnknown = db_get_b(NULL, MODULENAME, "UseUnknownFlag", SETTING_USEUNKNOWNFLAG_DEFAULT) != 0;
- bUseIpToCountry = db_get_b(NULL, MODULENAME, "UseIpToCountry", SETTING_USEIPTOCOUNTRY_DEFAULT) != 0;
-}
-
#define M_ENABLE_SUBCTLS (WM_APP+1)
static INT_PTR CALLBACK ExtraImgOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
@@ -47,14 +39,14 @@ static INT_PTR CALLBACK ExtraImgOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,L case M_ENABLE_SUBCTLS:
{
- BOOL checked = IsDlgButtonChecked(hwndDlg,IDC_CHECK_SHOWEXTRAIMGFLAG);
- EnableWindow(GetDlgItem(hwndDlg,IDC_TEXT_EXTRAIMGFLAGCOLUMN),checked);
+ BOOL checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHOWEXTRAIMGFLAG);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_TEXT_EXTRAIMGFLAGCOLUMN), checked);
if (!checked)
- checked = IsDlgButtonChecked(hwndDlg,IDC_CHECK_SHOWSTATUSICONFLAG);
- EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_USEUNKNOWNFLAG),checked);
- EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_USEIPTOCOUNTRY),checked);
- return TRUE;
+ checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHOWSTATUSICONFLAG);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_USEUNKNOWNFLAG), checked);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_USEIPTOCOUNTRY), checked);
}
+ return TRUE;
case WM_COMMAND:
PostMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
@@ -64,16 +56,23 @@ static INT_PTR CALLBACK ExtraImgOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,L case WM_NOTIFY:
switch(((NMHDR*)lParam)->code) {
case PSN_APPLY: /* setting change hook will pick these up */
- db_set_b(NULL,MODULENAME,"UseUnknownFlag",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_USEUNKNOWNFLAG) != 0));
- db_set_b(NULL,MODULENAME,"UseIpToCountry",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_USEIPTOCOUNTRY) != 0));
+ bool bChanged = false, bTemp;
+
+ if ((bTemp = IsDlgButtonChecked(hwndDlg, IDC_CHECK_USEUNKNOWNFLAG) != 0) != bUseUnknown)
+ db_set_b(NULL, MODULENAME, "UseUnknownFlag", bUseUnknown = bTemp), bChanged = true;
+ if ((bTemp = IsDlgButtonChecked(hwndDlg, IDC_CHECK_USEIPTOCOUNTRY) != 0) != bUseIpToCountry)
+ db_set_b(NULL, MODULENAME, "UseIpToCountry", bUseIpToCountry = bTemp), bChanged = true;
/* Status Icon */
- if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_CHECK_SHOWSTATUSICONFLAG)))
- db_set_b(NULL,MODULENAME,"ShowStatusIconFlag",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SHOWSTATUSICONFLAG) != 0));
+ if ((bTemp = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHOWSTATUSICONFLAG) != 0) != bShowStatusIcon)
+ db_set_b(NULL, MODULENAME, "ShowStatusIconFlag", bShowStatusIcon = bTemp), bChanged = true;
/* Extra Image */
- if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_CHECK_SHOWEXTRAIMGFLAG)))
- db_set_b(NULL,MODULENAME,"ShowExtraImgFlag",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SHOWEXTRAIMGFLAG) != 0));
+ if ((bTemp = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHOWEXTRAIMGFLAG) != 0) != bShowExtraIcon)
+ db_set_b(NULL, MODULENAME, "ShowExtraImgFlag", bShowExtraIcon = bTemp), bChanged = true;
- LoadOptions();
+ if (bChanged) {
+ UpdateExtraImages();
+ UpdateStatusIcons(0);
+ }
return TRUE;
}
break;
@@ -81,7 +80,7 @@ static INT_PTR CALLBACK ExtraImgOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,L return FALSE;
}
-int OnOptionsInit(WPARAM wParam,LPARAM lParam)
+int OnOptionsInit(WPARAM wParam, LPARAM lParam)
{
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.hInstance = hInst;
|