Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.9, 0.9.1, and 0.9.1.1

thgmq: add 'gproperties' for changing column view from others

Changeset 9cb48e3799f4

Parent 3fbd9ed3012a

by Yuki KODAMA

Changes to one file · Browse files at 9cb48e3799f4 Showing diff from parent 3fbd9ed3012a Diff from another changeset...

Change 1 of 5 Show Entire File hggtk/​thgmq.py Stacked
 
27
28
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
31
32
 
127
128
129
 
130
131
132
 
188
189
190
191
 
192
193
194
 
494
495
496
497
 
498
499
500
501
 
 
 
 
 
502
503
504
505
 
506
507
508
509
510
511
512
513
514
515
 
 
 
 
 
 
516
517
518
 
531
532
533
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
535
536
 
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
 
155
156
157
158
159
160
161
 
217
218
219
 
220
221
222
223
 
523
524
525
 
526
527
528
529
 
530
531
532
533
534
535
536
537
 
538
539
540
541
542
543
 
 
 
 
 
544
545
546
547
548
549
550
551
552
 
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
@@ -27,6 +27,34 @@
   class MQWidget(gtk.HBox):   + __gproperties__ = { + 'index-column-visible': (gobject.TYPE_BOOLEAN, + 'Index', + 'Show index column', + False, + gobject.PARAM_READWRITE), + 'name-column-visible': (gobject.TYPE_BOOLEAN, + 'Name', + 'Show name column', + False, + gobject.PARAM_READWRITE), + 'summary-column-visible': (gobject.TYPE_BOOLEAN, + 'Summary', + 'Show summary column', + False, + gobject.PARAM_READWRITE), + 'editable-cell': (gobject.TYPE_BOOLEAN, + 'EditableCell', + 'Enable editable cells', + False, + gobject.PARAM_READWRITE), + 'show-qparent': (gobject.TYPE_BOOLEAN, + 'ShowQParent', + "Show 'qparent'", + False, + gobject.PARAM_READWRITE) + } +   __gsignals__ = {   'repo-invalidated': (gobject.SIGNAL_RUN_FIRST,   gobject.TYPE_NONE, @@ -127,6 +155,7 @@
  col.add_attribute(cell, 'text', col_idx)   col.set_cell_data_func(cell, self.cell_data_func)   col.set_resizable(resizable) + col.set_visible(self.get_property(self.col_to_prop(col_idx)))   if right:   col.set_alignment(1)   cell.set_property('xalign', 1) @@ -188,7 +217,7 @@
    # insert 'qparent' row   top = None - if self.qparent_item.get_active(): + if self.get_property('show-qparent'):   top = model.append((INDEX_QPARENT, None, None, None))     # add patches @@ -494,25 +523,30 @@
  item.connect('activate', handler)   menu.append(item)   return item - def colappend(label, col_idx): + def colappend(label, col_idx, active=True):   def handler(menuitem):   col = self.cols[col_idx]   col.set_visible(menuitem.get_active()) - item = append(label, handler, check=True, active=True) + propname = self.col_to_prop(col_idx) + item = append(label, handler, check=True, active=active) + self.vmenu[propname] = item + + self.vmenu = {}     colappend(_('Show index'), MQ_INDEX)   colappend(_('Show name'), MQ_NAME) - colappend(_('Show summary'), MQ_SUMMARY) + colappend(_('Show summary'), MQ_SUMMARY, active=False)     append(sep=True)     def enable_editable(item):   self.cells[MQ_NAME].set_property('editable', item.get_active()) - append(_('Enable editable cells'), enable_editable, check=True) - def show_qparent(item): - self.refresh() - self.qparent_item = append(_("Show 'qparent'"), - show_qparent, check=True) + item = append(_('Enable editable cells'), enable_editable, + check=True, active=False) + self.vmenu['editable-cell'] = item + item = append(_("Show 'qparent'"), lambda item: self.refresh(), + check=True, active=True) + self.vmenu['show-qparent'] = item     menu.show_all()   return menu @@ -531,6 +565,27 @@
  if not noemit:   self.emit('repo-invalidated')   + def do_get_property(self, property): + try: + return self.vmenu[property.name].get_active() + except: + raise AttributeError, 'unknown property %s' % property.name + + def do_set_property(self, property, value): + try: + self.vmenu[property.name].set_active(value) + except: + raise AttributeError, 'unknown property %s' % property.name + + def col_to_prop(self, col_idx): + if col_idx == MQ_INDEX: + return 'index-column-visible' + elif col_idx == MQ_NAME: + return 'name-column-visible' + elif col_idx == MQ_SUMMARY: + return 'summary-column-visible' + return '' +   ### signal handlers ###     def list_pressed(self, list, event):