diff options
author | amartin <olpc@xo-05-28-21.localdomain> | 2007-08-31 09:33:44 (GMT) |
---|---|---|
committer | amartin <olpc@xo-05-28-21.localdomain> | 2007-08-31 09:33:44 (GMT) |
commit | 1204c5b72630555a5e86dc5de58081baa48f7709 (patch) | |
tree | f58890a2a810335c49688a39a47604378e619e0f /Jam | |
parent | c72c8119c18fca5f277cb3efd61acead578cd4d0 (diff) |
Jam popups
Diffstat (limited to 'Jam')
-rw-r--r-- | Jam/Desktop.py | 15 | ||||
-rw-r--r-- | Jam/Popup.py | 50 |
2 files changed, 59 insertions, 6 deletions
diff --git a/Jam/Desktop.py b/Jam/Desktop.py index 568695d..7380385 100644 --- a/Jam/Desktop.py +++ b/Jam/Desktop.py @@ -56,8 +56,9 @@ class Desktop( gtk.EventBox ): self.rightClicked = False self.popup = {} - self.popup[Popup.Shortcut] = Popup.Shortcut( _("Assign Key"), self.owner ) self.popup[Popup.Instrument] = Popup.Instrument( _("Instrument Properties"), self.owner ) + self.popup[Popup.Drum] = Popup.Drum( _("Drum Kit Properties"), self.owner ) + self.popup[Popup.Shortcut] = Popup.Shortcut( _("Assign Key"), self.owner ) def dumpToStream( self, ostream ): for b in self.blocks: @@ -235,7 +236,17 @@ class Desktop( gtk.EventBox ): if self.clickedBlock: if self.clickedBlock.type == Block.Instrument: self.popup[Popup.Instrument].setBlock( self.clickedBlock ) - self.popup[Popup.Instrument].popup() + if self.popup[Popup.Instrument].is_up(): + self.popup[Popup.Instrument].updatePosition() + else: + self.popup[Popup.Instrument].popup( True ) + + elif self.clickedBlock.type == Block.Drum: + #self.popup[Popup.Drum].setBlock( self.clickedBlock ) + if self.popup[Popup.Drum].is_up(): + self.popup[Popup.Drum].updatePosition() + else: + self.popup[Popup.Drum].popup( True ) self.clickedBlock = None self.rightClicked = False diff --git a/Jam/Popup.py b/Jam/Popup.py index 1e4f326..587a34d 100644 --- a/Jam/Popup.py +++ b/Jam/Popup.py @@ -7,9 +7,23 @@ import Config from gettext import gettext as _ from sugar.graphics import style -from sugar.graphics.palette import Palette, WidgetInvoker +from sugar.graphics.palette import Palette, Invoker, _palette_observer +class NoneInvoker( Invoker ): + + def __init__( self ): + Invoker.__init__( self ) + + def get_default_position( self ): + return Palette.AT_CURSOR + + def get_rect( self ): + return gtk.gdk.Rectangle( 0, 0, 0, 0 ) + + def get_toplevel( self ): + return None + class Popup( Palette ): def __init__( self, label, owner ): @@ -17,9 +31,11 @@ class Popup( Palette ): self.owner = owner - self.props.invoker = WidgetInvoker( gtk.HBox() ) # garbage invoker + self.props.invoker = NoneInvoker() self.set_property( "position", Palette.AT_CURSOR ) self.set_group_id( "TamTamPopup" ) + + self._set_state( Palette.SECONDARY ) # skip to fully exposed self.connect( "key-press-event", self.owner.onKeyPress ) self.connect( "key-release-event", self.owner.onKeyRelease ) @@ -27,7 +43,14 @@ class Popup( Palette ): self.connect( "focus_out_event", self.closePopup ) def _leave_notify_event_cb( self, widget, event ): - pass # don't popdown() + return # don't popdown() + + def _show( self ): + Palette._show( self ) + + if self._palette_popup_sid != None: + _palette_observer.disconnect( self._palette_popup_sid ) # don't hide when other palettes pop + self._palette_popup_sid = None def popup( self, immediate = False ): self.owner.activity.handler_block(self.owner.activity.focusOutHandler) @@ -36,13 +59,18 @@ class Popup( Palette ): Palette.popup( self, immediate ) def popdown( self, immediate = False ): + Palette.popdown( self, immediate ) self.owner.activity.handler_unblock(self.owner.activity.focusOutHandler) self.owner.activity.handler_unblock(self.owner.activity.focusInHandler) + def updatePosition( self ): + self._update_cursor_position() + self._update_position() + def closePopup( self, widget, event ): - self.popdown() + self.popdown( True ) class Instrument( Popup ): @@ -134,6 +162,20 @@ class Instrument( Popup ): def handleReverb( self, widget ): self.block.setData( "reverb", widget.get_value() ) + +class Drum( Popup ): + + def __init__( self, label, owner ): + Popup.__init__( self, label, owner ) + + self.GUI = {} + + self.GUI["mainBox"] = gtk.VBox() + self.set_content( self.GUI["mainBox"] ) + + self.GUI["mainBox"].show_all() + + class Shortcut( Popup ): def __init__( self, label, owner ): |