def __callback__refresh_state_box(self, *w): import StringIO msg = StringIO.StringIO() current_all = libserver.get_all_current_repositories() current_official = libserver.get_current_official_repositories() # print tip print >> msg, _("<small>(Click mouse right button to display the context menu.)</small>") self.__print_the_fastest_repository(msg, current_all, current_official) self.__print_repositories_currently_in_use(msg, current_all, current_official) self.__print_repository_configuration_files(msg, current_all, current_official) # show text self.label_state.set_markup(msg.getvalue()) # set the menu-item sensitive state try: fastest = Config.get_fastest_repository() except: self.mi_use_fastest_repo.set_sensitive(False) else: self.mi_use_fastest_repo.set_sensitive(bool(fastest and (fastest not in current_official)))
def __use_repository(self, new_repo): assert isinstance(new_repo, str) assert ":" in new_repo old_repos = [r for r in libserver.get_current_official_repositories() if r != new_repo] if old_repos == []: notify(_("Currently you are using %s.") % new_repo, " ") return check_boxes = [] for r in old_repos: check_boxes.append(RepoCheckButton(r, new_repo)) dialog = gtk.Dialog( _("Change repository"), None, gtk.DIALOG_NO_SEPARATOR, (gtk.STOCK_CANCEL, gtk.RESPONSE_NO, gtk.STOCK_OK, gtk.RESPONSE_YES), ) dialog.vbox.set_spacing(5) for i in check_boxes: dialog.vbox.pack_start(i, False) dialog.vbox.show_all() ret = dialog.run() dialog.destroy() if ret != gtk.RESPONSE_YES: return changes = {} for c in check_boxes: if c.get_active(): changes[c.old_repo] = c.new_repo if changes == {}: return libserver.change_repositories_in_source_files(changes) self.__callback__refresh_state_box() notify(_('Run "apt-get update". Please wait for few minutes.'), " ") APT.apt_get_update()