Implement palette groups. Use them to not popdown frame when hover a palette.

This commit is contained in:
Marco Pesenti Gritti
2007-07-06 14:36:59 +02:00
parent 9ec946d2d0
commit 7468faa840
6 changed files with 52 additions and 7 deletions
+1
View File
@@ -16,6 +16,7 @@ sugar_PYTHON = \
radiotoolbutton.py \
roundbox.py \
palette.py \
palettegroup.py \
panel.py \
spreadlayout.py \
toggletoolbutton.py \
+29 -2
View File
@@ -1,4 +1,4 @@
# Copyright (C) 2007, Eduardo Silva (edsiper@gmail.com)
# Copyright (C) 2007, Eduardo Silva <edsiper@gmail.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,7 @@ import gobject
import time
import hippo
from sugar.graphics import palettegroup
from sugar.graphics import animator
from sugar.graphics import units
from sugar import _sugarext
@@ -51,9 +52,18 @@ class Palette(gobject.GObject):
0, gobject.PARAM_READWRITE)
}
__gsignals__ = {
'popup' : (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, ([])),
'popdown' : (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, ([]))
}
def __init__(self, label, accel_path=None):
gobject.GObject.__init__(self)
self._group_id = None
self._up = False
self._position = self.AUTOMATIC
self._palette_popup_sid = None
@@ -88,6 +98,9 @@ class Palette(gobject.GObject):
self._menu.connect('button-press-event',
self._button_press_event_cb)
def is_up(self):
return self._up
def set_primary_text(self, label, accel_path=None):
self._primary.set_label(label, accel_path)
@@ -119,7 +132,15 @@ class Palette(gobject.GObject):
def append_button(self, button):
self._button_bar.append_button(button)
self._button_bar.show()
def set_group_id(self, group_id):
if self._group_id:
group = palettegroup.get_group(self._group_id)
group.remove(self)
if group_id:
group = palettegroup.get_group(group_id)
group.add(self)
def do_set_property(self, pspec, value):
if pspec.name == 'invoker':
self._invoker = value
@@ -206,7 +227,10 @@ class Palette(gobject.GObject):
self._palette_popup_sid = _palette_observer.connect('popup',
self._palette_observer_popup_cb)
self._menu.popup(x, y)
self._up = True
_palette_observer.emit('popup', self)
self.emit('popup')
def _hide(self):
if not self._palette_popup_sid is None:
@@ -214,6 +238,9 @@ class Palette(gobject.GObject):
self._palette_popup_sid = None
self._menu.popdown()
self._up = False
self.emit('popdown')
def popup(self):
self._popdown_anim.stop()
self._popup_anim.start()