252
252
def input_table_factory(inputs, table=None):
253
253
'''Takes a list of inputs and returns a table with nice layout
254
for those inputs. Inputs in the list given should be either a
255
gtk widget or a tuple of a string and one or more widgets.
254
for those inputs. Inputs in the list given should be either 'None',
255
a gtk widget, or a tuple of a string and one or more widgets.
256
256
If a tuple is given and the first item is 'None', the widget
257
257
will be lined out in the 2nd column. A 'None' value in the input
258
258
list represents an empty row in the table.
270
270
for input in inputs:
271
271
if input is None:
272
table.attach(gtk.Label(' '), 0,2, i,i+1, xoptions=gtk.FILL)
272
table.attach(gtk.Label(' '), 0,1, i,i+1, xoptions=gtk.FILL)
273
273
# HACK: force empty row to have height of label
274
274
elif isinstance(input, tuple):
277
277
label = gtk.Label(text + ':')
278
278
label.set_alignment(0.0, 0.5)
279
table.attach(label, 0,1, i,i+1, xoptions=gtk.FILL)
280
_sync_widget_state(input[1], label)
280
label = gtk.Label(' '*4) # minimum label width
282
table.attach(label, 0,1, i,i+1, xoptions=gtk.FILL)
283
_sync_widget_state(input[1], label)
281
285
for j, widget in enumerate(input[1:]):
282
table.attach(widget, j+1,j+2, i,i+1)
286
table.attach(widget, j+1,j+2, i,i+1, xoptions=gtk.FILL)
284
288
_sync_widget_state(input[1], widget)
287
table.attach(widget, 0,2, i,i+1)
291
table.attach(widget, 0,4, i,i+1)
292
# We span 4 columns here so in case these widgets are
293
# the widest in the tables (e.g. checkbox + label)
294
# they don't force expanded size on first 3 columns
295
# (e.g. label + entry + button).
1141
1149
self.force_existing = False
1142
1150
self._completing = ''
1144
self.completion_model = gtk.ListStore(str)
1145
1152
completion = gtk.EntryCompletion()
1146
completion.set_model(self.completion_model)
1153
completion.set_model(gtk.ListStore(str))
1147
1154
completion.set_text_column(0)
1148
1155
completion.set_inline_completion(True)
1149
1156
self.set_completion(completion)
1252
1259
self._completing = completing
1254
1261
# Else fill model with pages from namespace
1255
self.completion_model.clear()
1262
completion = self.get_completion()
1263
model = completion.get_model()
1257
1266
if completing == ':':
1258
1267
path = Path(':')
1265
1274
# TODO also add parent namespaces in case text did not contain any ':' (anchored == False)
1266
1275
#~ print '!! COMPLETING %s context: %s prefix: %s' % (path, self.path_context, prefix)
1267
1276
for p in self.notebook.index.list_pages(path):
1268
self.completion_model.append((prefix+p.basename,))
1277
model.append((prefix+p.basename,))
1279
completion.complete()
1271
1282
class NamespaceEntry(PageEntry):