OSDN Git Service

Create portable copy dialog: The portable directory field is left blank by default...
authorMichael Curran <mick@kulgan.net>
Mon, 16 Apr 2012 12:32:28 +0000 (22:32 +1000)
committerMichael Curran <mick@kulgan.net>
Mon, 16 Apr 2012 12:32:28 +0000 (22:32 +1000)
source/gui/installerGui.py

index 659b21e..230eddd 100644 (file)
@@ -136,12 +136,11 @@ class PortableCreaterDialog(wx.Dialog):
                # Translators: An informational message displayed in the Create Portable NVDA dialog.\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
-               # Translators: The label of the grouping containing options in the Create Portable NVDA dialog.\r
-               optionsSizer = wx.StaticBoxSizer(wx.StaticBox(self, label=_("Portable options")), wx.HORIZONTAL)\r
+               optionsSizer = wx.BoxSizer(wx.HORIZONTAL)\r
                # Translators: The label of a grouping containing controls to select the destination directory\r
                # in the Create Portable NVDA dialog.\r
                sizer = wx.StaticBoxSizer(wx.StaticBox(self, label=_("Portable directory:")), wx.HORIZONTAL)\r
-               ctrl = self.portableDirectoryEdit = wx.TextCtrl(self, value='e:\\')\r
+               ctrl = self.portableDirectoryEdit = wx.TextCtrl(self)\r
                sizer.Add(ctrl)\r
                # Translators: The label of a button to browse for a directory.\r
                ctrl = wx.Button(self, label=_("Browse..."))\r
@@ -173,11 +172,22 @@ class PortableCreaterDialog(wx.Dialog):
        def onBrowseForPortableDirectory(self, evt):\r
                # Translators: The title of the dialog presented when browsing for the\r
                # destination directory when creating a portable copy of NVDA.\r
-               with wx.DirDialog(self, _("Select portable  directory"), defaultPath=self.portableDirectoryEdit.Value) as d:\r
+               with wx.DirDialog(self, _("Select portable  directory"), defaultPath=self.portableDirectoryEdit.Value or "c:\\") as d:\r
                        if d.ShowModal() == wx.ID_OK:\r
                                self.portableDirectoryEdit.Value = d.Path\r
 \r
        def onCreatePortable(self, evt):\r
+               if not self.portableDirectoryEdit.Value:\r
+                       gui.messageBox(_("Please provide a directory to place the portable copy."),\r
+                       # Translators: The title of a dialog presented when an error occurs.\r
+                       _("Error"))\r
+                       return\r
+               drv=os.path.splitdrive(self.portableDirectoryEdit.Value)[0]\r
+               if drv and not os.path.isdir(drv):\r
+                       gui.messageBox(_("Invalid drive %s")%drv,\r
+                       # Translators: The title of a dialog presented when an error occurs.\r
+                       _("Error"))\r
+                       return\r
                self.Hide()\r
                doCreatePortable(self.portableDirectoryEdit.Value,self.createAutorunCheckbox.Value,self.copyUserConfigCheckbox.Value)\r
                self.Destroy()\r