def show(self, pkg): priority = sysconf.get(("package-priorities", pkg.name), {}) table = self._table #table.foreach(table.remove) label = QtWidgets.QLabel(_("Package:"), table) label.show() table.layout().addWidget(label) label = QtWidgets.QLabel("<b>%s</b>" % pkg.name, table) label.show() table.layout().addWidget(label) class AliasCheckBox(QtWidgets.QCheckBox): def __init__(self, name, parent): QtWidgets.QSpinBox.__init__(self, name, parent) def connect(self, signal, slot, spin, alias): # FIXME Ambiguous syntax for this signal connection, can't refactor it. QtCore.QObject.connect(self, QtCore.SIGNAL(signal), slot) self._spin = spin self._alias = alias def toggled(self, check): spin = self._spin alias = self._alias if check: priority[alias] = int(spin.value()) spin.setEnabled(True) else: if alias in priority: del priority[alias] spin.setEnabled(False) class AliasSpinBox(QtWidgets.QSpinBox): def __init__(self, parent): QtWidgets.QSpinBox.__init__(self, parent) def connect(self, signal, slot, alias): # FIXME Ambiguous syntax for this signal connection, can't refactor it. QtCore.QObject.connect(self, QtCore.SIGNAL(signal), slot) self._alias = alias def value_changed(self, value): alias = spin._alias priority[alias] = value label = QtWidgets.QLabel(_("Default priority:"), table) label.show() table.layout().addWidget(label) hbox = QtWidgets.QWidget(table) QtWidgets.QHBoxLayout(hbox) hbox.layout().setSpacing(10) hbox.show() table.layout().addWidget(hbox) radio = QtWidgets.QRadioButton(_("Channel default"), hbox) radio.setChecked(None not in priority) radio.show() hbox.layout().addWidget(radio) radio = QtWidgets.QRadioButton(_("Set to"), hbox) radio.setChecked(None in priority) radio.show() hbox.layout().addWidget(radio) spin = QtWidgets.QSpinBox(hbox) spin.setSingleStep(1) spin.setRange(-100000,+100000) spin.setValue(priority.get(None, 0)) spin.show() table.layout().addWidget(spin) label = QtWidgets.QLabel(_("Channel priority:"), table) label.show() table.layout().addWidget(label) chantable = QtWidgets.QWidget(table) QtWidgets.QGridLayout(chantable) chantable.layout().setSpacing(10) chantable.show() table.layout().addWidget(chantable) pos = 0 channels = sysconf.get("channels") for alias in channels: channel = channels[alias] if not getChannelInfo(channel.get("type")).kind == "package": continue name = channel.get("name") if not name: name = alias check = AliasCheckBox(name, chantable) check.setChecked(alias in priority) check.show() chantable.layout().addWidget(check) spin = AliasSpinBox(chantable) if alias not in priority: spin.setEnabled(False) spin.setSingleStep(1) spin.setRange(-100000,+100000) spin.setValue(priority.get(alias, 0)) spin.connect("valueChanged(int)", spin.value_changed, alias) check.connect("toggled(bool)", check.toggled, spin, alias) spin.show() chantable.layout().addWidget(spin) pos += 1 table.adjustSize() self._vbox.adjustSize() self._window.adjustSize() self._window.show() self._window.raise_() self._window.activateWindow() self._window.exec_() self._window.hide() if not priority: sysconf.remove(("package-priorities", pkg.name)) else: sysconf.set(("package-priorities", pkg.name), priority)
def show(self, pkg): priority = sysconf.get(("package-priorities", pkg.name), {}) table = self._table #table.foreach(table.remove) label = qt.QLabel(_("Package:"), table) label.show() label = qt.QLabel("<b>%s</b>" % pkg.name, table) label.show() class AliasCheckBox(qt.QCheckBox): def __init__(self, name, parent): qt.QSpinBox.__init__(self, name, parent) def connect(self, signal, slot, spin, alias): qt.QObject.connect(self, qt.SIGNAL(signal), slot) self._spin = spin self._alias = alias def toggled(self, check): spin = self._spin alias = self._alias if check: priority[alias] = int(spin.value()) spin.setEnabled(True) else: if alias in priority: del priority[alias] spin.setEnabled(False) class AliasSpinBox(qt.QSpinBox): def __init__(self, parent): qt.QSpinBox.__init__(self, parent) def connect(self, signal, slot, alias): qt.QObject.connect(self, qt.SIGNAL(signal), slot) self._alias = alias def value_changed(self, value): alias = spin._alias priority[alias] = value label = qt.QLabel(_("Default priority:"), table) label.show() hbox = qt.QHBox(table) hbox.setSpacing(10) hbox.show() radio = qt.QRadioButton(_("Channel default"), hbox) radio.setChecked(None not in priority) radio.show() radio = qt.QRadioButton(_("Set to"), hbox) radio.setChecked(None in priority) radio.show() spin = qt.QSpinBox(hbox) spin.setSteps(1, 10) spin.setRange(-100000,+100000) spin.setValue(priority.get(None, 0)) spin.show() label = qt.QLabel(_("Channel priority:"), table) label.show() chantable = qt.QGrid(2, table) chantable.setSpacing(10) chantable.show() pos = 0 channels = sysconf.get("channels") for alias in channels: channel = channels[alias] if not getChannelInfo(channel.get("type")).kind == "package": continue name = channel.get("name") if not name: name = alias check = AliasCheckBox(name, chantable) check.setChecked(alias in priority) check.show() spin = AliasSpinBox(chantable) if alias not in priority: spin.setEnabled(False) spin.setSteps(1, 10) spin.setRange(-100000,+100000) spin.setValue(priority.get(alias, 0)) spin.connect("valueChanged(int)", spin.value_changed, alias) check.connect("toggled(bool)", check.toggled, spin, alias) spin.show() pos += 1 table.adjustSize() self._vbox.adjustSize() self._window.adjustSize() self._window.show() self._window.raiseW() self._window.setActiveWindow() self._window.exec_loop() self._window.hide() if not priority: sysconf.remove(("package-priorities", pkg.name)) else: sysconf.set(("package-priorities", pkg.name), priority)
def show(self, pkg): priority = sysconf.get(("package-priorities", pkg.name), {}) table = self._table table.foreach(table.remove) label = gtk.Label(_("Package:")) label.set_alignment(1.0, 0.5) label.show() table.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.FILL) label = gtk.Label() label.set_markup("<b>%s</b>" % pkg.name) label.set_alignment(0.0, 0.5) label.show() table.attach(label, 1, 2, 0, 1, gtk.FILL, gtk.FILL) def toggled(check, spin, alias): if check.get_active(): priority[alias] = int(spin.get_value()) spin.set_sensitive(True) else: if alias in priority: del priority[alias] spin.set_sensitive(False) def value_changed(spin, alias): priority[alias] = int(spin.get_value()) label = gtk.Label(_("Default priority:")) label.set_alignment(1.0, 0.5) label.show() table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL) hbox = gtk.HBox() hbox.set_spacing(10) hbox.show() table.attach(hbox, 1, 2, 1, 2, gtk.FILL, gtk.FILL) radio = gtk.RadioButton(None, _("Channel default")) radio.set_active(None not in priority) radio.show() hbox.pack_start(radio, expand=False) radio = gtk.RadioButton(radio, _("Set to")) radio.set_active(None in priority) radio.show() hbox.pack_start(radio, expand=False) spin = gtk.SpinButton() if None not in priority: spin.set_sensitive(False) spin.set_increments(1, 10) spin.set_numeric(True) spin.set_range(-100000, +100000) spin.set_value(priority.get(None, 0)) spin.connect("value-changed", value_changed, None) radio.connect("toggled", toggled, spin, None) spin.show() hbox.pack_start(spin, expand=False) label = gtk.Label(_("Channel priority:")) label.set_alignment(1.0, 0.0) label.show() table.attach(label, 0, 1, 2, 3, gtk.FILL, gtk.FILL) chantable = gtk.Table() chantable.set_row_spacings(10) chantable.set_col_spacings(10) chantable.show() table.attach(chantable, 1, 2, 2, 3, gtk.FILL, gtk.FILL) pos = 0 channels = sysconf.get("channels") for alias in channels: channel = channels[alias] if not getChannelInfo(channel.get("type")).kind == "package": continue name = channel.get("name") if not name: name = alias check = gtk.CheckButton(name) check.set_active(alias in priority) check.show() chantable.attach(check, 0, 1, pos, pos + 1, gtk.FILL, gtk.FILL) spin = gtk.SpinButton() if alias not in priority: spin.set_sensitive(False) spin.set_increments(1, 10) spin.set_numeric(True) spin.set_range(-100000, +100000) spin.set_value(int(priority.get(alias, 0))) spin.connect("value_changed", value_changed, alias) check.connect("toggled", toggled, spin, alias) spin.show() chantable.attach(spin, 1, 2, pos, pos + 1, gtk.FILL, gtk.FILL) pos += 1 self._window.show() gtk.main() self._window.hide() if not priority: sysconf.remove(("package-priorities", pkg.name)) else: sysconf.set(("package-priorities", pkg.name), priority)
def show(self, pkg): priority = sysconf.get(("package-priorities", pkg.name), {}) table = self._table table.foreach(table.remove) label = gtk.Label(_("Package:")) label.set_alignment(1.0, 0.5) label.show() table.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.FILL) label = gtk.Label() label.set_markup("<b>%s</b>" % pkg.name) label.set_alignment(0.0, 0.5) label.show() table.attach(label, 1, 2, 0, 1, gtk.FILL, gtk.FILL) def toggled(check, spin, alias): if check.get_active(): priority[alias] = int(spin.get_value()) spin.set_sensitive(True) else: if alias in priority: del priority[alias] spin.set_sensitive(False) def value_changed(spin, alias): priority[alias] = int(spin.get_value()) label = gtk.Label(_("Default priority:")) label.set_alignment(1.0, 0.5) label.show() table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL) hbox = gtk.HBox() hbox.set_spacing(10) hbox.show() table.attach(hbox, 1, 2, 1, 2, gtk.FILL, gtk.FILL) radio = gtk.RadioButton(None, _("Channel default")) radio.set_active(None not in priority) radio.show() hbox.pack_start(radio, expand=False) radio = gtk.RadioButton(radio, _("Set to")) radio.set_active(None in priority) radio.show() hbox.pack_start(radio, expand=False) spin = gtk.SpinButton() if None not in priority: spin.set_sensitive(False) spin.set_increments(1, 10) spin.set_numeric(True) spin.set_range(-100000,+100000) spin.set_value(priority.get(None, 0)) spin.connect("value-changed", value_changed, None) radio.connect("toggled", toggled, spin, None) spin.show() hbox.pack_start(spin, expand=False) label = gtk.Label(_("Channel priority:")) label.set_alignment(1.0, 0.0) label.show() table.attach(label, 0, 1, 2, 3, gtk.FILL, gtk.FILL) chantable = gtk.Table() chantable.set_row_spacings(10) chantable.set_col_spacings(10) chantable.show() table.attach(chantable, 1, 2, 2, 3, gtk.FILL, gtk.FILL) pos = 0 channels = sysconf.get("channels") for alias in channels: channel = channels[alias] if not getChannelInfo(channel.get("type")).kind == "package": continue name = channel.get("name") if not name: name = alias check = gtk.CheckButton(name) check.set_active(alias in priority) check.show() chantable.attach(check, 0, 1, pos, pos+1, gtk.FILL, gtk.FILL) spin = gtk.SpinButton() if alias not in priority: spin.set_sensitive(False) spin.set_increments(1, 10) spin.set_numeric(True) spin.set_range(-100000,+100000) spin.set_value(int(priority.get(alias, 0))) spin.connect("value_changed", value_changed, alias) check.connect("toggled", toggled, spin, alias) spin.show() chantable.attach(spin, 1, 2, pos, pos+1, gtk.FILL, gtk.FILL) pos += 1 self._window.show() gtk.main() self._window.hide() if not priority: sysconf.remove(("package-priorities", pkg.name)) else: sysconf.set(("package-priorities", pkg.name), priority)