Example #1
0
 def __addNewProject__(self, core=None, threadBlock=True, focused=False, projectType=None):
     """
     @summary: Add new project.
     @param core: Core that will be added. Default value is None
     @param threadBlock: True if it will be locked gtk-loop. Default True
     @param focused: True if new tab project will get the focus.
     """
     __log__.debug("Add new project: core=%s | threadBlock=%s | focused=%s | projectType=%s" % (core, threadBlock, focused, projectType))
     if (core == None):
         core = CamCore(temp=__TEMP_FOLDER__, projectType=projectType)
         __log__.debug("New core created. %s" % core)
         
     text = ""
     if (core.getName() == ""):    
         text = "%s_%d" % (_("Project"), len(self.__lsTabs__))
     else:
         text = core.getName()
     __log__.info("Project name %s" % text)
     tab = TabProject(core, name=text, iconsPath=os.path.join(__ICONS_FOLDER__),
                      iconName=core.getProjectType().getIconName())
     tab.setCloseCallback(self.__closeProject__)
     __log__.debug("Callbacks set")
     core.setName(text)
     tab.addToNotebook(self.__nbProjects__, threadBlock=threadBlock, focused=focused)
     tab.load()
     
     self.__lsTabs__.append(tab)
     
     if (self.__currentTab__ == None):
         __log__.debug("There is not current tab. It will set %s as current tab." % core.getName())
         self.__currentTab__ = tab
     
     __log__.debug("New project added to project notebook")
     
     self.__enableOptions__(blockGtk=threadBlock)
Example #2
0
 def __openProjectEvent__ (self, b):
     """
     @summary: Handle open project action.
     @param b: Button that threw event.
     """
     
     fileSel = gtk.FileChooserDialog(title=_("Open project"),
                                     parent=self.__mainWindow__,
                                     action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                     buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                              gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT))
     
     fileSel.set_default_response(gtk.RESPONSE_CANCEL)
     
     filterCam = gtk.FileFilter()
     filterCam.set_name(_("PyCamimg file"))
     filterCam.add_pattern("*%s" % self.PYCAMIMG_FILE_EXTENSION)
     fileSel.add_filter(filterCam)
     
     fileSel.set_modal(True)
     fileSel.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
     if (fileSel.run() == gtk.RESPONSE_ACCEPT):
         filename = fileSel.get_filename()
         __log__.debug("Open project from %s" % filename)
         if (not filename.endswith(self.PYCAMIMG_FILE_EXTENSION)):
             filename = "%s%s" % (filename, self.PYCAMIMG_FILE_EXTENSION)
         
         try:
             core = CamCore.load(filename, tempFolder=__TEMP_FOLDER__)
         except Exception, e:
             __log__.error("It could not load project from %s. %s" % (filename, e))
             FactoryControls.getMessage(_("An error was occurred when it was loading project from %s" % filename),
                                        type=gtk.MESSAGE_ERROR,
                                        title=_("Open project"),
                                        parent=self.__mainWindow__)
             return
         finally: