On Linux, file overwrite confirmation occurs twice:
- due to dlg.set_do_overwrite_confirmation(True)
- and at the caller of gtklib.NativeSaveFileDialogWrapper()
This changeset adds overwrite confirmation to
gtklib.NativeSaveFileDialogWrapper() so that it works the
same way on Windows and Linux.
# HG changeset patch
# User Emmanuel Rosa <goaway1...@gmail.com>
# Date 1256358612 14400
# Branch stable
# Node ID d72d0c6765e4f6edbf6c200ee1c256d5fed478cb
# Parent e99854462f58cb9e03468c6f648575008055322c
gtklib: centralize file overwrite confirmation
On Linux, file overwrite confirmation occurs twice:
- due to dlg.set_do_overwrite_confirmation(True)
- and at the caller of gtklib.NativeSaveFileDialogWrapper()
This changeset adds overwrite confirmation to
gtklib.NativeSaveFileDialogWrapper() so that it works the
same way on Windows and Linux.
diff --git a/tortoisehg/hgtk/gtklib.py b/tortoisehg/hgtk/gtklib.py
--- a/tortoisehg/hgtk/gtklib.py
+++ b/tortoisehg/hgtk/gtklib.py
@@ -16,7 +16,7 @@
from tortoisehg.util.i18n import _
from tortoisehg.util import paths, hglib, thread2
-from tortoisehg.hgtk import hgtk
+from tortoisehg.hgtk import hgtk, gdialog
if gtk.gtk_version < (2, 14, 0):
# at least on 2.12.12, gtk widgets can be confused by control
@@ -162,10 +162,11 @@
"""run the file dialog, either return a file name, or False if
the user aborted the dialog"""
try:
- import win32gui, win32con, pywintypes
- return self.runWindows()
+ import win32gui, win32con, pywintypes
+ filepath = self.runWindows()
except ImportError:
- return self.runCompatible()
+ filepath = self.runCompatible()
+ return self.overwriteConfirmation(filepath)
def runWindows(self):
@@ -217,7 +218,6 @@
buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_SAVE, gtk.RESPONSE_OK)
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.initial)
if not self.open:
@@ -233,6 +233,18 @@
result = False
dlg.destroy()
return result
+
+ def overwriteConfirmation(self, filepath):
+ result = filepath
+ if os.path.exists(filepath):
+ res = gdialog.Confirm(_('Confirm Overwrite'), [], None,
+ _('The file "%s" already exists!\n\n'
+ 'Do you want to overwrite it?') % filepath).run()
+ if res == gtk.RESPONSE_YES:
+ os.remove(filepath)
+ else:
+ result = False
+ return result
class NativeFolderSelectDialog:
"""Wrap the windows folder dialog, or display default gtk dialog if
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Tortoisehg-develop mailing list
Tortoisehg-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop