Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

Merge with Yuki

Changeset cb60f632d185

Parents 4582ce8cabac

Parents ef7cc78eb71a

by Adrian Buehlmann

Changes to 5 files · Browse files at cb60f632d185 Showing diff from parent 4582ce8cabac ef7cc78eb71a Diff from another changeset...

 
1
2
3
 
4
5
6
 
1
2
 
3
4
5
6
@@ -1,6 +1,6 @@
 [py2exe]  excludes=pywin, pywin.dialogs, pywin.dialogs.list -includes=cairo, pango, pangocairo, atk, gobject, dbhash, gtk.keysyms, gio +includes=cairo, pango, pangocairo, atk, gobject, dbhash, gtk.keysyms, gio, sip  packages=ctypes, email, hgext, hgext.convert, encodings, tortoisehg.hgtk, tortoisehg.hgtk.logview, tortoisehg.util, iniparse, pygments, dulwich    dll_excludes=iconv.dll, intl.dll, libatk-1.0-0.dll, libgdk_pixbuf-2.0-0.dll, libgdk-win32-2.0-0.dll, libglib-2.0-0.dll, libgmodule-2.0-0.dll, libgobject-2.0-0.dll, libgthread-2.0-0.dll, libgtk-win32-2.0-0.dll, libpango-1.0-0.dll, libpangowin32-1.0-0.dll, libcairo-2.dll, libglade-2.0-0.dll, libpangocairo-1.0-0.dll, libpangoft2-1.0-0.dll, libgio-2.0-0.dll, mswsock.dll, powrprof.dll, shfolder.dll, credui.dll, msvcp60.dll, secur32.dll
Change 1 of 3 Show Entire File hgtk Stacked
 
25
26
27
 
28
29
30
 
36
37
38
39
 
40
41
42
 
52
53
54
55
 
56
57
58
59
60
61
62
 
63
64
65
66
67
68
69
 
70
71
72
 
25
26
27
28
29
30
31
 
37
38
39
 
40
41
42
43
 
53
54
55
 
56
57
58
59
60
61
62
 
63
64
65
66
67
68
69
 
70
71
72
73
@@ -25,6 +25,7 @@
 import pygtk  pygtk.require('2.0')  import gtk +import PyQt4    from mercurial import demandimport  demandimport.ignore.append('win32com.shell') @@ -36,7 +37,7 @@
 import traceback    try: - import tortoisehg.hgtk.hgtk + import tortoisehg.hgqt.hgtk  except ImportError:   sys.stderr.write("abort: couldn't find hgtk libraries in [%s]\n" %   ';'.join(sys.path)) @@ -52,21 +53,21 @@
  sys.exit(1)    if not capt or 'THGDEBUG' in os.environ or '--profile' in sys.argv: - sys.exit(tortoisehg.hgtk.hgtk.dispatch(sys.argv[1:])) + sys.exit(tortoisehg.hgqt.hgtk.dispatch(sys.argv[1:]))  else:   mystderr = cStringIO.StringIO()   origstderr = sys.stderr   sys.stderr = mystderr   ret = 0   try: - ret = tortoisehg.hgtk.hgtk.dispatch(sys.argv[1:]) + ret = tortoisehg.hgqt.hgtk.dispatch(sys.argv[1:])   sys.stderr = origstderr   mystderr.seek(0)   for l in mystderr.readlines():   if l.startswith('Traceback') or l.startswith('TypeError') or \   l.startswith('NameError'):   from tortoisehg.hgtk.bugreport import run - from tortoisehg.hgtk.hgtk import gtkrun + from tortoisehg.hgqt.hgtk import gtkrun   error = 'Recoverable runtime error (stderr):\n'   error += mystderr.getvalue()   opts = {}
Change 1 of 1 Show Entire File setup.py Stacked
 
57
58
59
 
60
61
62
 
57
58
59
60
61
62
63
@@ -57,6 +57,7 @@
  _scripts = []   _data_files = []   _packages = ['tortoisehg.hgtk', 'tortoisehg.hgtk.logview', + 'tortoisehg.hgqt',   'tortoisehg.util', 'tortoisehg']   extra = {}   hgextmods = []
Change 1 of 1 Show Entire File tortoisehg/​hgqt/​hgtk.py Stacked
copied from tortoisehg/hgtk/hgtk.py
 
394
395
396
397
398
 
 
 
 
 
 
399
400
401
 
394
395
396
 
 
397
398
399
400
401
402
403
404
405
@@ -394,8 +394,12 @@
   def shellconfig(ui, *pats, **opts):   """Explorer extension configuration editor""" - from tortoisehg.hgtk.shellconf import run - gtkrun(run, ui, *pats, **opts) + from PyQt4 import QtGui + from tortoisehg.hgqt.shellconf import ShellConfigWindow + app = QtGui.QApplication(sys.argv) + form = ShellConfigWindow() + form.show() + app.exec_()    def rename(ui, *pats, **opts):   """rename a single file or directory"""
Change 1 of 1 Show Entire File tortoisehg/​hgqt/​shellconf.py Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
@@ -0,0 +1,290 @@
+# shellconf.py - User interface for the TortoiseHg shell extension settings +# +# Copyright 2009 Steve Borho <steve@borho.org> +# Copyright 2010 Adrian Buehlmann <adrian@cadifra.com> +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2 or any later version. + +import sys + +from PyQt4 import QtCore, QtGui +from PyQt4.QtCore import SIGNAL, SLOT + +from tortoisehg.util.i18n import _ +from tortoisehg.util import menuthg + +from _winreg import (HKEY_CURRENT_USER, REG_SZ, REG_DWORD, + OpenKey, CreateKey, QueryValueEx, SetValueEx) + +THGKEY = 'TortoiseHg' +OVLKEY = 'TortoiseOverlays' +PROMOTEDITEMS = 'PromotedItems' + +# reading functions +def is_true(x): return x in ('1', 'True') +def nonzero(x): return x != 0 + +# writing functions +def one_str(x): + if x: return '1' + return '0' +def one_int(x): + if x: return 1 + return 0 + +def noop(x): return x + +vars = { + # name: + # default, regkey, regtype, evalfunc, wrfunc, checkbuttonattribute + 'EnableOverlays': + [True, THGKEY, REG_SZ, is_true, one_str, 'ovenable'], + 'LocalDisksOnly': + [False, THGKEY, REG_SZ, is_true, one_str, 'localonly'], + 'ShowTaskbarIcon': + [True, THGKEY, REG_SZ, is_true, one_str, 'show_taskbaricon'], + 'HighlightTaskbarIcon': + [True, THGKEY, REG_SZ, is_true, one_str, 'highlight_taskbaricon'], + PROMOTEDITEMS: + ['commit', THGKEY, REG_SZ, noop, noop, None], + 'ShowUnversionedOverlay': + [True, OVLKEY, REG_DWORD, nonzero, one_int, 'enableUnversionedHandler'], + 'ShowIgnoredOverlay': + [True, OVLKEY, REG_DWORD, nonzero, one_int, 'enableIgnoredHandler'], + 'ShowLockedOverlay': + [True, OVLKEY, REG_DWORD, nonzero, one_int, 'enableLockedHandler'], + 'ShowReadonlyOverlay': + [True, OVLKEY, REG_DWORD, nonzero, one_int, 'enableReadonlyHandler'], + 'ShowDeletedOverlay': + [True, OVLKEY, REG_DWORD, nonzero, one_int, 'enableDeletedHandler'], + 'ShowAddedOverlay': + [True, OVLKEY, REG_DWORD, nonzero, one_int, 'enableAddedHandler'] +} + + +class ShellConfigWindow(QtGui.QDialog): + + def __init__(self, parent=None): + super(ShellConfigWindow, self).__init__(parent) + + self.menu_cmds = {} + self.dirty = False + + layout = QtGui.QVBoxLayout() + + tw = QtGui.QTabWidget() + layout.addWidget(tw) + + # cmenu tab + cmenuwidget = QtGui.QWidget() + grid = QtGui.QGridLayout() + cmenuwidget.setLayout(grid) + tw.addTab(cmenuwidget, _("Contex Menu")) + + w = QtGui.QLabel(_("Top menu items:")) + grid.addWidget(w, 0, 0) + self.topmenulist = w = QtGui.QListWidget() + grid.addWidget(w, 1, 0, 4, 1) + self.connect(w, SIGNAL("itemClicked(QListWidgetItem*)"), + self.listItemClicked) + + w = QtGui.QLabel(_("Sub menu items:")) + grid.addWidget(w, 0, 2) + self.submenulist = w = QtGui.QListWidget() + grid.addWidget(w, 1, 2, 4, 1) + self.connect(w, SIGNAL("itemClicked(QListWidgetItem*)"), + self.listItemClicked) + + style = QtGui.QApplication.style() + icon = style.standardIcon(QtGui.QStyle.SP_ArrowLeft) + self.top_button = w = QtGui.QPushButton(icon, '') + grid.addWidget(w, 2, 1) + self.connect(w, SIGNAL("clicked()"), self.top_clicked) + icon = style.standardIcon(QtGui.QStyle.SP_ArrowRight) + self.sub_button = w = QtGui.QPushButton(icon, '') + grid.addWidget(w, 3, 1) + self.connect(w, SIGNAL("clicked()"), self.sub_clicked) + + grid.setRowStretch(1, 10) + grid.setRowStretch(4, 10) + + # Icons tab + iconswidget = QtGui.QWidget() + iconslayout = QtGui.QVBoxLayout() + iconswidget.setLayout(iconslayout) + tw.addTab(iconswidget, _("Icons")) + + def checkbox(label): + cb = QtGui.QCheckBox(label) + self.connect(cb, SIGNAL("stateChanged(int)"), self.stateChanged) + return cb + + # Overlays group + gbox = QtGui.QGroupBox(_("Overlays")) + iconslayout.addWidget(gbox) + hb = QtGui.QHBoxLayout() + gbox.setLayout(hb) + self.ovenable = cb = checkbox(_("Enabled overlays")) + hb.addWidget(cb) + self.localonly = checkbox(_("Local disks only")) + hb.addWidget(self.localonly) + hb.addStretch() + + # Enabled Overlay Handlers group + gbox = QtGui.QGroupBox(_("Enabled Overlay Handlers")) + iconslayout.addWidget(gbox) + grid = QtGui.QGridLayout() + gbox.setLayout(grid) + grid.setColumnStretch(3, 10) + w = QtGui.QLabel(_("Warning: affects all Tortoises, logoff required after change")) + grid.addWidget(w, 0, 0, 1, 3) + self.enableAddedHandler = w = checkbox(_("Added")) + grid.addWidget(w, 1, 0) + self.enableLockedHandler = w = checkbox(_("Locked*")) + grid.addWidget(w, 1, 1) + self.enableIgnoredHandler = w = checkbox(_("Ignored*")) + grid.addWidget(w, 1, 2) + self.enableUnversionedHandler = w = checkbox(_("Unversioned")) + grid.addWidget(w, 2, 0) + self.enableReadonlyHandler = w = checkbox(_("Readonly*")) + grid.addWidget(w, 2, 1) + self.enableDeletedHandler = w = checkbox(_("Deleted*")) + grid.addWidget(w, 2, 2) + w = QtGui.QLabel(_("*: not used by TortoiseHg")) + grid.addWidget(w, 3, 0, 1, 3) + + # Taskbar group + gbox = QtGui.QGroupBox(_("Taskbar")) + iconslayout.addWidget(gbox) + hb = QtGui.QHBoxLayout() + gbox.setLayout(hb) + self.show_taskbaricon = cb = checkbox(_("Show Icon")) + hb.addWidget(cb) + self.highlight_taskbaricon = cb = checkbox(_("Highlight Icon")) + hb.addWidget(cb) + hb.addStretch() + + iconslayout.addStretch() + + # dialog buttons + BB = QtGui.QDialogButtonBox + bb = QtGui.QDialogButtonBox(BB.Ok|BB.Cancel|BB.Apply) + self.apply_button = bb.button(BB.Apply) + self.connect(bb, SIGNAL("accepted()"), self, SLOT("accept()")) + self.connect(bb, SIGNAL("rejected()"), self, SLOT("reject()")) + self.connect(bb.button(BB.Apply), SIGNAL("clicked()"), self.apply) + bb.button(BB.Ok).setDefault(True) + layout.addWidget(bb) + + self.setLayout(layout) + self.setWindowTitle(_("TortoiseHg Shell Configuration")) + + self.load_shell_configs() + + def load_shell_configs(self): + for name, info in vars.iteritems(): + default, regkey, regtype, evalfunc, wrfunc, cbattr = info + try: + hkey = OpenKey(HKEY_CURRENT_USER, 'Software\\' + regkey) + v = QueryValueEx(hkey, name)[0] + vars[name][0] = evalfunc(v) + except (WindowsError, EnvironmentError): + pass + if cbattr != None: + checkbutton = getattr(self, cbattr) + checkbutton.setChecked(vars[name][0]) + + promoteditems = vars[PROMOTEDITEMS][0] + self.set_menulists(promoteditems) + + self.dirty = False + self.update_states() + + def set_menulists(self, promoteditems): + for list in (self.topmenulist, self.submenulist): + list.clear() + list.setSortingEnabled(True) + promoted = [pi.strip() for pi in promoteditems.split(',')] + for cmd, info in menuthg.thgcmenu.items(): + label = info['label']['str'] + self.menu_cmds[label] = cmd + if cmd in promoted: + self.topmenulist.addItem(label) + else: + self.submenulist.addItem(label) + + def store_shell_configs(self): + if not self.dirty: + return + + promoted = [] + list = self.topmenulist + for row in range(list.count()): + label = str(list.item(row).text()) + cmd = self.menu_cmds[label] + promoted.append(cmd) + + hkey = CreateKey(HKEY_CURRENT_USER, "Software\\" + THGKEY) + SetValueEx(hkey, PROMOTEDITEMS, 0, REG_SZ, ','.join(promoted)) + + for name, info in vars.iteritems(): + default, regkey, regtype, evalfunc, wrfunc, cbattr = info + if cbattr == None: + continue + checkbutton = getattr(self, cbattr) + v = wrfunc(checkbutton.isChecked()) + hkey = CreateKey(HKEY_CURRENT_USER, 'Software\\' + regkey) + SetValueEx(hkey, name, 0, regtype, v) + + self.dirty = False + self.update_states() + + def accept(self): + self.store_shell_configs() + QtGui.QDialog.accept(self) + + def reject(self): + QtGui.QDialog.reject(self) + + def apply(self): + self.store_shell_configs() + + def top_clicked(self): + self.move_selected(self.submenulist, self.topmenulist) + + def sub_clicked(self): + self.move_selected(self.topmenulist, self.submenulist) + + def move_selected(self, fromlist, tolist): + row = fromlist.currentRow() + if row < 0: + return + item = fromlist.takeItem(row) + tolist.addItem(item) + tolist.setCurrentItem(item) + fromlist.setCurrentItem(None) + self.dirty = True + self.update_states() + + def update_states(self): + self.top_button.setEnabled(len(self.submenulist.selectedItems()) > 0) + self.sub_button.setEnabled(len(self.topmenulist.selectedItems()) > 0) + self.apply_button.setEnabled(self.dirty) + + def stateChanged(self, state): + self.dirty = True + self.update_states() + + def listItemClicked(self, item): + itemlist = item.listWidget() + for list in (self.topmenulist, self.submenulist): + if list != itemlist: + list.setCurrentItem(None) + self.update_states() + +if __name__ == "__main__": + app = QtGui.QApplication(sys.argv) + form = ShellConfigWindow() + form.show() + app.exec_()