Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoramartin <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)
commit1204c5b72630555a5e86dc5de58081baa48f7709 (patch)
treef58890a2a810335c49688a39a47604378e619e0f
parentc72c8119c18fca5f277cb3efd61acead578cd4d0 (diff)
Jam popups
-rw-r--r--Config.py8
-rw-r--r--Jam/Desktop.py15
-rw-r--r--Jam/Popup.py50
-rwxr-xr-xTamTam.py1
4 files changed, 60 insertions, 14 deletions
diff --git a/Config.py b/Config.py
index 1a5fe4c..7b30cf9 100644
--- a/Config.py
+++ b/Config.py
@@ -36,20 +36,12 @@ if SugarMode == True:
SYNTH_DIR=env.get_profile_path() + '/tamtam/synthlab'
SNDS_DIR=env.get_profile_path() + '/tamtam/snds'
SCRATCH_DIR = PREF_DIR + "/.scratch/"
- try: # can't add .scratch to git for some reason so make sure it exists here
- os.mkdir( SCRATCH_DIR )
- except:
- pass
else:
PREF_DIR = os.getenv('HOME') + '/.tamtam'
TUNE_DIR= os.getenv('HOME') + '/.tamtam/tunes'
SYNTH_DIR= os.getenv('HOME') + '/.tamtam/synthlab'
SNDS_DIR= os.getenv('HOME') + '/.tamtam/snds'
SCRATCH_DIR = PREF_DIR + "/.scratch/"
- try: # can't add .scratch to git for some reason so make sure it exists here
- os.mkdir( SCRATCH_DIR )
- except:
- pass
#PLUGIN
PLUGIN_DEBUG = PREF_DIR + "/clooper.log"
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 ):
diff --git a/TamTam.py b/TamTam.py
index ac4a8dd..e71b508 100755
--- a/TamTam.py
+++ b/TamTam.py
@@ -250,6 +250,7 @@ class TamTam(Activity):
self.ensure_dir(Config.TUNE_DIR)
self.ensure_dir(Config.SYNTH_DIR)
self.ensure_dir(Config.SNDS_DIR)
+ self.ensure_dir(Config.SCRATCH_DIR)
if not os.path.isdir(Config.PREF_DIR):
os.mkdir(Config.PREF_DIR)