Пример #1
0
 def __loadCore__(self, core):
     """
     @summary: Load core information in treeview. It will be called by a thread.
     @param core: Core that will be loaded into tab project.
     """
     self.__doPreviewList__ = Configuration().getConfiguration().getboolean("TABPROJECT", "show_image_list")
     self.__maxHeight__ = Configuration().getConfiguration().getint("TABPROJECT", "max_height_list")
     self.__rescalePercent__ = Configuration().getConfiguration().getfloat("TABPROJECT", "resize_percent_list")
     self.__maxHeightImageIconView__ = Configuration().getConfiguration().getint("TABPROJECT", "max_height_imagelist")
     self.__numberOfColumns__ = Configuration().getConfiguration().getint("TABPROJECT", "number_of_columns_iconview")
     
     gtk.gdk.threads_enter()
     try:
         self.__iconview__.set_columns(self.__numberOfColumns__)
     finally:
         gtk.gdk.threads_leave()
     
     UIUtils.clearModelTreeview(self.__model__)
     
     # Gets pixbuf file 
     icon = FactoryControls.getPixbufFromStock(gtk.STOCK_FILE)
     
     for key, item in core.getItems().iteritems():
         item.refreshThumbnail()
         
         # Handler to extract metadata
         metaData = item.getMetadata()
         
         # Create a new row
         newRowData = [icon,
                       item.getPath(),
                       metaData.getDateTimeDigitized(),
                       item.getTarget() ,
                       item.getDescription(),
                       icon,
                       False]
         
         iterAdd = UIUtils.insertIterAtPathPosition(self.__model__, newRowData,
                                                     None, position=gtk.TREE_VIEW_DROP_AFTER)
         __log__.info("File inserted into target treeview. %s" % file)
         
         self.updateItemImage(iterAdd, item)
         
     self.__core__ = core
Пример #2
0
 def __addTargetFiles__(self, files, defaultIcon,
                        iterOp,
                        iter=None,
                        position=gtk.TREE_VIEW_DROP_AFTER,
                        recursiveLevel=0,
                        gtkLock=True):
     """
     @summary: Add files to target listview.
     @param files: List of files to add.
     @param defaultIcon: Default icon to associate with each file.
     @param iterOp: GtkIter of operation progress bar.
     @param recursiveLevel: Current recursive level.
     @param iter: Iter that it will use as reference to insert new files.
     @param position: Position over iter.    
     @param gtkLock: True to do a lock on gtk loop.
     """
     if (files != None):
         operations = RegOperations()
         
         # Add each file into target TreeView
         for file in files:
             __log__.debug("Adding %s" % file)
             if (iterOp != None):
                 operations.stepOperation(iterOp)
             if (file == ""):
                 __log__.warn("Empty file path. Skip file")
                 continue
             if (self.__core__.getItem(file) != None):
                 __log__.info("File %s already exists in target file list" % file)
                 continue
             
             # Checks if is a folder and system is configured to add files recursively
             if (os.path.isdir(file) and Configuration().getConfiguration().getboolean("UI_CORE", "add_recursive")):
                 __log__.debug("%s is folder. Adding images into folder." % file)
                 # Do recursivity
                 if (recursiveLevel < Configuration().getConfiguration().getint("UI_CORE", "recursive_level")):
                     ioUtils = IOUtils()
                     listNewFiles = []
                     if ((recursiveLevel + 1) != Configuration().getConfiguration().getint("UI_CORE", "recursive_level")):
                         listNewFiles += ioUtils.getDirectories(file, Configuration().getConfiguration().getboolean("NAVIGATOR", "show_hiddens"), getFullpath=True)
                     
                     listNewFiles += ioUtils.getFiles(file, Configuration().getConfiguration().getboolean("NAVIGATOR", "show_hiddens"), getFullpath=True)
                     __log__.debug("Adding images from folder %s" % file)
                     
                     operations.addElements(iterOp, len(listNewFiles), gtkLock=gtkLock)
                     self.__addTargetFiles__(listNewFiles, defaultIcon, iterOp,
                                             iter=iter, position=position,
                                             recursiveLevel=(recursiveLevel + 1), gtkLock=gtkLock)
                     
                     del ioUtils
                 else:
                     __log__.debug("Max. recursive level got.")
                 continue
 
             head, filename = os.path.split(file)
             item = CamItem(file, target=filename)
             __log__.debug("New CamItem created for filename %s. %s" % (filename, item))
                 
             # Create a new row
             newRowData = [defaultIcon,
                           file,
                           _("Loading..."),
                           filename ,
                           item.getDescription(),
                           defaultIcon,
                           False,
                           True]
             
             iterAdd = UIUtils.insertIterAtPathPosition(self.__model__, newRowData,
                                                        iter, position=position,
                                                        doGObject=gtkLock)
             __log__.info("New file inserted into target treeview. %s" % file)
         
             if (iterAdd != None):
                 self.__core__.addItem(file, item)
                 self.updateItem(iterAdd, item, gtkLock=gtkLock)
             else:
                 __log__.error("It could not insert new item into project. %s" % file)
                 del newRowData
                 del item
     else:
         __log__.warning("Files parameter is None")