summaryrefslogtreecommitdiff
path: root/protocols/IRCG
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-03-24 15:38:17 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-03-24 15:38:17 +0300
commite84bafdd3f3d2eb67e10a9bd3fbe600748962b6f (patch)
tree1b563061e473ef8bbe62b86821da21c319cca2c5 /protocols/IRCG
parentaa55162ab85df5aa0ac6b87711bfee222b3222dd (diff)
revolution in chat menus
- common code moved to the core (Chat_CreateGCMenu, Chat_DestroyGCMenu); - ability added to any plugin to add its own items into any GC menu, not only to the protocol plugins to do that a plugin calls Chat_AddMenuItems and returns 0 to allow any other plugin to process menu hook
Diffstat (limited to 'protocols/IRCG')
-rw-r--r--protocols/IRCG/src/resource.h1
-rw-r--r--protocols/IRCG/src/services.cpp27
2 files changed, 11 insertions, 17 deletions
diff --git a/protocols/IRCG/src/resource.h b/protocols/IRCG/src/resource.h
index 8727232122..b2462f00ca 100644
--- a/protocols/IRCG/src/resource.h
+++ b/protocols/IRCG/src/resource.h
@@ -11,7 +11,6 @@
#define IDD_PREFS_OTHER 113
#define IDD_ADDSERVER 120
#define IDD_LIST 123
-#define IDR_MENU 129
#define IDD_QUICKCONN 133
#define IDI_MAIN 136
#define IDD_USERINFO 154
diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp
index 6dae62da22..8e56330c58 100644
--- a/protocols/IRCG/src/services.cpp
+++ b/protocols/IRCG/src/services.cpp
@@ -819,28 +819,23 @@ int __cdecl CIrcProto::GCMenuHook(WPARAM, LPARAM lParam)
if (gcmi) {
if (!mir_strcmpi(gcmi->pszModule, m_szModuleName)) {
if (gcmi->Type == MENU_ON_LOG) {
- if (mir_wstrcmpi(gcmi->pszID, SERVERWINDOW)) {
- gcmi->nItems = _countof(logItems);
- gcmi->Item = logItems;
- }
- else gcmi->nItems = 0;
+ if (mir_wstrcmpi(gcmi->pszID, SERVERWINDOW))
+ Chat_AddMenuItems(gcmi->hMenu, _countof(logItems), logItems);
}
if (gcmi->Type == MENU_ON_NICKLIST) {
CONTACT user = { (wchar_t*)gcmi->pszUID, NULL, NULL, false, false, false };
MCONTACT hContact = CList_FindContact(&user);
- gcmi->nItems = _countof(nickItems);
- gcmi->Item = nickItems;
BOOL bIsInList = (hContact && db_get_b(hContact, "CList", "NotOnList", 0) == 0);
- gcmi->Item[gcmi->nItems - 1].bDisabled = bIsInList;
+ nickItems[_countof(nickItems)-1].bDisabled = bIsInList;
unsigned long ulAdr = 0;
if (m_manualHost)
ulAdr = ConvertIPToInteger(m_mySpecifiedHostIP);
else
ulAdr = ConvertIPToInteger(m_IPFromServer ? m_myHost : m_myLocalHost);
- gcmi->Item[23].bDisabled = ulAdr == 0 ? TRUE : FALSE; // DCC submenu
+ nickItems[23].bDisabled = ulAdr == 0 ? TRUE : FALSE; // DCC submenu
CHANNELINFO *wi = (CHANNELINFO *)Chat_GetUserInfo(m_szModuleName, gcmi->pszID);
BOOL bServOwner = strchr(sUserModes.c_str(), 'q') == NULL ? FALSE : TRUE;
@@ -852,13 +847,13 @@ int __cdecl CIrcProto::GCMenuHook(WPARAM, LPARAM lParam)
BOOL bForceEnable = GetAsyncKeyState(VK_CONTROL);
- gcmi->Item[6].bDisabled /* "Control" submenu */ = !(bForceEnable || bHalfop || bOp || bAdmin || bOwner);
- gcmi->Item[7].uType = gcmi->Item[8].uType = /* +/- Owner */ bServOwner ? MENU_POPUPITEM : 0;
- gcmi->Item[9].uType = gcmi->Item[10].uType = /* +/- Admin */ bServAdmin ? MENU_POPUPITEM : 0;
- gcmi->Item[7].bDisabled = gcmi->Item[8].bDisabled = gcmi->Item[9].bDisabled = gcmi->Item[10].bDisabled = /* +/- Owner/Admin */
- !(bForceEnable || bOwner);
- gcmi->Item[11].bDisabled = gcmi->Item[12].bDisabled = gcmi->Item[13].bDisabled = gcmi->Item[14].bDisabled = /* +/- Op/hop */
- !(bForceEnable || bOp || bAdmin || bOwner);
+ nickItems[6].bDisabled = !(bForceEnable || bHalfop || bOp || bAdmin || bOwner);
+ nickItems[7].uType = nickItems[8].uType = bServOwner ? MENU_POPUPITEM : 0;
+ nickItems[9].uType = nickItems[10].uType = bServAdmin ? MENU_POPUPITEM : 0;
+ nickItems[7].bDisabled = nickItems[8].bDisabled = nickItems[9].bDisabled = nickItems[10].bDisabled = !(bForceEnable || bOwner);
+ nickItems[11].bDisabled = nickItems[12].bDisabled = nickItems[13].bDisabled = nickItems[14].bDisabled = !(bForceEnable || bOp || bAdmin || bOwner);
+
+ Chat_AddMenuItems(gcmi->hMenu, _countof(nickItems), nickItems);
}
}
}