Ejemplo n.º 1
0
    def render(self):
        def search(model, path, rowiter, processed):
            val = model.get_value(rowiter, 2)
            if val not in processed and val != -3:
                model.itersToRemove.append(rowiter)

        objs = self.getApplication().getObjectStore().getAllOfClass(self.objectType, self.virtualRootObject)

        if len(objs) >= 1 and self.selectFirst and self.selectedObjectId is None and not self.firstSelected:
            self.selectedObjectId = objs[0].getLocalId()
            self.firstSelected = True

        processedObjectIds = []

        for obj in objs:
            rowiter = self.getIterById(self.model, obj.getLocalId())
            if rowiter is None:
                self.model.append((IconStock.getAppropriateIcon(obj), obj.getName(), obj.getLocalId()))
            else:
                self.model.set_value(rowiter, 0, IconStock.getAppropriateIcon(obj))
                self.model.set_value(rowiter, 1, obj.getName())
            processedObjectIds.append(obj.getLocalId())

        if self.selectedObjectId is not None:
            activeiter = self.getIterById(self.model, self.selectedObjectId)
            if activeiter is not None:
                self.set_active_iter(activeiter)
        self.model.itersToRemove = []
        self.model.foreach(search, processedObjectIds)
        for rowiter in self.model.itersToRemove:
            self.model.remove(rowiter)
Ejemplo n.º 2
0
    def render(self):
        def search(model, path, rowiter, processed):
            val = model.get_value(rowiter,3)
            if val not in processed:
                model.itersToRemove.append(rowiter)
        
        js_iconmap = {
            JSMandatory.NO : IconStock.JS_NO,
            JSMandatory.SUPPORTED : IconStock.JS_SUPPORTED,
            JSMandatory.MANDATORY : IconStock.JS_MANDATORY
        }

        modules = self.getMyObject()
        if not modules:
            self.destroy()
            return

        if modules.getRepoState():
            self.modbox.remove(self.mod_norepo_label)
            self.modbox.attach(self.mod_AListScroll,1,2,2,3)
        else:
            self.modbox.remove(self.mod_AListScroll)
            self.modbox.attach(self.mod_norepo_label,1,2,2,3)

        self.processedIListIds = []
        self.processedAListIds = []
        
        for module in modules.getAllModules():
            if module.data.has_key('installed') and module.data['installed'] == True:
                rowiter = self.getModuleIterById(self.mod_IListStore,module.getLocalId())
                if rowiter is None:
                    self.mod_IListStore.append((IconStock.getAppropriateIcon(module), module.getName(), js_iconmap[module.getJSMandatory()], module.getLocalId() ))
                else:
                    self.mod_IListStore.set_value(rowiter,0,IconStock.getAppropriateIcon(module))
                    self.mod_IListStore.set_value(rowiter,1,module.getName())
                    self.mod_IListStore.set_value(rowiter,2,js_iconmap[module.getJSMandatory()])
                self.processedIListIds.append(module.getLocalId())
            else:
                rowiter = self.getModuleIterById(self.mod_AListStore,module.getLocalId())
                if rowiter is None:
                    self.mod_AListStore.append((IconStock.MODULE, module.getName(), js_iconmap[module.getJSMandatory()], module.getLocalId() ))
                else:
                    self.mod_AListStore.set_value(rowiter,0,IconStock.getAppropriateIcon(module))
                    self.mod_IListStore.set_value(rowiter,1,module.getName())
                    self.mod_IListStore.set_value(rowiter,2,js_iconmap[module.getJSMandatory()])
                self.processedAListIds.append(module.getLocalId())
        
        self.mod_IListStore.itersToRemove = []
        self.mod_AListStore.itersToRemove = []
        self.mod_IListStore.foreach(search, self.processedIListIds)
        self.mod_AListStore.foreach(search, self.processedAListIds)
        
        for rowiter in self.mod_IListStore.itersToRemove:
            self.mod_IListStore.remove(rowiter)
        for rowiter in self.mod_AListStore.itersToRemove:
            self.mod_AListStore.remove(rowiter)
Ejemplo n.º 3
0
 def addObject(self,obj,addToRootIfNoParent=True):
     obj = self.objectStore.getLocalObjectById(obj)
     if obj.__class__.__name__ in self.EXCLUDED_CLASSES:
         return True
     if obj.__class__.__name__ == "Module" and (not obj.data.has_key('installed') or obj.data['installed'] == False):
         return True
     try:
         parentIter = self.getIterById(obj.getPar().getLocalId())
         self.append(parentIter,(IconStock.getAppropriateIcon(obj), obj.getName(),obj.getLocalId()))
         return True
     except:
         if addToRootIfNoParent or obj.par is None: 
             root = self.getIterById(-2)
             self.append(root,(IconStock.getAppropriateIcon(obj), obj.getName(),obj.getLocalId()))
             return True
         return False
Ejemplo n.º 4
0
 def __init__(self,parent,obj):
     self.objId = obj.getLocalId()
     gtk.Button.__init__(self,obj.getName())
     self.par = parent
     self.image = gtk.Image()
     self.image.set_from_pixbuf(IconStock.getAppropriateIcon(obj))
     self.set_image(self.image)
     self.connect("clicked",self.cb_Click)
Ejemplo n.º 5
0
 def render(self):
     try:
         obj = self.getApplication().getLocalObjectById(self.objId)
     except GenericObjectStoreException:
         self.getPar().closePage(self.objId)
         return
     self.icon.set_from_pixbuf(IconStock.getAppropriateIcon(obj))
     self.label.set_text(obj.getName())
Ejemplo n.º 6
0
 def addObject(self,obj,addToRootIfNoParent=True):
     obj = self.objectStore.getLocalObjectById(obj)
     if obj.__class__.__name__ in self.EXCLUDED_CLASSES:
         return True
     if self.filterString is not None and obj.getName().lower().find(self.filterString.lower()) < 0:
         return True
     
     self.append((IconStock.getAppropriateIcon(obj), obj.getName(),obj.getLocalId()))
     return True
Ejemplo n.º 7
0
 def search(model, path, iter):
     id = model.get_value(iter,2)
     if id >= 0:
         try:
             obj = self.objectStore.getLocalObjectById(model.get_value(iter,2))
         except GenericObjectStoreException:
             self.itersToRemove.append(iter)
         else:
             model.set_value(iter,0,IconStock.getAppropriateIcon(obj))
             displayName = str(obj.getLocalId())
             try:
                 displayName = obj.getName()
             except Exception:
                 pass
             model.set_value(iter,1,displayName)
             self.objectsToAllocate.remove(id)
Ejemplo n.º 8
0
 def search(model, path, rowiter):
     nr = model.get_value(rowiter,2)
     if nr >= 0:
         try:
             obj = self.objectStore.getLocalObjectById(model.get_value(rowiter,2))
         except GenericObjectStoreException:
             self.itersToRemove.append(rowiter)
         else:
             if self.filterString is not None and obj.getName().lower().find(model.filterString.lower()) < 0:
                 self.itersToRemove.append(rowiter)
                 return
             if obj.__class__.__name__ == "Server":
                 model.set_value(rowiter,0,IconStock.getServerIcon(obj))
             displayName = str(obj.getLocalId())
             try:
                 displayName = obj.getName()
             except Exception:
                 pass
             model.set_value(rowiter,1,displayName)
             self.objectsToAllocate.remove(nr)