Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.4rc1, 0.4rc2, and 0.4rc3

hggtk/thgconfig: add new data to drop-down lists

Changeset 56b35d77b290

Parent ed9d23a42197

by TK Soh

Changes to one file · Browse files at 56b35d77b290 Showing diff from parent ed9d23a42197 Diff from another changeset...

 
290
291
292
 
293
294
295
 
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
 
484
485
486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
488
489
 
563
564
565
 
 
566
567
568
 
290
291
292
293
294
295
296
 
423
424
425
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426
427
428
 
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
 
570
571
572
573
574
575
576
577
@@ -290,6 +290,7 @@
    # Force dialog into clean state in the beginning   self._btn_apply.set_sensitive(False) + self._refresh_vlist()   self.dirty = False     def _delete(self, widget, event): @@ -422,57 +423,6 @@
  combo.set_row_separator_func(lambda model, iter: model[iter][1])   widgets.append(combo)   - # Get currently configured value from this config file - curvalue = self.get_ini_config(cpath) - - if cpath == 'tortoisehg.vdiff': - # Special case, add extdiff.cmd.* to possible values - for name, value in self.ui.configitems('extdiff'): - if name.startswith('cmd.'): - values.append(name[4:]) - elif cpath == 'ui.merge': - # Special case, add [merge-tools] to possible values - try: - from mercurial import filemerge - tools = [] - for key, value in self.ui.configitems('merge-tools'): - t = key.split('.')[0] - if t not in tools: - tools.append(t) - for t in tools: - # Ensure the tool is installed - if filemerge._findtool(self.ui, t): - values.append(t) - except ImportError: - pass - - currow = None - vlist.append([_unspecstr, False]) - if values: - vlist.append(['Suggested', True]) - for v in values: - vlist.append([v, False]) - if v == curvalue: - currow = len(vlist) - 1 - if cpath in self.history.get_keys(): - separator = False - for v in self.history.mrul(cpath): - if v in values: continue - if not separator: - vlist.append(['History', True]) - separator = True - vlist.append([v, False]) - if v == curvalue: - currow = len(vlist) - 1 - - if curvalue is None: - combo.set_active(0) - elif currow is None: - combo.child.set_text(curvalue) - else: - combo.set_active(currow) - -   lbl = gtk.Label(label + ':')   lbl.set_alignment(1.0, 0.0)   eventbox = gtk.EventBox() @@ -484,6 +434,63 @@
  self.pages.append((vbox, info, widgets))   return vbox   + def _refresh_vlist(self): + for vbox, info, widgets in self.pages: + for row, (label, cpath, values, tooltip) in enumerate(info): + combo = widgets[row] + vlist = combo.get_model() + vlist.clear() + + # Get currently configured value from this config file + curvalue = self.get_ini_config(cpath) + + if cpath == 'tortoisehg.vdiff': + # Special case, add extdiff.cmd.* to possible values + for name, value in self.ui.configitems('extdiff'): + if name.startswith('cmd.') and name[4:] not in values: + values.append(name[4:]) + elif cpath == 'ui.merge': + # Special case, add [merge-tools] to possible values + try: + from mercurial import filemerge + tools = [] + for key, value in self.ui.configitems('merge-tools'): + t = key.split('.')[0] + if t not in tools: + tools.append(t) + for t in tools: + # Ensure the tool is installed + if filemerge._findtool(self.ui, t): + values.append(t) + except ImportError: + pass + + currow = None + vlist.append([_unspecstr, False]) + if values: + vlist.append(['Suggested', True]) + for v in values: + vlist.append([v, False]) + if v == curvalue: + currow = len(vlist) - 1 + if cpath in self.history.get_keys(): + separator = False + for v in self.history.mrul(cpath): + if v in values: continue + if not separator: + vlist.append(['History', True]) + separator = True + vlist.append([v, False]) + if v == curvalue: + currow = len(vlist) - 1 + + if curvalue is None: + combo.set_active(0) + elif currow is None: + combo.child.set_text(curvalue) + else: + combo.set_active(currow) +   def add_page(self, notebook, tab):   frame = gtk.Frame()   frame.set_border_width(10) @@ -563,6 +570,8 @@
  self.record_new_value(cpath, newvalue)     self.history.write() + self._refresh_vlist() +   try:   f = open(self.fn, "w")   f.write(str(self.ini))