From c511a3103873b40b47103b509f011a1624bc2e8c Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 22 Nov 2005 23:10:08 +0000 Subject: [PATCH] list-multi are now handled in DataForm --- src/common/connection.py | 5 +++-- src/config.py | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index b99649a28..ca484ca98 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -2228,12 +2228,13 @@ class Connection: if config[i].has_key('var'): tag.setAttr('var', config[i]['var']) if config[i].has_key('values'): - for val in config[i]['values']: + for val in config[i]['values']: if val == False: val = '0' elif val == True: val = '1' - tag.setTagData('value', val) + # Force to create a new child + tag.addChild('value').addData(val) i += 1 def send_gc_config(self, room_jid, config): diff --git a/src/config.py b/src/config.py index 8b3f13e91..69ecb4d61 100644 --- a/src/config.py +++ b/src/config.py @@ -1727,6 +1727,13 @@ class DataFormWindow: def on_checkbutton_toggled(self, widget, index): self.config[index]['values'][0] = widget.get_active() + def on_checkbutton_toggled2(self, widget, index1, index2): + val = self.config[index1]['options'][index2]['values'][0] + if widget.get_active() and val not in self.config[index1]['values']: + self.config[index1]['values'].append(val) + elif not widget.get_active() and val in self.config[index1]['values']: + self.config[index1]['values'].remove(val) + def on_combobox_changed(self, widget, index): self.config[index]['values'][0] = self.config[index]['options'][ \ widget.get_active()]['values'][0] @@ -1739,6 +1746,7 @@ class DataFormWindow: self.config[index]['values'][0] = widget.get_text(begin, end) def fill_table(self): + '''see JEP0004''' if self.config.has_key('title'): self.window.set_title(self.config['title']) if self.config.has_key('instructions'): @@ -1780,8 +1788,18 @@ class DataFormWindow: #TODO widget = gtk.Label('') elif ctype == 'list-multi': - #TODO - widget = gtk.Label('') + j = 0 + widget = gtk.Table(1, 1) + while self.config[i]['options'].has_key(j): + widget.resize(j + 1, 1) + child = gtk.CheckButton(self.config[i]['options'][j]['label'], + False) + if self.config[i]['options'][j]['values'][0] in self.config[i]['values']: + child.set_active(True) + child.connect('toggled', self.on_checkbutton_toggled2, i, j) + widget.attach(child, 0, 1, j, j+1) + j += 1 + max = 4 elif ctype == 'list-single': widget = gtk.combo_box_new_text() widget.connect('changed', self.on_combobox_changed, i)