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

taskbarui: change to 2-panes style for menu promoting

fixes #337, but not completely

Changeset 95f1091d20ef

Parent 24df8c18d97e

by Yuki KODAMA

Changes to one file · Browse files at 95f1091d20ef Showing diff from parent 24df8c18d97e 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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
 
 
 
 
 
 
 
 
 
205
206
 
207
208
209
210
211
212
213
 
 
214
215
216
217
218
219
220
221
222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
224
225
226
227
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
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
280
281
282
283
284
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
 # taskbarui.py - User interface for the TortoiseHg taskbar app  #  # Copyright 2009 Steve Borho <steve@borho.org>  #  # This software may be used and distributed according to the terms of the  # GNU General Public License version 2, incorporated herein by reference.    import os  import gtk  import gobject    from thgutil.i18n import _  from thgutil import hglib, settings  from hggtk import gtklib    shellcmds = '''about add clone commit datamine init log recovery  shelve synch status thgstatus userconf repoconf remove rename  revert serve update vdiff'''.split()    class TaskBarUI(gtk.Window):   'User interface for the TortoiseHg taskbar application'   def __init__(self, inputq, requestq):   'Initialize the Dialog'   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)   gtklib.set_tortoise_icon(self, 'hg.ico')   gtklib.set_tortoise_keys(self)     self.set_default_size(400, 520)   self.set_title(_('TortoiseHg Taskbar'))     about = gtk.Button(_('About'))   apply = gtk.Button(_('Apply'))   close = gtk.Button(_('Close'))     vbox = gtk.VBox()   self.add(vbox)     # Create a new notebook, place the position of the tabs   self.notebook = notebook = gtk.Notebook()   notebook.set_tab_pos(gtk.POS_TOP)   vbox.pack_start(notebook, True, True)   notebook.show()   self.show_tabs = True   self.show_border = True   + # Options page   settingsframe = self.add_page(notebook, _('Options'))   settingsvbox = gtk.VBox()   settingsframe.add(settingsvbox)   + ## Overlays group   ovframe = gtk.Frame(_('Overlays'))   ovframe.set_border_width(2)   settingsvbox.pack_start(ovframe, False, False, 2)   ovcvbox = gtk.VBox()   ovframe.add(ovcvbox)   hbox = gtk.HBox()   ovcvbox.pack_start(hbox, False, False, 2)   self.ovenable = gtk.CheckButton(_('Enable overlays'))   hbox.pack_start(self.ovenable, False, False, 2)   self.lclonly = gtk.CheckButton(_('Local disks only'))   hbox.pack_start(self.lclonly, False, False, 2)   + ## Context Menu group   cmframe = gtk.Frame(_('Context Menu'))   cmframe.set_border_width(2)   settingsvbox.pack_start(cmframe, False, False, 2)   cmcvbox = gtk.VBox() - cmframe.add(cmcvbox)     lbl = gtk.Label(_('Promote menu items to the top menu'))   cmcvbox.pack_start(lbl, False, False, 2)   + table = gtk.Table(2, 3) + cmframe.add(table) + def setcell(child, row, col): + table.attach(child, col, col + 1, row, row + 1, gtk.FILL|gtk.EXPAND, 0, 4, 2) + def withframe(widget): + scroll = gtk.ScrolledWindow() + scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) + scroll.set_shadow_type(gtk.SHADOW_ETCHED_IN) + scroll.add(widget) + return scroll + + # Sub menus pane + label = gtk.Label(_('Sub menu items:')) + label.set_alignment(0, 0.5) + setcell(label, 0, 0) + + self.submmodel = model = gtk.ListStore(gobject.TYPE_STRING) + self.submlist = list = gtk.TreeView(model) + list.set_size_request(-1, 180) + list.set_headers_visible(False) + column = gtk.TreeViewColumn() + list.append_column(column) + cell = gtk.CellRendererText() + column.pack_start(cell, True) + column.add_attribute(cell, 'text', 0) + setcell(withframe(list), 1, 0) + + # Top menus pane + label = gtk.Label(_('Top menu items:')) + label.set_alignment(0, 0.5) + setcell(label, 0, 2) + + self.topmmodel = model = gtk.ListStore(gobject.TYPE_STRING) + self.topmlist = list = gtk.TreeView(model) + list.set_size_request(-1, 180) + list.set_headers_visible(False) + column = gtk.TreeViewColumn() + list.append_column(column) + cell = gtk.CellRendererText() + column.pack_start(cell, True) + column.add_attribute(cell, 'text', 0) + setcell(withframe(list), 1, 2) + + # move buttons + mbbox = gtk.VBox() + setcell(mbbox, 1, 1) + + topbutton = gtk.Button(_('Top ->')) + topbutton.connect('clicked', self.top_clicked, apply) + mbbox.add(topbutton) + subbutton = gtk.Button(_('<- Sub')) + subbutton.connect('clicked', self.sub_clicked, apply) + mbbox.add(subbutton) + + # Tooltips   tips = gtk.Tooltips()   rows = (len(shellcmds) + 2) / 3   table = gtk.Table(rows, 3, False)   cmcvbox.pack_start(table, False, False, 2)   self.cmptoggles = {}   for i, cmd in enumerate(shellcmds):   row, col = divmod(i, 3)   check = gtk.CheckButton(cmd)   table.attach(check, col, col+1,   row, row+1, gtk.FILL|gtk.EXPAND, 0, 4, 3)   self.cmptoggles[cmd] = check   tooltip = _('Promote menu item "%s" to top menu') % cmd   tips.set_tip(check, tooltip)   check.connect('toggled', lambda x: apply.set_sensitive(True))   + ## Taskbar group   taskbarframe = gtk.Frame(_('Taskbar'))   taskbarframe.set_border_width(2)   settingsvbox.pack_start(taskbarframe, False, False, 2)   taskbarbox = gtk.VBox()   taskbarframe.add(taskbarbox)   hbox = gtk.HBox()   taskbarbox.pack_start(hbox, False, False, 2)   self.hgighlight_taskbaricon = gtk.CheckButton(_('Highlight Icon'))   hbox.pack_start(self.hgighlight_taskbaricon, False, False, 2)     tooltip = _('Enable/Disable the overlay icons globally')   tips.set_tip(self.ovenable, tooltip)   self.ovenable.connect('toggled', self.ovenable_toggled, apply)   tooltip = _('Only enable overlays on local disks')   tips.set_tip(self.lclonly, tooltip)   self.lclonly.connect('toggled', lambda x: apply.set_sensitive(True))     tooltip = _('Highlight the taskbar icon during activity')   tips.set_tip(self.hgighlight_taskbaricon, tooltip)   self.hgighlight_taskbaricon.connect('toggled', lambda x: apply.set_sensitive(True))     self.load_shell_configs()   + # Event log page   frame = self.add_page(notebook, _('Event Log'))   frame.set_border_width(2)     scrolledwindow = gtk.ScrolledWindow()   scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)   scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   scrolledwindow.set_border_width(2)   textview = gtk.TextView()   textview.set_editable(False)   scrolledwindow.add(textview)   frame.add(scrolledwindow)   gobject.timeout_add(100, self.pollq, inputq, textview)     accelgroup = gtk.AccelGroup()   self.add_accel_group(accelgroup)   + # Bottom buttons   bbox = gtk.HBox()   vbox.pack_start(bbox, False, False, 2)     lefthbbox = gtk.HButtonBox()   lefthbbox.set_layout(gtk.BUTTONBOX_START)   bbox.pack_start(lefthbbox, False, False)     about.connect('clicked', self.about)   lefthbbox.pack_start(about, False, False)     bbox.pack_start(gtk.Label(''), True, True)     righthbbox = gtk.HButtonBox()   righthbbox.set_layout(gtk.BUTTONBOX_END)   bbox.pack_start(righthbbox, False, False)     apply.connect('clicked', self.applyclicked)   apply.set_sensitive(False)   righthbbox.pack_start(apply, False, False)     close.connect('clicked', lambda x: self.destroy())   key, modifier = gtk.accelerator_parse('Escape')   close.add_accelerator('clicked', accelgroup, key, 0,   gtk.ACCEL_VISIBLE)   righthbbox.pack_start(close, False, False)     def add_page(self, notebook, tab):   frame = gtk.Frame()   frame.set_border_width(5)   frame.set_shadow_type(gtk.SHADOW_NONE)   frame.show()   label = gtk.Label(tab)   notebook.append_page(frame, label)   return frame     def about(self, button):   from hggtk import about   dlg = about.AboutDialog()   dlg.show_all()     def pollq(self, queue, textview):   'Poll the input queue'   buf = textview.get_buffer()   enditer = buf.get_end_iter()   while queue.qsize():   try:   msg = queue.get(0)   buf.insert(enditer, msg+'\n')   textview.scroll_to_mark(buf.get_insert(), 0)   except Queue.Empty:   pass   return True     def load_shell_configs(self):   overlayenable = True   localdisks = False   promoteditems = 'commit'   hgighlight_taskbaricon = True   try:   from _winreg import HKEY_CURRENT_USER, OpenKey, QueryValueEx   hkey = OpenKey(HKEY_CURRENT_USER, r'Software\TortoiseHg')   t = ('1', 'True')   try: overlayenable = QueryValueEx(hkey, 'EnableOverlays')[0] in t   except EnvironmentError: pass   try: localdisks = QueryValueEx(hkey, 'LocalDisksOnly')[0] in t   except EnvironmentError: pass   try: hgighlight_taskbaricon = QueryValueEx(hkey, 'HighlightTaskbarIcon')[0] in t   except EnvironmentError: pass   try: promoteditems = QueryValueEx(hkey, 'PromotedItems')[0]   except EnvironmentError: pass   except (ImportError, WindowsError):   pass     self.ovenable.set_active(overlayenable)   self.lclonly.set_active(localdisks)   self.lclonly.set_sensitive(overlayenable)   self.hgighlight_taskbaricon.set_active(hgighlight_taskbaricon) +   promoted = [pi.strip() for pi in promoteditems.split(',')] - for cmd, check in self.cmptoggles.iteritems(): - check.set_active(cmd in promoted) + self.submmodel.clear() + self.topmmodel.clear() + for cmd in shellcmds: + if cmd in promoted: + self.topmmodel.append((cmd,)) + else: + self.submmodel.append((cmd,)) + self.submmodel.set_sort_column_id(0, gtk.SORT_ASCENDING) + self.topmmodel.set_sort_column_id(0, gtk.SORT_ASCENDING)   - def applyclicked(self, button): + def store_shell_configs(self):   overlayenable = self.ovenable.get_active() and '1' or '0'   localdisks = self.lclonly.get_active() and '1' or '0'   hgighlight_taskbaricon = self.hgighlight_taskbaricon.get_active() and '1' or '0'   promoted = [] - for cmd, check in self.cmptoggles.iteritems(): - if check.get_active(): - promoted.append(cmd) + for row in self.topmmodel: + promoted.append(row[0])   try:   from _winreg import HKEY_CURRENT_USER, CreateKey, SetValueEx, REG_SZ   hkey = CreateKey(HKEY_CURRENT_USER, r"Software\TortoiseHg")   SetValueEx(hkey, 'EnableOverlays', 0, REG_SZ, overlayenable)   SetValueEx(hkey, 'LocalDisksOnly', 0, REG_SZ, localdisks)   SetValueEx(hkey, 'HighlightTaskbarIcon', 0, REG_SZ, hgighlight_taskbaricon)   SetValueEx(hkey, 'PromotedItems', 0, REG_SZ, ','.join(promoted))   except ImportError:   pass + def sub_clicked(self, button, apply): + model, paths = self.topmlist.get_selection().get_selected_rows() + for path in paths: + menu = model[path][0] + model.remove(model.get_iter(path)) + self.submmodel.append((menu,)) + self.submmodel.set_sort_column_id(0, gtk.SORT_ASCENDING) + apply.set_sensitive(True) + + def top_clicked(self, button, apply): + model, paths = self.submlist.get_selection().get_selected_rows() + for path in paths: + menu = model[path][0] + model.remove(model.get_iter(path)) + self.topmmodel.append((menu,)) + self.topmmodel.set_sort_column_id(0, gtk.SORT_ASCENDING) + apply.set_sensitive(True) + + def applyclicked(self, button): + self.store_shell_configs()   button.set_sensitive(False)     def ovenable_toggled(self, check, apply):   self.lclonly.set_sensitive(check.get_active())   apply.set_sensitive(True)