nes DataForm design that allow each widget on each line to have different size (it means I remove the gtk.Table). Fixes #1633

This commit is contained in:
Yann Leboulanger 2006-03-03 08:15:53 +00:00
parent 4a0a252d84
commit 7126dfb679
2 changed files with 44 additions and 60 deletions

View File

@ -1713,12 +1713,12 @@ class DataFormWindow:
self.config = config self.config = config
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'data_form_window', APP) self.xml = gtk.glade.XML(GTKGUI_GLADE, 'data_form_window', APP)
self.window = self.xml.get_widget('data_form_window') self.window = self.xml.get_widget('data_form_window')
self.config_table = self.xml.get_widget('config_table') self.config_vbox = self.xml.get_widget('config_vbox')
if config: if config:
self.fill_table() self.fill_vbox()
else: else:
self.config_table.set_no_show_all(True) self.config_vbox.set_no_show_all(True)
self.config_table.hide() self.config_vbox.hide()
self.xml.signal_autoconnect(self) self.xml.signal_autoconnect(self)
self.window.show_all() self.window.show_all()
@ -1754,7 +1754,7 @@ class DataFormWindow:
begin, end = widget.get_bounds() begin, end = widget.get_bounds()
self.config[index]['values'][0] = widget.get_text(begin, end) self.config[index]['values'][0] = widget.get_text(begin, end)
def fill_table(self): def fill_vbox(self):
'''see JEP0004''' '''see JEP0004'''
if self.config.has_key('title'): if self.config.has_key('title'):
self.window.set_title(self.config['title']) self.window.set_title(self.config['title'])
@ -1770,29 +1770,28 @@ class DataFormWindow:
if ctype == 'hidden': if ctype == 'hidden':
i += 1 i += 1
continue continue
nbrows = self.config_table.get_property('n-rows') hbox = gtk.HBox(spacing = 5)
self.config_table.resize(nbrows + 1, 2) label = gtk.Label('')
label.set_line_wrap(True)
label.set_alignment(0.0, 0.5)
label.set_property('width_request', 150)
hbox.pack_start(label, False)
if self.config[i].has_key('label'): if self.config[i].has_key('label'):
label = gtk.Label(self.config[i]['label']) label.set_text(self.config[i]['label'])
label.set_alignment(0.0, 0.5)
self.config_table.attach(label, 0, 1, nbrows, nbrows + 1,
gtk.FILL | gtk.SHRINK)
desc = None
if self.config[i].has_key('desc'):
desc = self.config[i]['desc']
max = 1
if ctype == 'boolean': if ctype == 'boolean':
desc = None
if self.config[i].has_key('desc'):
desc = self.config[i]['desc']
widget = gtk.CheckButton(desc, False) widget = gtk.CheckButton(desc, False)
activ = False activ = False
if self.config[i].has_key('values'): if self.config[i].has_key('values'):
activ = self.config[i]['values'][0] activ = self.config[i]['values'][0]
widget.set_active(activ) widget.set_active(activ)
widget.connect('toggled', self.on_checkbutton_toggled, i) widget.connect('toggled', self.on_checkbutton_toggled, i)
max = 2
elif ctype == 'fixed': elif ctype == 'fixed':
widget = gtk.Label('\n'.join(self.config[i]['values'])) widget = gtk.Label('\n'.join(self.config[i]['values']))
widget.set_line_wrap(True)
widget.set_alignment(0.0, 0.5) widget.set_alignment(0.0, 0.5)
max = 4
elif ctype == 'jid-multi': elif ctype == 'jid-multi':
#FIXME #FIXME
widget = gtk.Label('') widget = gtk.Label('')
@ -1806,12 +1805,12 @@ class DataFormWindow:
widget.resize(j + 1, 1) widget.resize(j + 1, 1)
child = gtk.CheckButton(self.config[i]['options'][j]['label'], child = gtk.CheckButton(self.config[i]['options'][j]['label'],
False) False)
if self.config[i]['options'][j]['values'][0] in self.config[i]['values']: if self.config[i]['options'][j]['values'][0] in \
self.config[i]['values']:
child.set_active(True) child.set_active(True)
child.connect('toggled', self.on_checkbutton_toggled2, i, j) child.connect('toggled', self.on_checkbutton_toggled2, i, j)
widget.attach(child, 0, 1, j, j+1) widget.attach(child, 0, 1, j, j+1)
j += 1 j += 1
max = 4
elif ctype == 'list-single': elif ctype == 'list-single':
widget = gtk.combo_box_new_text() widget = gtk.combo_box_new_text()
widget.connect('changed', self.on_combobox_changed, i) widget.connect('changed', self.on_combobox_changed, i)
@ -1824,13 +1823,12 @@ class DataFormWindow:
widget.append_text(self.config[i]['options'][j]['label']) widget.append_text(self.config[i]['options'][j]['label'])
j += 1 j += 1
widget.set_active(index) widget.set_active(index)
max = 3
elif ctype == 'text-multi': elif ctype == 'text-multi':
widget = gtk.TextView() widget = gtk.TextView()
widget.set_size_request(100, -1)
widget.get_buffer().connect('changed', self.on_textbuffer_changed, \ widget.get_buffer().connect('changed', self.on_textbuffer_changed, \
i) i)
widget.get_buffer().set_text('\n'.join(self.config[i]['values'])) widget.get_buffer().set_text('\n'.join(self.config[i]['values']))
max = 4
elif ctype == 'text-private': elif ctype == 'text-private':
widget = gtk.Entry() widget = gtk.Entry()
widget.connect('changed', self.on_entry_changed, i) widget.connect('changed', self.on_entry_changed, i)
@ -1838,26 +1836,17 @@ class DataFormWindow:
self.config[i]['values'] = [''] self.config[i]['values'] = ['']
widget.set_text(self.config[i]['values'][0]) widget.set_text(self.config[i]['values'][0])
widget.set_visibility(False) widget.set_visibility(False)
max = 3
elif ctype == 'text-single': elif ctype == 'text-single':
widget = gtk.Entry() widget = gtk.Entry()
widget.connect('changed', self.on_entry_changed, i) widget.connect('changed', self.on_entry_changed, i)
if not self.config[i].has_key('values'): if not self.config[i].has_key('values'):
self.config[i]['values'] = [''] self.config[i]['values'] = ['']
widget.set_text(self.config[i]['values'][0]) widget.set_text(self.config[i]['values'][0])
max = 3
i += 1 i += 1
if max < 4: hbox.pack_start(widget, False)
self.config_table.attach(widget, 1, max, hbox.pack_start(gtk.Label('')) # So that widhet doesn't take all space
nbrows, nbrows + 1, self.config_vbox.pack_start(hbox, False)
gtk.FILL | gtk.SHRINK) self.config_vbox.show_all()
widget = gtk.Label()
self.config_table.attach(widget, max, 4,
nbrows, nbrows + 1)
else:
self.config_table.attach(widget, 1, max,
nbrows, nbrows + 1)
self.config_table.show_all()
class ServiceRegistrationWindow(DataFormWindow): class ServiceRegistrationWindow(DataFormWindow):
'''Class for Service registration window: '''Class for Service registration window:

View File

@ -11329,33 +11329,16 @@ Static</property>
<property name="spacing">0</property> <property name="spacing">0</property>
<child> <child>
<widget class="GtkTable" id="config_table"> <widget class="GtkVBox" id="config_vbox">
<property name="border_width">5</property> <property name="border_width">5</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">4</property>
<property name="homogeneous">False</property> <property name="homogeneous">False</property>
<property name="row_spacing">5</property> <property name="spacing">5</property>
<property name="column_spacing">5</property>
<child>
<widget class="GtkHSeparator" id="hseparator13">
<property name="visible">True</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child> <child>
<widget class="GtkLabel" id="instructions_label"> <widget class="GtkLabel" id="instructions_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes"></property> <property name="label" translatable="yes">label385</property>
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>
@ -11371,14 +11354,26 @@ Static</property>
<property name="angle">0</property> <property name="angle">0</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">0</property> <property name="padding">5</property>
<property name="right_attach">4</property> <property name="expand">False</property>
<property name="top_attach">0</property> <property name="fill">False</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkHSeparator" id="hseparator15">
<property name="visible">True</property>
</widget>
<packing>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>