def populate(self): "Populate the richlist using available_plugins field" # We need a list of present plugin row to check for dup presents = [] def add_to_list(row, list): list.append(row) self.richlist.foreach(add_to_list, presents) warn_reboot = False # We have to load available_plugins from engine for reader in self.p_window.engine.available_plugins: if reader.audit_type != -1: continue # Check if it's already present then remove the original # and add the new in case something is getting update. row = PluginRow(self.richlist, reader) for old in presents: # FIXME? we need to check also for version equality # and if are different just ignore the addition and # continue with the loop if old.reader.get_path() == row.reader.get_path(): self.richlist.remove_row(old) row.enabled = True warn_reboot = True # Connect the various buttons row.action_btn.connect('clicked', self.__on_row_action, row) row.uninstall_btn.connect('clicked', self.__on_row_uninstall, row) row.preference_btn.connect('clicked', self.__on_row_preference, row) row.connect('clicked', self.__on_row_preference, row) row.connect('popup', self.__on_row_popup) self.richlist.append_row(row) if warn_reboot: # Warn the user self.p_window.animated_bar.label = \ _('Remember that you have to restart PacketManipulator to make ' 'new version of plugins to be loaded correctly.') self.p_window.animated_bar.start_animation(True)
def __on_find_updates(self, widget): """ Called when the user click on 'find updates' button This function call the start_update() of UpdateEngine and then add a timeout callback (__update_rich_list) to update the gui at interval of 300 milliseconds. """ # First add audits to the list presents = [] def add_to_list(row, list): list.append(row) self.richlist.foreach(add_to_list, presents) warn_reboot = False # We have to load available_plugins from engine for reader in self.p_window.engine.available_plugins: if reader.audit_type == -1: continue # Check if it's already present then remove the original # and add the new in case something is getting update. row = PluginRow(self.richlist, reader) for old in presents: # FIXME? we need to check also for version equality # and if are different just ignore the addition and # continue with the loop if old.reader.get_path() == row.reader.get_path(): self.richlist.remove_row(old) row.enabled = True warn_reboot = True # Connect the various buttons row.action_btn.connect('clicked', self.__on_row_action, row) row.uninstall_btn.connect('clicked', self.__on_row_uninstall, row) row.preference_btn.connect('clicked', self.__on_row_preference, row) row.connect('clicked', self.__on_row_preference, row) row.connect('popup', self.__on_row_popup) self.richlist.append_row(row) # Then goes with the update self.find_updates_btn.set_sensitive(False) self.menu_enabled = False lst = [] def append(row, lst): if row.reader.update: row.message = _("Waiting ...") row.activatable = False row.enabled = True lst.append(row) else: self.richlist.remove_row(row) self.richlist.foreach(append, lst) if not lst: self.p_window.toolbar.unset_status() self.p_window.animated_bar.label = \ _("No plugins provide an update URL. Cannot proceed.") self.p_window.animated_bar.image = gtk.STOCK_DIALOG_ERROR self.p_window.animated_bar.start_animation(True) self.p_window.update_eng.updating = False self.find_updates_btn.set_sensitive(True) self.menu_enabled = True self.richlist.clear() self.populate() return # We can now begin the update phase, so warn the user. self.p_window.toolbar.show_message( \ _("<b>Looking for %d updates ...</b>") % len(lst), \ file=os.path.join(PIXMAPS_DIR, "Throbber.gif") \ ) self.p_window.update_eng.list = lst self.p_window.update_eng.start_update() # Add a timeout function to update label gobject.timeout_add(300, self.__update_rich_list)