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

histdetails: use standard buttons

Changeset 22fa91441ef3

Parent 9dcecf4c8975

by Adrian Buehlmann

Changes to 2 files · Browse files at 22fa91441ef3 Showing diff from parent 9dcecf4c8975 Diff from another changeset...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
 
21
22
23
24
25
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
74
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
 
134
135
136
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
18
 
19
20
21
22
23
24
25
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
74
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
 
143
144
145
146
 # histdetails.py - TortoiseHg dialog for defining log viewing details  #  # Copyright 2009 Adrian Buehlmann <adrian@cadifra.com>  #  # This software may be used and distributed according to the terms of the  # GNU General Public License version 2, incorporated herein by reference.    import gtk  import gobject    from tortoisehg.util.i18n import _    from tortoisehg.hgtk import gtklib    class LogDetailsDialog(gtk.Dialog):     def __init__(self, model, apply_func): - buttons = (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)   super(LogDetailsDialog, self).__init__( - flags=gtk.DIALOG_MODAL, buttons=buttons) + flags=gtk.DIALOG_MODAL) + self.connect('response', self.dialog_response)     self.apply_func = apply_func   self.dirty = False     gtklib.set_tortoise_icon(self, 'general.ico')   gtklib.set_tortoise_keys(self)   - self._btn_apply = gtk.Button(_('Apply')) - self._btn_apply.set_sensitive(False) - self._btn_apply.connect('clicked', self._btn_apply_clicked) - self.action_area.pack_end(self._btn_apply) + # add dialog buttons + self.okbtn = self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) + self.applybtn = self.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) + self.cancelbtn = self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CLOSE) + self.set_default_response(gtk.RESPONSE_OK)     self.set_title(_('Log Details'))     self.set_default_size(350, 120)     hbox = gtk.HBox()   lb = gtk.Label(_('Columns') + ':')   hbox.pack_start(lb, False, False, 6)   self.vbox.pack_start(gtk.HBox(), False, False, 3)   self.vbox.pack_start(hbox, False, False)     mainhbox = gtk.HBox()   self.vbox.pack_start(mainhbox)     leftvbox = gtk.VBox()   rightvbox = gtk.VBox()   mainhbox.pack_start(leftvbox, True, True)   mainhbox.pack_start(gtk.VBox(), False, False, 0)   mainhbox.pack_start(rightvbox, False, False, 4)     tv = self.tv = gtk.TreeView(model)   tv.set_headers_visible(False)     cr = gtk.CellRendererToggle()   cr.set_property('activatable', True)     def toggled(cell, path):   model[path][0] = not model[path][0]   self.dirty = True   self.update_buttons()     cr.connect('toggled', toggled)     show_col = gtk.TreeViewColumn('', cr, active=0)   tv.append_column(show_col)     cr = gtk.CellRendererText()   info_col = gtk.TreeViewColumn('', cr, text=1)   tv.append_column(info_col)     def activated(treeview, path, column):   toggled(None, path)   tv.connect('row-activated', activated)     frm = gtk.Frame()   frm.add(tv)     vbox = gtk.VBox()   vbox.set_border_width(4)   vbox.pack_start(frm)     leftvbox.pack_start(vbox, True, True)     self.up_button = gtk.Button(_('Move Up'))   self.up_button.connect('clicked', self.up_clicked)     self.down_button = gtk.Button(_('Move Down'))   self.down_button.connect('clicked', self.down_clicked)     rightvbox.pack_start(self.up_button, False, False, 2)   rightvbox.pack_start(self.down_button, False, False, 4)     self.tv.connect('cursor-changed', lambda tv: self.update_buttons())     self.show_all()   + def dialog_response(self, dialog, response_id): + if response_id == gtk.RESPONSE_OK: + self.apply() + self.destroy() + elif response_id == gtk.RESPONSE_APPLY: + self.apply() + else: + self.destroy() +   def update_buttons(self): - self._btn_apply.set_sensitive(self.dirty) + self.applybtn.set_sensitive(self.dirty)     model, seliter = self.tv.get_selection().get_selected()     next = model.iter_next(seliter)   self.down_button.set_sensitive(next != None)     firstiter = model.get_iter_first()   islast = model.get_path(seliter) != model.get_path(firstiter)   self.up_button.set_sensitive(islast)     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):   while True:   next = model.iter_next(i)   if next == None:   break   if model.get_path(next) == model.get_path(seliter):   model.swap(i, next)   self.dirty = True   break   i = next   self.update_buttons()     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.dirty = True   self.update_buttons()   - def _btn_apply_clicked(self, button, data=None): + def apply(self):   self.apply_func()   self.dirty = False   self.update_buttons()
 
235
236
237
238
239
240
241
242
243
 
269
270
271
272
273
274
275
 
235
236
237
 
 
 
238
239
240
 
266
267
268
 
269
270
271
@@ -235,9 +235,6 @@
    def show_details_dialog(self):   - def close(dialog, response_id): - dialog.destroy() -   columns = {}   columns['graph'] = (self.graphcol, _('Graph'), 'graphcol', 'graph')   @@ -269,7 +266,6 @@
  self.details_model = model     dlg = histdetails.LogDetailsDialog(model, self.apply_details) - dlg.connect('response', close)   dlg.show()     def apply_details(self):