Changeset 3281

Show
Ignore:
Timestamp:
08/01/08 14:19:42 (5 years ago)
Author:
nopper
Message:

Implementing expand on ToolBox?

Location:
branch/PacketManipulator/widgets
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branch/PacketManipulator/widgets/Expander.py

    r3280 r3281  
    503503    (friend of ToolBox. Don't use in other widgets) 
    504504    """ 
    505     def __init__(self, parent, label=None, image=gtk.STOCK_PROPERTIES): 
     505    def __init__(self, parent, label=None, image=gtk.STOCK_PROPERTIES, expand=True): 
    506506        assert(isinstance(parent, ToolBox)) 
    507507 
     
    509509 
    510510        self._parent = parent 
    511         self._active = False 
     511        self._expand = expand 
    512512 
    513513        self._layout.connect('animation-end', self.__on_end_anim) 
     
    573573    # Public API 
    574574 
    575     def append_page(self, child, txt): 
    576         page = ToolPage(self, txt) 
     575    def append_page(self, child, txt=None, image=gtk.STOCK_PROPERTIES, expand=True): 
     576        page = ToolPage(self, txt, image, expand) 
    577577        page.add_widget(child, False) 
    578578 
     
    602602        children.reverse() 
    603603 
     604        spulciato = filter(lambda x: x._expand and x._layout.get_active(), children) 
     605 
     606        if spulciato: 
     607            children = spulciato 
     608 
    604609        for child in children: 
    605610            if page == child or \ 
     
    619624                return 
    620625 
     626        print "nothing setted", children 
    621627        self._active_page = None 
    622628     
    623629    def _repack(self, page): 
     630        if not page._expand: 
     631            return False 
     632 
    624633        info = self.query_child_packing(page) 
    625634 
     
    636645        return False 
    637646 
    638     def _set_active_page(self, page=None): 
    639         if self._active_page: 
     647    def _set_active_page(self, page): 
     648 
     649        if page._expand and self._active_page: 
    640650            if self._one_page: 
    641651                self._set_expanded(self._active_page, False) 
     
    646656 
    647657        if page: 
     658 
     659            # Here we should check if there's a child with True as packing options 
     660            # if not ignore the page._expand and set the packing to True 
     661 
     662            print "yuuuuuuuuu" 
     663 
     664            for child in self.get_children(): 
     665                print "OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO" 
     666                print self.query_child_packing(child) 
     667 
     668                if 1 in self.query_child_packing(child)[0:2]: 
     669                    self.set_child_packing(page, page._expand, page._expand, 0, gtk.PACK_START) 
     670                    return 
     671 
     672            # If we are here not True :D 
    648673            self.set_child_packing(page, True, True, 0, gtk.PACK_START) 
     674 
    649675 
    650676    # Public stuff 
     
    686712    box = ToolBox() 
    687713    box.append_page(gtk.Label("Testing"), "miao") 
    688     box.append_page(gtk.Label("Testing"), "miao") 
     714    box.append_page(gtk.Label("Testing"), "miao", expand=False) 
    689715    box.append_page(gtk.Label("Testing"), "miao") 
    690716    w.add(box) 
  • branch/PacketManipulator/widgets/PropertyGrid.py

    r3279 r3281  
    623623            toolbox = ToolBox() 
    624624            toolbox.append_page(self.tree, 'Protocol') 
    625             toolbox.append_page(sw, 'Description') 
     625            toolbox.append_page(sw, 'Description', expand=False) 
    626626            self.pack_start(toolbox) 
    627627        else: