Ticket #1300: sugar-1300.patch

File sugar-1300.patch, 2.2 KB (added by alsroot, 12 years ago)
  • src/sugar/graphics/toolbarbox.py

    From 39ad67fdda53e367bc0af1baefa6dde3661017d7 Mon Sep 17 00:00:00 2001
    From: Aleksey Lim <alsroot@member.fsf.org>
    Date: Tue, 8 Sep 2009 13:05:04 +0000
    Subject: Simple scheme for hidding ToolbarBox subpalettes #1300
    
    ---
     src/sugar/graphics/toolbarbox.py |   21 +++++++++------------
     1 files changed, 9 insertions(+), 12 deletions(-)
    
    diff --git a/src/sugar/graphics/toolbarbox.py b/src/sugar/graphics/toolbarbox.py
    index 8cc52df..cc5edb8 100644
    a b class _ToolbarPalette(PaletteWindow): 
    188188        PaletteWindow.__init__(self, **kwargs)
    189189        self.toolbar_box = None
    190190        self.set_border_width(0)
    191         self._focus = 0
     191        self._focus = False
    192192
    193193        group = palettegroup.get_group('default')
    194194        group.connect('popdown', self.__group_popdown_cb)
    class _ToolbarPalette(PaletteWindow): 
    196196
    197197    def on_invoker_enter(self):
    198198        PaletteWindow.on_invoker_enter(self)
    199         self._handle_focus(+1)
     199        self._handle_focus(True)
    200200
    201201    def on_invoker_leave(self):
    202202        PaletteWindow.on_invoker_leave(self)
    203         self._handle_focus(-1)
     203        self._handle_focus(False)
    204204
    205205    def on_enter(self, event):
    206206        PaletteWindow.on_enter(self, event)
    207         self._handle_focus(+1)
     207        self._handle_focus(True)
    208208
    209209    def on_leave(self, event):
    210210        PaletteWindow.on_enter(self, event)
    211         self._handle_focus(-1)
     211        self._handle_focus(False)
    212212
    213     def _handle_focus(self, delta):
    214         self._focus += delta
    215         if self._focus not in (0, 1):
    216             logging.error('_Palette._focus=%s not in (0, 1)', self._focus)
    217 
    218         if self._focus == 0:
     213    def _handle_focus(self, new_focus):
     214        self._focus = new_focus
     215        if not self._focus:
    219216            group = palettegroup.get_group('default')
    220217            if not group.is_up():
    221218                self.popdown()
    class _ToolbarPalette(PaletteWindow): 
    235232        PaletteWindow.popup(self, immediate)
    236233
    237234    def __group_popdown_cb(self, group):
    238         if self._focus == 0:
     235        if not self._focus:
    239236            self.popdown(immediate=True)
    240237
    241238