Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.9, 0.9.1, and 0.9.1.1

gtklib: add new MenuItems class

Changeset 746f79461d85

Parent db91c1765441

by Adrian Buehlmann

Changes to one file · Browse files at 746f79461d85 Showing diff from parent db91c1765441 Diff from another changeset...

 
514
515
516
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
517
518
519
 
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
@@ -514,6 +514,38 @@
  def append_space(self):   self.append_widget(gtk.Label(), expand=True, padding=0)   +class MenuItems(object): + '''controls creation of menus by ignoring separators at odd places''' + + def __init__(self): + self.reset() + + def reset(self): + self.childs = [] + self.sep = None + + def append(self, child): + '''appends the child menu item, but ignores odd separators''' + if isinstance(child, gtk.SeparatorMenuItem): + if len(self.childs) > 0: + self.sep = child + else: + if self.sep: + self.childs.append(self.sep) + self.sep = None + self.childs.append(child) + + def append_sep(self): + self.append(gtk.SeparatorMenuItem()) + + def create_menu(self): + '''creates the menu by ignoring any extra separator''' + res = gtk.Menu() + for c in self.childs: + res.append(c) + self.reset() + return res +  def addspellcheck(textview, ui=None):   lang = None   if ui: