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

history: provide method for user to change column order

Changeset 14f9ae5699c1

Parent 6f5b11cd6a37

by Adrian Buehlmann

Changes to 2 files · Browse files at 14f9ae5699c1 Showing diff from parent 6f5b11cd6a37 Diff from another changeset...

 
39
40
41
42
 
 
 
 
 
 
 
 
 
43
44
45
 
67
68
69
70
 
 
 
 
 
 
 
 
 
71
72
73
74
75
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
78
79
 
39
40
41
 
42
43
44
45
46
47
48
49
50
51
52
53
 
75
76
77
 
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
@@ -39,7 +39,15 @@
  hbox.pack_start(lb, False, False, 4)   self.vbox.pack_start(hbox, False, False, 4)   - tv = gtk.TreeView(model) + mainhbox = gtk.HBox() + self.vbox.pack_start(mainhbox) + + leftvbox = gtk.VBox() + rightvox = gtk.VBox() + mainhbox.pack_start(leftvbox, True, True) + mainhbox.pack_start(rightvox, False, False) + + tv = self.tv = gtk.TreeView(model)   tv.set_headers_visible(False)     cr = gtk.CellRendererToggle() @@ -67,13 +75,45 @@
  vbox.set_border_width(4)   vbox.pack_start(tv)   - self.vbox.pack_start(vbox, True, True) + leftvbox.pack_start(vbox, True, True) + + self.up_button = gtk.ToolButton(gtk.STOCK_GO_UP) + self.up_button.connect('clicked', self.up_clicked) + self.down_button = gtk.ToolButton(gtk.STOCK_GO_DOWN) + self.down_button.connect('clicked', self.down_clicked) + + rightvox.pack_start(self.up_button, False, False) + rightvox.pack_start(self.down_button, False, False)     self.show_all()     def update_buttons(self):   self._btn_apply.set_sensitive(self.dirty)   + def up_clicked(self, button): + model, seliter = self.tv.get_selection().get_selected() + i = model.get_iter_first() + if model.get_path(seliter) == model.get_path(i): + return + while True: + next = model.iter_next(i) + if next == None: + return + if model.get_path(next) == model.get_path(seliter): + model.swap(i, next) + self._btn_apply.set_sensitive(True) + self.dirty = True + return + i = next + + def down_clicked(self, button): + model, seliter = self.tv.get_selection().get_selected() + next = model.iter_next(seliter) + if next: + model.swap(seliter, next) + self._btn_apply.set_sensitive(True) + self.dirty = True +   def _btn_apply_clicked(self, button, data=None):   self.apply_func()   self.dirty = False
 
247
248
249
250
251
 
 
252
253
254
 
255
256
257
258
259
260
261
262
263
264
265
266
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
268
269
 
273
274
275
 
 
 
 
276
277
 
278
279
280
 
247
248
249
 
 
250
251
252
 
 
253
254
255
 
 
 
 
 
 
 
 
 
 
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
 
283
284
285
286
287
288
289
290
 
291
292
293
294
@@ -247,23 +247,33 @@
  def close(dialog, response_id):   dialog.destroy()   - model = gtk.ListStore( - gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING) + columns = {} + columns['graph'] = (self.graphcol, _('Graph'), 'graphcol', 'graph')   - model.append([self.graphcol, _('Graph'), 'graphcol']) - def column(col, default, text): + def column(col, text):   prop = col + '-column-visible'   vis = self.graphview.get_property(prop) - model.append([vis, text, prop]) - column('rev', True, _('Revision Number')) - column('id', False, _('Changeset ID')) - column('branch', False, _('Branch Name')) - column('msg', True, _('Summary')) - column('user', True, _('User')) - column('date', False, _('Local Date')) - column('utc', False, _('UTC Date')) - column('age', True, _('Age')) - column('tag', False, _('Tags')) + columns[col] = (vis, text, prop, col) + + column('rev', _('Revision Number')) + column('id', _('Changeset ID')) + column('branch', _('Branch Name')) + column('msg', _('Summary')) + column('user', _('User')) + column('date', _('Local Date')) + column('utc', _('UTC Date')) + column('age', _('Age')) + column('tag', _('Tags')) + + model = gtk.ListStore( + gobject.TYPE_BOOLEAN, + gobject.TYPE_STRING, + gobject.TYPE_STRING, + gobject.TYPE_STRING) + + for c in self.graphview.get_columns(): + vis, text, prop, col = columns[c] + model.append([vis, text, prop, col])     self.details_model = model   @@ -273,8 +283,12 @@
    def apply_details(self):   if self.details_model: + columns = [] + for show, uitext, property, colname in self.details_model: + columns.append(colname) + self.graphview.set_columns(columns)   reload = False - for show, uitext, property in self.details_model: + for show, uitext, property, colname in self.details_model:   if property == 'graphcol':   if self.graphcol != show:   self.graphcol = show