Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

hggtk: consistent behavior for ctrl-w and ctrl-q

ctrl-w closes the window with focus
ctrl-q closes the application

Refs #32, does not fix it entirely

Changeset 5eb521beaac7

Parent 03ae3c1a9691

by Steve Borho

Changes to 24 files · Browse files at 5eb521beaac7 Showing diff from parent 03ae3c1a9691 Diff from another changeset...

Change 1 of 1 Show Entire File hggtk/​about.py Stacked
 
46
47
48
 
49
50
51
 
46
47
48
49
50
51
52
@@ -46,6 +46,7 @@
 class AboutDialog(gtk.AboutDialog):   def __init__(self):   super(AboutDialog, self).__init__() + shlib.set_tortoise_keys(self)     lib_versions = ', '.join([   "Mercurial-%s" % hgversion,
Change 1 of 1 Show Entire File hggtk/​backout.py Stacked
 
12
13
14
 
15
16
17
18
19
20
 
21
22
23
 
12
13
14
15
16
17
18
19
20
21
22
23
24
25
@@ -12,12 +12,14 @@
 from hgcmd import CmdDialog  from mercurial.i18n import _  import histselect +import shlib    class BackoutDialog(gtk.Window):   """ Backout effect of a changeset """   def __init__(self, root='', rev=''):   """ Initialize the Dialog """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) + shlib.set_tortoise_keys(self)     self.root = root   self.set_title(_('Backout changeset - ') + rev)
Change 1 of 1 Show Entire File hggtk/​clone.py Stacked
 
19
20
21
 
22
23
24
 
19
20
21
22
23
24
25
@@ -19,6 +19,7 @@
  """ Initialize the Dialog """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)   shlib.set_tortoise_icon(self, 'menuclone.ico') + shlib.set_tortoise_keys(self)     # set dialog title   title = 'hg clone'
Change 1 of 1 Show Entire File hggtk/​commit.py Stacked
 
26
27
28
 
29
30
31
 
26
27
28
29
30
31
32
@@ -26,6 +26,7 @@
  def __init__(self, branch, close):   gtk.Dialog.__init__(self, parent=None, flags=gtk.DIALOG_MODAL,   buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) + shlib.set_tortoise_keys(self)   self.connect('response', self.response)   self.set_title(_('Branch Operations'))   self.newbranch = None
Change 1 of 1 Show Entire File hggtk/​gdialog.py Stacked
 
257
258
259
 
260
261
262
 
257
258
259
260
261
262
263
@@ -257,6 +257,7 @@
  def _setup_gtk(self):   self.set_title(self.get_title())   shlib.set_tortoise_icon(self, self.get_icon()) + shlib.set_tortoise_keys(self)     # Minimum size   minx, miny = self.get_minsize()
Change 1 of 2 Show Changes Only hggtk/​guess.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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
 #  # guess.py - TortoiseHg's dialogs for detecting copies and renames  #  # Copyright (C) 2009 Steve Borho <steve@borho.org>  #    import os  import sys  import gtk  import gobject  import pango  import cStringIO  import shlib  import Queue  import thread2  from dialog import error_dialog  from mercurial.i18n import _  from mercurial import hg, ui, mdiff, cmdutil, match, util, commands  from hglib import toutf, fromutf, diffexpand, rootpath, RepoError -from shlib import set_tortoise_icon +import shlib  import gtklib    # This function and some key bits below borrowed ruthelessly from  # Peter Arrenbrecht <peter.arrenbrecht@gmail.com>  # Thanks!  def findmoves(repo, added, removed, threshold):   '''find renamed files -- yields (before, after, score) tuples'''   ctx = repo['.']   for r in removed:   rr = ctx.filectx(r).data()   for a in added:   aa = repo.wread(a)   if aa == rr:   yield r, a, 1.0   break    class DetectRenameDialog(gtk.Window):   'Detect renames after they occur'   def __init__(self):   'Initialize the Dialog'   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) - set_tortoise_icon(self, 'detect_rename.ico') + shlib.set_tortoise_icon(self, 'detect_rename.ico') + shlib.set_tortoise_keys(self)     self.root = rootpath()   self.notify_func = None   path = toutf(os.path.basename(self.root))   self.set_title(_('Detect Copies/Renames in ') + path)   settings = shlib.Settings('rename')   dims = settings.get_value('dims', (800, 600))   self.set_default_size(dims[0], dims[1])     adjustment = gtk.Adjustment(50, 0, 100, 1)   value = settings.get_value('percent', None)   if value: adjustment.set_value(value)   hscale = gtk.HScale(adjustment)   frame = gtk.Frame(_('Minimum Simularity Percentage'))   frame.add(hscale)   topvbox = gtk.VBox()   topvbox.pack_start(frame, False, False, 2)     unkmodel = gtk.ListStore(str, str)   unknowntree = gtk.TreeView(unkmodel)   unknowntree.get_selection().set_mode(gtk.SELECTION_MULTIPLE)   cell = gtk.CellRendererText()   cell.set_property("ellipsize", pango.ELLIPSIZE_START)   col = gtk.TreeViewColumn('File', cell, text=1)   unknowntree.append_column(col)   unknowntree.set_enable_search(True)   unknowntree.set_headers_visible(False)   scroller = gtk.ScrolledWindow()   scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   scroller.add(unknowntree)     vbox = gtk.VBox()   vbox.pack_start(scroller, True, True, 2)   fr = gtk.Button(_('Find Renames'))   fc = gtk.Button(_('Find Copies'))   hbox = gtk.HBox()   hbox.pack_start(fr, False, False, 2)   hbox.pack_start(fc, False, False, 2)   vbox.pack_start(hbox, False, False, 2)   fr.set_sensitive(False)   fc.set_sensitive(False)     unknownframe = gtk.Frame(_('Unrevisioned Files'))   unknownframe.add(vbox)     # source, dest, percent match, sensitive   cmodel = gtk.ListStore(str, str, str, str, str, bool)   ctree = gtk.TreeView(cmodel)   ctree.set_rules_hint(True)   ctree.set_reorderable(False)   ctree.set_enable_search(False)   ctree.get_selection().set_mode(gtk.SELECTION_MULTIPLE)     cell = gtk.CellRendererText()   cell.set_property('width-chars', 30)   cell.set_property('ellipsize', pango.ELLIPSIZE_START)   col = gtk.TreeViewColumn(_('Source'), cell, text=1, sensitive=5)   col.set_resizable(True)   ctree.append_column(col)     cell = gtk.CellRendererText()   cell.set_property('width-chars', 30)   cell.set_property('ellipsize', pango.ELLIPSIZE_START)   col = gtk.TreeViewColumn(_('Dest'), cell, text=3, sensitive=5)   col.set_resizable(True)   ctree.append_column(col)     cell = gtk.CellRendererText()   cell.set_property('width-chars', 5)   cell.set_property('ellipsize', pango.ELLIPSIZE_NONE)   col = gtk.TreeViewColumn('%', cell, text=4, sensitive=5)   col.set_resizable(True)   ctree.append_column(col)     scroller = gtk.ScrolledWindow()   scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   scroller.add(ctree)     stbar = gtklib.StatusBar()   vbox = gtk.VBox()   vbox.pack_start(scroller, True, True, 2)   ac = gtk.Button(_('Accept Match'))   hbox = gtk.HBox()   hbox.pack_start(ac, False, False, 2)   vbox.pack_start(hbox, False, False, 2)   ac.set_sensitive(False)     candidateframe = gtk.Frame(_('Candidate Matches'))   candidateframe.add(vbox)     hpaned = gtk.HPaned()   hpaned.pack1(unknownframe, True, True)   hpaned.pack2(candidateframe, True, True)   pos = settings.get_value('hpaned', None)   if pos: hpaned.set_position(pos)     topvbox.pack_start(hpaned, True, True, 2)     diffframe = gtk.Frame(_('Differences from Source to Dest'))   diffframe.set_shadow_type(gtk.SHADOW_ETCHED_IN)   scroller = gtk.ScrolledWindow()   scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   diffframe.add(scroller)     buf = gtk.TextBuffer()   buf.create_tag('removed', foreground='#900000')   buf.create_tag('added', foreground='#006400')   buf.create_tag('position', foreground='#FF8000')   buf.create_tag('header', foreground='#000090')     diffview = gtk.TextView(buf)   diffview.modify_font(pango.FontDescription('monospace'))   diffview.set_wrap_mode(gtk.WRAP_NONE)   diffview.set_editable(False)   scroller.add(diffview)     vpaned = gtk.VPaned()   vpaned.pack1(topvbox, True, False)   vpaned.pack2(diffframe)   pos = settings.get_value('vpaned', None)   if pos: vpaned.set_position(pos)     vbox = gtk.VBox()   vbox.pack_start(vpaned, True, True, 2)   vbox.pack_start(stbar, False, False, 2)   self.add(vbox)     args = (unknowntree, ctree, adjustment, stbar)   fc.connect('pressed', self.find_copies, *args)   fr.connect('pressed', self.find_renames, *args)   ac.connect('pressed', self.accept_match, *args)     unknowntree.get_selection().connect('changed',   self.unknown_sel_change, fr, fc)   ctree.connect('row-activated',   self.candidate_row_act, unknowntree, stbar)   ctree.get_selection().connect('changed', self.show_diff, buf, ac)   self.connect('delete-event', self.save_settings,   settings, hpaned, vpaned, adjustment)   gobject.idle_add(self.refresh, unkmodel)     def set_notify_func(self, func):   self.notify_func = func     def refresh(self, unkmodel):   q = Queue.Queue()   unkmodel.clear()   thread = thread2.Thread(target=self.unknown_thread,   args=(self.root, q))   thread.start()   gobject.timeout_add(50, self.unknown_wait, thread, q, unkmodel)     def unknown_thread(self, root, q):   try:   repo = hg.repository(ui.ui(), root)   except RepoError:   return   matcher = match.always(repo.root, repo.root)   status = repo.status(node1=repo.dirstate.parents()[0], node2=None,   match=matcher, ignored=False, clean=False, unknown=True)   (modified, added, removed, deleted, unknown, ignored, clean) = status   for u in unknown:   q.put( u )   for a in added:   if not repo.dirstate.copied(a):   q.put( a )     def unknown_wait(self, thread, q, unkmodel):   while q.qsize():   wfile = q.get(0)   unkmodel.append( [wfile, toutf(wfile)] )   return thread.isAlive()     def save_settings(self, w, event, settings, hpaned, vpaned, adjustment):   settings.set_value('vpaned', vpaned.get_position())   settings.set_value('hpaned', hpaned.get_position())   settings.set_value('percent', adjustment.get_value())   rect = self.get_allocation()   settings.set_value('dims', (rect.width, rect.height))   settings.write()     def find_renames(self, widget, unktree, ctree, adj, stbar):   'User pressed "find renames" button'   cmodel = ctree.get_model()   cmodel.clear()   umodel, paths = unktree.get_selection().get_selected_rows()   if not paths:   return   tgts = [ umodel[p][0] for p in paths ]   q = Queue.Queue()   thread = thread2.Thread(target=self.search_thread,   args=(self.root, q, tgts, adj))   thread.start()   stbar.begin()   stbar.set_status_text(_('finding source of ') + ', '.join(tgts))   gobject.timeout_add(50, self.search_wait, thread, q, cmodel, stbar)     def search_thread(self, root, q, tgts, adj):   try:   repo = hg.repository(ui.ui(), root)   except RepoError:   return   srcs = []   audit_path = util.path_auditor(repo.root)   m = cmdutil.match(repo)   for abs in repo.walk(m):   target = repo.wjoin(abs)   good = True   try:   audit_path(abs)   except:   good = False   status = repo.dirstate[abs]   if (not good or not util.lexists(target)   or (os.path.isdir(target) and not os.path.islink(target))):   srcs.append(abs)   elif not adj and status == 'n':   # looking for copies, so any revisioned file is a   # potential source (yes, this will be expensive)   # Added and removed files are not considered as copy   # sources.   srcs.append(abs)   if adj:   simularity = adj.get_value() / 100.0;   gen = cmdutil.findrenames   else:   simularity = 1.0   gen = findmoves   for old, new, score in gen(repo, tgts, srcs, simularity):   q.put( [old, new, '%d%%' % (score*100)] )     def search_wait(self, thread, q, cmodel, stbar):   while q.qsize():   source, dest, sim = q.get(0)   cmodel.append( [source, toutf(source), dest, toutf(dest), sim, True] )   if thread.isAlive():   return True   else:   stbar.end()   return False     def find_copies(self, widget, unktree, ctree, adj, stbar):   'User pressed "find copies" button'   # call rename function with simularity = 100%   self.find_renames(widget, unktree, ctree, None, stbar)     def accept_match(self, widget, unktree, ctree, adj, stbar):   'User pressed "accept match" button'   try:   repo = hg.repository(ui.ui(), self.root)   except RepoError:   return   cmodel, paths = ctree.get_selection().get_selected_rows()   for path in paths:   row = cmodel[path]   src, usrc, dest, udest, percent, sensitive = row   if not sensitive:   continue   if not os.path.exists(repo.wjoin(src)):   # Mark missing rename source as removed   repo.remove([src])   repo.copy(src, dest)   shlib.shell_notify([src, dest])   if self.notify_func:   self.notify_func()   # Mark all rows with this target file as non-sensitive   for row in cmodel:   if row[2] == dest:   row[5] = False   self.refresh(unktree.get_model())     def candidate_row_act(self, ctree, path, column, unktree, stbar):   'User activated row of candidate list'   self.accept_match(ctree, unktree, ctree, None, stbar)     def unknown_sel_change(self, selection, fr, fc):   'User selected a row in the unknown tree'   model, paths = selection.get_selected_rows()   sensitive = paths and True or False   fr.set_sensitive(sensitive)   fc.set_sensitive(sensitive)     def show_diff(self, selection, buf, ac):   'User selected a row in the candidate tree'   model, paths = selection.get_selected_rows()   sensitive = paths and True or False   ac.set_sensitive(sensitive)     try:   repo = hg.repository(ui.ui(), self.root)   except RepoError:   return     buf.set_text('')   bufiter = buf.get_start_iter()   for path in paths:   row = model[path]   src, usrc, dest, udest, percent, sensitive = row   if not sensitive:   continue   ctx = repo['.']   aa = repo.wread(dest)   rr = ctx.filectx(src).data()   opts = mdiff.defaultopts   difftext = mdiff.unidiff(rr, '', aa, '', src, dest, None, opts=opts)   if not difftext:   l = _('== %s and %s have identical contents ==\n\n') % (src, dest)   buf.insert(bufiter, l)   continue   difflines = difftext.splitlines(True)   for line in difflines:   line = toutf(line)   if line.startswith('---') or line.startswith('+++'):   buf.insert_with_tags_by_name(bufiter, line, 'header')   elif line.startswith('-'):   line = diffexpand(line)   buf.insert_with_tags_by_name(bufiter, line, 'removed')   elif line.startswith('+'):   line = diffexpand(line)   buf.insert_with_tags_by_name(bufiter, line, 'added')   elif line.startswith('@@'):   buf.insert_with_tags_by_name(bufiter, line, 'position')   else:   line = diffexpand(line)   buf.insert(bufiter, line)    def run(ui, *pats, **opts):   return DetectRenameDialog()
Change 1 of 3 Show Entire File hggtk/​hgcmd.py Stacked
 
10
11
12
 
13
14
15
16
17
 
23
24
25
26
 
 
27
28
29
 
146
147
148
149
 
150
151
152
 
10
11
12
13
14
 
15
16
17
 
23
24
25
 
26
27
28
29
30
 
147
148
149
 
150
151
152
153
@@ -10,8 +10,8 @@
 import os  import threading  import Queue +import shlib  from hglib import HgThread, hgcmd_toq, toutf -from shlib import set_tortoise_icon, get_system_times  from mercurial.i18n import _    class CmdDialog(gtk.Dialog): @@ -23,7 +23,8 @@
  #buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)   )   - set_tortoise_icon(self, 'hg.ico') + shlib.set_tortoise_icon(self, 'hg.ico') + shlib.set_tortoise_keys(self)   self.cmdline = cmdline   self.returncode = None   self.hgthread = None @@ -146,7 +147,7 @@
  self.pbar.unmap()   else:   # pulse the progress bar every ~100ms - tm = get_system_times()[4] + tm = shlib.get_system_times()[4]   if tm - self.last_pbar_update < 0.100:   return   self.last_pbar_update = tm
Change 1 of 3 Show Entire File hggtk/​hgemail.py Stacked
 
16
17
18
19
20
21
22
 
25
26
27
 
28
29
30
 
352
353
354
 
355
356
357
 
16
17
18
 
19
20
21
 
24
25
26
27
28
29
30
 
352
353
354
355
356
357
358
@@ -16,7 +16,6 @@
 from mercurial import hg, ui, extensions  from mercurial.i18n import _  from hglib import RepoError, fromutf, toutf -from hgcmd import CmdDialog    class EmailDialog(gtk.Window):   """ Send patches or bundles via email """ @@ -25,6 +24,7 @@
  gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)     shlib.set_tortoise_icon(self, 'hg.ico') + shlib.set_tortoise_keys(self)   self.root = root   self.revargs = revargs   @@ -352,6 +352,7 @@
  cmdline += ['--desc', tmpfile]   cmdline.extend(self.revargs)   + from hgcmd import CmdDialog   dlg = CmdDialog(cmdline)   dlg.show_all()   dlg.run()
Change 1 of 3 Show Entire File hggtk/​hgignore.py Stacked
 
10
11
12
13
 
14
15
16
 
18
19
20
21
 
 
22
23
24
 
192
193
194
195
 
196
197
198
 
10
11
12
 
13
14
15
16
 
18
19
20
 
21
22
23
24
25
 
193
194
195
 
196
197
198
199
@@ -10,7 +10,7 @@
 from mercurial import hg, ui, match  from mercurial.i18n import _  from dialog import * -from shlib import shell_notify, set_tortoise_icon +import shlib  import hglib    class HgIgnoreDialog(gtk.Window): @@ -18,7 +18,8 @@
  def __init__(self, fileglob='', *pats):   'Initialize the Dialog'   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) - set_tortoise_icon(self, 'ignore.ico') + shlib.set_tortoise_icon(self, 'ignore.ico') + shlib.set_tortoise_keys(self)     self.root = hglib.rootpath()   self.set_title(_('Ignore filter for ') + os.path.basename(self.root)) @@ -192,7 +193,7 @@
  f.close()   except IOError:   pass - shell_notify(self.repo.wjoin('.hgignore')) + shlib.shell_notify(self.repo.wjoin('.hgignore'))   if self.notify_func: self.notify_func()    def run(_ui, *pats, **opts):
Change 1 of 1 Show Entire File hggtk/​hginit.py Stacked
 
17
18
19
 
 
20
21
22
23
24
25
26
27
28
 
17
18
19
20
21
22
23
24
25
26
 
27
28
29
@@ -17,12 +17,13 @@
  def __init__(self, repos=[]):   """ Initialize the Dialog """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) + shlib.set_tortoise_icon(self, 'menucreaterepos.ico') + shlib.set_tortoise_keys(self)     # set dialog title and icon   self.cwd = cwd and cwd or os.getcwd()   title = 'hg init - %s' % toutf(self.cwd)   self.set_title(title) - shlib.set_tortoise_icon(self, 'menucreaterepos.ico')     # preconditioning info   self._dest_path = os.path.abspath(repos and repos[0] or os.getcwd())
Change 1 of 4 Show Entire File hggtk/​hgtk.py Stacked
 
17
18
19
20
21
22
23
 
25
26
27
 
 
 
 
 
 
 
 
28
29
30
 
41
42
43
44
 
45
46
47
 
167
168
169
170
171
172
173
174
175
176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
178
179
 
17
18
19
 
20
21
22
 
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
48
49
50
 
51
52
53
54
 
174
175
176
 
 
 
 
 
 
 
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
@@ -17,7 +17,6 @@
 import hglib  import gtk  import gobject -  import os  import pdb  import sys @@ -25,6 +24,14 @@
   nonrepo_commands = 'userconfig clone debugcomplete init about help version'   +if 'copy-clipboard' not in gobject.signal_list_names(gtk.TreeView): + gobject.signal_new('copy-clipboard', gtk.TreeView, + gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) + gobject.signal_new('thg-exit', gtk.Window, + gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) + gobject.signal_new('thg-close', gtk.Window, + gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) +  def dispatch(args):   "run the command specified in args"   try: @@ -41,7 +48,7 @@
  opts['cmd'] = ' '.join(sys.argv[1:])   opts['error'] = error   print error - gtkrun(run(u, **opts)) + run(u, **opts)    def get_list_from_file(filename):   try: @@ -167,13 +174,21 @@
  raise   raise hglib.ParseError(cmd, _("invalid arguments"))   -def gtkrun(mainwin): - if hasattr(mainwin, 'display'): - mainwin.display() - mainwin.show_all() - mainwin.connect('destroy', gtk.main_quit) - if 'response' in gobject.signal_list_names(mainwin): - mainwin.connect('response', gtk.main_quit) +mainwindow = None +def thgexit(win): + if hasattr(mainwindow, 'should_live'): + if mainwindow.should_live(): return + mainwindow.destroy() + +def gtkrun(win): + global mainwindow + mainwindow = win + if hasattr(win, 'display'): + win.display() + win.show_all() + if 'response' in gobject.signal_list_names(win): + win.connect('response', gtk.main_quit) + win.connect('destroy', gtk.main_quit)   gtk.gdk.threads_init()   gtk.gdk.threads_enter()   gtk.main()
 
10
11
12
13
 
14
15
16
 
25
26
27
 
 
28
29
30
31
32
 
10
11
12
 
13
14
15
16
 
25
26
27
28
29
30
 
31
32
33
@@ -10,7 +10,7 @@
 from dialog import question_dialog, error_dialog  from mercurial import util  from mercurial.i18n import _ -from shlib import set_tortoise_icon +import shlib  import hglib    class HistoryDialog(gtk.Dialog): @@ -25,8 +25,9 @@
  buttons = (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)   super(HistoryDialog, self).__init__(flags=gtk.DIALOG_MODAL,   buttons=buttons) + shlib.set_tortoise_icon(self, 'menulog.ico') + shlib.set_tortoise_keys(self)   - set_tortoise_icon(self, 'menulog.ico')   # set dialog title   title = "hg log "   if root: title += " - %s" % hglib.toutf(root)
 
11
12
13
14
 
15
16
17
 
20
21
22
 
 
23
24
25
26
27
 
11
12
13
 
14
15
16
17
 
20
21
22
23
24
25
 
26
27
28
@@ -11,7 +11,7 @@
 from mercurial import cmdutil, util, hg, ui  from mercurial.i18n import _  from hglib import RepoError -from shlib import shell_notify, set_tortoise_icon +import shlib    class FilterDialog(gtk.Dialog):   """ Dialog for creating log filters """ @@ -20,8 +20,9 @@
  buttons = (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)   super(FilterDialog, self).__init__(flags=gtk.DIALOG_MODAL,   buttons=buttons) + shlib.set_tortoise_icon(self, 'menucheckout.ico') + shlib.set_tortoise_keys(self)   - set_tortoise_icon(self, 'menucheckout.ico')   self.set_title("hg log filter - %s" % os.path.basename(root))     self.filterfunc = filterfunc
Change 1 of 4 Show Entire File hggtk/​merge.py Stacked
 
11
12
13
14
 
15
16
17
 
20
21
22
 
 
23
24
25
26
27
 
205
206
207
208
 
209
210
211
 
229
230
231
232
 
233
234
235
 
11
12
13
 
14
15
16
17
 
20
21
22
23
24
25
 
26
27
28
 
206
207
208
 
209
210
211
212
 
230
231
232
 
233
234
235
236
@@ -11,7 +11,7 @@
 from mercurial.i18n import _  from mercurial import util, hg, ui  from hgcmd import CmdDialog -from shlib import set_tortoise_icon, shell_notify +import shlib  import histselect  import hglib   @@ -20,8 +20,9 @@
  def __init__(self, root='', rev=''):   """ Initialize the Dialog """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) + shlib.set_tortoise_icon(self, 'menumerge.ico') + shlib.set_tortoise_keys(self)   - set_tortoise_icon(self, 'menumerge.ico')   # set dialog title   title = "hg merge"   if root: title += " - %s" % root @@ -205,7 +206,7 @@
  dlg.hide()   if self.notify_func:   self.notify_func(self.notify_args) - shell_notify([self.root]) + shlib.shell_notify([self.root])   self._refresh()     def _do_merge(self): @@ -229,7 +230,7 @@
  dlg = CmdDialog(cmdline)   dlg.run()   dlg.hide() - shell_notify([self.root]) + shlib.shell_notify([self.root])   if self.notify_func:   self.notify_func(self.notify_args)   self._refresh()
Change 1 of 2 Show Entire File hggtk/​recovery.py Stacked
 
15
16
17
18
 
19
20
21
22
23
24
 
 
25
26
27
28
29
 
127
128
129
130
 
131
132
133
 
15
16
17
 
18
19
20
21
22
23
24
25
26
27
 
28
29
30
 
128
129
130
 
131
132
133
134
@@ -15,15 +15,16 @@
 from mercurial import hg, ui, util  from dialog import error_dialog, question_dialog  from hglib import HgThread, toutf, RepoError, rootpath -from shlib import set_tortoise_icon, shell_notify +import shlib  import gtklib    class RecoveryDialog(gtk.Window):   def __init__(self):   """ Initialize the Dialog. """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) + shlib.set_tortoise_icon(self, 'general.ico') + shlib.set_tortoise_keys(self)   - set_tortoise_icon(self, 'general.ico')   self.root = rootpath()   self.selected_path = None   self.hgthread = None @@ -127,7 +128,7 @@
  def _notify(self, ret, *args):   import time   time.sleep(0.5) # give fs some time to pick up changes - shell_notify([self.root]) + shlib.shell_notify([self.root])     def _rollback_clicked(self, toolbutton, data=None):   response = question_dialog(self, _('Rollback repository'),
Change 1 of 2 Show Entire File hggtk/​serve.py Stacked
 
29
30
31
32
33
34
 
 
35
36
37
 
135
136
137
138
 
139
140
 
141
142
 
143
144
145
 
29
30
31
 
 
 
32
33
34
35
36
 
134
135
136
 
137
138
 
139
140
 
141
142
143
144
@@ -29,9 +29,8 @@
  def __init__(self, webdir_conf):   """ Initialize the Dialog """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) - - set_tortoise_icon(self, 'proxy.ico') - self.connect('delete-event', self._delete) + shlib.set_tortoise_icon(self, 'proxy.ico') + shlib.set_tortoise_keys(self)     # Pipe stderr, stdout to self.write   self._queue = Queue.Queue() @@ -135,11 +134,11 @@
  tbutton.connect('clicked', handler, userdata)   return tbutton   - def _delete(self, widget, event): + def should_live(self, widget, event):   if self._server_stopped(): - gtk.main_quit() + return True   else: - return True + return False     def _server_stopped(self):   '''
Change 1 of 1 Show Entire File hggtk/​shlib.py Stacked
 
130
131
132
133
134
135
136
137
138
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
141
142
 
130
131
132
 
 
133
 
 
 
 
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
@@ -130,13 +130,22 @@
 def set_tortoise_icon(window, thgicon):   ico = get_tortoise_icon(thgicon)   if ico: window.set_icon_from_file(ico) - # Global keybindings for TortoiseHg - window.connect('key-press-event', window_key_press)   -def window_key_press(window, event): - if event.keyval == ord('q') and (event.state & gtk.gdk.CONTROL_MASK): - devent = gtk.gdk.Event(gtk.gdk.DELETE) - window.emit('delete_event', devent) +def set_tortoise_keys(window): + accelgroup = gtk.AccelGroup() + window.add_accel_group(accelgroup) + key, modifier = gtk.accelerator_parse('<Control>w') + window.add_accelerator('thg-close', accelgroup, key, modifier, gtk.ACCEL_VISIBLE) + window.connect('thg-close', thgclose) + key, modifier = gtk.accelerator_parse('<Control>q') + window.add_accelerator('thg-exit', accelgroup, key, modifier, gtk.ACCEL_VISIBLE) + from hgtk import thgexit + window.connect('thg-exit', thgexit) + +def thgclose(window): + if hasattr(window, 'should_live'): + if window.should_live(): return + window.destroy()    def get_tortoise_icon(thgicon):   '''Find a tortoise icon, apply to PyGtk window'''
Change 1 of 1 Show Entire File hggtk/​status.py Stacked
 
329
330
331
332
333
334
335
336
337
338
339
340
 
329
330
331
 
332
 
 
 
 
333
334
335
@@ -329,12 +329,7 @@
  self.diff_model = gtk.ListStore(bool, str, str, str, bool, int,   pango.FontDescription)   - # Create a new signal for our purposes   newsigname = 'copy-clipboard' - if newsigname not in gobject.signal_list_names(gtk.TreeView): - gobject.signal_new(newsigname, gtk.TreeView, - gobject.SIGNAL_ACTION, gobject.TYPE_NONE, ()) -   self.diff_tree = gtk.TreeView(self.diff_model)   self.diff_tree.connect(newsigname, self.copy_to_clipboard)  
Change 1 of 1 Show Entire File hggtk/​synch.py Stacked
 
23
24
25
 
 
26
27
28
29
30
 
23
24
25
26
27
28
 
29
30
31
@@ -23,8 +23,9 @@
  def __init__(self, repos=[], pushmode=False):   """ Initialize the Dialog. """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) + shlib.set_tortoise_icon(self, 'menusynch.ico') + shlib.set_tortoise_keys(self)   - shlib.set_tortoise_icon(self, 'menusynch.ico')   self.root = rootpath()   self.selected_path = None   self.hgthread = None
Change 1 of 1 Show Entire File hggtk/​tagadd.py Stacked
 
11
12
13
 
14
15
16
17
18
19
 
20
21
22
 
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@@ -11,12 +11,14 @@
 from mercurial.i18n import _  from mercurial.node import short, nullid  from hglib import RepoError +import shlib    class TagAddDialog(gtk.Window):   """ Dialog to add tag to Mercurial repo """   def __init__(self, root='', tag='', rev=''):   """ Initialize the Dialog """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) + shlib.set_tortoise_keys(self)     # set dialog title   title = 'hg tag '
 
198
199
200
 
201
202
203
 
341
342
343
 
344
345
346
 
353
354
355
356
357
 
358
359
360
 
424
425
426
427
428
429
430
 
431
432
433
434
 
 
 
435
436
437
 
198
199
200
201
202
203
204
 
342
343
344
345
346
347
348
 
355
356
357
 
 
358
359
360
361
 
425
426
427
 
 
 
 
428
429
430
431
 
432
433
434
435
436
437
@@ -198,6 +198,7 @@
  def __init__(self, path, alias):   gtk.Dialog.__init__(self, parent=None, flags=gtk.DIALOG_MODAL,   buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) + shlib.set_tortoise_keys(self)   self.connect('response', self.response)   self.set_title(_('Edit remote repository path'))   self.newpath, self.newalias = None, None @@ -341,6 +342,7 @@
  """ Initialize the Dialog. """   gtk.Dialog.__init__(self, parent=None, flags=0,   buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) + shlib.set_tortoise_keys(self)     self.ui = ui.ui()   try: @@ -353,8 +355,7 @@
  self.response(gtk.RESPONSE_CANCEL)     # Catch close events - self.connect('delete-event', self._delete) - self.connect('response', self._response) + self.connect('response', self.should_live)     if configrepo:   self.ui = repo.ui @@ -424,14 +425,13 @@
  self._btn_apply.set_sensitive(False)   self.dirty = False   - def _delete(self, widget, event): - return True - - def _response(self, widget, response_id): + def should_live(self, *args):   if self.dirty:   if question_dialog(self, _('Quit without saving?'),   _('Yes to abandon changes, No to continue')) != gtk.RESPONSE_YES: - widget.emit_stop_by_name('response') + self.emit_stop_by_name('response') + return True + return False     def focus_field(self, focusfield):   '''Set page and focus to requested datum'''
Change 1 of 2 Show Entire File hggtk/​update.py Stacked
 
11
12
13
14
15
 
16
17
18
19
20
21
22
 
 
23
24
25
 
177
178
179
180
 
181
182
183
 
11
12
13
 
14
15
16
17
18
19
20
21
 
22
23
24
25
26
 
178
179
180
 
181
182
183
184
@@ -11,15 +11,16 @@
 from mercurial import util, hg, ui  from mercurial.node import *  from mercurial.i18n import _ -from shlib import shell_notify, set_tortoise_icon  from hglib import rootpath, toutf, RepoError +import shlib    class UpdateDialog(gtk.Window):   """ Dialog to update Mercurial repo """   def __init__(self, rev=None):   """ Initialize the Dialog """   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) - set_tortoise_icon(self, 'menucheckout.ico') + shlib.set_tortoise_icon(self, 'menucheckout.ico') + shlib.set_tortoise_keys(self)   self.root = rootpath()   self.rev = rev   self.notify_func = None @@ -177,7 +178,7 @@
  if self.notify_func:   self.notify_func(self.notify_args)   self._refresh() - shell_notify([self.root]) + shlib.shell_notify([self.root])    def run(ui, *pats, **opts):   return UpdateDialog()
Change 1 of 1 Show Entire File hggtk/​visdiff.py Stacked
 
50
51
52
 
 
 
53
54
55
56
57
 
50
51
52
53
54
55
56
 
57
58
59
@@ -50,8 +50,10 @@
  def __init__(self, canonpats, opts):   'Initialize the Dialog'   gtk.Dialog.__init__(self) + shlib.set_tortoise_icon(self, 'menushowchanged.ico') + shlib.set_tortoise_keys(self) +   self.set_title('Visual Diffs') - shlib.set_tortoise_icon(self, 'menushowchanged.ico')   self.set_default_size(400, 150)     lbl = gtk.Label(_('Temporary files are removed when this dialog'
Change 1 of 1 Show Entire File hgtk Stacked
 
51
52
53
 
 
54
55
56
 
57
58
 
51
52
53
54
55
56
57
 
58
59
60
@@ -51,8 +51,10 @@
 for l in sys.stderr.readlines():   if l.startswith('Traceback'):   from hggtk.bugreport import run + from mercurial import ui + from hggtk.hgtk import gtkrun   sys.stderr.seek(0)   error = 'Recoverable runtime error (stderr):\n' + sys.stderr.read() - run(**{'cmd':' '.join(sys.argv[1:]), 'error':error}) + gtkrun(run(ui.ui(), **{'cmd':' '.join(sys.argv[1:]), 'error':error}))   break  sys.exit(ret)