[Quake2world-dev] r556 - pymp/trunk

fsx at jdolan.dyndns.org fsx at jdolan.dyndns.org
Mon Jun 22 18:04:09 UTC 2009


Author: fsx
Date: 2009-06-22 18:04:08 +0000 (Mon, 22 Jun 2009)
New Revision: 556

Added:
   pymp/trunk/pymp_tray.png
   pymp/trunk/systray.py
Modified:
   pymp/trunk/CHANGELOG
   pymp/trunk/LICENSE
   pymp/trunk/Makefile
   pymp/trunk/README
   pymp/trunk/control.py
   pymp/trunk/menu.py
   pymp/trunk/playlist.py
   pymp/trunk/pymp.py
Log:
Added "hide in systemtray" function and systemtray menu.

Modified: pymp/trunk/CHANGELOG
===================================================================
--- pymp/trunk/CHANGELOG	2009-06-21 16:11:26 UTC (rev 555)
+++ pymp/trunk/CHANGELOG	2009-06-22 18:04:08 UTC (rev 556)
@@ -1,5 +1,11 @@
 Changelog
 
+Version 1.2
+---
+
+ - Added "hide in systemtray" function and systemtray menu.
+
+
 Version 1.1
 ---
 

Modified: pymp/trunk/LICENSE
===================================================================
--- pymp/trunk/LICENSE	2009-06-21 16:11:26 UTC (rev 555)
+++ pymp/trunk/LICENSE	2009-06-22 18:04:08 UTC (rev 556)
@@ -55,7 +55,7 @@
 
   The precise terms and conditions for copying, distribution and
 modification follow.
-
+
 		    GNU GENERAL PUBLIC LICENSE
    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 
@@ -110,7 +110,7 @@
     License.  (Exception: if the Program itself is interactive but
     does not normally print such an announcement, your work based on
     the Program is not required to print an announcement.)
-
+
 These requirements apply to the modified work as a whole.  If
 identifiable sections of that work are not derived from the Program,
 and can be reasonably considered independent and separate works in
@@ -168,7 +168,7 @@
 access to copy the source code from the same place counts as
 distribution of the source code, even though third parties are not
 compelled to copy the source along with the object code.
-
+
   4. You may not copy, modify, sublicense, or distribute the Program
 except as expressly provided under this License.  Any attempt
 otherwise to copy, modify, sublicense or distribute the Program is
@@ -225,7 +225,7 @@
 
 This section is intended to make thoroughly clear what is believed to
 be a consequence of the rest of this License.
-
+
   8. If the distribution and/or use of the Program is restricted in
 certain countries either by patents or by copyrighted interfaces, the
 original copyright holder who places the Program under this License
@@ -278,7 +278,7 @@
 POSSIBILITY OF SUCH DAMAGES.
 
 		     END OF TERMS AND CONDITIONS
-
+
 	    How to Apply These Terms to Your New Programs
 
   If you develop a new program, and you want it to be of the greatest

Modified: pymp/trunk/Makefile
===================================================================
--- pymp/trunk/Makefile	2009-06-21 16:11:26 UTC (rev 555)
+++ pymp/trunk/Makefile	2009-06-22 18:04:08 UTC (rev 556)
@@ -6,22 +6,22 @@
 
 all: control.py menu.py mplayer.py playlist.py prefs.py pymp.py
 	$(PYTHON) ./build.py; rm -f ./build.pyc
-	
+
 install: all
-	
+
 	install -d $(DESTDIR)/$(PREFIX)/lib/pymp
 	install *.pyc $(DESTDIR)/$(PREFIX)/lib/pymp
-	
+
 	install -d $(DESTDIR)/$(PREFIX)/share/pixmaps
-	install -m 644 pymp.png $(DESTDIR)/$(PREFIX)/share/pixmaps
-	
+	install -m 644 *.png $(DESTDIR)/$(PREFIX)/share/pixmaps
+
 	install -d $(DESTDIR)/$(PREFIX)/bin
 	install pymp $(DESTDIR)/$(PREFIX)/bin
-	
+
 	sed -i "s|PREFIX|$(PREFIX)|g" \
 		$(DESTDIR)/$(PREFIX)/bin/pymp
-	
+
 clean:
 	rm -f *.pyc
-	
+
 #End of file

Modified: pymp/trunk/README
===================================================================
--- pymp/trunk/README	2009-06-21 16:11:26 UTC (rev 555)
+++ pymp/trunk/README	2009-06-22 18:04:08 UTC (rev 556)
@@ -1,42 +1,77 @@
 Pymp: A Gtk interface for MPlayer
-(c) Jay Dolan 2004-2007
+(c) Jay Dolan 2004-2009
+---
 
-http://jaydolan.com/pymp.html
+http://jdolan.dyndns.org/trac/wiki/Pymp
 
-Pymp is a simple, clean Gtk2 interface for MPlayer.  It supports 
+Pymp is a simple, clean Gtk2 interface for MPlayer. It supports
 any media type MPlayer does, and has nice features like:
 
--Opening files on the command line: pymp *.mp3
+ - Opening files on the command line: pymp *.mp3
+ - Open files or locations, i.e.: http://x.com/foo.avi, dvd://1
+ - Drag and drop files or folders to playlist
+ - Remote commands on a running instance:
+    * pymp -remote pause
+    * pymp -remote stop
+    * pymp -remote play 12
+    * pymp -remote status
+    * pymp -remote seek 20
+ - Simple playlist format: find ~/ -name "*.mp3" > playlist.m3u
+ - Auto save/restore last playlist
+ - Continuous, random, and repeat play
+ - Interactive progress bar
+ - Find file in list: <Ctrl+F>
+ - Really freakin' tiny.
 
--Open files or locations, i.e.: http://x.com/foo.avi, dvd://1
 
--Drag and drop files or folders to playlist
+Keyboard shortcuts
+---
 
--Remote commands on a running instance:
-	pymp -remote pause
-	pymp -remote stop
-	pymp -remote play 12
-	pymp -remote status
-	pymp -remote seek 20
+ - Del (delete): remove selected items.
+ - Enter: play selected item.
+ - Left/Right: seek reverse/forward.
+ - </>: jump previsous/next item.
+ - P/Spacebar: pause current item.
+ - S: stop current item.
+ - Ctrl+F: search.
 
--Simple playlist format:
-	find ~/ -name "*.mp3" > playlist.m3u
 
--Auto save/restore last playlist
+Credits
+---
 
--Continuous, random, and repeat play
+ - Matt Housh: the name Pymp.
+ - Lucas Hazel: mplayer io, ui enhancements.
+ - Greg Harris: mplayer io, playback status.
 
--Interactive progress bar
 
--Find file in list: <ctrl+f>
+License
+---
 
--Really freakin' tiny
+Pymp's released under the GPL. Improvements and feedback are very
+welcome. Contact me at jay at jaydolan.com.
 
-Credits:
-Matt Housh - the name pymp
-Lucas Hazel - mplayer io, ui enhancements
-Greg Harris - mplayer io, playback status
 
-Pymp's released under the GPL.  Improvements and feedback are very
-welcome.  Contact me at jay at jaydolan.com.
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Modified: pymp/trunk/control.py
===================================================================
--- pymp/trunk/control.py	2009-06-21 16:11:26 UTC (rev 555)
+++ pymp/trunk/control.py	2009-06-22 18:04:08 UTC (rev 556)
@@ -116,10 +116,12 @@
 		if status == 1 and self.PLAYSTATUS == 1:
 			self.pseBox.remove(self.plyImg)
 			self.pseBox.add(self.pseImg)
+			self.pymp.systray.menuPlay.get_children()[0].set_label('Pause')
 			self.PLAYSTATUS = 0
 		elif status == 0 and self.PLAYSTATUS == 0:
 			self.pseBox.remove(self.pseImg)
 			self.pseBox.add(self.plyImg)
+			self.pymp.systray.menuPlay.get_children()[0].set_label('Play')
 			self.PLAYSTATUS = 1
 
 	#

Modified: pymp/trunk/menu.py
===================================================================
--- pymp/trunk/menu.py	2009-06-21 16:11:26 UTC (rev 555)
+++ pymp/trunk/menu.py	2009-06-22 18:04:08 UTC (rev 556)
@@ -326,10 +326,12 @@
 
 		about.set_logo(self.pymp.getIcon())
 
-		about.show()
-		about.run()
-		about.hide()
+		# about.show() # Not sure if this is necessary
+		about.present()
+		about.run() # This line throws an error when the dialog is closed
+		# about.hide() # Not sure if this is necessary
 		about.destroy()
+
 		return True
 
 #End of file

Modified: pymp/trunk/playlist.py
===================================================================
--- pymp/trunk/playlist.py	2009-06-21 16:11:26 UTC (rev 555)
+++ pymp/trunk/playlist.py	2009-06-22 18:04:08 UTC (rev 556)
@@ -112,6 +112,7 @@
 	def set_track_title(self, title):
 
 		self.pymp.playlist.view.get_model().set(self.pymp.playlist.it, COL_TITLE, title)
+		self.pymp.systray.staticon.set_tooltip(title)
 		self.pymp.window.set_title(title)
 
 	#  Returns the current path of target by tid, or None if such a target is no longer in list.

Modified: pymp/trunk/pymp.py
===================================================================
--- pymp/trunk/pymp.py	2009-06-21 16:11:26 UTC (rev 555)
+++ pymp/trunk/pymp.py	2009-06-22 18:04:08 UTC (rev 556)
@@ -2,7 +2,7 @@
 
 import sys, os, fcntl, pygtk, gtk, gobject, time
 
-import prefs, menu, remote, playlist, control, mplayer
+import prefs, menu, remote, playlist, control, mplayer, systray
 
 HOME = os.path.expanduser("~/.pymp")
 
@@ -11,9 +11,10 @@
 #
 class Pymp:
 
-	versionString = "Pymp v1.0.1"
+	versionString = "Pymp v1.2"
 	window, prefs, menu, remote = None, None, None, None
 	playlist, control, mplayer = None, None, None
+	position = (0, 0)
 
 	#
 	#  Returns a gtk.gdk.Pixbuf
@@ -41,6 +42,12 @@
 		gtk.main_quit()
 
 	#
+	#  Store the position of the window when it's moved or resized
+	#
+	def cb_store_position(self, event, position):
+		self.position = (position.x, position.y)
+
+	#
 	#  Initializes and the player and its components.
 	#
 	def __init__(self, targets):
@@ -59,6 +66,7 @@
 		self.playlist = playlist.Playlist(self)
 		self.control = control.Control(self)
 		self.menu = menu.Menu(self)
+		self.systray = systray.Systray(self)
 
 		vbox = gtk.VBox(False, 0)
 		vbox.pack_start(self.playlist.scrollview, True, True, 0)
@@ -80,6 +88,8 @@
 		else:  #or load last list
 			self.playlist.loadm3u()
 
+		window.connect("configure-event", self.cb_store_position)
+
 		gtk.main()
 
 #

Added: pymp/trunk/pymp_tray.png
===================================================================
(Binary files differ)


Property changes on: pymp/trunk/pymp_tray.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: pymp/trunk/systray.py
===================================================================
--- pymp/trunk/systray.py	                        (rev 0)
+++ pymp/trunk/systray.py	2009-06-22 18:04:08 UTC (rev 556)
@@ -0,0 +1,86 @@
+#!/usr/bin/env python
+
+import pygtk, gtk, sys, os
+
+class Systray:
+
+	pymp = None
+
+	def __init__(self, pymp):
+
+		self.pymp = pymp
+
+		# Menu
+		menu = gtk.Menu()
+
+		menuPrev = gtk.ImageMenuItem(gtk.STOCK_MEDIA_PREVIOUS)
+		menuNext = gtk.ImageMenuItem(gtk.STOCK_MEDIA_NEXT)
+		self.menuPlay = gtk.ImageMenuItem(gtk.STOCK_MEDIA_PLAY)
+		menuStop = gtk.ImageMenuItem(gtk.STOCK_MEDIA_STOP)
+		menuAbout = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
+		menuQuit = gtk.ImageMenuItem(gtk.STOCK_QUIT)
+
+		menuPrev.connect("button-press-event", self.pymp.playlist.prev)
+		menuNext.connect("button-press-event", self.pymp.playlist.next)
+		self.menuPlay.connect("button-press-event", self.pymp.control.playPause)
+		menuStop.connect("button-press-event", self.pymp.playlist.stop)
+		menuAbout.connect("button-press-event", self.pymp.menu.openAbout)
+		menuQuit.connect("button-press-event", self.pymp.quit)
+
+		menu.append(menuPrev)
+		menu.append(menuNext)
+		menu.append(self.menuPlay)
+		menu.append(menuStop)
+		menu.append(gtk.SeparatorMenuItem())
+		menu.append(menuAbout)
+		menu.append(gtk.SeparatorMenuItem())
+		menu.append(menuQuit)
+
+		# Icon
+		self.staticon = gtk.StatusIcon()
+		self.staticon.set_from_pixbuf(self.getTrayIcon())
+
+		self.staticon.connect('activate', self.cb_activate_icon)
+		self.staticon.connect('popup-menu', self.cb_popup_menu, menu)
+
+		self.staticon.set_visible(True)
+
+	#
+	#  System tray icon actions
+	#
+	def cb_activate_icon(self, widget, data=None):
+
+		if self.pymp.window.get_property("visible"):
+			self.pymp.window.hide()
+		else:
+			self.pymp.window.move(self.pymp.position[0], self.pymp.position[1])
+			self.pymp.window.show()
+			self.pymp.window.present()
+
+	#
+	#  System tray menu
+	#
+	def cb_popup_menu(self, widget, button, time, data = None):
+
+		if button == 3:
+			if data:
+				data.show_all()
+				data.popup(None, None, None, 3, time)
+
+		pass
+
+	#
+	#  Returns a gtk.gdk.Pixbuf
+	#
+	def getTrayIcon(self):
+
+		icons = [sys.path[0] + "/../../share/pixmaps/pymp_tray.png",
+			"./pymp_tray.png"]  #for development
+
+		for icon in icons:
+			if os.access(icon, os.F_OK):
+				return gtk.gdk.pixbuf_new_from_file(icon)
+
+		return None
+
+#End of file



More information about the Quake2World-dev mailing list