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

use gtklib.idle_add_single_call

Changeset 33a1a07adece

Parent ea119f5700cb

by Adrian Buehlmann

Changes to 17 files · Browse files at 33a1a07adece Showing diff from parent ea119f5700cb Diff from another changeset...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
 
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
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
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
 # archive.py - TortoiseHg's dialog for archiving a repo revision  #  # Copyright 2009 Emmanuel Rosa <goaway1000@gmail.com>  #  # This software may be used and distributed according to the terms of the  # GNU General Public License version 2, incorporated herein by reference.    import os  import gtk  import gobject  import pango    from mercurial import hg, ui    from tortoisehg.util.i18n import _  from tortoisehg.util import hglib, paths    from tortoisehg.hgtk import hgcmd, gtklib, gdialog    WD_PARENT = _('= Working Directory Parent =')  MODE_NORMAL = 'normal'  MODE_WORKING = 'working'    class ArchiveDialog(gtk.Dialog):   """ Dialog to archive a Mercurial repo """     def __init__(self, rev=None):   """ Initialize the Dialog """   gtk.Dialog.__init__(self)   gtklib.set_tortoise_icon(self, 'menucheckout.ico')   gtklib.set_tortoise_keys(self)   self.set_resizable(False)   self.set_has_separator(False)   self.connect('response', self.dialog_response)     # buttons   self.archivebtn = self.add_button(_('Archive'), gtk.RESPONSE_OK)   self.closebtn = self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)     try:   repo = hg.repository(ui.ui(), path=paths.find_root())   except hglib.RepoError: - gobject.idle_add(self.destroy) + gtklib.idle_add_single_call(self.destroy)   return   self.repo = repo   self.set_title(_('Archive - %s') % hglib.get_reponame(repo))   self.prevtarget = None     # layout table   self.table = table = gtklib.LayoutTable()   self.vbox.pack_start(table, True, True, 2)     ## revision combo   self.combo = gtk.combo_box_entry_new_text()   self.combo.child.set_width_chars(28)   self.combo.child.connect('activate',   lambda b: self.response(gtk.RESPONSE_OK))   if rev:   self.combo.append_text(str(rev))   else:   self.combo.append_text(WD_PARENT)   self.combo.set_active(0)   for b in repo.branchtags():   self.combo.append_text(b)   tags = list(repo.tags())   tags.sort()   tags.reverse()   for t in tags:   self.combo.append_text(t)     table.add_row(_('Archive revision:'), self.combo)     ## dest combo & browse button   self.destentry = gtk.Entry()   self.destentry.set_width_chars(46)     destbrowse = gtk.Button(_('Browse...'))   destbrowse.connect('clicked', self.browse_clicked)     table.add_row(_('Destination path:'), self.destentry, 0, destbrowse)     ## archive types   self.filesradio = gtk.RadioButton(None, _('Directory of files'))   self.filesradio.connect('toggled', self.type_changed)   table.add_row(_('Archive types:'), self.filesradio, ypad=0)   def add_type(label):   radio = gtk.RadioButton(self.filesradio, label)   radio.connect('toggled', self.type_changed)   table.add_row(None, radio, ypad=0)   return radio   self.tarradio = add_type(_('Uncompressed tar archive'))   self.tbz2radio = add_type(_('Tar archive compressed using bzip2'))   self.tgzradio = add_type(_('Tar archive compressed using gzip'))   self.uzipradio = add_type(_('Uncompressed zip archive'))   self.zipradio = add_type(_('Zip archive compressed using deflate'))     # register signal handlers   self.combo.connect('changed', lambda c: self.update_path())     # prepare to show   self.update_path(hglib.toutf(repo.root))   self.archivebtn.grab_focus() - gobject.idle_add(self.after_init) + gtklib.idle_add_single_call(self.after_init)     def after_init(self):   # CmdWidget   self.cmd = hgcmd.CmdWidget()   self.cmd.show_all()   self.cmd.hide()   self.vbox.pack_start(self.cmd, True, True, 6)     # abort button   self.abortbtn = self.add_button(_('Abort'), gtk.RESPONSE_CANCEL)   self.abortbtn.hide()     def dialog_response(self, dialog, response_id):   def abort():   self.cmd.stop()   self.cmd.show_log()   self.switch_to(MODE_NORMAL, cmd=False)   # Archive button   if response_id == gtk.RESPONSE_OK:   self.archive()   # Close button or dialog closing by the user   elif response_id in (gtk.RESPONSE_CLOSE, gtk.RESPONSE_DELETE_EVENT):   if self.cmd.is_alive():   ret = gdialog.Confirm(_('Confirm Abort'), [], self,   _('Do you want to abort?')).run()   if ret == gtk.RESPONSE_YES:   abort()   else:   self.destroy()   return # close dialog   # Abort button   elif response_id == gtk.RESPONSE_CANCEL:   abort()   else:   raise _('unexpected response id: %s') % response_id     self.run() # don't close dialog     def type_changed(self, radio):   if not radio.get_active():   return   self.update_path()     def update_path(self, path=None):   def remove_ext(path):   for ext in ('.tar', '.tar.bz2', '.tar.gz', '.zip'):   if path.endswith(ext):   return path.replace(ext, '')   return path   def remove_rev(path):   model = self.combo.get_model()   revs = [rev[0] for rev in model]   revs.append(wdrev)   if not self.prevtarget is None:   revs.append(self.prevtarget)   for rev in ['_' + rev for rev in revs]:   if path.endswith(rev):   return path.replace(rev, '')   return path   def add_rev(path, rev):   return '%s_%s' % (path, rev)   def add_ext(path):   select = self.get_selected_archive_type()   if select['type'] != 'files':   path += select['ext']   return path   text = self.combo.get_active_text()   if len(text) == 0:   return   wdrev = str(self.repo['.'].rev())   if text == WD_PARENT:   text = wdrev   else:   try:   self.repo[text]   except (hglib.RepoError, hglib.LookupError):   return   if path is None:   path = self.destentry.get_text()   path = remove_ext(path)   path = remove_rev(path)   path = add_rev(path, text)   path = add_ext(path)   self.destentry.set_text(path)   self.prevtarget = text     def get_selected_archive_type(self):   """Return a dictionary describing the selected archive type"""   if self.tarradio.get_active():   return {'type': 'tar', 'ext': '.tar',   'label': _('Tar archives')}   elif self.tbz2radio.get_active():   return {'type': 'tbz2', 'ext': '.tar.bz2',   'label': _('Bzip2 tar archives')}   elif self.tgzradio.get_active():   return {'type': 'tgz', 'ext': '.tar.gz',   'label': _('Gzip tar archives')}   elif self.uzipradio.get_active():   return {'type': 'uzip', 'ext': '.zip',   'label': ('Uncompressed zip archives')}   elif self.zipradio.get_active():   return {'type': 'zip', 'ext': '.zip',   'label': _('Compressed zip archives')}   return {'type': 'files', 'ext': None, 'label': None}     def browse_clicked(self, button):   """Select the destination directory or file"""   dest = hglib.fromutf(self.destentry.get_text())   if not os.path.exists(dest):   dest = os.path.dirname(dest)   select = self.get_selected_archive_type()   if select['type'] == 'files':   response = gtklib.NativeFolderSelectDialog(   initial=dest,   title=_('Select Destination Folder')).run()   else:   ext = '*' + select['ext']   label = '%s (%s)' % (select['label'], ext)   response = gtklib.NativeSaveFileDialogWrapper(   initial=dest,   title=_('Select Destination File'),   filter=((label, ext),   (_('All Files (*.*)'), '*.*'))).run()   if response:   self.destentry.set_text(response)     def switch_to(self, mode, cmd=True):   if mode == MODE_NORMAL:   normal = True   self.closebtn.grab_focus()   elif mode == MODE_WORKING:   normal = False   self.abortbtn.grab_focus()   else:   raise _('unknown mode name: %s') % mode   working = not normal     self.table.set_sensitive(normal)   self.archivebtn.set_property('visible', normal)   self.closebtn.set_property('visible', normal)   if cmd:   self.cmd.set_property('visible', working)   self.abortbtn.set_property('visible', working)     def archive(self):   # verify input   type = self.get_selected_archive_type()['type']   dest = self.destentry.get_text()   if os.path.exists(dest):   if type != 'files':   ret = gdialog.Confirm(_('Confirm Overwrite'), [], self,   _('The destination "%s" already exists!\n\n'   'Do you want to overwrite it?') % dest).run()   if ret != gtk.RESPONSE_YES:   return False   elif len(os.listdir(dest)) > 0:   ret = gdialog.Confirm(_('Confirm Overwrite'), [], self,   _('The directory "%s" isn\'t empty!\n\n'   'Do you want to overwrite it?') % dest).run()   if ret != gtk.RESPONSE_YES:   return False     cmdline = ['hg', 'archive', '--verbose']   rev = self.combo.get_active_text()   if rev != WD_PARENT:   cmdline.append('--rev')   cmdline.append(rev)   cmdline.append('-t')   cmdline.append(type)   cmdline.append(hglib.fromutf(dest))     def cmd_done(returncode, useraborted):   self.switch_to(MODE_NORMAL, cmd=False)   if returncode == 0:   if not self.cmd.is_show_log():   self.response(gtk.RESPONSE_CLOSE)   self.cmd.set_result(_('Archived successfully'), style='ok')   elif useraborted:   self.cmd.set_result(_('Canceled archiving'), style='error')   else:   self.cmd.set_result(_('Failed to archive'), style='error')   self.switch_to(MODE_WORKING)   self.cmd.execute(cmdline, cmd_done)    def run(ui, *pats, **opts):   return ArchiveDialog(opts.get('rev'))
 
44
45
46
47
 
48
49
50
 
103
104
105
106
 
107
108
109
 
44
45
46
 
47
48
49
50
 
103
104
105
 
106
107
108
109
@@ -44,7 +44,7 @@
  try:   repo = hg.repository(ui.ui(), path=paths.find_root())   except hglib.RepoError: - gobject.idle_add(self.destroy) + gtklib.idle_add_single_call(self.destroy)   return     # message @@ -103,7 +103,7 @@
  # prepare to show   self.load_settings()   self.backoutbtn.grab_focus() - gobject.idle_add(self.after_init) + gtklib.idle_add_single_call(self.after_init)     def after_init(self):   # CmdWidget
 
152
153
154
155
 
156
157
158
 
152
153
154
 
155
156
157
158
@@ -152,7 +152,7 @@
  # prepare to show   self.load_settings()   destcombo.grab_focus() - gobject.idle_add(self.after_init) + gtklib.idle_add_single_call(self.after_init)     def after_init(self):   #CmdWidget
 
388
389
390
391
 
392
393
394
 
388
389
390
 
391
392
393
394
@@ -388,7 +388,7 @@
  self.vpaned = gtk.VPaned()   self.vpaned.pack1(vbox, shrink=False)   self.vpaned.pack2(vbox2, shrink=False) - gobject.idle_add(self.realize_settings) + gtklib.idle_add_single_call(self.realize_settings)   return self.vpaned     def get_preview_tab_name(self):
 
45
46
47
48
 
49
50
51
 
217
218
219
220
 
221
222
223
 
45
46
47
 
48
49
50
51
 
217
218
219
 
220
221
222
223
@@ -45,7 +45,7 @@
  try:   repo = hg.repository(ui.ui(), path=paths.find_root())   except hglib.RepoError: - gobject.idle_add(self.destroy) + gtklib.idle_add_single_call(self.destroy)   return   self.repo = repo   self.notify_func = None @@ -217,7 +217,7 @@
  self.cantree.connect('row-activated', lambda b: self.accept_match())   self.cantree.get_selection().connect('changed', self.show_diff)   self.connect('delete-event', lambda *a: self.save_settings()) - gobject.idle_add(self.refresh) + gtklib.idle_add_single_call(self.refresh)     def set_notify_func(self, func):   self.notify_func = func
 
319
320
321
322
 
323
324
325
 
520
521
522
523
 
524
525
526
 
319
320
321
 
322
323
324
325
 
520
521
522
 
523
524
525
526
@@ -319,7 +319,7 @@
  self.show_log(False)   if self.is_compact:   self.set_pbar(False) - gobject.idle_add(after_init) + gtklib.idle_add_single_call(after_init)     ### public functions ###   @@ -520,7 +520,7 @@
  def call_callback():   callback(returncode, self.useraborted, *args, **kargs)   self.useraborted = False - gobject.idle_add(call_callback) + gtklib.idle_add_single_call(call_callback)   return False # Stop polling this function   else:   return True # Continue polling
 
209
210
211
212
 
213
214
215
 
209
210
211
 
212
213
214
215
@@ -209,7 +209,7 @@
  frame.add(eventbox)   self._eventbox = eventbox   mainvbox.pack_start(frame, True, True, 4) - gobject.idle_add(self._refresh, True) + gtklib.idle_add_single_call(self._refresh, True)     def _toolbutton(self, stock, label, handler, tip):   tbutton = gtk.ToolButton(stock)
 
29
30
31
32
 
33
34
35
 
146
147
148
149
 
150
151
152
 
29
30
31
 
32
33
34
35
 
146
147
148
 
149
150
151
152
@@ -29,7 +29,7 @@
  try:   repo = hg.repository(ui.ui(), path=paths.find_root())   except hglib.RepoError: - gobject.idle_add(self.destroy) + gtklib.idle_add_single_call(self.destroy)   return   self.repo = repo   self.set_title(_('Ignore filter - %s') % hglib.get_reponame(repo)) @@ -146,7 +146,7 @@
    # prepare to show   self.glob_entry.grab_focus() - gobject.idle_add(self.refresh) + gtklib.idle_add_single_call(self.refresh)     def file_selected(self, combo):   'select another ignore file'
 
969
970
971
972
 
973
974
975
 
969
970
971
 
972
973
974
975
@@ -969,7 +969,7 @@
  self.vpaned = gtk.VPaned()   self.vpaned.pack1(midpane, True, False)   self.vpaned.pack2(self.hpaned) - gobject.idle_add(self.realize_settings) + gtklib.idle_add_single_call(self.realize_settings)     vbox = gtk.VBox()   vbox.pack_start(self.vpaned, True, True)
 
39
40
41
42
 
43
44
45
46
47
48
 
49
50
51
 
94
95
96
97
 
98
99
100
 
39
40
41
 
42
43
44
45
46
47
 
48
49
50
51
 
94
95
96
 
97
98
99
100
@@ -39,13 +39,13 @@
  if not rev:   gdialog.Prompt(_('Unable to merge'),   _('Must supply a target revision'), self).run() - gobject.idle_add(self.destroy) + gtklib.idle_add_single_call(self.destroy)   return     try:   repo = hg.repository(ui.ui(), path=paths.find_root())   except hglib.RepoError: - gobject.idle_add(self.destroy) + gtklib.idle_add_single_call(self.destroy)   return   self.set_title(_('Merging in %s') % hglib.get_reponame(repo))   @@ -94,7 +94,7 @@
  self.mergebtn.grab_focus()   self.commitbtn.set_sensitive(False)   self.undobtn.set_sensitive(False) - gobject.idle_add(self.after_init) + gtklib.idle_add_single_call(self.after_init)     def after_init(self):   # CmdWidget
 
35
36
37
38
 
39
40
41
 
157
158
159
160
 
161
162
163
164
165
166
 
167
168
169
 
244
245
246
247
 
248
249
250
 
35
36
37
 
38
39
40
41
 
157
158
159
 
160
161
162
163
164
165
 
166
167
168
169
 
244
245
246
 
247
248
249
250
@@ -35,7 +35,7 @@
  try:   repo = hg.repository(ui.ui(), path=paths.find_root())   except hglib.RepoError: - gobject.idle_add(self.destroy) + gtklib.idle_add_single_call(self.destroy)   return     # Handle rm alias @@ -157,13 +157,13 @@
  if not len(fm):   gdialog.Prompt(_('No appropriate files'),   _('No files found for this operation'), self).run() - gobject.idle_add(self.destroy) + gtklib.idle_add_single_call(self.destroy)   self.hide()   return     # prepare to show   self.gobutton.grab_focus() - gobject.idle_add(self.after_init) + gtklib.idle_add_single_call(self.after_init)     def after_init(self):   # CmdWidget @@ -244,7 +244,7 @@
  pass     if not list: - gobject.idle_add(self.response, gtk.RESPONSE_CLOSE) + gtklib.idle_add_single_call(self.response, gtk.RESPONSE_CLOSE)   return     cmdline = ['hg', self.command, '--verbose'] + list
 
33
34
35
36
 
37
38
39
 
33
34
35
 
36
37
38
39
@@ -33,7 +33,7 @@
  try:   repo = hg.repository(ui.ui(), path=paths.find_root())   except hglib.RepoError: - gobject.idle_add(self.destroy) + gtklib.idle_add_single_call(self.destroy)   return   self.repo = repo   self.reponame = hglib.get_reponame(repo)
 
467
468
469
470
 
471
472
473
 
467
468
469
 
470
471
472
473
@@ -467,7 +467,7 @@
  def prepare_display(self):   val = self.repo.ui.config('tortoisehg', 'ciexclude', '')   self.excludes = [i.strip() for i in val.split(',') if i.strip()] - gobject.idle_add(self.realize_status_settings) + gtklib.idle_add_single_call(self.realize_status_settings)     def refresh_complete(self):   pass
 
261
262
263
264
 
265
266
267
 
313
314
315
316
 
317
318
319
 
261
262
263
 
264
265
266
267
 
313
314
315
 
316
317
318
319
@@ -261,7 +261,7 @@
  # prepare to show   self.load_settings()   self.update_pull_setting() - gobject.idle_add(self.finalize_startup) + gtklib.idle_add_single_call(self.finalize_startup)     def create_bottombox(self):   self.buttonhbox = gtk.HBox() @@ -313,7 +313,7 @@
  def _drag_receive(self, widget, context, x, y, selection, targetType, time):   if time != self.last_drop_time:   files = selection.get_uris() - gobject.idle_add(self._set_path, files[0]) + gtklib.idle_add_single_call(self._set_path, files[0])   self.last_drop_time = time     def _set_path(self, uri):
 
121
122
123
124
 
125
126
127
 
651
652
653
654
 
655
656
657
 
121
122
123
 
124
125
126
127
 
651
652
653
 
654
655
656
657
@@ -121,7 +121,7 @@
  self.btn['menu'] = menubtn   def after_init():   menubtn.child.get_children()[0].hide() - gobject.idle_add(after_init) + gtklib.idle_add_single_call(after_init)   self.pack_start(tbar, False, False)     # center pane @@ -651,7 +651,7 @@
  def unselect():   selection = list.get_selection()   selection.unselect_all() - gobject.idle_add(unselect) + gtklib.idle_add_single_call(unselect)   elif event.button == 3:   if pathinfo:   self.show_patch_cmenu(self.list, pathinfo[0])
 
36
37
38
39
 
40
41
42
 
96
97
98
99
 
100
101
102
 
36
37
38
 
39
40
41
42
 
96
97
98
 
99
100
101
102
@@ -36,7 +36,7 @@
  try:   repo = hg.repository(ui.ui(), path=paths.find_root())   except hglib.RepoError: - gobject.idle_add(self.destroy) + gtklib.idle_add_single_call(self.destroy)   return   self.repo = repo   self.set_title(_('Update - %s') % hglib.get_reponame(repo)) @@ -96,7 +96,7 @@
    # prepare to show   self.updatebtn.grab_focus() - gobject.idle_add(self.after_init) + gtklib.idle_add_single_call(self.after_init)     def after_init(self):   # CmdWidget
 
139
140
141
142
 
143
144
145
 
179
180
181
182
 
183
184
185
 
139
140
141
 
142
143
144
145
 
179
180
181
 
182
183
184
185
@@ -139,7 +139,7 @@
  dlg.focus_field('tortoisehg.vdiff')   dlg.run()   dlg.hide() - gobject.idle_add(self.destroy) + gtklib.idle_add_single_call(self.destroy)     def search_filelist(self, model, column, key, iter):   'case insensitive filename search' @@ -179,7 +179,7 @@
  gdialog.Prompt(_('No file changes'),   _('There are no file changes to view'), self).run()   # GTK+ locks up if this is done immediately here - gobject.idle_add(self.destroy) + gtklib.idle_add_single_call(self.destroy)   return     tmproot = tempfile.mkdtemp(prefix='extdiff.')