summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Clist_modern/src/groupmenu.cpp112
-rw-r--r--plugins/UserInfoEx/src/init.cpp3
-rw-r--r--plugins/UserInfoEx/src/mir_menuitems.cpp81
-rw-r--r--plugins/UserInfoEx/src/mir_menuitems.h3
4 files changed, 73 insertions, 126 deletions
diff --git a/plugins/Clist_modern/src/groupmenu.cpp b/plugins/Clist_modern/src/groupmenu.cpp
index 0afffb63e2..36f7d3b617 100644
--- a/plugins/Clist_modern/src/groupmenu.cpp
+++ b/plugins/Clist_modern/src/groupmenu.cpp
@@ -27,115 +27,53 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////// Group MENU //////////////////////////////
-HGENMENU hGroupMainMenuItemProxy, hGroupStatusMenuItemProxy;
-
-void InitSubGroupMenus(void);
+static HGENMENU hShowOfflineUsersHereMenuItem;
-INT_PTR GroupMenuOnAddService(WPARAM wParam, LPARAM lParam)
+// wparam menu handle to pass to clc.c
+// lparam WM_COMMAND HWND
+static int OnBuildSubGroupMenu(WPARAM wParam, LPARAM)
{
- MENUITEMINFO *mii = (MENUITEMINFO*)wParam;
- if (mii == nullptr)
- return 0;
+ bool showOfflineinGroup, gray;
- if (hGroupMainMenuItemProxy == (HANDLE)lParam) {
- mii->fMask |= MIIM_SUBMENU;
- mii->hSubMenu = Menu_GetMainMenu();
+ ClcGroup *group = (ClcGroup *)wParam;
+ if (wParam == 0 || MirandaExiting())
+ showOfflineinGroup = gray = false;
+ else {
+ showOfflineinGroup = CLCItems_IsShowOfflineGroup(group);
+ gray = !group->bHideOffline;
}
- if (hGroupStatusMenuItemProxy == (HANDLE)lParam) {
- mii->fMask |= MIIM_SUBMENU;
- mii->hSubMenu = Menu_GetStatusMenu();
- }
+ Menu_ShowItem(hShowOfflineUsersHereMenuItem, gray);
+ Menu_SetChecked(hShowOfflineUsersHereMenuItem, showOfflineinGroup && gray);
+ return 0;
+}
- return TRUE;
+static INT_PTR GroupMenuExecProxy(WPARAM wParam, LPARAM lParam)
+{
+ SendMessage(lParam ? (HWND)lParam : (HWND)g_clistApi.hwndContactTree, WM_COMMAND, wParam, 0);
+ return 0;
}
void InitGroupMenus(void)
{
- CreateServiceFunction("CLISTMENUSGroup/GroupMenuOnAddService", GroupMenuOnAddService);
-
- InitSubGroupMenus();
-
CMenuItem mi(&g_plugin);
SET_UID(mi, 0xe386678a, 0x5aee, 0x4bfa, 0xa8, 0x23, 0xd, 0xa0, 0x11, 0x99, 0xb1, 0x98);
- mi.position = 500;
+ mi.position = 500001;
mi.pszService = MS_CLIST_SHOWHIDE;
mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_SHOWHIDE);
mi.name.a = LPGEN("&Hide/show");
Menu_AddGroupMenuItem(&mi);
- SET_UID(mi, 0xb0f29663, 0x68b6, 0x494c, 0xaf, 0xab, 0xf6, 0x86, 0x45, 0xb8, 0xdb, 0xde);
- mi.position = 200000;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_FINDUSER);
- mi.pszService = "FindAdd/FindAddCommand";
- mi.name.a = LPGEN("&Find/add contacts...");
- Menu_AddGroupMenuItem(&mi);
-
- SET_UID(mi, 0xff6855b4, 0x8c50, 0x43b7, 0x97, 0x51, 0xc1, 0x28, 0xa3, 0x10, 0x2b, 0x86);
- mi.position = 300000;
- mi.pszService = "";
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_MAINMENU);
- mi.name.a = LPGEN("&Main menu");
- hGroupMainMenuItemProxy = Menu_AddGroupMenuItem(&mi);
-
- SET_UID(mi, 0xba91af46, 0x34e5, 0x4f3a, 0x88, 0x1c, 0xe7, 0xa3, 0x53, 0x58, 0x19, 0xde);
- mi.position = 300100;
- mi.pszService = "";
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_STATUS);
- mi.name.a = LPGEN("&Status");
- hGroupStatusMenuItemProxy = Menu_AddGroupMenuItem(&mi);
-
- SET_UID(mi, 0xc2895531, 0x98e9, 0x40bc, 0x9b, 0x8e, 0xfb, 0x33, 0xe8, 0xab, 0xcc, 0xef);
- mi.position = 400000;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_OPTIONS);
- mi.pszService = "Options/OptionsCommand";
- mi.name.a = LPGEN("&Options...");
- Menu_AddGroupMenuItem(&mi);
-
- SET_UID(mi, 0x2221068a, 0x285d, 0x490c, 0xb1, 0x95, 0xff, 0x49, 0x75, 0xbc, 0xe4, 0x59);
- mi.position = 1000000;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA);
- mi.pszService = "Help/AboutCommand";
- mi.name.a = LPGEN("&About");
- Menu_AddGroupMenuItem(&mi);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////// SubGroup MENU //////////////////////////////
-
-static HGENMENU hShowOfflineUsersHereMenuItem;
-
-// wparam menu handle to pass to clc.c
-// lparam WM_COMMAND HWND
-static int OnBuildSubGroupMenu(WPARAM wParam, LPARAM)
-{
- ClcGroup *group = (ClcGroup *)wParam;
- if (wParam == 0)
- return 0;
-
- if (MirandaExiting())
- return 0;
-
- bool showOfflineinGroup = CLCItems_IsShowOfflineGroup(group);
- bool gray2 = !group->bHideOffline;
-
- Menu_EnableItem(hShowOfflineUsersHereMenuItem, gray2);
- Menu_SetChecked(hShowOfflineUsersHereMenuItem, showOfflineinGroup && gray2);
- return 0;
-}
-
-void InitSubGroupMenus(void)
-{
- HookEvent(ME_CLIST_PREBUILDSUBGROUPMENU, OnBuildSubGroupMenu);
+ HookEvent(ME_CLIST_PREBUILDGROUPMENU, OnBuildSubGroupMenu);
// add exit command to menu
GroupMenuParam gmp = { POPUP_GROUPSHOWOFFLINE, 0 };
- CMenuItem mi(&g_plugin);
SET_UID(mi, 0x7E081A28, 0x19B3, 0x407F, 0x80, 0x6B, 0x70, 0xC3, 0xC3, 0xA9, 0xD2, 0xA4);
- mi.position = 1002;
- mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy";
+ mi.position = 900001;
+ mi.pszService = "Modern/GroupMenuExecProxy";
mi.name.a = LPGEN("&Show offline users in here");
- hShowOfflineUsersHereMenuItem = Menu_AddSubGroupMenuItem(&mi, &gmp);
+ hShowOfflineUsersHereMenuItem = Menu_AddGroupMenuItem(&mi, &gmp);
+ CreateServiceFunction(mi.pszService, GroupMenuExecProxy);
}
diff --git a/plugins/UserInfoEx/src/init.cpp b/plugins/UserInfoEx/src/init.cpp
index 46cf5dd029..628b9c0f99 100644
--- a/plugins/UserInfoEx/src/init.cpp
+++ b/plugins/UserInfoEx/src/init.cpp
@@ -154,7 +154,8 @@ static int OnModulesLoaded(WPARAM, LPARAM)
// build contact's menuitems
RebuildMenu();
- HookEvent(ME_CLIST_PREBUILDSTATUSMENU, (MIRANDAHOOK)RebuildAccount);
+ HookEvent(ME_CLIST_PREBUILDGROUPMENU, OnBuildGroupMenu);
+ HookEvent(ME_CLIST_PREBUILDSTATUSMENU, OnBuildStatusMenu);
return 0;
}
diff --git a/plugins/UserInfoEx/src/mir_menuitems.cpp b/plugins/UserInfoEx/src/mir_menuitems.cpp
index 5c7ee52469..6635f70216 100644
--- a/plugins/UserInfoEx/src/mir_menuitems.cpp
+++ b/plugins/UserInfoEx/src/mir_menuitems.cpp
@@ -40,7 +40,8 @@ HGENMENU *hMenuItemAccount = nullptr;
*
* @return 0 on success, -1 on failure
**/
-INT_PTR RemoveMenuItems(HGENMENU *pItems, int Count)
+
+static INT_PTR RemoveMenuItems(HGENMENU *pItems, int Count)
{
if (!Count || !pItems) {
return -1;
@@ -63,6 +64,7 @@ INT_PTR RemoveMenuItems(HGENMENU *pItems, int Count)
*
* @return nothing
**/
+
void RebuildContact()
{
HGENMENU mhRoot = nullptr;
@@ -85,7 +87,6 @@ void RebuildContact()
// support new genmenu style
CMenuItem mi(&g_plugin);
-
switch (flag) {
case 3:
//cascade off
@@ -280,14 +281,15 @@ void RebuildMain()
*
* @return nothing
**/
+
+static HGENMENU hGroupMenuItems[3], hSubGroupMenuItems[3];
+
void RebuildGroup()
{
int flag = 0;
uint8_t item = 0;
HGENMENU mhRoot = nullptr;
- HGENMENU mhExIm = nullptr;
- static HGENMENU hMenuItem[3] = { nullptr, nullptr, nullptr };
// load options
flag = g_plugin.getByte(SET_MI_GROUP, MCAS_NOTINITIATED);
@@ -297,7 +299,7 @@ void RebuildGroup()
}
// delete all MenuItems and set all bytes 0 to avoid problems
- RemoveMenuItems(hMenuItem, _countof(hMenuItem));
+ RemoveMenuItems(hGroupMenuItems, _countof(hGroupMenuItems));
// create service name main (prevent to generate {(Null)/Ex-/Import Group} in db) and set pointer to end it
char text[200];
@@ -308,19 +310,18 @@ void RebuildGroup()
switch (flag) {
case 3:
- //cascade off
- mhRoot = mhExIm = nullptr;
- hMenuItem[item++] = nullptr;
+ // cascade off
+ mhRoot = nullptr;
+ hGroupMenuItems[item++] = nullptr;
break;
case 5:
- //cascade all
+ // cascade all
SET_UID(mi, 0xfefe20db, 0x431f, 0x4fef, 0x9d, 0xa6, 0x70, 0xcd, 0x25, 0xf1, 0x2f, 0x1d);
mi.position = 250000;
mi.hIcolibItem = g_plugin.getIconHandle(IDI_MAIN);
mi.name.a = MODULELONGNAME;
mhRoot = Menu_AddGroupMenuItem(&mi);
- hMenuItem[item++] = mhRoot;
- mhExIm = mhRoot;
+ hGroupMenuItems[item++] = mhRoot;
break;
case 9:
//cascade Ex/Import
@@ -328,9 +329,8 @@ void RebuildGroup()
mi.position = 250100;
mi.hIcolibItem = g_plugin.getIconHandle(IDI_BTN_EXIMPORT);
mi.name.a = LPGEN("Export/import contact");
- mhExIm = Menu_AddGroupMenuItem(&mi);
- hMenuItem[item++] = mhExIm;
- mhRoot = nullptr;
+ mhRoot = Menu_AddGroupMenuItem(&mi);
+ hGroupMenuItems[item++] = mhRoot;
break;
default:
//disable Menue
@@ -338,7 +338,7 @@ void RebuildGroup()
}
// VCard's Ex/Import menuitems
- mi.root = mhExIm;
+ mi.root = mhRoot;
// Export
SET_UID(mi, 0x9a0d81ec, 0x6795, 0x421a, 0xb2, 0x79, 0x41, 0xbd, 0xde, 0x29, 0x3b, 0xa4);
@@ -346,7 +346,7 @@ void RebuildGroup()
mi.name.a = LPGEN("Export all contacts");
mi.position = 250200;
mi.hIcolibItem = g_plugin.getIconHandle(IDI_EXPORT);
- hMenuItem[item++] = Menu_AddGroupMenuItem(&mi);
+ hGroupMenuItems[item++] = Menu_AddGroupMenuItem(&mi);
// Import
SET_UID(mi, 0xd6d98c8f, 0x5cdf, 0x4138, 0x88, 0x6c, 0x31, 0x1a, 0x5a, 0x9, 0x56, 0xbb);
@@ -354,7 +354,7 @@ void RebuildGroup()
mi.name.a = LPGEN("Import all contacts");
mi.position = 250300;
mi.hIcolibItem = g_plugin.getIconHandle(IDI_IMPORT);
- hMenuItem[item++] = Menu_AddGroupMenuItem(&mi);
+ hGroupMenuItems[item++] = Menu_AddGroupMenuItem(&mi);
}
/******************************
@@ -376,10 +376,6 @@ void RebuildSubGroup()
uint8_t item = 0;
GroupMenuParam gmp = { 0 };
- HGENMENU mhRoot = nullptr;
- HGENMENU mhExIm = nullptr;
- static HGENMENU hMenuItem[3] = { nullptr, nullptr, nullptr };
-
// load options
flag = g_plugin.getByte(SET_MI_SUBGROUP, MCAS_NOTINITIATED);
if (flag == MCAS_NOTINITIATED) {
@@ -388,7 +384,7 @@ void RebuildSubGroup()
}
// delete all MenuItems and set all bytes 0 to avoid problems
- RemoveMenuItems(hMenuItem, _countof(hMenuItem));
+ RemoveMenuItems(hSubGroupMenuItems, _countof(hSubGroupMenuItems));
// create service name main (prevent to generate {(Null)/Ex-/Import Group} in db) and set pointer to end it
char text[200];
@@ -398,11 +394,13 @@ void RebuildSubGroup()
mi.pszService = text;
char* tDest = text + mir_strlen(text);
+ HGENMENU mhRoot;
+
switch (flag) {
case 3:
//cascade off
- mhRoot = mhExIm = nullptr;
- hMenuItem[item++] = nullptr;
+ mhRoot = nullptr;
+ hSubGroupMenuItems[item++] = nullptr;
break;
case 5:
//cascade all
@@ -410,9 +408,8 @@ void RebuildSubGroup()
mi.position = 1050000;
mi.hIcolibItem = g_plugin.getIconHandle(IDI_MAIN);
mi.name.a = MODULELONGNAME;
- mhRoot = Menu_AddSubGroupMenuItem(&mi);
- hMenuItem[item++] = mhRoot;
- mhExIm = mhRoot;
+ mhRoot = Menu_AddGroupMenuItem(&mi);
+ hSubGroupMenuItems[item++] = mhRoot;
break;
case 9:
//cascade Ex/Import
@@ -420,9 +417,8 @@ void RebuildSubGroup()
mi.position = 1050100;
mi.hIcolibItem = g_plugin.getIconHandle(IDI_BTN_EXIMPORT);
mi.name.a = LPGEN("Export/import group");
- mhExIm = Menu_AddSubGroupMenuItem(&mi);
- hMenuItem[item++] = mhExIm;
- mhRoot = nullptr;
+ mhRoot = Menu_AddGroupMenuItem(&mi);
+ hSubGroupMenuItems[item++] = mhRoot;
break;
default:
//disable Menue
@@ -430,27 +426,37 @@ void RebuildSubGroup()
}
// VCard's Ex/Import menuitems
- mi.root = mhExIm;
+ mi.root = mhRoot;
// Export
SET_UID(mi, 0x65be2523, 0x15fd, 0x45ca, 0xae, 0xe6, 0xc2, 0x98, 0xd2, 0xa9, 0xff, 0xd5);
mir_strcpy(tDest, "/ExportGroup"); //mi.pszService
if (!ServiceExists(mi.pszService)) CreateServiceFunction(mi.pszService, svcExIm_Group_Service);
- mi.name.a = mhExIm != NULL ? LPGEN("&Export") : LPGEN("&Export group");
+ mi.name.a = mhRoot!= NULL ? LPGEN("&Export") : LPGEN("&Export group");
mi.position = 1050200;
mi.hIcolibItem = g_plugin.getIconHandle(IDI_EXPORT);
gmp.wParam = TRUE;
- hMenuItem[item++] = Menu_AddSubGroupMenuItem(&mi, &gmp);
+ hSubGroupMenuItems[item++] = Menu_AddGroupMenuItem(&mi, &gmp);
// Import
SET_UID(mi, 0xf6be7278, 0x4adb, 0x4e6a, 0x9f, 0x63, 0x79, 0xda, 0xbb, 0xcd, 0xbe, 0x42);
mir_strcpy(tDest, "/ImportGroup"); //mi.pszService
if (!ServiceExists(mi.pszService)) CreateServiceFunction(mi.pszService, svcExIm_Group_Service);
- mi.name.a = mhExIm != NULL ? LPGEN("&Import") : LPGEN("&Import group");
+ mi.name.a = mhRoot != NULL ? LPGEN("&Import") : LPGEN("&Import group");
mi.position = 1050300;
mi.hIcolibItem = g_plugin.getIconHandle(IDI_IMPORT);
gmp.wParam = FALSE;
- hMenuItem[item++] = Menu_AddSubGroupMenuItem(&mi, &gmp);
+ hSubGroupMenuItems[item++] = Menu_AddGroupMenuItem(&mi, &gmp);
+}
+
+int OnBuildGroupMenu(WPARAM wParam, LPARAM)
+{
+ for (auto &it : hGroupMenuItems)
+ Menu_ShowItem(it, wParam == 0);
+
+ for (auto &it : hSubGroupMenuItems)
+ Menu_ShowItem(it, wParam != 0);
+ return 0;
}
/******************************
@@ -469,7 +475,7 @@ void RebuildSubGroup()
*
* @return always 0
**/
-INT_PTR RebuildAccount(WPARAM, LPARAM lParam)
+int OnBuildStatusMenu(WPARAM, LPARAM lParam)
{
if (Miranda_IsTerminated())
return 0;
@@ -577,5 +583,6 @@ void RebuildMenu()
RebuildContact();
RebuildGroup();
RebuildSubGroup();
- RebuildAccount(NULL, 1);
+
+ OnBuildStatusMenu(NULL, 1);
}
diff --git a/plugins/UserInfoEx/src/mir_menuitems.h b/plugins/UserInfoEx/src/mir_menuitems.h
index 27d8f7afc9..8dcb432cd9 100644
--- a/plugins/UserInfoEx/src/mir_menuitems.h
+++ b/plugins/UserInfoEx/src/mir_menuitems.h
@@ -32,7 +32,8 @@ void RebuildMain();
void RebuildContact();
void RebuildGroup();
void RebuildSubGroup();
-INT_PTR RebuildAccount(WPARAM wParam, LPARAM lParam);
+int OnBuildGroupMenu(WPARAM wParam, LPARAM lParam);
+int OnBuildStatusMenu(WPARAM wParam, LPARAM lParam);
#endif /* _UINFOEX_MENUITEMS_H_INCLUDED_ */