def refreshlist(self, host, port): self.combo_database.hide() self.combo_database_label.hide() self.combo_database_entry.hide() dbprogress = common.DBProgress(host, port) def callback(dbs): if dbs is None: self.combo_database_label.set_label( '<b>' + _('Could not connect to server!') + '</b>') self.combo_database_label.show() elif dbs == -1: self.combo_database_label.set_label( '<b>' + _('This client version is not compatible ' 'with the server!') + '</b>') self.combo_database_label.show() elif dbs == -2: self.combo_database_entry.show() self.combo_database_entry.grab_focus() elif dbs == 0: self.combo_database_label.set_label( '<b>' + _('No database found, you must create one!') + '</b>') self.combo_database_label.show() else: self.combo_database.show() dbprogress.update(self.combo_database, self.db_progressbar, callback)
def display_dbwidget(self, entry, event, dbname=None): host = self.host_entry.get_text() port = self.port_entry.get_text() if not (host and port): return if (host, port, self.current_profile['name']) == self.db_cache: return if self.updating_db: return if dbname is None: dbname = self.current_database dbprogress = common.DBProgress(host, int(port)) self.hide_database_info() self.add_button.set_sensitive(False) self.remove_button.set_sensitive(False) self.ok_button.set_sensitive(False) self.cell.set_property('editable', False) self.host_entry.set_sensitive(False) self.port_entry.set_sensitive(False) self.updating_db = True def callback(dbs): self.updating_db = False self.db_cache = (host, port, self.current_profile['name']) if dbs is None or dbs == -1: if dbs is None: label = _(u'Could not connect to the server') else: label = _(u'Incompatible version of the server') self.database_label.set_label('<b>%s</b>' % label) self.database_label.show() elif dbs == 0: self.database_button.show() elif dbs == -2: self.database_entry.show() else: self.database_entry.set_text(dbname if dbname else '') self.database_combo.show() self.add_button.set_sensitive(True) self.remove_button.set_sensitive(True) self.ok_button.set_sensitive(True) self.cell.set_property('editable', True) self.host_entry.set_sensitive(True) self.port_entry.set_sensitive(True) dbprogress.update(self.database_combo, self.database_progressbar, callback, dbname)