From fcb800cc6b9c2bf47a65750fa99065cb2a935b87 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 7 Dec 2015 11:42:40 +0000 Subject: menu converter now scheduled to be executed after all plugins git-svn-id: http://svn.miranda-ng.org/main/trunk@15825 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_app/src/clistmod.cpp | 3 +++ src/mir_app/src/menu_utils.cpp | 52 ++++++++++++++++++++++++++++++++---------- 2 files changed, 43 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index e99ea438df..535e33f27d 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -38,6 +38,7 @@ void LoadCluiServices(); INT_PTR Docking_IsDocked(WPARAM wParam, LPARAM lParam); int LoadCLUIModule(void); int InitClistHotKeys(void); +void ScheduleMenuUpdate(void); HANDLE hContactDoubleClicked, hContactIconChangedEvent; HIMAGELIST hCListImages; @@ -192,6 +193,8 @@ static void RemoveProtoIconIndex(PROTOACCOUNT *pa) static int ContactListModulesLoaded(WPARAM, LPARAM) { + ScheduleMenuUpdate(); + RebuildMenuOrder(); for (int i = 0; i < accounts.getCount(); i++) AddProtoIconIndex(accounts[i]); diff --git a/src/mir_app/src/menu_utils.cpp b/src/mir_app/src/menu_utils.cpp index f0bd1dcd82..b3430d527f 100644 --- a/src/mir_app/src/menu_utils.cpp +++ b/src/mir_app/src/menu_utils.cpp @@ -845,10 +845,6 @@ static void InsertMenuItemWithSeparators(HMENU hMenu, int uItem, MENUITEMINFO *l ///////////////////////////////////////////////////////////////////////////////////////// -#ifdef _DEBUG -#define PUTPOSITIONSONMENU -#endif - static int sttDumpItem(TMO_IntMenuItem *pmi, void *szModule) { if (!equalUUID(pmi->mi.uid, miid_last)) { @@ -866,6 +862,46 @@ static int sttDumpItem(TMO_IntMenuItem *pmi, void *szModule) return 0; } +#define MS_MENU_UPDATE "System/Genmenu/Update" + +static INT_PTR sttUpdateMenuService(WPARAM wParam, LPARAM) +{ + CallService(MS_SYSTEM_REMOVEWAIT, wParam, 0); + CloseHandle((HANDLE)wParam); + + for (int i = 0; i < g_menus.getCount(); i++) { + TIntMenuObject *pmo = g_menus[i]; + if (!pmo->m_bUseUserDefinedItems) + continue; + + char szModule[256]; + mir_snprintf(szModule, "%s_Items", pmo->pszName); + + // wipe out old trash, write new data & compatibility flag + CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szModule); + db_set_b(NULL, szModule, "MenuFormat", true); + + MO_RecursiveWalkMenu(pmo->m_items.first, sttDumpItem, szModule); + } + return 0; +} + +void ScheduleMenuUpdate() +{ + // already converted + if (db_get_b(NULL, "MainMenu_Items", "MenuFormat", 0) == 0) { + HANDLE hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); + CreateServiceFunction(MS_MENU_UPDATE, sttUpdateMenuService); + CallService(MS_SYSTEM_WAITONHANDLE, (WPARAM)hEvent, (LPARAM)MS_MENU_UPDATE); + } +} + +///////////////////////////////////////////////////////////////////////////////////////// + +#ifdef _DEBUG +#define PUTPOSITIONSONMENU +#endif + static HMENU BuildRecursiveMenu(HMENU hMenu, TMO_IntMenuItem *pRootMenu, WPARAM wParam, LPARAM lParam) { if (pRootMenu == NULL) @@ -1004,14 +1040,6 @@ static HMENU BuildRecursiveMenu(HMENU hMenu, TMO_IntMenuItem *pRootMenu, WPARAM } } - if (bOldMenuFormat && pRootMenu->mi.root == NULL && pmo->m_bUseUserDefinedItems) { - // wipe out old trash, write new data & compatibility flag - CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)szModule); - db_set_b(NULL, szModule, "MenuFormat", true); - - MO_RecursiveWalkMenu(pmo->m_items.first, sttDumpItem, szModule); - } - return hMenu; } -- cgit v1.2.3