Index: src/ch/MainWnd.cpp =================================================================== diff -u -N -r3c248d4f6d0fdb1e487cc868b2f0b219eec37ef4 -r306fbe693c70290af9de9a5779084a697de22d75 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 3c248d4f6d0fdb1e487cc868b2f0b219eec37ef4) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 306fbe693c70290af9de9a5779084a697de22d75) @@ -692,57 +692,6 @@ break; } - case WM_GETCONFIG: - { - try - { - chcore::TConfig& rConfig = GetConfig(); - - TShellExtMenuConfig cfgShellExt; - - // experimental - doesn't work on all systems - cfgShellExt.SetShowShortcutIcons(GetPropValue(rConfig)); - - cfgShellExt.SetInterceptDragAndDrop(GetPropValue(rConfig)); - cfgShellExt.SetInterceptKeyboardActions(GetPropValue(rConfig)); - cfgShellExt.SetInterceptCtxMenuActions(GetPropValue(rConfig)); - - cfgShellExt.GetFormatter()->SetValues( - GetResManager().LoadString(IDS_BYTE_STRING), - GetResManager().LoadString(IDS_KBYTE_STRING), - GetResManager().LoadString(IDS_MBYTE_STRING), - GetResManager().LoadString(IDS_GBYTE_STRING), - GetResManager().LoadString(IDS_TBYTE_STRING) - ); - - cfgShellExt.SetShowFreeSpace(GetPropValue(rConfig)); - - PrepareDragAndDropMenuItems(cfgShellExt); - PrepareNormalMenuItems(cfgShellExt); - - chcore::TConfig cfgStorage; - chcore::TString wstrData; - - cfgShellExt.StoreInConfig(cfgStorage, _T("ShellExtCfg")); - cfgStorage.WriteToString(wstrData); - - std::wstring strSHMName = IPCSupport::GenerateSHMName((unsigned long)lParam); - - m_tCHExtharedMemory.Create(strSHMName.c_str(), wstrData); - } - catch(const std::exception& e) - { - _ASSERTE(FALSE); - CString strMsg; - strMsg.Format(L"Encountered problem trying to retrieve shell ext configuration.\nReason: %S", e.what()); - LOG_ERROR(m_spLog) << strMsg; - - return FALSE; - } - - return TRUE; - } - case WM_IDENTIFY: { //decode @@ -794,160 +743,6 @@ return CWnd::WindowProc(message, wParam, lParam); } -void CMainWnd::PrepareDragAndDropMenuItems(TShellExtMenuConfig &cfgShellExt) const -{ - chcore::TConfig& rConfig = GetConfig(); - ictranslate::CResourceManager& rResManager = GetResManager(); - - TShellMenuItemPtr spDragAndDropRootItem = cfgShellExt.GetDragAndDropRoot(); - bool bAddedAnyOption = false; - if(GetPropValue(rConfig)) - { - spDragAndDropRootItem->AddChild(std::make_shared(rResManager.LoadString(IDS_MENUCOPY_STRING), rResManager.LoadString(IDS_MENUTIPCOPY_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject), - TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), false, chcore::eOperation_Copy)); - bAddedAnyOption = true; - } - - if(GetPropValue(rConfig)) - { - spDragAndDropRootItem->AddChild(std::make_shared(rResManager.LoadString(IDS_MENUMOVE_STRING), rResManager.LoadString(IDS_MENUTIPMOVE_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject), - TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), false, chcore::eOperation_Move)); - bAddedAnyOption = true; - } - - if(GetPropValue(rConfig)) - { - spDragAndDropRootItem->AddChild(std::make_shared(rResManager.LoadString(IDS_MENUCOPYMOVESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVESPECIAL_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject), - TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), true)); - bAddedAnyOption = true; - } - - if(bAddedAnyOption) - { - // insert separator as an addition to other items - spDragAndDropRootItem->AddChild(std::make_shared()); - } -} - -void CMainWnd::PrepareNormalMenuItems(TShellExtMenuConfig &cfgShellExt) const -{ - chcore::TConfig& rConfig = GetConfig(); - ictranslate::CResourceManager& rResManager = GetResManager(); - - TShellMenuItemPtr spNormalRootItem = cfgShellExt.GetNormalRoot(); - - if(GetPropValue(rConfig)) - { - spNormalRootItem->AddChild(std::make_shared(rResManager.LoadString(IDS_MENUPASTE_STRING), rResManager.LoadString(IDS_MENUTIPPASTE_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_Clipboard), - TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializeAuto, chcore::TSmartPath()), false)); - } - - if(GetPropValue(rConfig)) - { - spNormalRootItem->AddChild(std::make_shared(rResManager.LoadString(IDS_MENUPASTESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPPASTESPECIAL_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_Clipboard), - TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializeAuto, chcore::TSmartPath()), true)); - } - - if(GetPropValue(rConfig) || GetPropValue(rConfig) || GetPropValue(rConfig)) - { - // prepare shortcuts for all menu options - std::vector vShortcutStrings; - GetPropValue(rConfig, vShortcutStrings); - - std::vector vShortcuts; - - for(const CString& strShortcutString : vShortcutStrings) - { - CShortcut tShortcut; - if(tShortcut.FromString(strShortcutString)) - vShortcuts.push_back(tShortcut); - else - BOOST_ASSERT(false); // non-critical, but not very nice - } - - if(GetPropValue(rConfig)) - { - std::shared_ptr menuItem(std::make_shared(rResManager.LoadString(IDS_MENUCOPYTO_STRING), rResManager.LoadString(IDS_MENUTIPCOPYTO_STRING))); - for(const CShortcut& tShortcut : vShortcuts) - { - menuItem->AddChild(std::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, - TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), - TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), false)); - } - - spNormalRootItem->AddChild(menuItem); - - // optionally separator - if(!vShortcuts.empty()) - menuItem->AddChild(std::make_shared()); - - // "Choose" menu option - menuItem->AddChild(std::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), - TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), false)); - } - - if(GetPropValue(rConfig)) - { - std::shared_ptr menuItem(std::make_shared(rResManager.LoadString(IDS_MENUMOVETO_STRING), rResManager.LoadString(IDS_MENUTIPMOVETO_STRING))); - for(const CShortcut& tShortcut : vShortcuts) - { - menuItem->AddChild(std::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, - TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), - TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), false)); - } - - spNormalRootItem->AddChild(menuItem); - - // optionally separator - if(!vShortcuts.empty()) - menuItem->AddChild(std::make_shared()); - - // "Choose" menu option - menuItem->AddChild(std::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), - TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), false)); - } - - if(GetPropValue(rConfig)) - { - std::shared_ptr menuItem(std::make_shared(rResManager.LoadString(IDS_MENUCOPYMOVETOSPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVETOSPECIAL_STRING))); - for(const CShortcut& tShortcut : vShortcuts) - { - menuItem->AddChild(std::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, - TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), - TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), true)); - } - - spNormalRootItem->AddChild(menuItem); - - // optionally separator - if(!vShortcuts.empty()) - menuItem->AddChild(std::make_shared()); - - // "Choose" menu option - menuItem->AddChild(std::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), - TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), - TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), - TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), true)); - } - } -} void CMainWnd::OnAppAbout() { CAboutDlg *pdlg=new CAboutDlg;