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

View File

@ -11329,33 +11329,16 @@ Static</property>
<property name="spacing">0</property>
<child>
<widget class="GtkTable" id="config_table">
<widget class="GtkVBox" id="config_vbox">
<property name="border_width">5</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="row_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>
<property name="spacing">5</property>
<child>
<widget class="GtkLabel" id="instructions_label">
<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_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@ -11371,14 +11354,26 @@ Static</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">4</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</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>
<packing>
<property name="padding">0</property>