Changeset e7059ffc48ae…
Parent 9137e5c9bd56…
by
Changes to 2 files · Browse files at e7059ffc48ae Showing diff from parent 9137e5c9bd56 Diff from another changeset...
|
@@ -9,11 +9,12 @@ import gobject
from thgutil.i18n import _
+from thgutil import hglib, settings
from hggtk import gtklib
class TaskBarUI(gtk.Window):
'User interface for the TortoiseHg taskbar application'
- def __init__(self, inputq):
+ def __init__(self, inputq, requestq):
'Initialize the Dialog'
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
gtklib.set_tortoise_icon(self, 'hg.ico')
@@ -25,6 +26,48 @@ vbox = gtk.VBox()
self.add(vbox)
+ frame = gtk.Frame(_('Exclude Paths'))
+ frame.set_border_width(2)
+ vbox.pack_start(frame, True, True, 2)
+
+ tree = gtk.TreeView()
+ tree.get_selection().set_mode(gtk.SELECTION_SINGLE)
+ tree.set_enable_search(False)
+ tree.set_reorderable(False)
+ cell = gtk.CellRendererText()
+ cell.set_property('editable', True)
+ col = gtk.TreeViewColumn(_('Paths'), cell, text=0)
+ tree.append_column(col)
+ win = gtk.ScrolledWindow()
+ win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ win.set_border_width(4)
+ win.add(tree)
+ model = gtk.ListStore(str)
+ tree.set_model(model)
+ tree.set_headers_visible(False)
+
+ fvbox = gtk.VBox()
+ fvbox.pack_start(win, True, True, 2)
+ bhbox = gtk.HBox()
+ apply = gtk.Button(_('Apply'))
+ add = gtk.Button(_('Add'))
+ delete = gtk.Button(_('Del'))
+ apply.connect('clicked', self.applyclicked, model, requestq)
+ add.connect('clicked', self.addclicked, model, apply)
+ delete.connect('clicked', self.delclicked, tree, apply)
+ cell.connect('edited', self.edited, model, apply)
+ bhbox.pack_start(add, False, False, 2)
+ bhbox.pack_start(delete, False, False, 2)
+ bhbox.pack_end(apply, False, False, 2)
+ fvbox.pack_start(bhbox, False, False, 2)
+ fvbox.set_border_width(2)
+ frame.add(fvbox)
+
+ apply.set_sensitive(False)
+ set = settings.Settings('taskbar')
+ for path in set.get_value('excludes', []):
+ model.append([hglib.toutf(path)])
+
frame = gtk.Frame(_('Event Log'))
frame.set_border_width(2)
vbox.pack_start(frame, True, True, 2)
@@ -63,6 +106,33 @@ dlg = about.AboutDialog()
dlg.show_all()
+ def applyclicked(self, button, model, requests):
+ 'apply button clicked'
+ paths = [hglib.fromutf(r[0]) for r in model]
+ set = settings.Settings('taskbar')
+ set.set_value('excludes', paths)
+ set.write()
+ button.set_sensitive(False)
+ requests.put('load-config')
+
+ def edited(self, cell, path, new_text, model, applybutton):
+ dirty = model[path][0] != new_text
+ model[path][0] = new_text
+ if dirty:
+ applybutton.set_sensitive(True)
+
+ def addclicked(self, button, model, applybutton):
+ 'add button clicked'
+ model.append(['C:\\'])
+ applybutton.set_sensitive(True)
+
+ def delclicked(self, button, tree, applybutton):
+ 'delete button clicked'
+ model, pathlist = tree.get_selection().get_selected_rows()
+ if pathlist:
+ del model[pathlist[0]]
+ applybutton.set_sensitive(True)
+
def pollq(self, queue, textview):
'Poll the input queue'
buf = textview.get_buffer()
|
|
|
@@ -22,7 +22,7 @@ demandimport.ignore.append('win32com.shell')
demandimport.enable()
from mercurial import ui
-from thgutil import thread2, paths, shlib
+from thgutil import thread2, paths, shlib, settings
APP_TITLE = "TortoiseHg RPC server"
@@ -152,7 +152,7 @@ def launch():
import gtk
from hggtk import taskbarui, hgtk
- dlg = taskbarui.TaskBarUI(logq)
+ dlg = taskbarui.TaskBarUI(logger.getqueue(), requests)
dlg.show_all()
dlg.connect('destroy', gtk.main_quit)
self.dialog = dlg
@@ -160,6 +160,7 @@ gtk.gdk.threads_enter()
gtk.main()
gtk.gdk.threads_leave()
+ logger.reset()
self.guithread = thread2.Thread(target=launch)
self.guithread.start()
@@ -178,11 +179,26 @@
PIPEBUFSIZE = 4096
-logq = Queue.Queue(0)
-def logmsg(msg):
- if logq.qsize() < 100:
+class Logger():
+ def __init__(self):
+ self.q = None
+
+ def getqueue(self):
+ self.q = Queue.Queue()
+ return self.q
+
+ def reset(self):
+ self.q = None
+
+ def msg(self, msg):
ts = '[%s] ' % time.strftime('%c')
- logq.put(ts + msg)
+ if self.q:
+ self.q.put(ts + msg)
+ print 'L' + ts + msg
+ else:
+ print ts + msg
+
+logger = Logger()
def getrepos(batch):
roots = set()
@@ -210,16 +226,16 @@ try:
shlib.update_thgstatus(_ui, r, wait=False)
shlib.shell_notify([r])
- logmsg('Updated ' + r)
+ logger.msg('Updated ' + r)
except IOError:
print "IOError on updating %s (check permissions)" % r
- logmsg('Failed updating %s (check permissions)' % r)
+ logger.msg('Failed updating %s (check permissions)' % r)
failedroots.add(r)
notifypaths -= failedroots
if notifypaths:
time.sleep(2)
shlib.shell_notify(list(notifypaths))
- logmsg('Shell notified')
+ logger.msg('Shell notified')
requests = Queue.Queue(0)
@@ -251,7 +267,7 @@
def remove(args):
path = args[0]
- logmsg('Removing ' + path)
+ logger.msg('Removing ' + path)
roots, notifypaths = getrepos([path])
if roots:
for r in sorted(roots):
@@ -269,18 +285,34 @@ elif cmd == 'remove':
remove(args)
else:
- logmsg("Error: unknown request '%s'" % req)
+ logger.msg("Error: unknown request '%s'" % req)
class Updater(threading.Thread):
def run(self):
+ excludes = []
while True:
req = requests.get()
s = req.split('|')
cmd, args = s[0], s[1:]
if cmd == 'terminate':
- logmsg('Updater thread terminating')
+ logger.msg('Updater thread terminating')
return
- dispatch(req, cmd, args)
+ if cmd == 'load-config':
+ logger.msg('Loading configuration')
+ set = settings.Settings('taskbar')
+ excludes = set.get_value('excludes', [])
+ for p in excludes:
+ logger.msg(' exclude: %s' % p)
+ continue
+ ignored = False
+ for arg in args:
+ for e in excludes:
+ if arg.startswith(e):
+ logger.msg('%s command ignored in %s' % (cmd, e))
+ ignored = True
+ break
+ if not ignored:
+ dispatch(req, cmd, args)
gc.collect()
Updater().start()
@@ -299,6 +331,9 @@ # And create an event to be used in the OVERLAPPED object.
self.overlapped.hEvent = win32event.CreateEvent(None,0,0,None)
+ # Make updater load exclude masks
+ requests.put('load-config')
+
def SvcStop(self):
print 'PipeServer thread terminating'
win32event.SetEvent(self.hWaitStop)
|
Loading...