Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

taskbarui: add shell extension configurations

Changeset 228a8b9b29fc

Parent 35da5d117b02

by Steve Borho

Changes to one file · Browse files at 228a8b9b29fc Showing diff from parent 35da5d117b02 Diff from another changeset...

 
12
13
14
 
 
 
 
15
16
17
 
20
21
22
23
 
24
25
 
 
 
 
26
27
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
30
31
 
47
48
49
50
51
52
53
54
55
 
 
 
 
56
57
58
 
76
77
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
13
14
15
16
17
18
19
20
21
 
24
25
26
 
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
 
114
115
116
 
117
 
118
119
 
120
121
122
123
124
125
126
 
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
@@ -12,6 +12,10 @@
 from thgutil import hglib, settings  from hggtk import gtklib   +shellcmds = '''about add clone commit datamine init log recovery +shelve synch status thgstatus userconfig repoconfig guess remove rename +revert serve update vdiff'''.split() +  class TaskBarUI(gtk.Window):   'User interface for the TortoiseHg taskbar application'   def __init__(self, inputq, requestq): @@ -20,12 +24,75 @@
  gtklib.set_tortoise_icon(self, 'hg.ico')   gtklib.set_tortoise_keys(self)   - self.set_default_size(500, 220) + self.set_default_size(500, 420)   self.set_title(_('TortoiseHg Taskbar'))   + about = gtk.Button(_('About')) + apply = gtk.Button(_('Apply')) + close = gtk.Button(_('Close')) +   vbox = gtk.VBox()   self.add(vbox)   + ovframe = gtk.Frame(_('Overlay configuration')) + ovframe.set_border_width(10) + vbox.pack_start(ovframe, False, False, 2) + ovcvbox = gtk.VBox() + ovframe.add(ovcvbox) + hbox = gtk.HBox() + ovcvbox.pack_start(hbox, False, False, 2) + self.ovenable = gtk.CheckButton(_('Enable overlays')) + hbox.pack_start(self.ovenable, False, False, 2) + self.lclonly = gtk.CheckButton(_('Local disks only')) + hbox.pack_start(self.lclonly, False, False, 2) + + cmframe = gtk.Frame(_('Context menu configuration')) + cmframe.set_border_width(10) + vbox.pack_start(cmframe, False, False, 2) + cmcvbox = gtk.VBox() + cmframe.add(cmcvbox) + + descframe = gtk.Frame(_('Description')) + descframe.set_border_width(10) + desctext = gtk.TextView() + desctext.set_wrap_mode(gtk.WRAP_WORD) + desctext.set_editable(False) + desctext.set_sensitive(False) + scrolledwindow = gtk.ScrolledWindow() + scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + scrolledwindow.add(desctext) + descframe.add(scrolledwindow) + vbox.pack_start(gtk.Label(), True, True, 2) + vbox.pack_start(descframe, False, False, 2) + + lbl = gtk.Label(_('Promote menu items to the top menu')) + cmcvbox.pack_start(lbl, False, False, 2) + + rows = (len(shellcmds) + 2) / 3 + table = gtk.Table(rows, 3, False) + cmcvbox.pack_start(table, False, False, 2) + self.cmptoggles = {} + for i, cmd in enumerate(shellcmds): + row, col = divmod(i, 3) + check = gtk.CheckButton(cmd) + table.attach(check, col, col+1, + row, row+1, gtk.FILL|gtk.EXPAND, 0, 4, 3) + self.cmptoggles[cmd] = check + tooltip = _('Promote menu item "%s" to top menu') % cmd + check.connect('toggled', lambda x: apply.set_sensitive(True)) + check.connect('focus-in-event', self.set_help, + desctext.get_buffer(), tooltip) + + tooltip = _('Enable/Disable the overlay icons globally') + self.ovenable.connect('focus-in-event', self.set_help, + desctext.get_buffer(), tooltip) + self.ovenable.connect('toggled', self.ovenable_toggled, apply) + tooltip = _('Only enable overlays on local disks') + self.lclonly.connect('toggled', lambda x: apply.set_sensitive(True)) + self.lclonly.connect('focus-in-event', self.set_help, + desctext.get_buffer(), tooltip) + self.load_shell_configs() +   frame = gtk.Frame(_('Event Log'))   frame.set_border_width(2)   vbox.pack_start(frame, True, True, 2) @@ -47,12 +114,13 @@
  hbbox.set_layout(gtk.BUTTONBOX_END)   vbox.pack_start(hbbox, False, False, 2)   - about = gtk.Button(_('About'))   about.connect('clicked', self.about) - key, modifier = gtk.accelerator_parse('Escape')   hbbox.add(about)   - close = gtk.Button(_('Close')) + apply.connect('clicked', self.applyclicked) + apply.set_sensitive(False) + hbbox.add(apply) +   close.connect('clicked', lambda x: self.destroy())   key, modifier = gtk.accelerator_parse('Escape')   close.add_accelerator('clicked', accelgroup, key, 0, @@ -76,3 +144,51 @@
  except Queue.Empty:   pass   return True + + def load_shell_configs(self): + overlayenable = True + localdisks = False + promoteditems = 'commit' + try: + from _winreg import HKEY_CURRENT_USER, OpenKey, QueryValueEx + hkey = OpenKey(HKEY_CURRENT_USER, r'Software\TortoiseHg') + t = ('1', 'True') + try: overlayenable = QueryValueEx(hkey, 'EnableOverlays')[0] in t + except EnvironmentError: pass + try: localdisks = QueryValueEx(hkey, 'LocalDisksOnly')[0] in t + except EnvironmentError: pass + try: promoteditems = QueryValueEx(hkey, 'PromotedItems')[0] + except EnvironmentError: pass + except (ImportError, WindowsError): + pass + + self.ovenable.set_active(overlayenable) + self.lclonly.set_active(localdisks) + promoted = [pi.strip() for pi in promoteditems.split(',')] + for cmd, check in self.cmptoggles.iteritems(): + check.set_active(cmd in promoted) + + def applyclicked(self, button): + overlayenable = self.ovenable.get_active() and '1' or '0' + localdisks = self.lclonly.get_active() and '1' or '0' + promoted = [] + for cmd, check in self.cmptoggles.iteritems(): + if check.get_active(): + promoted.append(cmd) + try: + from _winreg import HKEY_CURRENT_USER, CreateKey, SetValueEx, REG_SZ + hkey = CreateKey(HKEY_CURRENT_USER, r"Software\TortoiseHg") + SetValueEx(hkey, 'EnableOverlays', 0, REG_SZ, overlayenable) + SetValueEx(hkey, 'LocalDisksOnly', 0, REG_SZ, localdisks) + SetValueEx(hkey, 'PromotedItems', 0, REG_SZ, ','.join(promoted)) + except ImportError: + pass + button.set_sensitive(False) + + def set_help(self, widget, event, buffer, tooltip): + text = ' '.join(tooltip.splitlines()) + buffer.set_text(text) + + def ovenable_toggled(self, check, apply): + self.lclonly.set_sensitive(check.get_active()) + apply.set_sensitive(True)