Exemplo n.º 1
0
 def expandToPath(self, path, glock=True):
     """
     @summary: Expand row at path, expanding any ancestors as needed.
     @param path: Path to expand.
     @param glock: True to look gtk-loop. Default True.
     """
     UIUtils.expandTreeview(self.__explorer__, path, glock)
Exemplo n.º 2
0
 def enabledNavigationButtons(self, glock=False):
     """
     @summary: Enabled or disabled navigation buttons.
     @param glock: True if gtk loop must be locked. 
     """
     UIUtils.enabledWidget(self.__bBack__, self.__currPointStack__ > 0, glock)
     UIUtils.enabledWidget(self.__bForward__, self.__currPointStack__ < (len(self.__stackDirs__) - 1), glock)
Exemplo n.º 3
0
 def deleteNode (self, iter, glock=True):
     """
     @summary: Delete an iter from TreeView.
     @param iter: TreeIter to delete.
     @param glock: True to look gtk-loop. Default True.  
     """
     UIUtils.deleteIter(self.__model__, iter, glock)   
Exemplo n.º 4
0
    def __expandPath__ (self, path, select):
        """
        @summary: Expand a path on navigator TreeView.
        @param path: Path to expand.
        @param select: True to select TreeIter.  
        """
        head, dir = os.path.split(path)
        iter = None
        
        if (path == os.path.expanduser("~")):
            __log__.debug("Expanding home directory...")
            iter = self.__findDirectoryOnParent__(None, self.__HOME_NODE__)
        elif(head == path):
            # If head is equal path, path is a drive or mount point
            iter = self.__findDirectoryOnParent__(None, head)

        if (iter == None):
            iterparent = self.__expandPath__ (head, False)
            if (iterparent != None):
                iter = self.__findDirectoryOnParent__ (iterparent, dir)

        if (iter != None):
            treepath = self.__model__.get_path(iter)
            self.__fillDirectory__(treepath)
            if (select):
                UIUtils.expandTreeview(self.__explorer__, treepath)

                selection = self.__explorer__.get_selection()
                selection.select_path(treepath)
                
                UIUtils.scrollTreeviewToPath(self.__explorer__, treepath)
                
        return iter
Exemplo n.º 5
0
 def removeOperation(self, iter):
     """
     @summary: Removes an operation from TreeView.
     @param iter: Iter to delete. 
     """
     UIUtils.deleteIter(self.__opsModel__, iter)
     del iter
Exemplo n.º 6
0
 def deleteImages (self, paths, gtkLock=True):
     """
     @summary: Delete images from target treeview.
     @param paths: Paths to delete 
     @param gtkLock: True to do a lock on gtk loop.
     """
     if (paths != None):
         paths.sort(reverse=True)
         for path in paths:
             # Delete selected items on target treeview
             iter = self.__model__.get_iter(path)
             if (iter != None):
                 text = self.__model__.get_value(iter, self.COLUMN_SOURCE)
             else:
                 __log__.warn("Can not find iter from path %s. Skip path" % path)
                 continue
             
             waitDelete = self.__model__.get_value(iter, self.COLUMN_LOADING)
             while (waitDelete):
                 time.sleep(WAIT_UPDATE)
                 waitDelete = self.__model__.get_value(iter, self.COLUMN_LOADING)
             
             
             self.__core__.removeItem(text)
             UIUtils.deleteIter(self.__model__, iter, doGObject=gtkLock)
             __log__.info("Delete file %s from project" % text)
     else:
         __log__.debug("There are not files to delete")
Exemplo n.º 7
0
 def updateItemDescription(self, iter, item, gtkLock=True):
     """
     @summary: Update description of an item.
     @param iter: GtkTreeIter that represents an item.
     @param item: CamItem to update.
     @param gtkLock: True to do the action with gtklock.
     """
     UIUtils.setIterData(self.getModel(), iter, self.COLUMN_OPERATIONS, item.getDescription(), doGObject=gtkLock)
Exemplo n.º 8
0
 def updateItemTarget(self, iter, item, gtkLock=True):
     """
     @summary: Update target of an item.
     @param iter: GtkTreeIter that represents an item.
     @param item: CamItem to update.
     @param gtkLock: True to do the action with gtklock
     """
     UIUtils.setIterData(self.getModel(), iter, self.COLUMN_TARGET, item.getTarget(), doGObject=gtkLock)
Exemplo n.º 9
0
 def stepOperation(self, iter):
     """
     @summary: Does a step.
     @param iter: Do a step on a iter.
     """
     value = float(self.__opsModel__.get_value(iter, self.__VALUE_COLUMN__)) / 100
     step = self.__opsModel__.get_value(iter, self.__STEP_COLUMN__)
     value += step
     UIUtils.setIterData(self.__opsModel__, iter, self.__VALUE_COLUMN__, value * 100)
Exemplo n.º 10
0
 def __initData__(self, gtkLock=False):
     """
     @summary: Set data to dialog.
     """        
     if (self.__item__ != None):
         lOperations = self.__item__.getOperations()
         if (lOperations != None):
             for key, op in lOperations.iteritems():
                 newRowData = [key, op.getOp(), op.toString(), False]
                 UIUtils.addIterListView(self.__model__,
                                         newRowData,
                                         doGObject=gtkLock)
                 __log__.info("New file inserted into operations treeview. %s" % key)
Exemplo n.º 11
0
 def addToNotebook(self, notebook, threadBlock=True, focused=True):
     """
     @summary: Add tab to notebook.
     @param notebook: Notebook where tab will be added.
     @param threadBlock: True for block gtk loop.
     @param focused: True for focus tab when will be added.   
     """
     self.__notebook__ = notebook
     UIUtils.addTabControl(notebook,
                           self.__scroll__,
                           self.__tabWidget__,
                           doGObject=threadBlock)
     if (focused):
         self.__notebook__.set_current_page(self.__notebook__.page_num(self.__scroll__)) 
Exemplo n.º 12
0
    def __updateTitle__(self, threadBlock=False):
        """Update title of the window"""
        title = ""
        if (self.__currentTab__ != None):
            if (self.__currentTab__.getCore().getFilename() != None):
                title = "%s - %s - %s" % (self.__currentTab__.getCore().getName(),
                                          self.__currentTab__.getCore().getFilename(),
                                          self.PYCAMIMG_TITLE)
            else:
                title = "%s - %s" % (self.__currentTab__.getCore().getName(), self.PYCAMIMG_TITLE)
        else:
            title = self.PYCAMIMG_TITLE
            
        __log__.debug("New window title %s" % title)

        UIUtils.setTitleWindow(self.__mainWindow__, title, doGObject=threadBlock)
Exemplo n.º 13
0
 def addOperation(self, data):
     """
     @summary: Adds an operation in operation treeview.
     @param data: Tuple with operation data. (id, name, value, step)
     @return: New iter inserted.
     """
     return UIUtils.addIterListView(self.__opsModel__, data)
Exemplo n.º 14
0
 def __searchOperationsPlugins__(self):
     """
     @summary: Search operations, and create a menu item for each.
     """
     __log__.debug("Project modules are loaded")
     
     operationsPlugins = Loader.getPluginsType(pycamimg.core.plugins.ICamimgPlugin.PLUGIN_TYPE.OPERATION)
     actionGroupOperationPlugins = gtk.ActionGroup("ActionGroupOperationPlugins")
     self.__uiManager__.insert_action_group(actionGroupOperationPlugins, pos=-1)
     
     for operation in operationsPlugins:
         __log__.debug("Processing plugin %s" % operation[Loader.INDEX_PLUGIN])    
                     
         operationInstance = operation[Loader.INDEX_PLUGIN_INSTANCE]()
         __log__.debug("Creating operation %s" % operationInstance.getOperationName())
         
         lActions = operationInstance.getActions()
         if (lActions != None):
             for aAction in lActions:
                 aAction.connect("activate", self.__activateOperation__, operationInstance.callbackAction)
                 __log__.debug("Add activate signal to  %s" % operationInstance.getOperationName())
                 actionGroupOperationPlugins.add_action(aAction)
         else:
             __log__.debug("There is not action for %s" % operationInstance.getOperationName())
             
         if (operationInstance.getXmlLocation() != ""):
             self.__uiManager__.add_ui_from_file(os.path.join(__XMLUI_FOLDER__, operationInstance.getXmlLocation()))
             
             dIcons = operationInstance.getIconsActions()
             for actionPath, iconPath in dIcons.iteritems():
                 mi = self.__uiManager__.get_widget(actionPath)
                 if (mi != None): 
                     iconPath = os.path.join(__ICONS_FOLDER__, iconPath)            
                     __log__.debug("Get project icon from %s" % iconPath)
                     if (isinstance(mi, gtk.ImageMenuItem)):
                         UIUtils.setImageToMenuItem(mi, iconPath, doGObject=False)
                     elif (isinstance(mi, gtk.ToolButton)):
                         UIUtils.setImageToToolItem(mi, iconPath, size=self.__toolBar__.get_icon_size(), doGObject=False)
                     else:
                         __log__.warning("Unknown type control.")
                 else:
                     __log__.warning("It could not update icon of %s. Action name %s was not found." % (operationInstance.getOperationName(), actionPath))
         else:
             __log__.debug("%s is not in menu." % operationInstance.getOperationName())
             
         __log__.debug("Added new operation %s" % operationInstance.getOperationName())
Exemplo n.º 15
0
 def __initData__(self, gtkLock=False):
     """
     @summary: Set data to dialog.
     """
     mPlugins = Loader.pluginsLoaded
     if (mPlugins != None):
         for key, lPlugins in mPlugins.iteritems():
             for plugin, pluginRef in lPlugins:
                 obj = gobject.GObject()
                 obj.set_data("plugin", plugin)
                 newRowData = [plugin.getId(), plugin.getName(), PLUGIN_TYPE.getTypeDescription(plugin.getType()), obj]
                 UIUtils.addIterListView(self.__model__,
                                         newRowData,
                                         doGObject=gtkLock)
                 __log__.info("New file inserted into plugins treeview. %s" % plugin.getId())
     else:
         __log__.debug("There are not plugins")
Exemplo n.º 16
0
    def __fillLanguages__(self, gtkLock=False):
        """
        @summary: Fill combobox with available languages.
        @param gtkLock: True to lock gtk-loop. 
        """
        
        if (not hasattr(self, "__lsLanguages__")):
            self.__lsLanguages__ = gtk.ListStore(gobject.TYPE_STRING,
                                                     gobject.TYPE_STRING)
            render_text = gtk.CellRendererText()
            UIUtils.setModelTreeview(self.__cbLanguages__, self.__lsLanguages__, doGObject=gtkLock)
            
            self.__cbLanguages__.pack_start(render_text)
            self.__cbLanguages__.add_attribute(render_text, 'text', __COLUMN_TEXT__)
        
        iterSelected = None
        for key, lang in self.__langs__.iteritems():
            if (lang == ""):
                continue
            iter = UIUtils.addIterListView(self.__lsLanguages__, (lang, key), doGObject=gtkLock)
            if (key == self.__currLang__):
                iterSelected = iter

        if (iterSelected != None):
            UIUtils.setActiveIter(self.__cbLanguages__, iterSelected, doGObject=gtkLock)
        else:
            UIUtils.setActiveIter(self.__cbLanguages__, 0, doGObject=gtkLock)
Exemplo n.º 17
0
 def addDirectory (self, dirname, fullpath, icon, iter=None, glock=True):
     """
     @summary: Add a directory on navigator.
     @param dirname: Directory name.
     @param fullpath: Full path of the directory.
     @param icon: Icon associated with the directory.
     @param iter: Parent TreeIter. None to add directory as a root TreeIter,
     @param glock: True to lock gtk-loop.     
     """
     newIter = None
     if (iter != None):
         newIter = UIUtils.insertIter(self.__model__, iter, (icon, dirname, fullpath),
                                      self.__PATH_COLUMN__, self.__directoryNameComparer__, doGObject=glock)
     else:
         newIter = UIUtils.addIter(self.__model__, None, (icon, dirname, fullpath), glock)
         
     if (newIter != None):
         self.__prepareDirectory__(fullpath, newIter, glock=glock)
Exemplo n.º 18
0
 def updateItemDate(self, iter, item, gtkLock=True):
     """
     @summary: Update target of an item.
     @param iter: GtkTreeIter that represents an item.
     @param item: CamItem to update.
     @param gtkLock: True to do the action with gtklock
     @return: true if operation is done.
     """
     item.waitLoadThumbnail()
     if (item.getMetadata() == None):
         __log__.warn("There is not metadata in %s. Skip file" % item.getPath())
         UIUtils.setIterData(self.getModel(), iter, self.COLUMN_DATE, _("Unknown"), doGObject=gtkLock)
         
         return False
     else:
         UIUtils.setIterData(self.getModel(), iter, self.COLUMN_DATE, item.getMetadata().getDateTimeDigitized(), doGObject=gtkLock)
     
     return True
Exemplo n.º 19
0
 def __prepareDirectory__(self, directory, iter, glock=True):
     """
     @summary: Checks if a directory has some directory. 
         In truth case, add a temporal subitem.
     @param directory: Directory to prepare.
     @param iter: TreeIter of the directory.
     @param glock: True to lock gtk-loop.  
     """
     sSubDirs = self.__ioUtils__.getDirectories(directory)
     if (sSubDirs != None) and (len(sSubDirs) > 0):
             UIUtils.addIter(self.__model__,
                             iter,
                             (FactoryControls.getPixbufFromStock(gtk.STOCK_EXECUTE) ,
                              _("Loading..."),
                              self.__TEMP_NODE__
                             ),
                             glock
                         )
Exemplo n.º 20
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
Exemplo n.º 21
0
 def moveTargetFiles(self,
                     paths,
                     iterRef=None,
                     position=gtk.TREE_VIEW_DROP_AFTER,
                     gtkLock=True):
     """
     @summary: Move files into target view.
     @param paths:  A list of TreePath to move.
     @param iterRef: 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 (paths != None):
         for path in paths:
             iter = self.__model__.get_iter(path)
             if (iter != None):
                 UIUtils.moveIterAtPathPosition(self.__model__, iter, iterRef, position, doGObject=gtkLock)
             else:
                 __log__.warning("It could not retrieve iter from path")
     else:
         __log__.debug("There are not paths to move")
Exemplo n.º 22
0
    def __updateImageTarget__(self, iter, item, delMetadata=False):
        """
        @summary: Updates image of target file.
        @param iter: Iter of listview that matches with target file.
        @param item: CamItem to update.
        @param delMetadata: True to delete metadata at the end of function
        """
        little = None
        big = None
        
        item.waitLoadThumbnail()
        imgPil = item.doPreview()
        if (imgPil != None):
            metaData = ImgMeta(item.getPath(), image=imgPil)
        else:
            metaData = item.getMetadata()
        
        UIUtils.setIterData(self.getModel(), iter, self.COLUMN_LOADING, True)
        
        if (self.__doPreviewList__):
            if (not self.__model__.get_value(iter, self.COLUMN_DO_IMG)):
                __log__.debug("Get thumbnail from %s" % file)
                little = metaData.getIcon(maxHeight=self.__maxHeight__, rescale=self.__rescalePercent__)

                if (little):
                    UIUtils.setIterData(self.__model__, iter, self.COLUMN_IMAGE, little)
                    UIUtils.setIterData(self.__model__, iter, self.COLUMN_DO_IMG, True)
            
        __log__.debug("Doing preview image of %s" % self.__model__.get_value(iter, self.COLUMN_SOURCE))
        if (metaData != None):
            big = metaData.getIcon(rescale=100, maxHeight=self.__maxHeightImageIconView__)
        if (big):
            __log__.debug("Updating data on model for %s." % self.__model__.get_value(iter, self.COLUMN_SOURCE))
            UIUtils.setIterData(self.__model__, iter, self.COLUMN_PREVIEW, big)
            
        if (delMetadata and (metaData != None)):
            del metaData
            
        UIUtils.setIterData(self.getModel(), iter, self.COLUMN_LOADING, False)
Exemplo n.º 23
0
 def __selectRowTvOneClickSignal__ (self, treeview):
     """
     @summary: Handle select row on explorer TreeView.
     @param treeview: TreeView associated with the event. 
     """
     selection = treeview.get_selection()
     (model, iter) = selection.get_selected()
     if (iter != None):
         sPath = model.get_value(iter, self.__PATH_COLUMN__)
         if (sPath != self.__selectedPath__):
             self.__selectedPath__ = sPath
         else:
             return None
         
         treepath = model.get_path(iter)
         UIUtils.selectPath(selection, treepath, False)
         
         # Runs callback
         if (self.__selectCallback__ != None):
             self.__selectCallback__(self.__selectedPath__)
     else:
         __log__.warning("It could not get TreeIter")
Exemplo n.º 24
0
 def __searchProjectPlugins__(self):
     """
     @summary: Search new kind of projects, and create a menu item for each.
     """
     __log__.debug("Project modules are loaded")
     
     projectTypes = Loader.getPluginsType(pycamimg.core.plugins.ICamimgPlugin.PLUGIN_TYPE.PROJECT)
     actionGroupProjectPlugins = gtk.ActionGroup("ActionGroupProjectPlugins")
     self.__uiManager__.insert_action_group(actionGroupProjectPlugins, pos=-1)
     
     for project in projectTypes:
         __log__.debug("Processing plugin %s" % project[Loader.INDEX_PLUGIN].getName())    
                     
         projectInstance = project[Loader.INDEX_PLUGIN_INSTANCE]()
         __log__.debug("Creating new menu item for project type %s" % projectInstance.getTypeName())
         
         aAction = projectInstance.getGtkAction()
         if (aAction != None):
             aAction.connect("activate", self.__newProjectEvent__, project[Loader.INDEX_PLUGIN_INSTANCE])
             __log__.debug("Add activate signal to  %s" % projectInstance.getTypeName())
             actionGroupProjectPlugins.add_action(aAction)
         else:
             __log__.debug("There is not action for %s" % projectInstance.getTypeName())
             
         if (projectInstance.getXmlLocation() != ""):
             self.__uiManager__.add_ui_from_file(os.path.join(__XMLUI_FOLDER__, projectInstance.getXmlLocation()))
         
             mi = self.__uiManager__.get_widget("/MenuPyCaming/FileMenu/NewProject/NewProjectAdditions/%s" % projectInstance.getTypeName())
             if (mi != None):
                 iconPath = os.path.join(__ICONS_FOLDER__, projectInstance.getIconName())
                 __log__.debug("Get project icon from %s" % iconPath)
                 UIUtils.setImageToMenuItem(mi, iconPath, doGObject=False)
             else:
                 __log__.warning("It could not update icon of %s. Action name %s was not found." % (projectInstance.getTypeName(), projectInstance.getTypeName()))
         else:
             __log__.debug("%s is not in menu." % projectInstance.getTypeName())
             
         __log__.debug("Added new project type %s" % projectInstance.getTypeName())
Exemplo n.º 25
0
 def __enableOptions__(self, blockGtk=True):
     """
     @summary: Enable or disable all options.
     """
     enable = (self.__currentTab__ != None)
     
     toolbar = self.__uiManager__.get_widget("/ToolsPyCamimg")
     imiSave = self.__uiManager__.get_widget("/MenuPyCaming/FileMenu/SaveProject")
     imiSaveAs = self.__uiManager__.get_widget("/MenuPyCaming/FileMenu/SaveAsProject")
     iOptions = 0
     
     mOperations = self.__uiManager__.get_widget("/MenuPyCaming/ToolsMenu/Operations")
     if (mOperations != None):
         if (mOperations.get_submenu() != None):
             __log__.debug("Enabling operations of operation menu")
             mOperations.get_submenu().foreach(lambda mi: UIUtils.enabledWidget(mi, enable, blockGtk))
         else:
             __log__.debug("Operation menu does not have menu")
                     
     if (toolbar != None):
         iOptions = toolbar.get_n_items()
         
     if (iOptions > 0):
         for i in range(0, iOptions):
             itItem = toolbar.get_nth_item(i)
             if (itItem != None):
                 if (blockGtk):
                     gtk.gdk.threads_enter()
                 try:
                     itItem.set_sensitive(enable)
                 finally:
                     if (blockGtk):
                         gtk.gdk.threads_leave()
             else:
                 __log__.warning("It could not recover item of index %d" % i)
     else:
         __log__.debug("There are not options.")
         
     if (imiSave != None):
         imiSave.set_sensitive(enable)
         
     if (imiSaveAs != None):
         imiSaveAs.set_sensitive(enable)
Exemplo n.º 26
0
 def addElements(self, iter, elements, gtkLock=True):
     """
     @summary: Sets new values of progress bar.
     @param iter: GtkTreeIter where progress bar is.
     @param elements: New number of elements.
     @param gtkLock: True when lock gtk-loop.
     """               
     newValue = 0.00
     newStep = 1
     if (elements > 0):
         currElems = self.__opsModel__.get_value(iter, self.__ELEMNS_COLUMN__)
         newStep = float(1) / (float(currElems) + float(elements))
         
         currValue = float(self.__opsModel__.get_value(iter, self.__VALUE_COLUMN__)) / 100
         currStep = self.__opsModel__.get_value(iter, self.__STEP_COLUMN__)
         
         newValue = newStep * (currValue / currStep)
         
         UIUtils.setIterData(self.__opsModel__, iter, self.__ELEMNS_COLUMN__, float(currElems) + float(elements), doGObject=gtkLock)
         UIUtils.setIterData(self.__opsModel__, iter, self.__STEP_COLUMN__, newStep, doGObject=gtkLock)
         UIUtils.setIterData(self.__opsModel__, iter, self.__VALUE_COLUMN__, newValue, doGObject=gtkLock)
     else:
         __log__.warning("It can not set 0 elements on a operation")
Exemplo n.º 27
0
    def __dropTarget__ (self, treeview, context, x, y, selection, info, etime):
        """
        @summary: Handle drop event on target treeview.
        @param treeview: TreeView that receives data.
        @param context: Drag&Drop context.
        @param x: X coordinate.
        @param y: Y coordinate.  
        @param selection: Drag&Drop selection.
        @param info: Drag&Drop information.
        @param timestamp: Timestamp when the event raise.
        """
        iter = None
        path = None
        position = gtk.TREE_VIEW_DROP_AFTER
        drop_info = None
        
        # Gets model of the TreeView
        model = treeview.get_model()
        
        # Gets drop position into TreeView
        if (treeview == self.__treeview__):
            drop_info = treeview.get_dest_row_at_pos(x, y)
        elif (treeview == self.__iconview__):
            drop_info = treeview.get_dest_item_at_pos(x, y)
        else:
            __log__.warning("Unknown view")
        if drop_info:
            path, position = drop_info
            iter = model.get_iter(path)
        
        if (selection.data == None):
            __log__.info("There is not data in the drag & drop event.")
            context.finish(False, False, etime)
        if ((info == self.TARGET_TEXT) and
            (context.action != gtk.gdk.ACTION_COPY)):
            __log__.info("It can not receive these data.")
            context.finish(False, False, etime)
        elif ((info == 0) and 
              (context.action != gtk.gdk.ACTION_MOVE)):
            __log__.info("It can not receive these data.")
            context.finish(False, False, etime)

        if (info == self.TARGET_TEXT):
            # Declare a list of files that are going to drop on target TreeView
            files = []
            # Check type target
            uris = selection.get_uris()
            
            if (uris != None):
                __log__.debug("Checking each file received")
                for uri in uris:
                    (scheme, netloc, path, params, query, fragment) = urlparse(uri)
                    if (scheme == "file"):
                        files.append(urllib.url2pathname(path))
                    else:
                        __log__.warning("URI scheme not supported. %s" % scheme)

            if (len(files) == 0):
                __log__.info("There are not valid files.")
                context.finish(False, False, etime)
                
            # Add items
            Thread(target=self.addTargetFiles,
                   args=(files, iter, position,)).start()

            context.finish(True, False, etime)
                
        elif  (info == 0):
            # Gets model of the TreeView
            model = treeview.get_model()
            paths = None
            try:
                paths = cPickle.loads(selection.data)
            except:
                __log__.warning("Data was not retrieved.")
                paths = None
            if (paths != None):
                sortTuple = self.__model__.get_sort_column_id()
                if (sortTuple[0] != None):
                    if (sortTuple[0] >= 0):
                        UIUtils.setColumnOrder(self.__model__, -2, gtk.SORT_ASCENDING, False)
                else:
                    UIUtils.setColumnOrder(self.__model__, -2, gtk.SORT_ASCENDING, False)
                self.moveTargetFiles(paths, iter, position, gtkLock=False)
            
            context.finish(True, False, etime)
        else:
            context.finish(False, False, etime)
Exemplo n.º 28
0
 def __loaded__(self):
     """
     @summary: Update ui when explorer is loaded.
     """
     UIUtils.clearImage(self.__imgLoad__)
Exemplo n.º 29
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")
Exemplo n.º 30
0
 def closeTab (self):
     """
     @summary: Close tab from notebook.
     """
     UIUtils.removeTab(self.__notebook__, self.__scroll__, doGObject=False)