Ticket #42: palette.patch

File palette.patch, 1.7 KB (added by marcopg, 12 years ago)

Cleanup state handling

  • src/sugar/graphics/palette.py

    diff --git a/src/sugar/graphics/palette.py b/src/sugar/graphics/palette.py
    index e4f6ab5..3623dce 100644
    a b class Palette(gtk.Window): 
    546546
    547547        self.move(position.x, position.y)
    548548
    549     def popup(self, immediate=False):
     549    def popup(self, immediate=False, state=None):
    550550        logging.debug('Palette.popup immediate %r' % immediate)
     551
     552        if state is None:
     553            state = self.PRIMARY
     554        self.set_state(state)
     555
    551556        if self._invoker is not None:
    552557            self._update_full_request()
    553558            self._alignment = self._invoker.get_alignment(self._full_request)
    class Palette(gtk.Window): 
    602607        if self._group_id:
    603608            group = palettegroup.get_group(self._group_id)
    604609            if group and group.is_up():
    605                 self.set_state(self.PRIMARY)
    606 
    607610                immediate = True
    608611                group.popdown()
    609612
    class Palette(gtk.Window): 
    620623        self.popdown()
    621624
    622625    def _invoker_right_click_cb(self, invoker):
    623         self._popup_anim.stop()
    624         self._secondary_anim.stop()
    625         self._popdown_anim.stop()
    626         self.set_state(self.SECONDARY)
    627         self.show()
     626        self.popup(immediate=True, state=self.SECONDARY)
    628627
    629628    def __enter_notify_event_cb(self, widget, event):
    630629        if event.detail != gtk.gdk.NOTIFY_INFERIOR and \
    class _PopupAnimation(animator.Animation): 
    713712
    714713    def next_frame(self, current):
    715714        if current == 1.0:
    716             self._palette.set_state(Palette.PRIMARY)
    717715            self._palette.show()
    718716
    719717class _SecondaryAnimation(animator.Animation):