From bd820972afe24409e6b570adbc45f5dc0fa2385d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 11 Apr 2013 07:08:40 +0000 Subject: SRMM icons to be unloaded automatically git-svn-id: http://svn.miranda-ng.org/main/trunk@4418 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Popup/src/main.cpp | 1 - plugins/Popup/src/srmm_menu.cpp | 92 ++++++++++++++--------------------------- plugins/Popup/src/srmm_menu.h | 1 - 3 files changed, 32 insertions(+), 62 deletions(-) (limited to 'plugins/Popup/src') diff --git a/plugins/Popup/src/main.cpp b/plugins/Popup/src/main.cpp index e7199dae36..8ec040ab6c 100644 --- a/plugins/Popup/src/main.cpp +++ b/plugins/Popup/src/main.cpp @@ -326,7 +326,6 @@ MIRAPI PLUGININFOEX* MirandaPluginInfoEx(DWORD) //called before the app goes into shutdown routine to make sure everyone is happy to exit static int OkToExit(WPARAM, LPARAM) { - SrmmMenu_Unload(); closing = TRUE; StopPopupThread(); return 0; diff --git a/plugins/Popup/src/srmm_menu.cpp b/plugins/Popup/src/srmm_menu.cpp index 32f207e8c4..06456618cc 100644 --- a/plugins/Popup/src/srmm_menu.cpp +++ b/plugins/Popup/src/srmm_menu.cpp @@ -37,62 +37,37 @@ static int SrmmMenu_ProcessIconClick(WPARAM wParam, LPARAM lParam); void SrmmMenu_Load() { - if (ServiceExists(MS_MSG_ADDICON)) - { - StatusIconData sid = {0}; - sid.cbSize = sizeof(sid); - sid.szModule = MODULNAME; - sid.flags = 0; - - sid.dwId = 0; - sid.szTooltip = Translate("Popup Mode: Auto"); - sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_POPUP_ON,0); - CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); - - sid.dwId = 1; - sid.szTooltip = Translate("Popup Mode: Favourite"); - sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_FAV,0); - CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); - - sid.dwId = 2; - sid.szTooltip = Translate("Popup Mode: Ignore fullscreen"); - sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_FULLSCREEN,0); - CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); - - sid.dwId = 3; - sid.szTooltip = Translate("Popup Mode: Block contact"); - sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_POPUP_OFF,0); - CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid); - - HookEvent(ME_MSG_ICONPRESSED, SrmmMenu_ProcessIconClick); - HookEvent(ME_MSG_WINDOWEVENT, SrmmMenu_ProcessEvent); - } -} - -void SrmmMenu_Unload() -{ - if (ServiceExists(MS_MSG_REMOVEICON)) - { - StatusIconData sid = { sizeof(sid) }; - sid.szModule = MODULNAME; - - sid.dwId = 0; - CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid); - - sid.dwId = 1; - CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid); - - sid.dwId = 2; - CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid); + StatusIconData sid = { sizeof(sid) }; + sid.szModule = MODULNAME; - sid.dwId = 3; - CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid); - } + sid.dwId = 0; + sid.szTooltip = Translate("Popup Mode: Auto"); + sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_POPUP_ON,0); + Srmm_AddIcon(&sid); + + sid.dwId = 1; + sid.szTooltip = Translate("Popup Mode: Favourite"); + sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_FAV,0); + Srmm_AddIcon(&sid); + + sid.dwId = 2; + sid.szTooltip = Translate("Popup Mode: Ignore fullscreen"); + sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_FULLSCREEN,0); + Srmm_AddIcon(&sid); + + sid.dwId = 3; + sid.szTooltip = Translate("Popup Mode: Block contact"); + sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_POPUP_OFF,0); + Srmm_AddIcon(&sid); + + HookEvent(ME_MSG_ICONPRESSED, SrmmMenu_ProcessIconClick); + HookEvent(ME_MSG_WINDOWEVENT, SrmmMenu_ProcessEvent); } static void SrmmMenu_UpdateIcon(HANDLE hContact) { - if (!hContact) return; + if (!hContact) + return; int mode = db_get_b(hContact, MODULNAME, "ShowMode", PU_SHOWMODE_AUTO); @@ -100,8 +75,7 @@ static void SrmmMenu_UpdateIcon(HANDLE hContact) sid.cbSize = sizeof(sid); sid.szModule = MODULNAME; - for (int i=0; i < 4; ++i) - { + for (int i=0; i < 4; ++i) { sid.dwId = i; sid.flags = (i == mode) ? 0 : MBF_HIDDEN; CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid); @@ -112,15 +86,14 @@ static int SrmmMenu_ProcessEvent(WPARAM, LPARAM lParam) { MessageWindowEventData *mwevent = (MessageWindowEventData *)lParam; - if ( mwevent->uType == MSG_WINDOW_EVT_OPEN ) - { + if (mwevent->uType == MSG_WINDOW_EVT_OPEN) { if (!hDialogsList) hDialogsList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); WindowList_Add(hDialogsList, mwevent->hwndWindow, mwevent->hContact); SrmmMenu_UpdateIcon(mwevent->hContact); } - else if ( mwevent->uType == MSG_WINDOW_EVT_CLOSING ) + else if (mwevent->uType == MSG_WINDOW_EVT_CLOSING) { if (hDialogsList) WindowList_Remove(hDialogsList, mwevent->hwndWindow); @@ -139,8 +112,7 @@ static int SrmmMenu_ProcessIconClick(WPARAM wParam, LPARAM lParam) int mode = db_get_b(hContact, MODULNAME, "ShowMode", PU_SHOWMODE_AUTO); - if (sicd->flags&MBCF_RIGHTBUTTON) - { + if (sicd->flags & MBCF_RIGHTBUTTON) { HMENU hMenu = CreatePopupMenu(); AppendMenu(hMenu, MF_STRING, 1+PU_SHOWMODE_AUTO, TranslateT("Auto")); @@ -157,8 +129,8 @@ static int SrmmMenu_ProcessIconClick(WPARAM wParam, LPARAM lParam) db_set_b(hContact, MODULNAME, "ShowMode", mode-1); SrmmMenu_UpdateIcon(hContact); } - } else - { + } + else { db_set_b(hContact, MODULNAME, "ShowMode", (mode == PU_SHOWMODE_AUTO) ? PU_SHOWMODE_BLOCK : PU_SHOWMODE_AUTO); SrmmMenu_UpdateIcon(hContact); } diff --git a/plugins/Popup/src/srmm_menu.h b/plugins/Popup/src/srmm_menu.h index c64d3b303c..67ea73cc12 100644 --- a/plugins/Popup/src/srmm_menu.h +++ b/plugins/Popup/src/srmm_menu.h @@ -25,6 +25,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define __srmm_menu_h__ void SrmmMenu_Load(); -void SrmmMenu_Unload(); #endif // __srmm_menu_h__ -- cgit v1.2.3