OSDN Git Service

PATCH: [ 1258270 ] ShellExtension: allow re-selecting first item
authorKimmo Varis <kimmov@gmail.com>
Tue, 16 Aug 2005 13:56:45 +0000 (13:56 +0000)
committerKimmo Varis <kimmov@gmail.com>
Tue, 16 Aug 2005 13:56:45 +0000 (13:56 +0000)
26 files changed:
ShellExtension/Languages/ShellExtensionBrazilian.rc
ShellExtension/Languages/ShellExtensionBulgarian.rc
ShellExtension/Languages/ShellExtensionCatalan.rc
ShellExtension/Languages/ShellExtensionChineseSimplified.rc
ShellExtension/Languages/ShellExtensionChineseTraditional.rc
ShellExtension/Languages/ShellExtensionCzech.rc
ShellExtension/Languages/ShellExtensionDanish.rc
ShellExtension/Languages/ShellExtensionDutch.rc
ShellExtension/Languages/ShellExtensionFrench.rc
ShellExtension/Languages/ShellExtensionGerman.rc
ShellExtension/Languages/ShellExtensionHungarian.rc
ShellExtension/Languages/ShellExtensionItalian.rc
ShellExtension/Languages/ShellExtensionJapanese.rc
ShellExtension/Languages/ShellExtensionKorean.rc
ShellExtension/Languages/ShellExtensionNorwegian.rc
ShellExtension/Languages/ShellExtensionPolish.rc
ShellExtension/Languages/ShellExtensionRussian.rc
ShellExtension/Languages/ShellExtensionSlovak.rc
ShellExtension/Languages/ShellExtensionSpanish.rc
ShellExtension/Languages/ShellExtensionSwedish.rc
ShellExtension/Languages/ShellExtensionTurkish.rc
ShellExtension/Resource.h
ShellExtension/ShellExtension.rc
ShellExtension/WinMergeShell.cpp
ShellExtension/WinMergeShell.h
Src/readme.txt

index 10db1a4..ac40186 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Portuguese (Brazil) resources
index 66bfc1c..cfec271 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Bulgarian resources
index 80225f4..df5e54d 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compara amb"
     IDS_HELP_SAVETHIS       "Selecciona aquest camí. Tria un altre camí per a comparar-lo amb aquest camí."
     IDS_HELP_COMPARESAVED   "Compara amb el camí anteriorment seleccionat (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Catalan resources
index 0653197..fe97a06 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Chinese (Traditional) resources
index 8e56a0f..ece6579 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Chinese (Traditional) resources
index c058f09..01d7dab 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Czech resources
index b2a79b0..3384eb8 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Danish resources
index e2dcc40..22d7b4a 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Dutch (Netherlands) resources
index 96d1c4b..a076681 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // French (France) resources
index 4ac1a36..247665e 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // German (Germany) resources
index 35cee59..e46f7e7 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // English (U.S.) resources
index 5d606ce..5e2c0ec 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Italian (Italy) resources
index 2d18964..d62af85 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "\94ä\8ar\91Î\8fÛ\82Æ\82µ\82Ä\91I\91ð"
     IDS_HELP_SAVETHIS       "\82±\82Ì\83p\83X\82ð\95Û\91\82µ\82Ü\82·\81\82±\82Ì\83p\83X\82Æ\94ä\8ar\82·\82é\82½\82ß\82É\95Ê\82Ì\83p\83X\82ð\91I\91ð\82µ\82Ä\82­\82¾\82³\82¢\81B"
     IDS_HELP_COMPARESAVED   "\95Û\91\82³\82ê\82½\83p\83X(%1)\82Æ\94ä\8ar\82µ\82Ü\82·\81B"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // \93ú\96{\8cê resources
index a9d77c2..087c716 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Korean resources
index 31c9bfc..53c6943 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Norwegian (Bokmal) resources
index 5b53775..6211333 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Polish resources
index 8762b2c..ca84340 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Russian resources
index b145058..22a44d6 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Slovak resources
index 2a1974b..e9656f9 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Spanish (Modern) resources
index 061b003..98f1544 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Swedish resources
index feb869e..806bc09 100644 (file)
@@ -39,6 +39,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // Turkish resources
index 80eb31e..64b18ff 100644 (file)
@@ -13,6 +13,7 @@
 #define IDS_HELP_SAVETHIS               107
 #define IDS_HELP_COMPARESTORED          108
 #define IDS_HELP_COMPARESAVED           109
+#define IDS_RESELECT_FIRST              110
 #define IDB_WINMERGE                    202
 
 // Next default values for new objects
@@ -22,6 +23,6 @@
 #define _APS_NEXT_RESOURCE_VALUE        203
 #define _APS_NEXT_COMMAND_VALUE         32768
 #define _APS_NEXT_CONTROL_VALUE         201
-#define _APS_NEXT_SYMED_VALUE           103
+#define _APS_NEXT_SYMED_VALUE           111
 #endif
 #endif
index c7c0173..b00e09d 100644 (file)
@@ -294,6 +294,7 @@ BEGIN
     IDS_COMPARE_TO          "Compare To"
     IDS_HELP_SAVETHIS       "Save this path. Select another path to compare with this path."
     IDS_HELP_COMPARESAVED   "Compare to saved path (%1)"
+    IDS_RESELECT_FIRST      "Re-select First"
 END
 
 #endif    // English (U.S.) resources
index db0c94e..4aabe78 100644 (file)
@@ -265,6 +265,7 @@ HRESULT CWinMergeShell::GetCommandString(UINT idCmd, UINT uFlags,
 HRESULT CWinMergeShell::InvokeCommand(LPCMINVOKECOMMANDINFO pCmdInfo)
 {
        AFX_MANAGE_STATE(AfxGetStaticModuleState())
+       CRegKeyEx reg;
        CString strWinMergePath;
        BOOL bCompare = FALSE;
        USES_WINMERGELOCALE;
@@ -283,7 +284,6 @@ HRESULT CWinMergeShell::InvokeCommand(LPCMINVOKECOMMANDINFO pCmdInfo)
 
        if (LOWORD(pCmdInfo->lpVerb) == 0)
        {
-               CRegKeyEx reg;
                switch (m_dwMenuState)
                {
                case MENU_SIMPLE:
@@ -315,9 +315,20 @@ HRESULT CWinMergeShell::InvokeCommand(LPCMINVOKECOMMANDINFO pCmdInfo)
        }
        else if (LOWORD(pCmdInfo->lpVerb) == 1)
        {
-               // "Compare..." - user wants to compare this single item and open WinMerge
-               m_strPaths[1].Empty();
-               bCompare = TRUE;
+               switch (m_dwMenuState)
+               {
+               case MENU_ONESEL_PREV:
+                       m_strPreviousPath = m_strPaths[0];
+                       if (reg.Open(HKEY_CURRENT_USER, f_RegDir) == ERROR_SUCCESS)
+                               reg.WriteString(f_FirstSelection, m_strPreviousPath);
+                       bCompare = FALSE;
+                       break;
+               default:
+                       // "Compare..." - user wants to compare this single item and open WinMerge
+                       m_strPaths[1].Empty();
+                       bCompare = TRUE;
+                       break;
+               }
        }
        else
                return E_INVALIDARG;
@@ -325,12 +336,8 @@ HRESULT CWinMergeShell::InvokeCommand(LPCMINVOKECOMMANDINFO pCmdInfo)
        if (bCompare == FALSE)
                return S_FALSE;
 
-       // Format command line
-       CString strCommandLine = strWinMergePath + _T(" \"") +
-               m_strPaths[0] + _T("\"");
-       
-       if (!m_strPaths[1].IsEmpty())
-               strCommandLine += _T(" \"") + m_strPaths[1] + _T("\"");
+       CString strCommandLine = FormatCmdLine(strWinMergePath, m_strPaths[0],
+               m_strPaths[1]);
 
        // Finally start a new WinMerge process
        BOOL retVal = FALSE;
@@ -412,14 +419,18 @@ int CWinMergeShell::DrawAdvancedMenu(HMENU hmenu, UINT uMenuIndex,
        CString strCompare;
        CString strCompareEllipsis;
        CString strCompareTo;
+       CString strReselect;
        int nItemsAdded = 0;
 
        VERIFY(strCompare.LoadString(IDS_COMPARE));
        VERIFY(strCompareEllipsis.LoadString(IDS_COMPARE_ELLIPSIS));
        VERIFY(strCompareTo.LoadString(IDS_COMPARE_TO));
+       VERIFY(strReselect.LoadString(IDS_RESELECT_FIRST));
 
        switch (m_dwMenuState)
        {
+       // No items selected earlier
+       // Select item as first item to compare
        case MENU_ONESEL_NOPREV:
                InsertMenu(hmenu, uMenuIndex, MF_BYPOSITION, uidFirstCmd, strCompareTo);
                uMenuIndex++;
@@ -428,14 +439,18 @@ int CWinMergeShell::DrawAdvancedMenu(HMENU hmenu, UINT uMenuIndex,
                nItemsAdded = 2;
                break;
 
+       // One item selected earlier:
+       // Allow re-selecting first item or selecting second item
        case MENU_ONESEL_PREV:
                InsertMenu(hmenu, uMenuIndex, MF_BYPOSITION, uidFirstCmd, strCompare);
                uMenuIndex++;
                uidFirstCmd++;
-               InsertMenu(hmenu, uMenuIndex, MF_BYPOSITION, uidFirstCmd, strCompareEllipsis);
+               InsertMenu(hmenu, uMenuIndex, MF_BYPOSITION, uidFirstCmd, strReselect);
                nItemsAdded = 2;
                break;
 
+       // Two items selected
+       // Select both items for compare
        case MENU_TWOSEL:
                InsertMenu(hmenu, uMenuIndex, MF_BYPOSITION, uidFirstCmd, strCompare);
                nItemsAdded = 1;
@@ -501,7 +516,47 @@ CString CWinMergeShell::GetHelpText(int idCmd)
        }
        else if (idCmd == 1)
        {
-               VERIFY(strHelp.LoadString(IDS_CONTEXT_HELP));
+               switch (m_dwMenuState)
+               {
+               case MENU_ONESEL_PREV:
+                       VERIFY(strHelp.LoadString(IDS_HELP_SAVETHIS));
+                       break;
+               default:
+                       VERIFY(strHelp.LoadString(IDS_CONTEXT_HELP));
+                       break;
+               }
        }
        return strHelp;
 }
+
+/// Format commandline used to start WinMerge
+CString CWinMergeShell::FormatCmdLine(const CString &winmergePath,
+       const CString &path1, const CString &path2)
+{
+       CString strCommandline = winmergePath;
+       BOOL bOnlyFiles = FALSE;
+       
+       if (!path1.IsEmpty() && !path2.IsEmpty())
+       {
+               CFileStatus status;
+               CFileStatus status2;
+               if (CFile::GetStatus(path1, status) &&
+                       CFile::GetStatus(path2, status2))
+               {
+                       // Check if both paths are files
+                       if ((status.m_attribute & CFile::Attribute::directory) == 0 &&
+                               (status2.m_attribute & CFile::Attribute::directory) == 0)
+                       {
+                               bOnlyFiles = TRUE;
+                       }
+               }
+       }
+
+       strCommandline += _T(" \"") +
+               path1 + _T("\"");
+       
+       if (!m_strPaths[1].IsEmpty())
+               strCommandline += _T(" \"") + path2 + _T("\"");
+
+       return strCommandline;
+}
index 3a5948b..a1d69c4 100644 (file)
@@ -70,6 +70,8 @@ protected:
        int DrawSimpleMenu(HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd);
        int DrawAdvancedMenu(HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd);
        CString GetHelpText(int idCmd);
+       CString FormatCmdLine(const CString &winmergePath,
+               const CString &path1, const CString &path2);
 
 public:
     // IShellExtInit
index f396792..c3b91a5 100644 (file)
@@ -1,3 +1,8 @@
+2005-08-16 Kimmo
+ PATCH: [ 1258270 ] ShellExtension: allow re-selecting first item
+  ShellExtension: Resource.h ShellExtension.rc WinMergeShell.cpp WinMergeShell.h
+  ShellExtension/Languages: *.rc
+
 2005-08-14 Kimmo
  PATCH: [ 1255864 ] Different icons for Folder and File Comparison
   Icon submitted by Tim