Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

gtklib: add group features to SlimToolbar

It allows to make a group contains widgets and sets sensitives/visibilities
for difined group.

Changeset efa1a55204c3

Parent c998501a9fc3

by Yuki KODAMA

Changes to one file · Browse files at efa1a55204c3 Showing diff from parent c998501a9fc3 Diff from another changeset...

 
590
591
592
593
 
594
595
596
597
598
 
599
600
 
 
 
601
602
603
 
608
609
610
611
 
612
613
614
 
615
 
616
617
618
619
620
621
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
622
623
624
 
590
591
592
 
593
594
 
595
596
597
598
599
 
600
601
602
603
604
605
 
610
611
612
 
613
614
615
 
616
617
618
619
620
621
622
 
 
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
@@ -590,14 +590,16 @@
   class SlimToolbar(gtk.HBox):   """ - Slim Toolbar, allows to add the buttons of menu size. + Slim Toolbar, allows to add the buttons with small icon.   """ -   def __init__(self, tooltips=None):   gtk.HBox.__init__(self)   self.tooltips = tooltips + self.groups = {}   - def append_stock(self, stock_id, tooltip=None, toggle=False): + ### public methods ### + + def append_stock(self, stock_id, tooltip=None, toggle=False, group=None):   icon = gtk.image_new_from_stock(stock_id, gtk.ICON_SIZE_MENU)   if toggle:   button = gtk.ToggleButton() @@ -608,17 +610,43 @@
  button.set_focus_on_click(False)   if self.tooltips and tooltip:   self.tooltips.set_tip(button, tooltip) - self.append_widget(button, padding=0) + self.append_widget(button, padding=0, group=group)   return button   - def append_widget(self, widget, expand=False, padding=2): + def append_widget(self, widget, expand=False, padding=2, group=None):   self.pack_start(widget, expand, expand, padding) + self.add_group(group, widget)     def append_space(self):   self.append_widget(gtk.Label(), expand=True, padding=0)   - def append_separator(self): - self.append_widget(gtk.VSeparator()) + def append_separator(self, group=None): + self.append_widget(gtk.VSeparator(), group=group) + + def set_enable(self, group, enable=True): + if not group or not self.groups.has_key(group): + return + for widget in self.groups[group]: + widget.set_sensitive(enable) + + def set_visible(self, group, visible=True): + if not group or not self.groups.has_key(group): + return + for widget in self.groups[group]: + if visible is True: + widget.set_no_show_all(False) + widget.set_property('visible', visible) + if visible is False: + widget.set_no_show_all(True) + + ### internal method ### + + def add_group(self, group, widget): + if not group or not widget: + return + if not self.groups.has_key(group): + self.groups[group] = [] + self.groups[group].append(widget)    class MenuItems(object):   '''controls creation of menus by ignoring separators at odd places'''