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

taskbar: add exclude path functionality

Changeset e7059ffc48ae

Parent 9137e5c9bd56

by Steve Borho

Changes to 2 files · Browse files at e7059ffc48ae Showing diff from parent 9137e5c9bd56 Diff from another changeset...

 
9
10
11
 
12
13
14
15
16
 
17
18
19
 
25
26
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
29
30
 
63
64
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
67
68
 
9
10
11
12
13
14
15
16
 
17
18
19
20
 
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
 
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
@@ -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()
Change 1 of 8 Show Entire File taskbar.py Stacked
 
22
23
24
25
 
26
27
28
 
152
153
154
155
 
156
157
158
 
160
161
162
 
163
164
165
 
178
179
180
181
182
183
 
 
 
 
 
 
 
 
 
 
 
 
184
185
 
 
 
 
 
 
 
186
187
188
 
210
211
212
213
 
214
215
216
 
217
218
219
220
221
222
 
223
224
225
 
251
252
253
254
 
255
256
257
 
269
270
271
272
 
273
274
275
 
276
277
278
279
280
281
 
282
283
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
285
286
 
299
300
301
 
 
 
302
303
304
 
22
23
24
 
25
26
27
28
 
152
153
154
 
155
156
157
158
 
160
161
162
163
164
165
166
 
179
180
181
 
 
 
182
183
184
185
186
187
188
189
190
191
192
193
194
 
195
196
197
198
199
200
201
202
203
204
 
226
227
228
 
229
230
231
 
232
233
234
235
236
237
 
238
239
240
241
 
267
268
269
 
270
271
272
273
 
285
286
287
 
288
289
290
291
292
293
294
295
296
297
 
298
299
 
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
 
331
332
333
334
335
336
337
338
339
@@ -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)