self.timer.Stop()\r
self.Destroy()\r
\r
-def createPortableCopy():\r
- with wx.DirDialog(gui.mainFrame,_("Choose where you wish to place the portable copy of NVDA")) as d:\r
- if d.ShowModal()!=wx.ID_OK:\r
- return\r
- path=d.Path\r
- copyUserConfig=gui.messageBox(_("Would you like to include your current NVDA settings in the portable copy?"), _("Copy User Configuration"), wx.YES_NO|wx.ICON_QUESTION) == wx.YES\r
- createAutorun=(ctypes.windll.kernel32.GetDriveTypeW(os.path.splitdrive(path)[0]+u'\\')==2 and gui.messageBox(_("Would you like to create an autorun file for your removable drive to allow NVDA to start automatically?"), _("Removable Drive Detected"), wx.YES_NO|wx.ICON_QUESTION) == wx.YES)\r
-\r
- d = IndeterminateProgressDialog(gui.mainFrame, _("Creating Portable Copy"), _("Please wait while a portable copy of NVDA is created."))\r
- try:\r
- installer.CreatePortableCopy(path,copyUserConfig=copyUserConfig,createAutorun=createAutorun)\r
- except OSError:\r
- d.done()\r
- gui.messageBox(_("Failed to create portable copy"),_("Error"))\r
- return\r
+class PortableCreaterDialog(wx.Dialog):\r
+\r
+ def __init__(self, parent):\r
+ super(PortableCreaterDialog, self).__init__(parent, title=_("Create Portable NVDA"))\r
+ mainSizer = self.mainSizer = wx.BoxSizer(wx.VERTICAL)\r
+ dialogCaption=wx.StaticText(self,label=_("To create a portable copy of NVDA, please select the path and other options and then press Continue")) \r
+ mainSizer.Add(dialogCaption)\r
+ optionsSizer = wx.StaticBoxSizer(wx.StaticBox(self, label=_("Portable options")), wx.HORIZONTAL)\r
+ sizer = wx.StaticBoxSizer(wx.StaticBox(self, label=_("Portable directory:")), wx.HORIZONTAL)\r
+ ctrl = self.portableDirectoryEdit = wx.TextCtrl(self, value='e:\\')\r
+ sizer.Add(ctrl)\r
+ ctrl = wx.Button(self, label=_("Browse..."))\r
+ ctrl.Bind(wx.EVT_BUTTON, self.onBrowseForPortableDirectory)\r
+ sizer.Add(ctrl)\r
+ optionsSizer.Add(sizer)\r
+ ctrl = self.createAutorunCheckbox = wx.CheckBox(self, label=_("Create an &Autorun file"))\r
+ ctrl.Value = False\r
+ optionsSizer.Add(ctrl)\r
+ ctrl = self.copyUserConfigCheckbox = wx.CheckBox(self, label=_("Copy current &user configuration"))\r
+ ctrl.Value = False\r
+ optionsSizer.Add(ctrl)\r
+ mainSizer.Add(optionsSizer)\r
+\r
+ sizer = wx.BoxSizer(wx.HORIZONTAL)\r
+ ctrl = wx.Button(self, label=_("C&ontinue"), id=wx.ID_OK)\r
+ ctrl.Bind(wx.EVT_BUTTON, self.onCreatePortable)\r
+ sizer.Add(ctrl)\r
+ sizer.Add(wx.Button(self, id=wx.ID_CANCEL))\r
+ # If we bind this using button.Bind, it fails to trigger when the dialog is closed.\r
+ self.Bind(wx.EVT_BUTTON, self.onCancel, id=wx.ID_CANCEL)\r
+ mainSizer.Add(sizer)\r
+\r
+ self.Sizer = mainSizer\r
+\r
+ def onBrowseForPortableDirectory(self, evt):\r
+ with wx.DirDialog(self, _("Select portable directory"), defaultPath=self.portableDirectoryEdit.Value) as d:\r
+ if d.ShowModal() == wx.ID_OK:\r
+ self.portableDirectoryEdit.Value = d.Path\r
+\r
+ def onCreatePortable(self, evt):\r
+ self.Hide()\r
+ doCreatePortable(self.portableDirectoryEdit.Value,self.createAutorunCheckbox.Value,self.copyUserConfigCheckbox.Value)\r
+\r
+ def onCancel(self, evt):\r
+ self.Destroy()\r
+\r
+def doCreatePortable(portableDirectory,createAutorun=False,copyUserConfig=False):\r
+ d = IndeterminateProgressDialog(gui.mainFrame, _("Creating Portable Copy"), _("Please wait while a portable copy of NVDA is created."))\r
+ try:\r
+ installer.CreatePortableCopy(portableDirectory,copyUserConfig=copyUserConfig,createAutorun=createAutorun)\r
+ except:\r
+ log.error("Failed to create portable copy",exc_info=True)\r
d.done()\r
- gui.messageBox(_("Successfully created a portable copy of NVDA at %s")%path,_("Success"))\r
+ gui.messageBox(_("Failed to create portable copy"),_("Error"))\r
+ return\r
+ d.done()\r
+ gui.messageBox(_("Successfully created a portable copy of NVDA at %s")%portableDirectory,_("Success"))\r