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

merge

Changeset 3ae8a1d473ea

Parents b1f71cfb8602

Parents 857ca9bc6f4d

by Steve Borho

Changes to 3 files · Browse files at 3ae8a1d473ea Showing diff from parent b1f71cfb8602 857ca9bc6f4d Diff from another changeset...

 
82
83
84
 
 
 
 
 
 
 
 
 
 
85
86
87
88
89
90
 
 
 
 
 
91
92
93
 
153
154
155
 
156
157
158
 
161
162
163
 
 
164
165
166
 
168
169
170
 
171
172
173
 
175
176
177
 
178
179
180
 
184
185
186
 
187
188
189
 
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
 
168
169
170
171
172
173
174
 
177
178
179
180
181
182
183
184
 
186
187
188
189
190
191
192
 
194
195
196
197
198
199
200
 
204
205
206
207
208
209
210
@@ -82,12 +82,27 @@
  tips.set_tip(check, tooltip)   check.connect('toggled', lambda x: apply.set_sensitive(True))   + taskbarframe = gtk.Frame(_('Taskbar')) + taskbarframe.set_border_width(2) + settingsvbox.pack_start(taskbarframe, False, False, 2) + taskbarbox = gtk.VBox() + taskbarframe.add(taskbarbox) + hbox = gtk.HBox() + taskbarbox.pack_start(hbox, False, False, 2) + self.hgighlight_taskbaricon = gtk.CheckButton(_('Highlight Icon')) + hbox.pack_start(self.hgighlight_taskbaricon, False, False, 2) +   tooltip = _('Enable/Disable the overlay icons globally')   tips.set_tip(self.ovenable, tooltip)   self.ovenable.connect('toggled', self.ovenable_toggled, apply)   tooltip = _('Only enable overlays on local disks')   tips.set_tip(self.lclonly, tooltip)   self.lclonly.connect('toggled', lambda x: apply.set_sensitive(True)) + + tooltip = _('Highlight the taskbar icon during activity') + tips.set_tip(self.hgighlight_taskbaricon, tooltip) + self.hgighlight_taskbaricon.connect('toggled', lambda x: apply.set_sensitive(True)) +   self.load_shell_configs()     frame = self.add_page(notebook, _('Event Log')) @@ -153,6 +168,7 @@
  overlayenable = True   localdisks = False   promoteditems = 'commit' + hgighlight_taskbaricon = True   try:   from _winreg import HKEY_CURRENT_USER, OpenKey, QueryValueEx   hkey = OpenKey(HKEY_CURRENT_USER, r'Software\TortoiseHg') @@ -161,6 +177,8 @@
  except EnvironmentError: pass   try: localdisks = QueryValueEx(hkey, 'LocalDisksOnly')[0] in t   except EnvironmentError: pass + try: hgighlight_taskbaricon = QueryValueEx(hkey, 'HighlightTaskbarIcon')[0] in t + except EnvironmentError: pass   try: promoteditems = QueryValueEx(hkey, 'PromotedItems')[0]   except EnvironmentError: pass   except (ImportError, WindowsError): @@ -168,6 +186,7 @@
    self.ovenable.set_active(overlayenable)   self.lclonly.set_active(localdisks) + self.hgighlight_taskbaricon.set_active(hgighlight_taskbaricon)   promoted = [pi.strip() for pi in promoteditems.split(',')]   for cmd, check in self.cmptoggles.iteritems():   check.set_active(cmd in promoted) @@ -175,6 +194,7 @@
  def applyclicked(self, button):   overlayenable = self.ovenable.get_active() and '1' or '0'   localdisks = self.lclonly.get_active() and '1' or '0' + hgighlight_taskbaricon = self.hgighlight_taskbaricon.get_active() and '1' or '0'   promoted = []   for cmd, check in self.cmptoggles.iteritems():   if check.get_active(): @@ -184,6 +204,7 @@
  hkey = CreateKey(HKEY_CURRENT_USER, r"Software\TortoiseHg")   SetValueEx(hkey, 'EnableOverlays', 0, REG_SZ, overlayenable)   SetValueEx(hkey, 'LocalDisksOnly', 0, REG_SZ, localdisks) + SetValueEx(hkey, 'HighlightTaskbarIcon', 0, REG_SZ, hgighlight_taskbaricon)   SetValueEx(hkey, 'PromotedItems', 0, REG_SZ, ','.join(promoted))   except ImportError:   pass
Added image
Change 1 of 7 Show Entire File thgtaskbar.py Stacked
 
33
34
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
37
38
 
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
 
171
172
173
174
 
175
176
177
 
243
244
245
246
 
 
 
 
 
 
 
 
 
 
 
 
 
247
248
249
250
251
 
 
 
252
253
254
 
268
269
270
 
 
271
272
273
 
282
283
284
285
 
286
287
288
 
289
290
291
292
293
294
 
 
 
 
295
296
297
 
300
301
302
303
 
304
305
306
 
 
 
 
307
308
309
310
311
312
 
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
 
88
89
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
92
93
94
 
177
178
179
 
180
181
182
183
 
249
250
251
 
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
 
289
290
291
292
293
294
295
296
 
305
306
307
 
308
309
310
 
311
312
313
314
315
316
317
318
319
320
321
322
323
324
 
327
328
329
 
330
331
332
 
333
334
335
336
337
 
 
338
339
340
@@ -33,6 +33,33 @@
 SHOWLOG_CMD = 1023  EXIT_CMD = 1025   +def SetIcon(hwnd, name, add=False): + # Try and find a custom icon + print "SetIcon(%s)" % name + hinst = GetModuleHandle(None) + from thgutil.paths import get_tortoise_icon + iconPathName = get_tortoise_icon(name) + if iconPathName and os.path.isfile(iconPathName): + icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE + hicon = LoadImage(hinst, iconPathName, win32con.IMAGE_ICON, 0, 0, icon_flags) + else: + print "Can't find a Python icon file - using default" + hicon = LoadIcon(0, win32con.IDI_APPLICATION) + + flags = NIF_ICON | NIF_MESSAGE | NIF_TIP + nid = (hwnd, 0, flags, win32con.WM_USER+20, hicon, APP_TITLE) + action = NIM_MODIFY + if add: + action = NIM_ADD + try: + Shell_NotifyIcon(action, nid) + except error: + # This is common when windows is starting, and this code is hit + # before the taskbar has been created. + print "Failed to add the taskbar icon - is explorer running?" + # but keep running anyway - when explorer starts, we get the + # TaskbarCreated message. +  class MainWindow:   def __init__(self):   msg_TaskbarRestart = RegisterWindowMessage("TaskbarCreated"); @@ -61,28 +88,7 @@
  self._DoCreateIcons()     def _DoCreateIcons(self): - # Try and find a custom icon - hinst = GetModuleHandle(None) - from thgutil.paths import get_tortoise_icon - iconPathName = get_tortoise_icon("hg.ico") - if iconPathName and os.path.isfile(iconPathName): - icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE - hicon = LoadImage(hinst, iconPathName, win32con.IMAGE_ICON, 0, 0, icon_flags) - else: - print "Can't find a Python icon file - using default" - hicon = LoadIcon(0, win32con.IDI_APPLICATION) - - flags = NIF_ICON | NIF_MESSAGE | NIF_TIP - nid = (self.hwnd, 0, flags, win32con.WM_USER+20, hicon, APP_TITLE) - try: - Shell_NotifyIcon(NIM_ADD, nid) - except error: - # This is common when windows is starting, and this code is hit - # before the taskbar has been created. - print "Failed to add the taskbar icon - is explorer running?" - # but keep running anyway - when explorer starts, we get the - # TaskbarCreated message. - + SetIcon(self.hwnd, "hg.ico", add=True)   # start namepipe server for hg status   self.start_pipe_server()   @@ -171,7 +177,7 @@
    def start_pipe_server(self):   def servepipe(): - self.svc = PipeServer() + self.svc = PipeServer(self.hwnd)   self.svc.SvcDoRun()     self.pipethread = thread2.Thread(target=servepipe) @@ -243,12 +249,27 @@
   requests = Queue.Queue(0)   -def update(args): +def get_config(): + hgighlight_taskbaricon = True + try: + from _winreg import HKEY_CURRENT_USER, OpenKey, QueryValueEx + hkey = OpenKey(HKEY_CURRENT_USER, r'Software\TortoiseHg') + t = ('1', 'True') + try: hgighlight_taskbaricon = QueryValueEx(hkey, 'HighlightTaskbarIcon')[0] in t + except EnvironmentError: pass + except (ImportError, WindowsError): + pass + return hgighlight_taskbaricon + +def update(args, hwnd):   batch = []   r = args[0]   print "got update request %s (first in batch)" % r   batch.append(r)   print "wait a bit for additional requests..." + highlight = get_config() + if highlight: + SetIcon(hwnd, "hgB.ico")   time.sleep(0.2)   deferred_requests = []   try: @@ -268,6 +289,8 @@
  msg = "processing batch with %i update requests"   print msg % len(batch)   update_batch(batch) + if highlight: + SetIcon(hwnd, "hg.ico")    def remove(args):   path = args[0] @@ -282,16 +305,20 @@
  if notifypaths:   shlib.shell_notify(list(notifypaths))   -def dispatch(req, cmd, args): +def dispatch(req, cmd, args, hwnd):   print "dispatch(%s)" % req   if cmd == 'update': - update(args) + update(args, hwnd)   elif cmd == 'remove':   remove(args)   else:   logger.msg("Error: unknown request '%s'" % req)    class Updater(threading.Thread): + def __init__(self, hwnd): + threading.Thread.__init__(self) + self.hwnd = hwnd +   def run(self):   while True:   req = requests.get() @@ -300,13 +327,14 @@
  if cmd == 'terminate':   logger.msg('Updater thread terminating')   return - dispatch(req, cmd, args) + dispatch(req, cmd, args, self.hwnd)   gc.collect()   -Updater().start() +class PipeServer: + def __init__(self, hwnd): + self.updater = Updater(hwnd) + self.updater.start()   -class PipeServer: - def __init__(self):   # Create an event which we will use to wait on.   # The "service stop" request will set this event.   self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)