Commits

Wagner Bruna committed 1320387

cmenu: config option for menu behavior outside repositories

Makes the behavior introduced by 117befc5cb56 (hide the context
menu outside repositories) configurable.

Refs #1698

  • Participants
  • Parent commits b5c83a9
  • Branches stable

Comments (0)

Files changed (2)

File tortoisehg/hgtk/shellconf.py

         subbutton.connect('clicked', self.sub_clicked)
         mbbox.add(subbutton)
 
+        # menu behavior group
+        mbframe = gtk.Frame(_('Menu Behavior'))
+        mbframe.set_border_width(2)
+        cmenuvbox.pack_start(mbframe, True, True, 2)
+
+        mbbox = gtk.VBox()
+        mbframe.add(mbbox)
+        hbox = gtk.HBox()
+        mbbox.pack_start(hbox, False, False, 2)
+        self.hide_context_menu = gtk.CheckButton(_('Hide context menu outside repositories'))
+        hbox.pack_start(self.hide_context_menu, False, False, 2)
+
         # Icons page
         iconsframe = self.add_page(notebook, _('Icons'))
         iconsvbox = gtk.VBox()
         # Tooltips
         tips = gtklib.Tooltips()
 
+        tooltip = _('Do not show menu items on unversioned folders' 
+                    ' (use shift + click to override)')
+        tips.set_tip(self.hide_context_menu, tooltip)
         tooltip = _('Show overlay icons in Mercurial repositories')
         tips.set_tip(self.ovenable, tooltip)
         self.ovenable.connect('toggled', self.ovenable_toggled)
         return frame
 
     def load_shell_configs(self):
+        hide_context_menu = False
         overlayenable = True
         localdisks = False
         promoteditems = 'commit'
             from _winreg import HKEY_CURRENT_USER, OpenKey, QueryValueEx
             hkey = OpenKey(HKEY_CURRENT_USER, r'Software\TortoiseHg')
             t = ('1', 'True')
+            try: hide_context_menu = QueryValueEx(hkey, 'HideMenuOutsideRepo')[0] in t
+            except EnvironmentError: pass
             try: overlayenable = QueryValueEx(hkey, 'EnableOverlays')[0] in t
             except EnvironmentError: pass
             try: localdisks = QueryValueEx(hkey, 'LocalDisksOnly')[0] in t
         except (ImportError, WindowsError):
             pass
 
+        self.hide_context_menu.set_active(hide_context_menu)
         self.ovenable.set_active(overlayenable)
         self.lclonly.set_active(localdisks)
         self.lclonly.set_sensitive(overlayenable)
         self.topmmodel.set_sort_column_id(1, gtk.SORT_ASCENDING)
 
     def store_shell_configs(self):
+        hide_context_menu = self.hide_context_menu.get_active() and '1' or '0'
         overlayenable = self.ovenable.get_active() and '1' or '0'
         localdisks = self.lclonly.get_active() and '1' or '0'
         show_taskbaricon = self.show_taskbaricon.get_active() and '1' or '0'
         try:
             from _winreg import HKEY_CURRENT_USER, CreateKey, SetValueEx, REG_SZ, REG_DWORD
             hkey = CreateKey(HKEY_CURRENT_USER, r"Software\TortoiseHg")
+            SetValueEx(hkey, 'HideMenuOutsideRepo', 0, REG_SZ, hide_context_menu)
             SetValueEx(hkey, 'EnableOverlays', 0, REG_SZ, overlayenable)
             SetValueEx(hkey, 'LocalDisksOnly', 0, REG_SZ, localdisks)
             SetValueEx(hkey, 'ShowTaskbarIcon', 0, REG_SZ, show_taskbaricon)

File win32/shellext/CShellExtCMenu.cpp

         /* shift key is not down */
         if (!isHgrepo)
         {
-            /* We are not inside a repo -> don't show thg menu entries */
-            return S_OK;
+            std::string cval;
+            if (GetRegistryConfig("HideMenuOutsideRepo", cval) != 0 && cval == "1")
+            {
+                /* We are not inside a repo -> don't show thg menu entries */
+                return S_OK;
+            }
         }
     }