Refactor to use new protocol module and sipo.
[bertos.git] / wizard / BFolderPage.py
index 3b34f14af6e5bcbf4619d18e6866b8a24c53b4ef..f72df83511f4ccf10cf03f66bc5d84bcd73d1174 100644 (file)
@@ -28,7 +28,6 @@
 #
 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
 #
-# $Id$
 #
 # Author: Lorenzo Berni <duplo@develer.com>
 #
@@ -39,6 +38,9 @@ from PyQt4.QtGui import *
 from BWizardPage import *
 import bertos_utils
 
+from BCpuPage import BCpuPage
+from BBoardPage import BBoardPage
+
 from const import *
 
 class BFolderPage(BWizardPage):
@@ -62,6 +64,10 @@ class BFolderPage(BWizardPage):
         if self.pageContent.projectPath.text() != "None":
             self.setProjectInfo("PROJECT_PATH", unicode(self.pageContent.projectPath.text()))
             self.setProjectInfo("PROJECT_NAME", os.path.basename(unicode(self.pageContent.projectPath.text())))
+            self.setProjectInfo("PROJECT_SRC_PATH", os.path.join(self.projectInfo("PROJECT_PATH"), self.projectInfo("PROJECT_NAME")))
+            self.setProjectInfo("PROJECT_SRC_PATH_FROM_MAKEFILE", self.projectInfo("PROJECT_NAME"))
+            self.setProjectInfo("PROJECT_HW_PATH", os.path.join(self.projectInfo("PROJECT_PATH"), self.projectInfo("PROJECT_NAME")))
+            self.setProjectInfo("PROJECT_HW_PATH_FROM_MAKEFILE", self.projectInfo("PROJECT_NAME"))
             return True
         else:
             return False
@@ -83,6 +89,7 @@ class BFolderPage(BWizardPage):
         self.connect(self.pageContent.nameEdit, SIGNAL("textChanged(const QString)"), self.nameChanged)
         self.connect(self.pageContent.directoryEdit, SIGNAL("textChanged(const QString)"), self.directoryChanged)
         self.connect(self.pageContent.directoryButton, SIGNAL("clicked()"), self.selectDirectory)
+        # self.connect(self.pageContent.customButton, SIGNAL("toggled(bool)"), self.isComplete)
     
     ####
 
@@ -131,10 +138,15 @@ class BFolderPage(BWizardPage):
         if stored_folder != "":
             self._destination_folder = stored_folder
         elif os.name == "nt":
-            from win32com.shell import shell, shellcon
-            self._destination_folder = shell.SHGetFolderPath(0, shellcon.CSIDL_PERSONAL, 0, 0)
-            del shell
-            del shellcon
+            def _winGetSpecialFolder(csidl):
+                from ctypes import windll, create_unicode_buffer
+                MAX_PATH = 4096
+                buf = create_unicode_buffer(MAX_PATH)
+                if not windll.shell32.SHGetSpecialFolderPathW(0, buf, csidl, False):
+                    raise WindowsError("cannot get special folder location")
+                return buf.value
+            CSIDL_PERSONAL = 5
+            self._destination_folder = _winGetSpecialFolder(CSIDL_PERSONAL)
         else:
             self._destination_folder = os.path.expanduser("~")
         self.pageContent.directoryEdit.setText(self._destination_folder)