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

gtklib: fix argument names of NativeSaveFileDialogWrapper

Use similar argument names with NativeFolderSelectDialog.
Capitalized names are Win32 API's convention.

Changeset e8ee9d0617f5

Parent 93d3c0356c52

by Yuki KODAMA

Changes to 7 files · Browse files at e8ee9d0617f5 Showing diff from parent 93d3c0356c52 Diff from another changeset...

 
204
205
206
207
208
209
 
 
 
210
211
212
 
204
205
206
 
 
 
207
208
209
210
211
212
@@ -204,9 +204,9 @@
  ext = '*' + select['ext']   label = '%s (%s)' % (select['label'], ext)   response = gtklib.NativeSaveFileDialogWrapper( - InitialDir=dest, - Title=_('Select Destination File'), - Filter=((label, ext), + initial=dest, + title=_('Select Destination File'), + filter=((label, ext),   (_('All Files (*.*)'), '*.*'))).run()   if response:   self.destentry.set_text(response)
 
70
71
72
73
 
 
74
75
76
 
 
77
78
79
 
70
71
72
 
73
74
75
 
 
76
77
78
79
80
@@ -70,10 +70,11 @@
  return self.__error_text__     def save_report_clicked(self, button): - file_path = gtklib.NativeSaveFileDialogWrapper(Title = _('Save error report to')).run() + result = gtklib.NativeSaveFileDialogWrapper( + title=_('Save error report to')).run()   - if file_path: - fd = file(file_path, 'w') + if result: + fd = file(result, 'w')   fd.write(self.get_error_text())   fd.close()  
 
699
700
701
702
703
704
 
 
 
705
706
707
 
699
700
701
 
 
 
702
703
704
705
706
707
@@ -699,9 +699,9 @@
  filename = "%s@%d%s" % (wfile, self.currev, ext)   else:   filename = "%s@%d" % (ext, self.currev) - result = gtklib.NativeSaveFileDialogWrapper(Title=_("Save file to"), - InitialDir=self.cwd, - FileName=filename).run() + result = gtklib.NativeSaveFileDialogWrapper(title=_("Save file to"), + initial=self.cwd, + filename=filename).run()   if result:   if os.path.exists(result):   res = gdialog.Confirm(_('Confirm Overwrite'), [], self,
 
184
185
186
187
188
189
190
191
192
193
194
195
196
197
 
 
 
 
 
 
 
 
 
 
 
198
199
200
 
211
212
213
214
 
215
216
 
217
218
 
219
220
 
221
222
223
224
 
 
225
226
227
 
233
234
235
236
 
237
238
239
 
241
242
243
244
 
245
246
247
248
249
250
 
 
 
 
251
252
253
 
280
281
282
283
 
284
285
286
 
184
185
186
 
 
 
 
 
 
 
 
 
 
 
187
188
189
190
191
192
193
194
195
196
197
198
199
200
 
211
212
213
 
214
215
 
216
217
 
218
219
 
220
221
222
 
 
223
224
225
226
227
 
233
234
235
 
236
237
238
239
 
241
242
243
 
244
245
246
 
 
 
 
247
248
249
250
251
252
253
 
280
281
282
 
283
284
285
286
@@ -184,17 +184,17 @@
 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'), - Filter = ((_('All files'), '*.*'),), FilterIndex = 1, - FileName = '', Open=False): - if InitialDir == None: - InitialDir = os.path.expanduser("~") - self.InitialDir = InitialDir - self.FileName = FileName - self.Title = Title - self.Filter = Filter - self.FilterIndex = FilterIndex - self.Open = Open + def __init__(self, initial = None, title = _('Save File'), + filter = ((_('All files'), '*.*'),), filterindex = 1, + filename = '', open=False): + if initial is None: + initial = os.path.expanduser("~") + self.initial = initial + self.filename = filename + self.title = title + self.filter = filter + self.filterindex = filterindex + self.open = open     def run(self):   """run the file dialog, either return a file name, or False if @@ -211,17 +211,17 @@
  fname = None   try:   f = '' - for name, mask in self.Filter: + for name, mask in self.filter:   f += '\0'.join([name, mask,'']) - opts = dict(InitialDir=self.InitialDir, + opts = dict(InitialDir=self.initial,   Flags=win32con.OFN_EXPLORER, - File=self.FileName, + File=self.filename,   DefExt=None, - Title=hglib.fromutf(self.Title), + Title=hglib.fromutf(self.title),   Filter= hglib.fromutf(f),   CustomFilter=None, - FilterIndex=self.FilterIndex) - if self.Open: + FilterIndex=self.filterindex) + if self.open:   fname, _, _ = win32gui.GetOpenFileNameW(**opts)   else:   fname, _, _ = win32gui.GetSaveFileNameW(**opts) @@ -233,7 +233,7 @@
  return fname     def runCompatible(self): - if self.Open: + if self.open:   action = gtk.FILE_CHOOSER_ACTION_OPEN   buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,   gtk.STOCK_OPEN, gtk.RESPONSE_OK) @@ -241,13 +241,13 @@
  action = gtk.FILE_CHOOSER_ACTION_SAVE   buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,   gtk.STOCK_SAVE, gtk.RESPONSE_OK) - dlg = gtk.FileChooserDialog(self.Title, None, action, buttons) + dlg = gtk.FileChooserDialog(self.title, None, action, buttons)   dlg.set_do_overwrite_confirmation(True)   dlg.set_default_response(gtk.RESPONSE_OK) - dlg.set_current_folder(self.InitialDir) - if not self.Open: - dlg.set_current_name(self.FileName) - for name, pattern in self.Filter: + dlg.set_current_folder(self.initial) + if not self.open: + dlg.set_current_name(self.filename) + for name, pattern in self.filter:   fi = gtk.FileFilter()   fi.set_name(name)   fi.add_pattern(pattern) @@ -280,7 +280,7 @@
  import win32gui, pywintypes     def BrowseCallbackProc(hwnd, msg, lp, data): - if msg== shellcon.BFFM_INITIALIZED: + if msg == shellcon.BFFM_INITIALIZED:   win32gui.SendMessage(hwnd, shellcon.BFFM_SETSELECTION, 1, data)   elif msg == shellcon.BFFM_SELCHANGED:   # Set the status text of the
 
1312
1313
1314
1315
1316
1317
 
 
 
1318
1319
1320
 
1452
1453
1454
1455
1456
1457
 
 
 
1458
1459
1460
 
1481
1482
1483
1484
1485
1486
 
 
 
1487
1488
1489
 
1312
1313
1314
 
 
 
1315
1316
1317
1318
1319
1320
 
1452
1453
1454
 
 
 
1455
1456
1457
1458
1459
1460
 
1481
1482
1483
 
 
 
1484
1485
1486
1487
1488
1489
@@ -1312,9 +1312,9 @@
    filename = "%s_rev%d_to_rev%s.hg" % (os.path.basename(self.repo.root),   revrange[0], revrange[1]) - result = gtklib.NativeSaveFileDialogWrapper(Title=_('Write bundle to'), - InitialDir=self.repo.root, - FileName=filename).run() + result = gtklib.NativeSaveFileDialogWrapper(title=_('Write bundle to'), + initial=self.repo.root, + filename=filename).run()   if result:   cmdline = ['hg', 'bundle', '--base', str(parent),   '--rev', str(revrange[1]), result] @@ -1452,9 +1452,9 @@
  def export_patch(self, menuitem):   rev = self.currevid   filename = "%s_rev%s.patch" % (os.path.basename(self.repo.root), rev) - result = gtklib.NativeSaveFileDialogWrapper(Title=_('Save patch to'), - InitialDir=self.repo.root, - FileName=filename).run() + result = gtklib.NativeSaveFileDialogWrapper(title=_('Save patch to'), + initial=self.repo.root, + filename=filename).run()   if result:   if os.path.exists(result):   res = gdialog.Confirm(_('Confirm Overwrite'), [], self, @@ -1481,9 +1481,9 @@
  except (ValueError, hglib.LookupError):   return   filename = "%s_rev%d_to_tip.hg" % (os.path.basename(self.repo.root), rev) - result = gtklib.NativeSaveFileDialogWrapper(Title=_('Write bundle to'), - InitialDir=self.repo.root, - FileName=filename).run() + result = gtklib.NativeSaveFileDialogWrapper(title=_('Write bundle to'), + initial=self.repo.root, + filename=filename).run()   if result:   if os.path.exists(result):   res = gdialog.Confirm(_('Confirm Overwrite'), [], self,
 
852
853
854
855
856
857
858
859
 
 
 
 
860
861
862
 
 
863
864
865
 
1192
1193
1194
1195
1196
1197
1198
 
 
 
1199
1200
1201
 
852
853
854
 
 
 
 
 
855
856
857
858
859
 
 
860
861
862
863
864
 
1191
1192
1193
 
 
 
 
1194
1195
1196
1197
1198
1199
@@ -852,14 +852,13 @@
  def copy_file(self, wfile):   wfile = self.repo.wjoin(wfile)   fdir, fname = os.path.split(wfile) - response = gtklib.NativeSaveFileDialogWrapper( - Title=_('Copy file to'), - InitialDir=fdir, - FileName=fname).run() - if not response: + result = gtklib.NativeSaveFileDialogWrapper(title=_('Copy file to'), + initial=fdir, + filename=fname).run() + if not result:   return - if response != wfile: - self.hg_copy([wfile, response]) + if result != wfile: + self.hg_copy([wfile, result])   return True     @@ -1192,10 +1191,9 @@
  'Write selected diff hunks to a patch file'   revrange = self.opts.get('rev')[0]   filename = "%s.patch" % revrange.replace(':', '_to_') - fd = gtklib.NativeSaveFileDialogWrapper(Title=_('Save patch to'), - InitialDir=self.repo.root, - FileName=filename) - result = fd.run() + result = gtklib.NativeSaveFileDialogWrapper(title=_('Save patch to'), + initial=self.repo.root, + filename=filename).run()   if not result:   return  
 
374
375
376
377
378
379
380
381
 
 
 
 
 
382
383
384
385
386
387
388
389
390
391
392
 
 
 
 
 
 
 
 
393
394
395
 
374
375
376
 
 
 
 
 
377
378
379
380
381
382
383
384
 
 
 
 
 
 
 
 
385
386
387
388
389
390
391
392
393
394
395
@@ -374,22 +374,22 @@
    def btn_remotepath_clicked(self, button):   """ select source folder to clone """ - response = gtklib.NativeFolderSelectDialog( - initial=self.root, - title=_('Select Repository')).run() - if response: - self.pathtext.set_text(response) + result = gtklib.NativeFolderSelectDialog( + initial=self.root, + title=_('Select Repository')).run() + if result: + self.pathtext.set_text(result)     def btn_bundlepath_clicked(self, button):   """ select bundle to read from """ - response = gtklib.NativeSaveFileDialogWrapper( - InitialDir=self.root, - Title=_('Select Bundle'), - Filter=((_('Bundle (*.hg)'), '*.hg'), - (_('Bundle (*)'), '*.*')), - Open=True).run() - if response: - self.pathtext.set_text(response) + result = gtklib.NativeSaveFileDialogWrapper( + title=_('Select Bundle'), + initial=self.root, + filter=((_('Bundle (*.hg)'), '*.hg'), + (_('Bundle (*)'), '*.*')), + open=True).run() + if result: + self.pathtext.set_text(result)     def should_live(self):   if self.cmd_running():