fixed list of settings in config panel

This commit is contained in:
Daniel Pavel 2012-12-14 15:48:04 +02:00
parent a42e696695
commit 3cd0665166
3 changed files with 19 additions and 10 deletions

View File

@ -76,6 +76,10 @@ def error(window, title, text):
m.destroy()
def remove_children(container):
container.foreach(lambda x, _: container.remove(x), None)
# def find_children(container, *child_names):
# assert container is not None
# assert isinstance(container, Gtk.Container)

View File

@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
from gi.repository import Gtk, GObject
import ui
from logitech.unifying_receiver import settings as _settings
#
@ -150,6 +151,15 @@ def _update_setting_item(sbox, value):
raise NotImplemented
control.set_sensitive(True)
#
#
#
def create():
b = Gtk.VBox(homogeneous=False, spacing=4)
b.set_property('margin', 8)
return b
def update(frame):
box = frame._config_box
@ -159,7 +169,7 @@ def update(frame):
if device is None:
# remove all settings widgets
# if another device gets paired here, it will add its own widgets
box.foreach(lambda x, _: box.remove(x), None)
ui.remove_children(box)
return
if not box.get_visible():
@ -172,15 +182,12 @@ def update(frame):
force_read = False
items = box.get_children()
if not items:
if len(device.settings) != len(items):
ui.remove_children(box)
if device.status:
items = list(_add_settings(box, device))
assert len(device.settings) == len(items)
force_read = True
else:
# don't bother adding settings for offline devices,
# they're useless and might not guess all of them anyway
return
device_active = bool(device.status)
# if the device just became active, re-read the settings

View File

@ -218,10 +218,8 @@ def _make_device_box(index):
vbox.pack_start(Gtk.HSeparator(), False, False, 0)
vbox.pack_start(info_label, False, False, 0)
config_box = Gtk.VBox(homogeneous=False, spacing=4)
config_box.set_property('margin', 8)
vbox.pack_start(config_box, False, False, 0)
frame._config_box = config_box
frame._config_box = _config_panel.create()
vbox.pack_start(frame._config_box, False, False, 0)
unpair = Gtk.Button('Unpair')
unpair.set_image(Gtk.Image.new_from_icon_name('edit-delete', Gtk.IconSize.BUTTON))