by
Changes to 3 files · Browse files at 3ae8a1d473ea Showing diff from parent b1f71cfb8602 857ca9bc6f4d Diff from another changeset...
@@ -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
|
|
|
|
@@ -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)
|
Loading...