[Ap-python-commits] python/examples/aptk gtkplayer.py,1.6,1.7 panel.py,1.4,1.5
Status: Beta
Brought to you by:
sjah
|
From: <sj...@us...> - 2002-07-21 18:15:49
|
Update of /cvsroot/ap-python/python/examples/aptk
In directory usw-pr-cvs1:/tmp/cvs-serv26166/examples/aptk
Modified Files:
gtkplayer.py panel.py
Log Message:
Rewrite APTK to use it with PyGTK2!
Index: gtkplayer.py
===================================================================
RCS file: /cvsroot/ap-python/python/examples/aptk/gtkplayer.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** gtkplayer.py 19 Jul 2002 18:04:56 -0000 1.6
--- gtkplayer.py 21 Jul 2002 18:15:43 -0000 1.7
***************
*** 25,57 ****
__license__ = "GNU"
! import alsaplayer, aptk, gtk, GTK
- # Properties for widgets
- properties = {
- "control.play.button.xpmfile" : "play-sm.xpm",
- "control.play.button.relief" : GTK.RELIEF_NONE,
- "control.next.button.xpmfile" : "next-sm.xpm",
- "control.next.button.relief" : GTK.RELIEF_NONE,
- "control.prev.button.xpmfile" : "prev-sm.xpm",
- "control.prev.button.relief" : GTK.RELIEF_NONE,
- "control.stop.button.xpmfile" : "prev-sm.xpm",
- "control.stop.button.relief" : GTK.RELIEF_NONE,
- "tagslabel.format" : "%a - %t",
- "speed.pause.button.xpmfile" : "pause.xpm",
- "speed.pause.button.relief" : GTK.RELIEF_NONE,
- "speed.forward.button.xpmfile" : "f_play.xpm",
- "speed.forward.button.relief" : GTK.RELIEF_NONE,
- "speed.backward.button.xpmfile" : "r_play.xpm",
- "speed.backward.button.relief" : GTK.RELIEF_NONE,
- "pan.left.button.xpmfile" : "l_pan.xpm",
- "pan.left.button.relief" : GTK.RELIEF_NONE,
- "pan.center.button.xpmfile" : "c_pan.xpm",
- "pan.center.button.relief" : GTK.RELIEF_NONE,
- "pan.right.button.xpmfile" : "r_pan.xpm",
- "pan.right.button.relief" : GTK.RELIEF_NONE,
- }
pl = alsaplayer.get_playlist ()
- cp = pl.get_coreplayer ()
##########################################################
--- 25,52 ----
__license__ = "GNU"
! # Load modules
! import alsaplayer, aptk, gtk
! gdk = gtk.gdk
!
! # Init GDK threads
! gdk.threads_init ()
!
! # Properties
! properties = aptk.misc.WidgetProperties ([
! ('.control.play.button.file', 'play.xpm'),
! ('.control.next.button.file', 'next.xpm'),
! ('.control.stop.button.file', 'stop.xpm'),
! ('.control.prev.button.file', 'prev.xpm'),
! ('.*.*.button.relief', gtk.RELIEF_NONE),
! ('.speed.backward.button.file', 'r_play.xpm'),
! ('.speed.pause.button.file', 'pause.xpm'),
! ('.speed.forward.button.file', 'f_play.xpm'),
! ('.pan.left.button.file', 'l_pan.xpm'),
! ('.pan.center.button.file', 'c_pan.xpm'),
! ('.pan.right.button.file', 'r_pan.xpm')
! ])
pl = alsaplayer.get_playlist ()
##########################################################
***************
*** 60,76 ****
gtk.mainquit ();
! win = gtk.GtkWindow ()
win.connect ("delete_event", delete_event)
! win.set_usize (340, 0)
! win.set_border_width (2)
##########################################################
! position = aptk.position.HScale (cp)
! tagslabel = aptk.info.TagsLabel (cp, properties)
! fullstatusbox = aptk.info.FullStatusHBox (cp, position)
control = aptk.control.HControl (pl, properties)
! speed = aptk.speed.HSpeed (cp, properties)
! pan = aptk.pan.HPan (cp, properties)
! volume = aptk.volume.HVolume (cp)
position.show ()
--- 55,71 ----
gtk.mainquit ();
! win = gtk.Window ()
win.connect ("delete_event", delete_event)
! win.set_default_size (340, 0)
! win.set_border_width (4)
##########################################################
! position = aptk.position.HScale (pl)
! tagslabel = aptk.info.TagsLabel (pl, properties)
! fullstatusbox = aptk.info.FullStatusHBox (pl, position)
control = aptk.control.HControl (pl, properties)
! speed = aptk.speed.HSpeed (pl, properties)
! pan = aptk.pan.HPan (pl, properties)
! volume = aptk.volume.HVolume (pl)
position.show ()
***************
*** 82,86 ****
volume.show ()
##########################################################
! main_vbox = gtk.GtkVBox ()
win.add (main_vbox)
main_vbox.add (tagslabel)
--- 77,81 ----
volume.show ()
##########################################################
! main_vbox = gtk.VBox ()
win.add (main_vbox)
main_vbox.add (tagslabel)
***************
*** 89,103 ****
main_vbox.show ()
! hbox = gtk.GtkHBox ()
main_vbox.add (hbox)
hbox.pack_start (control, expand = gtk.FALSE)
hbox.show ()
! vbox = gtk.GtkVBox ()
hbox.add (vbox)
vbox.add (speed)
vbox.show ()
! hbox2 = gtk.GtkHBox ()
vbox.add (hbox2)
hbox2.add (pan)
--- 84,98 ----
main_vbox.show ()
! hbox = gtk.HBox ()
main_vbox.add (hbox)
hbox.pack_start (control, expand = gtk.FALSE)
hbox.show ()
! vbox = gtk.VBox ()
hbox.add (vbox)
vbox.add (speed)
vbox.show ()
! hbox2 = gtk.HBox ()
vbox.add (hbox2)
hbox2.add (pan)
***************
*** 108,112 ****
win.show ()
! gtk.threads_enter ()
gtk.mainloop ()
! gtk.threads_leave ()
--- 103,107 ----
win.show ()
! gdk.threads_enter ()
gtk.mainloop ()
! gdk.threads_leave ()
Index: panel.py
===================================================================
RCS file: /cvsroot/ap-python/python/examples/aptk/panel.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** panel.py 19 Jul 2002 18:04:56 -0000 1.4
--- panel.py 21 Jul 2002 18:15:43 -0000 1.5
***************
*** 25,99 ****
__license__ = "GNU"
! import alsaplayer, aptk, gtk, GTK
! pl = alsaplayer.get_playlist ()
! ##############################################################################
! # Properties for widgets
! properties = {
! "control.play.button.xpmfile" : "play-sm.xpm",
! "control.play.button.relief" : GTK.RELIEF_NONE,
! "control.next.button.xpmfile" : "next-sm.xpm",
! "control.next.button.relief" : GTK.RELIEF_NONE,
! "control.prev.button.xpmfile" : "prev-sm.xpm",
! "control.prev.button.relief" : GTK.RELIEF_NONE,
! "control.stop.button.xpmfile" : "prev-sm.xpm",
! "control.stop.button.relief" : GTK.RELIEF_NONE,
! "tagslabel.format" : "%a - %t (%y - %l)",
! "speed.pause.button.xpmfile" : "pause.xpm",
! "speed.pause.button.relief" : GTK.RELIEF_NONE,
! "speed.forward.button.xpmfile" : "f_play.xpm",
! "speed.forward.button.relief" : GTK.RELIEF_NONE,
! "speed.backward.button.xpmfile" : "r_play.xpm",
! "speed.backward.button.relief" : GTK.RELIEF_NONE,
! "pan.left.button.xpmfile" : "l_pan.xpm",
! "pan.left.button.relief" : GTK.RELIEF_NONE,
! "pan.center.button.xpmfile" : "c_pan.xpm",
! "pan.center.button.relief" : GTK.RELIEF_NONE,
! "pan.right.button.xpmfile" : "r_pan.xpm",
! "pan.right.button.relief" : GTK.RELIEF_NONE,
! }
- ##########################################################
# Main window
! def delete_event (foo, bar):
! gtk.mainquit ();
!
! win = gtk.GtkWindow ()
! win.connect ("delete_event", delete_event)
win.set_title ("AlsaPlayer-Python Panel")
! win.set_usize (gtk.screen_width (), 0)
! win.set_uposition (0, 0)
! ##############################################################################
! ##############################################################################
! class InfoPage (gtk.GtkHBox):
! def __init__ (self, pl):
! gtk.GtkHBox.__init__ (self)
! cp = pl.get_coreplayer ()
self.set_spacing (2)
self.set_border_width (1)
! # - - - - - aptk widgets
control = aptk.control.HControl (pl, properties)
! tagslabel = aptk.info.TagsLabel (cp, properties)
! status = aptk.info.FullStatusHBox (cp)
status.set_spacing (20)
! # - - - - Frames
! control_frame = gtk.GtkFrame ()
! status_frame = gtk.GtkFrame ()
! shadow_type = GTK.SHADOW_OUT
control_frame.set_shadow_type (shadow_type)
status_frame.set_shadow_type (shadow_type)
! self.pack_start (control_frame, expand = GTK.FALSE)
! self.pack_start (tagslabel, expand = GTK.TRUE)
! self.pack_end (status_frame, expand = GTK.FALSE)
# - - - - pack to frames
--- 25,93 ----
__license__ = "GNU"
! # Load modules
! import alsaplayer, aptk, gtk
! gdk = gtk.gdk
! # Init GDK threads
! gdk.threads_init ()
! # Get general playlist
! pl = alsaplayer.get_playlist ()
# Main window
! win = gtk.Window ()
! win.connect ("delete_event", lambda self, win: gtk.main_quit ())
+ # Setup window
win.set_title ("AlsaPlayer-Python Panel")
! win.set_size_request (gdk.screen_width (), 22)
! win.move (0, 0)
! win.stick ()
! win.set_resizable (gtk.FALSE)
! win.set_decorated (gtk.FALSE)
! # Properties
! properties = aptk.misc.WidgetProperties ([
! ('.tagsinfo.format', '%t - %a (%y - %l)'),
! ('.control.play.button.file', 'play-sm.xpm'),
! ('.control.next.button.file', 'next-sm.xpm'),
! ('.control.stop.button.file', 'stop-sm.xpm'),
! ('.control.prev.button.file', 'prev-sm.xpm'),
! ('.*.*.button.relief', gtk.RELIEF_NONE),
! ('.speed.backward.button.file', 'r_play.xpm'),
! ('.speed.pause.button.file', 'pause.xpm'),
! ('.speed.forward.button.file', 'f_play.xpm'),
! ('.pan.left.button.file', 'l_pan.xpm'),
! ('.pan.center.button.file', 'c_pan.xpm'),
! ('.pan.right.button.file', 'r_pan.xpm')
! ])
! ##########################################################################
! class InfoPage (gtk.HBox):
! def __init__ (self, pl):
! gtk.HBox.__init__ (self)
+ # Setup itself
self.set_spacing (2)
self.set_border_width (1)
! # - - - - - APTK widgets
control = aptk.control.HControl (pl, properties)
! tagslabel = aptk.info.TagsLabel (pl, properties)
! status = aptk.info.FullStatusHBox (pl)
status.set_spacing (20)
! # - - - - - Frames
! control_frame = gtk.Frame ()
! status_frame = gtk.Frame ()
! shadow_type = gtk.SHADOW_OUT
control_frame.set_shadow_type (shadow_type)
status_frame.set_shadow_type (shadow_type)
! self.pack_start (control_frame, expand = gtk.FALSE)
! self.pack_start (tagslabel, expand = gtk.TRUE)
! self.pack_end (status_frame, expand = gtk.FALSE)
# - - - - pack to frames
***************
*** 112,121 ****
##############################################################################
! ##############################################################################
! class ControlPage (gtk.GtkHBox):
def __init__ (self, pl):
! gtk.GtkHBox.__init__ (self)
!
! cp = pl.get_coreplayer ()
self.set_spacing (2)
--- 106,112 ----
##############################################################################
! class ControlPage (gtk.HBox):
def __init__ (self, pl):
! gtk.HBox.__init__ (self)
self.set_spacing (2)
***************
*** 124,142 ****
# - - - - - aptk widgets
control = aptk.control.HControl (pl, properties)
! position = aptk.position.HScale (cp)
! time_label = aptk.info.TimeLabel (cp, position)
! speed = aptk.speed.HSpeed (cp, properties)
! pan = aptk.pan.HPan (cp, properties)
!
! volume = aptk.volume.HVolume (cp)
# - - - - Frames
! control_frame = gtk.GtkFrame ()
! position_frame = gtk.GtkFrame ()
! speed_frame = gtk.GtkFrame ()
! pan_frame = gtk.GtkFrame ()
! volume_frame = gtk.GtkFrame ()
! shadow_type = GTK.SHADOW_OUT
control_frame.set_shadow_type (shadow_type)
position_frame.set_shadow_type (shadow_type)
--- 115,132 ----
# - - - - - aptk widgets
control = aptk.control.HControl (pl, properties)
! position = aptk.position.HScale (pl)
! time_label = aptk.info.TimeLabel (pl, position)
! speed = aptk.speed.HSpeed (pl, properties)
! pan = aptk.pan.HPan (pl, properties)
! volume = aptk.volume.HVolume (pl)
# - - - - Frames
! control_frame = gtk.Frame ()
! position_frame = gtk.Frame ()
! speed_frame = gtk.Frame ()
! pan_frame = gtk.Frame ()
! volume_frame = gtk.Frame ()
! shadow_type = gtk.SHADOW_OUT
control_frame.set_shadow_type (shadow_type)
position_frame.set_shadow_type (shadow_type)
***************
*** 145,149 ****
volume_frame.set_shadow_type (shadow_type)
! self.pack_start (control_frame, expand = GTK.FALSE)
self.add (position_frame)
self.add (speed_frame)
--- 135,139 ----
volume_frame.set_shadow_type (shadow_type)
! self.pack_start (control_frame, expand = gtk.FALSE)
self.add (position_frame)
self.add (speed_frame)
***************
*** 152,162 ****
# - - - - pack to frames
! control_hbox = gtk.GtkHBox ()
control_hbox.add (control)
control_frame.add (control_hbox)
! position_hbox = gtk.GtkHBox ()
position_hbox.set_spacing (2)
! position_hbox.pack_start (time_label, expand=GTK.FALSE)
position_hbox.add (position)
position_frame.add (position_hbox)
--- 142,152 ----
# - - - - pack to frames
! control_hbox = gtk.HBox ()
control_hbox.add (control)
control_frame.add (control_hbox)
! position_hbox = gtk.HBox ()
position_hbox.set_spacing (2)
! position_hbox.pack_start (time_label, expand = gtk.FALSE)
position_hbox.add (position)
position_frame.add (position_hbox)
***************
*** 181,193 ****
position_hbox.show ()
! ##########################################################
! # Create two pages.
! # Info page goes to be visible while cursor is out of panel
! # Else control page is visible.
info_page = InfoPage (pl)
- control_page = ControlPage (pl)
info_page.show ()
control_page.show ()
# Set default mode (show info page)
mode = 1
--- 171,186 ----
position_hbox.show ()
! # Remember
! self.control_widget = control
!
! ###########################################################################
! # Create two pages
info_page = InfoPage (pl)
info_page.show ()
+
+ control_page = ControlPage (pl)
control_page.show ()
+
# Set default mode (show info page)
mode = 1
***************
*** 202,229 ****
"""Return 1 if info widget should be shown."""
! # Get gdk windows of the handling areas
! gdkwin = win.get_window ()
!
! # Get window rect
! wx1 = gdkwin.x
! wy1 = gdkwin.y
! wx2 = wx1 + gdkwin.width
! wy2 = wy1 + gdkwin.height
! # Get control rect
! cx1, cy1, cx2, cy2 = gdkcontrol = info_page.control_widget.get_allocation ()
! cx1 += wx1
! cy1 += wy1
! cx2 += cx1
! cy2 += cy1
! # Get pointer xy
! px, py = gdkwin.pointer
!
! # Pointer is within control widget
! if cx1 <= px < cx2 and cy1 <= py < cy2: return 1
! # Pointer is within main window
! if wx1 <= px < wx2 and wy1 <= py < wy2: return 0
return 1
--- 195,213 ----
"""Return 1 if info widget should be shown."""
! # Check if we aren't in window
! alloc = win.get_allocation ()
! x, y = win.get_pointer ()
! if x < 0 or x >= alloc.width or y < 0 or y >= alloc.height:
! return 1
! # Check if we aren't in control widget
! w = mode and info_page or control_page
!
! alloc = w.control_widget.get_allocation ()
! x, y = w.control_widget.get_pointer ()
! if x < 0 or x >= alloc.width or y < 0 or y >= alloc.height:
! return 0
return 1
***************
*** 234,238 ****
global mode, newmode
! gtk.threads_enter ()
if newmode == 0:
--- 218,222 ----
global mode, newmode
! gdk.threads_enter ()
if newmode == 0:
***************
*** 243,247 ****
win.add (info_page)
! gtk.threads_leave ()
mode = newmode
--- 227,231 ----
win.add (info_page)
! gdk.threads_leave ()
mode = newmode
***************
*** 264,271 ****
win.connect ("enter_notify_event", pointer_moved_event)
! ##########################################################
win.show ()
! gtk.threads_enter ()
gtk.mainloop ()
! gtk.threads_leave ()
--- 248,258 ----
win.connect ("enter_notify_event", pointer_moved_event)
!
! ###########################################################################
! # Go!
!
win.show ()
! gdk.threads_enter ()
gtk.mainloop ()
! gdk.threads_leave ()
|