~bkidwell/zim/pyzim-win-installer

« back to all changes in this revision

Viewing changes to zim/gui/widgets.py

  • Committer: Jaap Karssenberg
  • Date: 2011-01-08 17:32:04 UTC
  • mfrom: (327.1.1 zim)
  • Revision ID: pardus@cpan.org-20110108173204-6f2xsmhbs4lljckl
Various small fixes:
* Bug fix for remove_link with selection
* Bug fix preferenes dialog (broke in refactoring)
* Small fix attachment browser
* Fix in www for url encode file names
* Added scrollbars to image generator dialog
* Fix in tasklist parsing of labels for checkbox lists
* Added some shortcut codes for inserting symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
251
251
 
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.
269
269
 
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):
275
275
                        text = input[0]
276
 
                        if not text is None:
 
276
                        if text:
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)
 
279
                        else:
 
280
                                label = gtk.Label(' '*4) # minimum label width
 
281
 
 
282
                        table.attach(label, 0,1, i,i+1, xoptions=gtk.FILL)
 
283
                        _sync_widget_state(input[1], label)
 
284
 
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)
283
287
                                if j > 0:
284
288
                                        _sync_widget_state(input[1], widget)
285
289
                else:
286
290
                        widget = input
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).
288
296
                i += 1
289
297
 
290
298
        return table
1141
1149
                self.force_existing = False
1142
1150
                self._completing = ''
1143
1151
 
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
1253
1260
 
1254
1261
                # Else fill model with pages from namespace
1255
 
                self.completion_model.clear()
 
1262
                completion = self.get_completion()
 
1263
                model = completion.get_model()
 
1264
                model.clear()
1256
1265
 
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,))
 
1278
 
 
1279
                completion.complete()
1269
1280
 
1270
1281
 
1271
1282
class NamespaceEntry(PageEntry):