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

hggtk: translatable strings, round 1

Changeset efd65cbaed9c

Parent 37b1f7742759

by Steve Borho

Changes to 8 files · Browse files at efd65cbaed9c Showing diff from parent 37b1f7742759 Diff from another changeset...

Change 1 of 2 Show Entire File hggtk/​about.py Stacked
 
11
12
13
 
14
15
16
 
56
57
58
59
 
60
61
62
 
11
12
13
14
15
16
17
 
57
58
59
 
60
61
62
63
@@ -11,6 +11,7 @@
 pygtk.require('2.0')  import gtk  import shlib +from mercurial.i18n import _    try:   # post 1.1.2 @@ -56,7 +57,7 @@
  "GTK-%s" % make_version(gtk.gtk_version),   ])   - comment = "Several icons are courtesy of the TortoiseSVN project" + comment = _("Several icons are courtesy of the TortoiseSVN project")     self.set_website("http://bitbucket.org/tortoisehg/stable/")   self.set_name("TortoiseHg")
Change 1 of 6 Show Entire File hggtk/​backout.py Stacked
 
10
11
12
 
13
14
15
 
19
20
21
22
 
23
24
25
 
31
32
33
34
 
35
36
 
37
38
39
 
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
 
81
82
83
84
 
85
86
87
 
104
105
106
107
108
 
 
109
110
111
 
10
11
12
13
14
15
16
 
20
21
22
 
23
24
25
26
 
32
33
34
 
35
36
 
37
38
39
40
 
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
 
82
83
84
 
85
86
87
88
 
105
106
107
 
 
108
109
110
111
112
@@ -10,6 +10,7 @@
 import pango  from dialog import *  from hgcmd import CmdDialog +from mercurial.i18n import _  import histselect    class BackoutDialog(gtk.Window): @@ -19,7 +20,7 @@
  gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)     self.root = root - self.set_title('Backout changeset - ' + rev) + self.set_title(_('Backout changeset - ') + rev)   self.set_default_size(600, 400)   self.notify_func = None   @@ -31,9 +32,9 @@
  sep.set_draw(False)     tbuttons = [ - self._toolbutton(gtk.STOCK_GO_BACK, 'Backout', + self._toolbutton(gtk.STOCK_GO_BACK, _('Backout'),   self._backout_clicked, - 'Backout selected changeset') + _('Backout selected changeset'))   ]   for btn in tbuttons:   self.tbar.insert(btn, -1) @@ -44,31 +45,31 @@
  # From: combo box   self.reventry = gtk.Entry()   self.reventry.set_text(rev) - self.browse = gtk.Button("Browse...") + self.browse = gtk.Button(_('Browse...'))   self.browse.connect('clicked', self._btn_rev_clicked)     hbox = gtk.HBox() - hbox.pack_start(gtk.Label('Revision to backout:'), False, False, 4) + hbox.pack_start(gtk.Label(_('Revision to backout:')), False, False, 4)   hbox.pack_start(self.reventry, True, True, 4)   hbox.pack_start(self.browse, False, False, 4)   vbox.pack_start(hbox, False, False, 4)     self.logview = gtk.TextView(buffer=None)   self.logview.set_editable(True) - self.logview.modify_font(pango.FontDescription("Monospace")) + self.logview.modify_font(pango.FontDescription('Monospace'))   buf = self.logview.get_buffer() - buf.set_text('Backed out changeset: ' + rev) + buf.set_text(_('Backed out changeset: ') + rev)   scrolledwindow = gtk.ScrolledWindow()   scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)   scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)   scrolledwindow.add(self.logview)   scrolledwindow.set_border_width(4) - frame = gtk.Frame('Backout commit message') + frame = gtk.Frame(_('Backout commit message'))   frame.set_border_width(4)   frame.add(scrolledwindow)   self.tips.set_tip(frame, - 'Commit message text for new changeset that reverses the' - ' effect of the change being backed out.') + _('Commit message text for new changeset that reverses the' + ' effect of the change being backed out.'))   vbox.pack_start(frame, True, True, 4)     def set_notify_func(self, func, *args): @@ -81,7 +82,7 @@
  if rev is not None:   self.reventry.set_text(rev)   buf = self.logview.get_buffer() - buf.set_text('Backed out changeset: ' + rev) + buf.set_text(_('Backed out changeset: ') + rev)     def _toolbutton(self, stock, label, handler, tip):   tbutton = gtk.ToolButton(stock) @@ -104,8 +105,8 @@
   def run(root='', **opts):   # This dialog is intended to be launched by the changelog browser - # It's not expected to be used from hgproc or the command line. I - # leave this path in place for testing purposes. + # It's not expected to be used from hgtk. I leave this path in + # place for testing purposes.   dialog = BackoutDialog(root, 'tip')   dialog.show_all()   dialog.connect('destroy', gtk.main_quit)
Change 1 of 11 Show Entire File hggtk/​clone.py Stacked
 
4
5
6
7
8
9
10
11
12
 
 
 
13
14
15
16
17
 
62
63
64
65
 
66
67
 
68
69
70
 
76
77
78
79
80
 
 
81
82
83
 
94
95
96
97
 
98
99
100
 
112
113
114
115
116
 
 
117
118
119
 
128
129
130
131
 
132
133
134
 
143
144
145
146
147
 
 
148
149
150
151
 
152
153
 
154
155
156
 
160
161
162
163
164
165
166
 
 
 
 
167
168
169
 
176
177
178
179
 
180
181
182
 
267
268
269
270
 
271
272
273
 
295
296
297
298
299
300
301
302
303
304
 
305
306
307
308
 
309
310
311
 
4
5
6
 
 
 
 
 
 
7
8
9
10
 
11
12
13
 
58
59
60
 
61
62
 
63
64
65
66
 
72
73
74
 
 
75
76
77
78
79
 
90
91
92
 
93
94
95
96
 
108
109
110
 
 
111
112
113
114
115
 
124
125
126
 
127
128
129
130
 
139
140
141
 
 
142
143
144
145
146
 
147
148
 
149
150
151
152
 
156
157
158
 
 
 
 
159
160
161
162
163
164
165
 
172
173
174
 
175
176
177
178
 
263
264
265
 
266
267
268
269
 
291
292
293
 
294
295
296
297
298
 
299
300
301
302
 
303
304
305
306
@@ -4,14 +4,10 @@
 # Copyright (C) 2007 TK Soh <teekaysoh@gmail.com>  #   -try: - import pygtk - pygtk.require("2.0") -except: - pass - +import pygtk +pygtk.require("2.0") +import gtk  import os -import gtk  import pango  from dialog import question_dialog, error_dialog, info_dialog  from mercurial import hg, ui, cmdutil, util @@ -62,9 +58,9 @@
    self._btn_clone = self._toolbutton(   gtk.STOCK_COPY, - 'clone', + _('clone'),   self._btn_clone_clicked, - tip='Clone a repository') + tip=_('Clone a repository'))   tbuttons = [   self._btn_clone,   ] @@ -76,8 +72,8 @@
    # clone source   srcbox = gtk.HBox() - lbl = gtk.Label("Source Path:") - lbl.set_property("width-chars", ewidth) + lbl = gtk.Label(_('Source Path:')) + lbl.set_property('width-chars', ewidth)   lbl.set_alignment(0, 0.5)     # create drop-down list for source paths @@ -94,7 +90,7 @@
  self._srclistbox.pack_start(cell)   self._srclistbox.add_attribute(cell, 'text', 0)   - self._btn_src_browse = gtk.Button("Browse...") + self._btn_src_browse = gtk.Button(_('Browse...'))   self._btn_src_browse.connect('clicked', self._btn_src_clicked)   srcbox.pack_start(lbl, False, False)   srcbox.pack_start(self._srclistbox, True, True) @@ -112,8 +108,8 @@
    # clone destination   destbox = gtk.HBox() - lbl = gtk.Label("Destination Path:") - lbl.set_property("width-chars", ewidth) + lbl = gtk.Label(_('Destination Path:')) + lbl.set_property('width-chars', ewidth)   lbl.set_alignment(0, 0.5)   self._destlist = gtk.ListStore(str)   self._destlistbox = gtk.ComboBoxEntry(self._destlist, 0) @@ -128,7 +124,7 @@
  self._destlistbox.pack_start(cell)   self._destlistbox.add_attribute(cell, 'text', 0)   - self._btn_dest_browse = gtk.Button("Browse...") + self._btn_dest_browse = gtk.Button(_('Browse...'))   self._btn_dest_browse.connect('clicked', self._btn_dest_clicked)   destbox.pack_start(lbl, False, False)   destbox.pack_start(self._destlistbox, True, True) @@ -143,14 +139,14 @@
    # revision input   revbox = gtk.HBox() - lbl = gtk.Label("Clone To Revision:") - lbl.set_property("width-chars", ewidth) + lbl = gtk.Label(_('Clone To Revision:')) + lbl.set_property('width-chars', ewidth)   lbl.set_alignment(0, 0.5)   self._rev_input = gtk.Entry()   self._rev_input.set_text("") - self._opt_allrev = gtk.CheckButton("Clone all revisions") + self._opt_allrev = gtk.CheckButton(_('Clone all revisions'))   self._opt_allrev.set_active(True) - self._btn_rev_browse = gtk.Button("Select...") + self._btn_rev_browse = gtk.Button(_('Select...'))   self._btn_rev_browse.connect('clicked', self._btn_rev_clicked)   revbox.pack_start(lbl, False, False)   revbox.pack_start(self._rev_input, False, False) @@ -160,10 +156,10 @@
    # options   option_box = gtk.VBox() - self._opt_update = gtk.CheckButton("do not update the new working directory") - self._opt_pull = gtk.CheckButton("use pull protocol to copy metadata") - self._opt_uncomp = gtk.CheckButton("use uncompressed transfer") - self._opt_proxy = gtk.CheckButton("use proxy server") + self._opt_update = gtk.CheckButton(_('do not update the new working directory') + self._opt_pull = gtk.CheckButton(_('use pull protocol to copy metadata')) + self._opt_uncomp = gtk.CheckButton(_('use uncompressed transfer')) + self._opt_proxy = gtk.CheckButton(_('use proxy server'))   option_box.pack_start(self._opt_update, False, False)   option_box.pack_start(self._opt_pull, False, False)   option_box.pack_start(self._opt_uncomp, False, False) @@ -176,7 +172,7 @@
  self._opt_proxy.set_sensitive(False)     # remote cmd - lbl = gtk.Label("Remote Cmd:") + lbl = gtk.Label(_('Remote Cmd:'))   lbl.set_alignment(0, 0.5)   self._remote_cmd = gtk.Entry()   vbox.pack_end(self._remote_cmd, False, False, 1) @@ -267,7 +263,7 @@
    # verify input   if src == "": - error_dialog(self, "Source path is empty", "Please enter") + error_dialog(self, _('Source path is empty'), _('Please enter'))   self._src_input.grab_focus()   return False   @@ -295,17 +291,16 @@
  if dest:   cmdline.append(dest)   - print "cmdline: ", ' '.join(cmdline)   from hgcmd import CmdDialog   dlg = CmdDialog(cmdline)   dlg.run()   dlg.hide()   except util.Abort, inst: - error_dialog(self, "Clone aborted", str(inst)) + error_dialog(self, _('Clone aborted'), str(inst))   return False   except:   import traceback - error_dialog(self, "Clone error", traceback.format_exc()) + error_dialog(self, _('Clone error'), traceback.format_exc())   return False     self._add_src_to_recent(src)
Change 1 of 17 Show Entire File hggtk/​commit.py Stacked
 
92
93
94
95
96
97
98
 
 
 
 
99
100
101
 
107
108
109
110
111
 
 
112
113
114
 
134
135
136
137
 
138
139
140
 
149
150
151
152
 
153
154
155
 
189
190
191
192
 
 
193
194
195
 
210
211
212
213
 
214
215
216
 
243
244
245
246
247
248
249
 
 
 
 
250
251
252
 
257
258
259
260
 
261
262
263
 
279
280
281
282
283
284
 
 
 
285
286
287
288
 
 
 
289
290
291
 
327
328
329
330
 
331
332
333
 
374
375
376
377
 
378
379
380
 
412
413
414
415
 
416
417
418
419
420
421
422
423
 
 
 
424
425
426
 
429
430
431
432
 
433
434
435
436
437
438
439
 
440
441
442
 
449
450
451
452
 
 
453
454
455
 
459
460
461
462
463
464
 
 
 
465
466
467
 
481
482
483
484
485
486
 
 
 
487
488
489
490
491
 
 
492
493
494
 
546
547
548
549
550
551
 
 
 
552
553
554
 
92
93
94
 
 
 
 
95
96
97
98
99
100
101
 
107
108
109
 
 
110
111
112
113
114
 
134
135
136
 
137
138
139
140
 
149
150
151
 
152
153
154
155
 
189
190
191
 
192
193
194
195
196
 
211
212
213
 
214
215
216
217
 
244
245
246
 
 
 
 
247
248
249
250
251
252
253
 
258
259
260
 
261
262
263
264
 
280
281
282
 
 
 
283
284
285
286
 
 
 
287
288
289
290
291
292
 
328
329
330
 
331
332
333
334
 
375
376
377
 
378
379
380
381
 
413
414
415
 
416
417
418
419
420
421
 
 
 
422
423
424
425
426
427
 
430
431
432
 
433
434
435
436
437
438
439
 
440
441
442
443
 
450
451
452
 
453
454
455
456
457
 
461
462
463
 
 
 
464
465
466
467
468
469
 
483
484
485
 
 
 
486
487
488
489
490
491
 
 
492
493
494
495
496
 
548
549
550
 
 
 
551
552
553
554
555
556
@@ -92,10 +92,10 @@
  def get_tbbuttons(self):   tbbuttons = GStatus.get_tbbuttons(self)   tbbuttons.insert(2, gtk.SeparatorToolItem()) - self._undo_button = self.make_toolbutton(gtk.STOCK_UNDO, '_Undo', - self._undo_clicked, tip='undo recent commit') - self._commit_button = self.make_toolbutton(gtk.STOCK_OK, '_Commit', - self._commit_clicked, tip='commit') + self._undo_button = self.make_toolbutton(gtk.STOCK_UNDO, _('_Undo'), + self._undo_clicked, tip=_('undo recent commit')) + self._commit_button = self.make_toolbutton(gtk.STOCK_OK, _('_Commit'), + self._commit_clicked, tip=_('commit'))   tbbuttons.insert(2, self._undo_button)   tbbuttons.insert(2, self._commit_button)   return tbbuttons @@ -107,8 +107,8 @@
  if index >= 0:   buf = self.text.get_buffer()   if buf.get_char_count() and buf.get_modified(): - response = Confirm('Discard Message', [], self, - 'Discard current commit message?').run() + response = Confirm(_('Discard Message'), [], self, + _('Discard current commit message?')).run()   if response != gtk.RESPONSE_YES:   combobox.set_active(-1)   return @@ -134,7 +134,7 @@
    mbox = gtk.HBox()   - label = gtk.Label('Branch: ') + label = gtk.Label(_('Branch: '))   mbox.pack_start(label, False, False, 2)   self.branchentry = gtk.Entry()   mbox.pack_start(self.branchentry, False, False, 2) @@ -149,7 +149,7 @@
  else:   self.qnew_name = None   - label = gtk.Label('Recent Commit Messages: ') + label = gtk.Label(_('Recent Commit Messages: '))   mbox.pack_start(label, False, False, 2)   self.msg_cbbox = gtk.combo_box_new_text()   liststore = gtk.ListStore(str, str) @@ -189,7 +189,8 @@
      def get_menu_info(self): - """Returns menu info in this order: merge, addrem, unknown, clean, ignored, deleted + """Returns menu info in this order: merge, addrem, unknown, + clean, ignored, deleted   """   merge, addrem, unknown, clean, ignored, deleted, unresolved, resolved \   = GStatus.get_menu_info(self) @@ -210,7 +211,7 @@
  live = False   buf = self.text.get_buffer()   if buf.get_char_count() > 10 and buf.get_modified(): - dialog = Confirm('Exit', [], self, 'Save commit message at exit?') + dialog = Confirm(_('Exit'), [], self, _('Save commit message at exit?'))   res = dialog.run()   if res == gtk.RESPONSE_YES:   self._update_recent_messages(cur_msg) @@ -243,10 +244,10 @@
  # disable the checkboxes on the filelist if repo in merging state   merged = len(self.repo.changectx(None).parents()) > 1   - self.get_toolbutton('Re_vert').set_sensitive(not merged) - self.get_toolbutton('_Add').set_sensitive(not merged) - self.get_toolbutton('_Remove').set_sensitive(not merged) - self.get_toolbutton('Move').set_sensitive(not merged) + self.get_toolbutton(_('Re_vert')).set_sensitive(not merged) + self.get_toolbutton(_('_Add')).set_sensitive(not merged) + self.get_toolbutton(_('_Remove')).set_sensitive(not merged) + self.get_toolbutton(_('Move')).set_sensitive(not merged)     if merged:   # select all changes if repo is merged @@ -257,7 +258,7 @@
    # pre-fill commit message   buf = self.text.get_buffer() - buf.set_text('merge') + buf.set_text(_('merge'))   buf.set_modified(False)   #else:   # self.selectlabel.set_text( @@ -279,13 +280,13 @@
  if buf.get_char_count() == 0 or not buf.get_modified():   buf.set_text(self.qheader)   buf.set_modified(False) - c_btn = self.get_toolbutton('_Commit') - c_btn.set_label('QRefresh') - c_btn.set_tooltip(self.tooltips, self.mqmode and 'QRefresh' or 'QNew') + c_btn = self.get_toolbutton(_('_Commit')) + c_btn.set_label(_('QRefresh')) + c_btn.set_tooltip(self.tooltips, self.mqmode and _('QRefresh') or _('QNew'))   else: - c_btn = self.get_toolbutton('_Commit') - c_btn.set_label('_Commit') - c_btn.set_tooltip(self.tooltips, 'commit') + c_btn = self.get_toolbutton(('_Commit')) + c_btn.set_label(_('_Commit')) + c_btn.set_tooltip(self.tooltips, _('commit'))   self.branchentry.set_sensitive(not mqmode)     def _commit_clicked(self, toolbutton, data=None): @@ -327,7 +328,7 @@
  os.mkdir(backupdir)   except OSError, err:   if err.errno != errno.EEXIST: - Prompt('Commit', 'Unable to create ' + backupdir, + Prompt(_('Commit'), _('Unable to create ') + backupdir,   self).run()   return   try: @@ -374,7 +375,7 @@
  if s:   raise util.Abort(s)   else: - Prompt('Commit', 'Unable to apply patch', self).run() + Prompt(_('Commit'), _('Unable to apply patch'), self).run()   raise util.Abort(_('patch failed to apply'))   del fp   @@ -412,15 +413,15 @@
      def _undo_clicked(self, toolbutton, data=None): - response = Confirm('Undo commit', [], self, 'Undo last commit').run() + response = Confirm(_('Undo commit'), [], self, _('Undo last commit')).run()   if response != gtk.RESPONSE_YES:   return     tip = self._get_tip_rev(True)   if not tip == self._last_commit_id: - Prompt('Undo commit', - 'Unable to undo!\n\n' - 'Tip revision differs from last commit.', + Prompt(_('Undo commit'), + _('Unable to undo!\n\n' + 'Tip revision differs from last commit.'),   self).run()   return   @@ -429,14 +430,14 @@
  self._last_commit_id = None   self.reload_status()   except: - Prompt('Undo commit', 'Errors during rollback!', self).run() + Prompt(_('Undo commit'), _('Errors during rollback!'), self).run()       def _should_addremove(self, files):   if self.test_opt('addremove'):   return True   else: - response = Confirm('Add/Remove', files, self).run() + response = Confirm(_('Add/Remove'), files, self).run()   if response == gtk.RESPONSE_YES:   # This will stay set for further commits (meaning no more prompts). Problem?   self.opts['addremove'] = True @@ -449,7 +450,8 @@
  return   buf = self.text.get_buffer()   if buf.get_char_count() == 0: - Prompt('Nothing Commited', 'Please enter commit message', self).run() + Prompt(_('Nothing Commited'), + _('Please enter commit message'), self).run()   self.text.grab_focus()   return False   begin, end = buf.get_bounds() @@ -459,9 +461,9 @@
    def _hg_commit(self, files):   if not self.repo.ui.config('ui', 'username'): - Prompt('Commit: Invalid username', - 'Your username has not been configured.\n\n' - 'Please configure your username and try again', + Prompt(_('Commit: Invalid username'), + _('Your username has not been configured.\n\n' + 'Please configure your username and try again'),   self).run()     # bring up the config dialog for user to enter their username. @@ -481,14 +483,14 @@
  if newbranch != self.repo.dirstate.branch():   if newbranch in self.repo.branchtags():   if newbranch not in [p.branch() for p in self.repo.parents()]: - response = Confirm('Override Branch', [], self, - 'A branch named "%s" already exists,\n' - 'override?' % newbranch).run() + response = Confirm(_('Override Branch'), [], self, + _('A branch named "%s" already exists,\n' + 'override?') % newbranch).run()   else:   response = gtk.RESPONSE_YES   else: - response = Confirm('New Branch', [], self, - 'Create new named branch "%s"?' % newbranch).run() + response = Confirm(_('New Branch'), [], self, + _('Create new named branch "%s"?') % newbranch).run()   if response == gtk.RESPONSE_YES:   self.repo.dirstate.setbranch(newbranch)   elif response != gtk.RESPONSE_NO: @@ -546,9 +548,9 @@
  mqmode = self.mqmode   self.mqmode = not self.qnew_name.get_text().strip()   if mqmode != self.mqmode: - c_btn = self.get_toolbutton('_Commit') - c_btn.set_label(self.mqmode and 'QRefresh' or 'QNew') - c_btn.set_tooltip(self.tooltips, self.mqmode and 'QRefresh' or 'QNew') + c_btn = self.get_toolbutton(_('_Commit')) + c_btn.set_label(self.mqmode and _('QRefresh') or _('QNew')) + c_btn.set_tooltip(self.tooltips, self.mqmode and _('QRefresh') or _)('QNew')   success, outtext = self._hg_call_wrapper('Status', self._do_reload_status)   self.qnew_name.grab_focus() # set focus back  
Change 1 of 14 Show Entire File hggtk/​datamine.py Stacked
 
12
13
14
 
15
16
17
 
29
30
31
32
 
33
34
35
 
38
39
40
41
42
 
 
43
44
45
 
 
46
47
48
 
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
 
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
 
222
223
224
225
226
227
 
 
 
228
229
230
231
 
 
 
232
233
234
235
236
237
 
238
239
240
 
246
247
248
249
 
250
251
252
 
277
278
279
280
281
 
 
282
283
284
 
306
307
308
309
 
310
311
312
 
412
413
414
415
416
 
 
417
418
419
 
433
434
435
436
 
437
438
439
 
456
457
458
459
460
461
462
463
 
 
 
 
 
464
465
466
467
 
 
 
468
469
470
471
472
473
474
 
 
475
476
477
 
533
534
535
536
 
537
538
539
 
677
678
679
680
681
 
 
682
683
684
 
12
13
14
15
16
17
18
 
30
31
32
 
33
34
35
36
 
39
40
41
 
 
42
43
44
 
 
45
46
47
48
49
 
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
 
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
 
223
224
225
 
 
 
226
227
228
229
 
 
 
230
231
232
233
234
235
236
237
 
238
239
240
241
 
247
248
249
 
250
251
252
253
 
278
279
280
 
 
281
282
283
284
285
 
307
308
309
 
310
311
312
313
 
413
414
415
 
 
416
417
418
419
420
 
434
435
436
 
437
438
439
440
 
457
458
459
 
 
 
 
 
460
461
462
463
464
465
 
 
 
466
467
468
469
470
471
472
473
 
 
474
475
476
477
478
 
534
535
536
 
537
538
539
540
 
678
679
680
 
 
681
682
683
684
685
@@ -12,6 +12,7 @@
 import Queue  import threading, thread2  from mercurial import hg, ui, util, revlog +from mercurial.i18n import _  from hglib import hgcmd_toq, toutf, fromutf, gettabwidth, displaytime, LookupError, rootpath  from gdialog import *  from vis import treemodel @@ -29,7 +30,7 @@
  COL_LINENUM = 6     def get_title(self): - return 'DataMining - ' + os.path.basename(self.repo.root) + return _('DataMining') + ' - ' + os.path.basename(self.repo.root)     def get_icon(self):   return 'menurepobrowse.ico' @@ -38,11 +39,11 @@
  pass     def get_tbbuttons(self): - self.stop_button = self.make_toolbutton(gtk.STOCK_STOP, 'Stop', - self._stop_current_search, tip='Stop operation on current tab') + self.stop_button = self.make_toolbutton(gtk.STOCK_STOP, _('Stop'), + self._stop_current_search, tip=_('Stop operation on current tab'))   return [ - self.make_toolbutton(gtk.STOCK_FIND, 'New Search', - self._search_clicked, tip='Open new search tab'), + self.make_toolbutton(gtk.STOCK_FIND, _('New Search'), + self._search_clicked, tip=_('Open new search tab')),   self.stop_button   ]   @@ -86,26 +87,26 @@
    def ann_header_context_menu(self, treeview):   _menu = gtk.Menu() - _button = gtk.CheckMenuItem("Filename") - _button.connect("toggled", self.toggle_annatate_columns, treeview, 2) + _button = gtk.CheckMenuItem(_('Filename')) + _button.connect('toggled', self.toggle_annatate_columns, treeview, 2)   _menu.append(_button) - _button = gtk.CheckMenuItem("User") - _button.connect("toggled", self.toggle_annatate_columns, treeview, 3) + _button = gtk.CheckMenuItem(_('User')) + _button.connect('toggled', self.toggle_annatate_columns, treeview, 3)   _menu.append(_button)   _menu.show_all()   return _menu     def grep_context_menu(self):   _menu = gtk.Menu() - _menu.append(create_menu('di_splay change', self._cmenu_display)) - _menu.append(create_menu('_annotate file', self._cmenu_annotate)) - _menu.append(create_menu('_file history', self._cmenu_file_log)) + _menu.append(create_menu(_('di_splay change'), self._cmenu_display)) + _menu.append(create_menu(_('_annotate file'), self._cmenu_annotate)) + _menu.append(create_menu(_('_file history'), self._cmenu_file_log))   _menu.show_all()   return _menu     def annotate_context_menu(self):   _menu = gtk.Menu() - _menu.append(create_menu('di_splay change', self._cmenu_display)) + _menu.append(create_menu(_('di_splay change'), self._cmenu_display))   _menu.show_all()   return _menu   @@ -181,29 +182,29 @@
  if self.cwd.startswith(self.repo.root):   includes.set_text(util.canonpath(self.repo.root, self.cwd, '.'))   excludes = gtk.Entry() - search = gtk.Button('Search') - search_hbox.pack_start(gtk.Label('Regexp:'), False, False, 4) + search = gtk.Button(_('Search')) + search_hbox.pack_start(gtk.Label(_('Regexp:')), False, False, 4)   search_hbox.pack_start(regexp, True, True, 4) - search_hbox.pack_start(gtk.Label('Includes:'), False, False, 4) + search_hbox.pack_start(gtk.Label(_('Includes:')), False, False, 4)   search_hbox.pack_start(includes, True, True, 4) - search_hbox.pack_start(gtk.Label('Excludes:'), False, False, 4) + search_hbox.pack_start(gtk.Label(_('Excludes:')), False, False, 4)   search_hbox.pack_start(excludes, True, True, 4)   search_hbox.pack_start(search, False, False) - self.tooltips.set_tip(search, 'Start this search') - self.tooltips.set_tip(regexp, 'Regular expression search pattern') - self.tooltips.set_tip(includes, 'Comma separated list of' + self.tooltips.set_tip(search, _('Start this search')) + self.tooltips.set_tip(regexp, _('Regular expression search pattern')) + self.tooltips.set_tip(includes, _('Comma separated list of'   ' inclusion patterns. By default, the entire repository' - ' is searched.') - self.tooltips.set_tip(excludes, 'Comma separated list of' + ' is searched.')) + self.tooltips.set_tip(excludes, _('Comma separated list of'   ' exclusion patterns. Exclusion patterns are applied' - ' after inclusion patterns.') + ' after inclusion patterns.'))   vbox.pack_start(search_hbox, False, False, 4)     hbox = gtk.HBox() - follow = gtk.CheckButton('Follow copies and renames') - ignorecase = gtk.CheckButton('Ignore case') - linenum = gtk.CheckButton('Show line numbers') - showall = gtk.CheckButton('Show all matching revisions') + follow = gtk.CheckButton(_('Follow copies and renames')) + ignorecase = gtk.CheckButton(_('Ignore case')) + linenum = gtk.CheckButton(_('Show line numbers')) + showall = gtk.CheckButton(_('Show all matching revisions'))   hbox.pack_start(follow, False, False, 4)   hbox.pack_start(ignorecase, False, False, 4)   hbox.pack_start(linenum, False, False, 4) @@ -222,19 +223,19 @@
  results = gtk.ListStore(str, str, str, str)   treeview.set_model(results)   for title, width, col, emode in ( - ('Rev', 10, self.COL_REVID, pango.ELLIPSIZE_NONE), - ('File', 25, self.COL_PATH, pango.ELLIPSIZE_START), - ('Matches', 80, self.COL_TEXT, pango.ELLIPSIZE_END)): + (_('Rev'), 10, self.COL_REVID, pango.ELLIPSIZE_NONE), + (_('File'), 25, self.COL_PATH, pango.ELLIPSIZE_START), + (_('Matches'), 80, self.COL_TEXT, pango.ELLIPSIZE_END)):   cell = gtk.CellRendererText() - cell.set_property("width-chars", width) - cell.set_property("ellipsize", emode) - cell.set_property("family", "Monospace") + cell.set_property('width-chars', width) + cell.set_property('ellipsize', emode) + cell.set_property('family', 'Monospace')   column = gtk.TreeViewColumn(title)   column.set_resizable(True)   column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)   column.set_fixed_width(cell.get_size(treeview)[2])   column.pack_start(cell, expand=True) - column.add_attribute(cell, "text", col) + column.add_attribute(cell, 'text', col)   treeview.append_column(column)   if hasattr(treeview, 'set_tooltip_column'):   treeview.set_tooltip_column(self.COL_TOOLTIP) @@ -246,7 +247,7 @@
  frame.show_all()     hbox = gtk.HBox() - lbl = gtk.Label('Search %d' % self.newpagecount) + lbl = gtk.Label(_('Search %d') % self.newpagecount)   close = self.create_tab_close_button()   close.connect('clicked', self.close_page, frame)   hbox.pack_start(lbl, True, True, 2) @@ -277,8 +278,8 @@
  excludes, includes, linenum, showall, search_hbox) = objs   retext = regexp.get_text()   if not retext: - Prompt('No regular expression given', - 'You must provide a search expression', self).run() + Prompt(_('No regular expression given'), + _('You must provide a search expression'), self).run()   regexp.grab_focus()   return   @@ -306,7 +307,7 @@
  self.stbar.set_status_text('hg ' + ' '.join(args[2:]))     hbox = gtk.HBox() - lbl = gtk.Label('Search "%s"' % retext.split()[0]) + lbl = gtk.Label(_('Search "%s"') % retext.split()[0])   close = self.create_tab_close_button()   close.connect('clicked', self.close_page, frame)   hbox.pack_start(lbl, True, True, 2) @@ -412,8 +413,8 @@
  try:   fctx = ctx.filectx(path)   except LookupError: - Prompt('File is unrevisioned', - 'Unable to annotate ' + path, self).run() + Prompt(_('File is unrevisioned'), + _('Unable to annotate ') + path, self).run()   return   rev = fctx.filelog().linkrev(fctx.filerev())   revid = str(rev) @@ -433,7 +434,7 @@
    hbox = gtk.HBox()   followlabel = gtk.Label('') - follow = gtk.Button('Follow') + follow = gtk.Button(_('Follow'))   follow.connect('clicked', self.follow_rename)   follow.hide()   follow.set_sensitive(False) @@ -456,22 +457,22 @@
    context_menu = self.ann_header_context_menu(treeview)   for title, width, col, emode, visible in ( - ('Line', 8, self.COL_LINENUM, pango.ELLIPSIZE_NONE, True), - ('Rev', 10, self.COL_REVID, pango.ELLIPSIZE_NONE, True), - ('File', 15, self.COL_PATH, pango.ELLIPSIZE_START, False), - ('User', 15, self.COL_USER, pango.ELLIPSIZE_END, False), - ('Source', 80, self.COL_TEXT, pango.ELLIPSIZE_END, True)): + (_('Line'), 8, self.COL_LINENUM, pango.ELLIPSIZE_NONE, True), + (_('Rev'), 10, self.COL_REVID, pango.ELLIPSIZE_NONE, True), + (_('File'), 15, self.COL_PATH, pango.ELLIPSIZE_START, False), + (_('User'), 15, self.COL_USER, pango.ELLIPSIZE_END, False), + (_('Source'), 80, self.COL_TEXT, pango.ELLIPSIZE_END, True)):   cell = gtk.CellRendererText() - cell.set_property("width-chars", width) - cell.set_property("ellipsize", emode) - cell.set_property("family", "Monospace") + cell.set_property('width-chars', width) + cell.set_property('ellipsize', emode) + cell.set_property('family', 'Monospace')   column = gtk.TreeViewColumn(title)   column.set_resizable(True)   column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)   column.set_fixed_width(cell.get_size(treeview)[2])   column.pack_start(cell, expand=True) - column.add_attribute(cell, "text", col) - column.add_attribute(cell, "background", self.COL_COLOR) + column.add_attribute(cell, 'text', col) + column.add_attribute(cell, 'background', self.COL_COLOR)   column.set_visible(visible)   treeview.append_column(column)   self._add_header_context_menu(column, context_menu) @@ -533,7 +534,7 @@
  button.set_label(toutf('%s@%s' % (rpath, frev)))   button.show()   button.set_sensitive(True) - label.set_text('Follow Rename:') + label.set_text(_('Follow Rename:'))   else:   button.hide()   button.set_sensitive(False) @@ -677,8 +678,8 @@
  if os.path.isfile(f):   cf.append(util.canonpath(root, cwd, f))   elif os.path.isdir(f): - Prompt('Invalid path', - 'Cannot annotate directory: %s' % f, None).run() + Prompt(_('Invalid path'), + _('Cannot annotate directory: %s') % f, None).run()     dialog = DataMineDialog(u, repo, cwd, files, cmdoptions, True)   dialog.display()
Change 1 of 2 Show Entire File hggtk/​dialog.py Stacked
 
18
19
20
 
21
22
23
24
25
26
27
28
 
53
54
55
56
 
57
58
59
 
18
19
20
21
22
 
 
 
 
23
24
25
 
50
51
52
 
53
54
55
56
@@ -18,11 +18,8 @@
 pygtk.require("2.0")  import gtk  from gtklib import MessageDialog +from mercurial.i18n import _   - -def about(): - raise "About dialog currently under construction" -  def _message_dialog(parent, type, primary, secondary, buttons=gtk.BUTTONS_OK,   title="TortoiseHg"):   """ Display a given type of MessageDialog with the given message. @@ -53,7 +50,7 @@
  gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)   dialog = gtk.Dialog(parent=parent, flags=gtk.DIALOG_MODAL,   buttons=buttons) - dialog.set_title('TortoiseHg Prompt') + dialog.set_title(_('TortoiseHg Prompt'))   entry = gtk.Entry()   entry.set_text(default or '')   entry.set_visibility(visible)
Change 1 of 9 Show Changes Only hggtk/​gdialog.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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
 
 
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
 
 
 
466
467
468
469
470
471
472
473
474
475
476
477
 
 
478
479
480
481
482
483
 
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
 
517
518
519
 
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
 
 
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
 
 
464
465
466
467
468
469
470
471
472
473
474
475
476
477
 
478
479
480
 
 
 
 
 
481
482
483
484
 
 
 
 
 
 
 
 
 
 
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
 
504
505
506
 
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
 # gdialog.py - base dialog for gtools  #  # Copyright 2007 Brad Schick, brad at gmail . com  #  # This software may be used and distributed according to the terms  # of the GNU General Public License, incorporated herein by reference.  #    import mercurial.demandimport; mercurial.demandimport.disable()    import os  import threading  import StringIO  import sys  import shutil  import tempfile  import datetime  import cPickle    import pygtk  pygtk.require('2.0')  import gtk  import gobject  import pango    from mercurial.i18n import _  from mercurial.node import short  from mercurial import cmdutil, util, ui, hg, commands  from hgext import extdiff  from shlib import shell_notify, set_tortoise_icon, Settings  from thgconfig import ConfigDialog  from gtklib import MessageDialog  from hglib import toutf      class SimpleMessage(MessageDialog):   def run(self):   response = MessageDialog.run(self)   self.destroy()   return response      class Prompt(SimpleMessage):   def __init__(self, title, message, parent):   SimpleMessage.__init__(self, parent, gtk.DIALOG_MODAL,   gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE)   self.set_title(toutf(title))   self.set_markup('<b>' + toutf(message) + '</b>')    class Confirm(SimpleMessage):   """Dialog returns gtk.RESPONSE_YES or gtk.RESPONSE_NO   """   def __init__(self, title, files, parent, primary=None):   SimpleMessage.__init__(self, parent, gtk.DIALOG_MODAL,   gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO) - self.set_title(toutf('Confirm ' + title)) + self.set_title(toutf(_('Confirm ') + title))   if primary is None:   primary = title + ' file' + ((len(files) > 1 and 's') or '') + '?'   primary = '<b>' + primary + '</b>'   self.set_markup(toutf(primary))   message = ''   for i, f in enumerate(files):   message += ' ' + f + '\n'   if i == 9:   message += ' ...\n'   break   self.format_secondary_text(toutf(message))   accel_group = gtk.AccelGroup()   self.add_accel_group(accel_group)   buttons = self.get_children()[0].get_children()[1].get_children()   buttons[1].add_accelerator("clicked", accel_group, ord("y"),   0, gtk.ACCEL_VISIBLE)   buttons[0].add_accelerator("clicked", accel_group, ord("n"),   0, gtk.ACCEL_VISIBLE)      class GDialog(gtk.Window):   """GTK+ based dialog for displaying mercurial information     The following methods are meant to be overridden by subclasses. At this   point GCommit is really the only intended subclass.     parse_opts(self)   get_title(self)   get_minsize(self)   get_defsize(self)   get_tbbuttons(self)   get_body(self)   get_extras(self)   prepare_display(self)   should_live(self, widget, event)   save_settings(self)   load_settings(self, settings)   """     # "Constants"   settings_version = 1     def __init__(self, ui, repo, cwd, pats, opts, main):   gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)   self.cwd = cwd   self.ui = ui   self.ui.interactive=False   self.repo = repo   self.pats = pats   self.opts = opts   self.main = main   self.tmproot = None   self.toolbuttons = {}   self.settings = Settings(self.__class__.__name__)   self.init()     ### Following methods are meant to be overridden by subclasses ###     def init(self):   pass     def parse_opts(self):   pass       def get_title(self):   return ''     def get_icon(self):   return ''     def get_minsize(self):   return (395, 200)       def get_defsize(self):   return self._setting_defsize       def get_tbbuttons(self):   return []       def get_body(self):   return None       def get_extras(self):   return None       def prepare_display(self):   pass       def should_live(self, widget=None, event=None):   if self.main:   self._destroying(widget)   else:   self.destroy()   return False       def save_settings(self):   rect = self.get_allocation()   return {'gdialog': (rect.width, rect.height)}       def load_settings(self, settings):   if settings:   self._setting_defsize = settings['gdialog']   else:   self._setting_defsize = (678, 585)     ### End of overridable methods ###     def display(self, opengui=True):   self._parse_config()   self._load_settings()   if opengui:   self._setup_gtk()   self._parse_opts()   self.prepare_display()   self.show_all()   else:   self._parse_opts()   self.tooltips = gtk.Tooltips()       def test_opt(self, opt):   return opt in self.opts and self.opts[opt]       def _parse_config(self):   # defaults   self.fontcomment = 'monospace 10'   self.fontdiff = 'monospace 10'   self.fontlist = 'monospace 9'   self.diffopts = ''   self.diffcmd = ''   self.diffbottom = ''     for attr, setting in self.ui.configitems('gtools'):   if setting : setattr(self, attr, setting)     if not self.diffcmd :   # default to tortoisehg's configuration   vdiff = self.ui.config('tortoisehg', 'vdiff', 'vdiff')   if vdiff:   self.diffcmd = self.ui.config('extdiff', 'cmd.'+vdiff) or vdiff   else:   self.diffcmd = 'diff'   if not self.diffopts :   self.diffopts = '-Npru'     if not self.diffbottom:   self.diffbottom = False   elif self.diffbottom.lower() == 'false' or self.diffbottom == '0':   self.diffbottom = False   else:   self.diffbottom = True       def _parse_opts(self):   # Remove dry_run since Hg only honors it for certain commands   self.opts['dry_run'] = False   self.opts['force_editor'] = False   self.parse_opts()       def merge_opts(self, defaults, mergelist=()):   """Merge default options with the specified local options and globals.   Results is defaults + merglist + globals   """   newopts = {}   for hgopt in defaults:   newopts[hgopt[1].replace('-', '_')] = hgopt[2]   for mergeopt in mergelist:   newopts[mergeopt] = self.opts[mergeopt]   newopts.update(self.global_opts())   return newopts       def global_opts(self):   globalopts = {}   hgglobals = [opt[1].replace('-', '_') for opt in commands.globalopts if opt[1] != 'help']   for key in self.opts:   if key in hgglobals :   globalopts[key] = self.opts[key]   return globalopts       def count_revs(self):   cnt = 0   if self.test_opt('rev'):   for rev in self.opts['rev']:   cnt += len(rev.split(cmdutil.revrangesep, 1))   return cnt       def make_toolbutton(self, stock, label, handler,   userdata=None, menu=None, tip=None):   if menu:   tbutton = gtk.MenuToolButton(stock)   tbutton.set_menu(menu)   else:   tbutton = gtk.ToolButton(stock)     if tip:   tbutton.set_tooltip(self.tooltips, tip)   tbutton.set_use_underline(True)   tbutton.set_label(label)   tbutton.connect('clicked', handler, userdata)   self.toolbuttons[label] = tbutton   return tbutton       def get_toolbutton(self, label):   return self.toolbuttons[label]       def _setup_gtk(self):   self.set_title(self.get_title())   set_tortoise_icon(self, self.get_icon())     # Minimum size   minx, miny = self.get_minsize()   self.set_size_request(minx, miny)   # Initial size   defx, defy = self.get_defsize()   self.set_default_size(defx, defy)     vbox = gtk.VBox(False, 0)   self.add(vbox)     self.tooltips = gtk.Tooltips()   toolbar = gtk.Toolbar()   tbuttons = self.get_tbbuttons()   for tbutton in tbuttons:   toolbar.insert(tbutton, -1)   self.toolbar = toolbar   vbox.pack_start(toolbar, False, False, 0)     # Subclass returns the main body   body = self.get_body()   vbox.pack_start(body, True, True, 0)     # Subclass provides extra stuff in bottom hbox   extras = self.get_extras()   if extras:   vbox.pack_end(extras, False, False, 0)     self.connect('destroy', self._destroying)   self.connect('delete_event', self.should_live)       def _destroying(self, gtkobj):   try:   settings = self.save_settings()   self.settings.set_value('settings_version', GDialog.settings_version)   self.settings.set_value('dialogs', settings)   self.settings.write()   finally:   if self.main:   gtk.main_quit()       def _load_settings(self):   settings = {}   version = self.settings.get_value('settings_version', None)   if version == GDialog.settings_version:   settings = self.settings.get_value('dialogs', {})   self.load_settings(settings)       def _hg_call_wrapper(self, title, command, showoutput=True): - """Run the specified command and display any resulting aborts, messages, - and errors + """Run the specified command and display any resulting aborts, + messages, and errors   """   textout = ''   saved = sys.stderr   errors = StringIO.StringIO()   try:   sys.stderr = errors   self.ui.pushbuffer()   try:   command()   except util.Abort, inst: - Prompt(title + ' Aborted', str(inst), self).run() + Prompt(title + _(' Aborted'), str(inst), self).run()   return False, ''   finally:   sys.stderr = saved   textout = self.ui.popbuffer()   prompttext = ''   if showoutput:   prompttext = textout + '\n'   prompttext += errors.getvalue()   errors.close()   if len(prompttext) > 1: - Prompt(title + ' Messages and Errors', prompttext, self).run() + Prompt(title + _(' Messages and Errors'), prompttext, self).run()     return True, textout     def _diff_file(self, stat, file):   def dodiff():   extdiff.dodiff(self.ui, self.repo, self.diffcmd, [self.diffopts],   [self.repo.wjoin(file)], self.opts)     if self.diffcmd == 'diff': - Prompt('No visual diff configured', - 'Please select a visual diff application.', self).run() + Prompt(_('No visual diff configured'), + _('Please select a visual diff application.'), self).run()   dlg = ConfigDialog(self.repo.root, False)   dlg.show_all()   dlg.focus_field('tortoisehg.vdiff')   dlg.run()   dlg.hide()   self.ui = ui.ui()   self._parse_config()   return   thread = threading.Thread(target=dodiff, name='diff:'+file)   thread.setDaemon(True)   thread.start()       def _view_file(self, stat, file, force_left=False):   import atexit     def cleanup():   shutil.rmtree(self.tmproot)     if not self.tmproot:   self.tmproot = tempfile.mkdtemp(prefix='gtools.')   atexit.register(cleanup)     def snapshot_node(ui, repo, files, node, tmproot):   '''   snapshot files as of some revision   (adapted from Extdiff extension)   '''   mf = repo.changectx(node).manifest()   dirname = os.path.basename(repo.root)   if dirname == "":   dirname = "root"   dirname = '%s.%s' % (dirname, short(node))   base = os.path.join(tmproot, dirname)   try:   os.mkdir(base)   except:   pass   ui.note(_('making snapshot of %d files from rev %s\n') %   (len(files), short(node)))   for fn in files:   if not fn in mf:   # skipping new file after a merge ?   continue   wfn = util.pconvert(fn)   ui.note(' %s\n' % wfn)   dest = os.path.join(base, wfn)   destdir = os.path.dirname(dest)   if not os.path.isdir(destdir):   os.makedirs(destdir)   data = repo.wwritedata(wfn, repo.file(wfn).read(mf[wfn]))   open(dest, 'wb').write(data)   return dirname     def doedit():   pathroot = self.repo.root   copynode = None   # if we aren't looking at the wc, copy the node...   if stat in 'R!' or force_left:   copynode = self._node1   elif self._node2:   copynode = self._node2     if copynode:   copydir = snapshot_node(self.ui, self.repo,   [util.pconvert(file)], copynode, self.tmproot)   pathroot = os.path.join(self.tmproot, copydir)     file_path = os.path.join(pathroot, file)   util.system("%s \"%s\"" % (editor, file_path),   environ={'HGUSER': self.ui.username()},   onerr=util.Abort, errprefix=_('edit failed'))     editor = (self.ui.config('tortoisehg', 'editor') or   self.ui.config('gtools', 'editor') or   os.environ.get('HGEDITOR') or   self.ui.config('ui', 'editor') or   os.environ.get('EDITOR', 'vi'))   if os.path.basename(editor) in ('vi', 'vim', 'hgeditor'): - Prompt('No visual editor configured', - 'Please configure a visual editor.', self).run() + Prompt(_('No visual editor configured'), + _('Please configure a visual editor.'), self).run()   dlg = ConfigDialog(self.repo.root, False)   dlg.show_all()   dlg.focus_field('tortoisehg.editor')   dlg.run()   dlg.hide()   self.ui = ui.ui()   self._parse_config()   return     file = util.localpath(file)   thread = threading.Thread(target=doedit, name='edit:'+file)   thread.setDaemon(True)   thread.start()    class NativeSaveFileDialogWrapper: - """Wrap the windows file dialog, or display default gtk dialog if that isn't available""" - def __init__(self, InitialDir = None, Title = "Save File", + """Wrap the windows file dialog, or display default gtk dialog if + that isn't available""" + def __init__(self, InitialDir = None, Title = _('Save File'),   Filter = {"All files": "*.*"}, FilterIndex = 1, FileName = ''):   import os.path   if InitialDir == None:   InitialDir = os.path.expanduser("~")   self.InitialDir = InitialDir   self.FileName = FileName   self.Title = Title   self.Filter = Filter   self.FilterIndex = FilterIndex     def run(self): - """run the file dialog, either return a file name, or False if the user aborted the dialog""" + """run the file dialog, either return a file name, or False if + the user aborted the dialog"""   try: - import win32gui - if self.tortoiseHgIsInstalled(): #as of 20071021, the file dialog will hang if the tortoiseHg shell extension is installed. I have no clue why, yet - Tyberius Prime - return self.runCompatible() - else: - return self.runWindows() + return self.runWindows()   except ImportError:   return self.runCompatible()   - def tortoiseHgIsInstalled(self): - import _winreg - try: - _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, - r"Software\TortoiseHg") - return True - except WindowsError: #reg key not found - pass - return False -   def runWindows(self):   import win32gui, win32con   #filter = ""   #for name, pattern in self.Filter.iteritems():   # filter += name + "\0" + pattern + "\0"   #customfilter = "\0"     fname, customfilter, flags=win32gui.GetSaveFileNameW(   InitialDir=self.InitialDir,   Flags=win32con.OFN_EXPLORER,   File=self.FileName,   DefExt='py',   Title=self.Title,   Filter="",   CustomFilter="",   FilterIndex=1)   if fname:   return fname   else: - return False + return False     def runCompatible(self): - file_save =gtk.FileChooserDialog(self.Title,None, + file_save = gtk.FileChooserDialog(self.Title,None,   gtk.FILE_CHOOSER_ACTION_SAVE   , (gtk.STOCK_CANCEL   , gtk.RESPONSE_CANCEL   , gtk.STOCK_SAVE   , gtk.RESPONSE_OK))   file_save.set_do_overwrite_confirmation(True)   file_save.set_default_response(gtk.RESPONSE_OK)   file_save.set_current_folder(self.InitialDir)   file_save.set_current_name(self.FileName)   for name, pattern in self.Filter.iteritems():   fi = gtk.FileFilter()   fi.set_name(name)   fi.add_pattern(pattern)   file_save.add_filter(fi)   if file_save.run() == gtk.RESPONSE_OK:   result = file_save.get_filename();   else:   result = False   file_save.destroy()   return result
Change 1 of 2 Show Entire File hggtk/​gtklib.py Stacked
 
9
10
11
 
12
13
14
 
33
34
35
36
 
37
38
39
40
41
42
 
43
44
45
 
9
10
11
12
13
14
15
 
34
35
36
 
37
38
39
40
41
42
 
43
44
45
46
@@ -9,6 +9,7 @@
 import gtk  import gobject  import pango +from mercurial.i18n import _    class StatusBar(gtk.HBox):   def __init__(self, extra=None): @@ -33,13 +34,13 @@
  self.pbar.pulse()   return True   - def begin(self, msg="Running", timeout=100): + def begin(self, msg=_('Running'), timeout=100):   self.pbox.set_child_visible(True)   self.pbox.map()   self.set_status_text(msg)   self._timeout_event = gobject.timeout_add(timeout, self._pulse_timer)   - def end(self, msg="Done", unmap=True): + def end(self, msg=_('Done'), unmap=True):   gobject.source_remove(self._timeout_event)   self.set_status_text(msg)   if unmap: