Development of 0.7 starts, added libplayers and fancy player selector
git-svn-id: svn://svn.berlios.de/gpodder@58 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
parent
6b7b332a9b
commit
bf07eb7ee0
8 changed files with 211 additions and 11 deletions
|
@ -1,3 +1,9 @@
|
|||
Thu, 30 Mar 2006 00:03:11 +0200 <thp@perli.net>
|
||||
* Bumped version number to 0.7-svn
|
||||
* Set "debugging" variable to True again
|
||||
* Added "libplayers", which searches for feasible audio players
|
||||
* Properties dialog uses libplayers to display cute players menu
|
||||
|
||||
Wed, 29 Mar 2006 16:54:38 +0200 <thp@perli.net>
|
||||
* ** gPodder version 0.6 is here! **
|
||||
* Bumped version number to 0.6
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
# PLEASE DO NOT CHANGE FORMAT OF __version__ LINE (Makefile reads this)
|
||||
|
||||
__author__ = "Thomas Perl <thp@perli.net>"
|
||||
__version__ = "0.6"
|
||||
__date__ = "2006-03-29"
|
||||
__version__ = "0.7-svn"
|
||||
__date__ = "2006-03-30"
|
||||
__copyright__ = "Copyright (c) 2005-2006 %s. All rights reserved." % __author__
|
||||
__licence__ = "GPL"
|
||||
|
||||
|
|
|
@ -1753,7 +1753,7 @@
|
|||
<child>
|
||||
<widget class="GtkLabel" id="label18">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Media player command:</property>
|
||||
<property name="label" translatable="yes">Player application:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
|
@ -1779,8 +1779,24 @@
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="openApp">
|
||||
<widget class="GtkComboBox" id="comboPlayerApp">
|
||||
<property name="visible">True</property>
|
||||
<property name="add_tearoffs">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="changed" handler="on_comboPlayerApp_changed" last_modification_time="Wed, 29 Mar 2006 21:25:13 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="y_options">fill</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="openApp">
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
|
@ -1793,8 +1809,35 @@
|
|||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="labelCustomCommand">
|
||||
<property name="label" translatable="yes">Command:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
|
||||
.TH GPODDER "1" "March 2006" "gpodder 0.6 2006-03-29" "User Commands"
|
||||
.TH GPODDER "1" "March 2006" "gpodder 0.7-svn 2006-03-30" "User Commands"
|
||||
.SH NAME
|
||||
gpodder \- manual page for gpodder 0.6 2006-03-29
|
||||
gpodder \- manual page for gpodder 0.7-svn 2006-03-30
|
||||
.SH DESCRIPTION
|
||||
usage: gpodder [options] arg1 arg2
|
||||
.PP
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# Python module src/gpodder/gpodder.py
|
||||
# Autogenerated from gpodder.glade
|
||||
# Generated on Wed Mar 29 16:56:31 2006
|
||||
# Generated on Thu Mar 30 00:02:27 2006
|
||||
|
||||
# Warning: Do not modify any context comment such as #--
|
||||
# They are required to keep user's code
|
||||
|
@ -42,6 +42,8 @@ from libgpodder import gPodderChannelWriter
|
|||
|
||||
from liblocaldb import localDB
|
||||
|
||||
from libplayers import UserAppsReader
|
||||
|
||||
# for isDebugging:
|
||||
import libgpodder
|
||||
|
||||
|
@ -780,10 +782,38 @@ class Gpodderproperties(SimpleGladeApp):
|
|||
self.openApp.set_text( gl.open_app)
|
||||
# if the symlink exists, set the checkbox active
|
||||
self.cbDesktopSymlink.set_active( gPodderLib().getDesktopSymlink())
|
||||
# fill players box with values
|
||||
uar = UserAppsReader()
|
||||
uar.read()
|
||||
# setup cell renderers
|
||||
cellrenderer = gtk.CellRendererPixbuf()
|
||||
self.comboPlayerApp.pack_start( cellrenderer, False)
|
||||
self.comboPlayerApp.add_attribute( cellrenderer, 'pixbuf', 2)
|
||||
cellrenderer = gtk.CellRendererText()
|
||||
self.comboPlayerApp.pack_start( cellrenderer, True)
|
||||
self.comboPlayerApp.add_attribute( cellrenderer, 'markup', 0)
|
||||
# end setup cell renderers
|
||||
self.comboPlayerApp.set_model( uar.get_applications_as_model())
|
||||
# try to activate an item
|
||||
index = self.find_active()
|
||||
self.comboPlayerApp.set_active( index)
|
||||
#-- Gpodderproperties.new }
|
||||
|
||||
#-- Gpodderproperties custom methods {
|
||||
# Write your own methods here
|
||||
def find_active( self):
|
||||
model = self.comboPlayerApp.get_model()
|
||||
iter = model.get_iter_first()
|
||||
index = 0
|
||||
while iter != None:
|
||||
command = model.get_value( iter, 1)
|
||||
if command == self.openApp.get_text():
|
||||
return index
|
||||
iter = model.iter_next( iter)
|
||||
index = index + 1
|
||||
# return last item = custom command
|
||||
return index-1
|
||||
# end find_active
|
||||
#-- Gpodderproperties custom methods }
|
||||
|
||||
#-- Gpodderproperties.on_gPodderProperties_destroy {
|
||||
|
@ -792,6 +822,26 @@ class Gpodderproperties(SimpleGladeApp):
|
|||
print "on_gPodderProperties_destroy called with self.%s" % widget.get_name()
|
||||
#-- Gpodderproperties.on_gPodderProperties_destroy }
|
||||
|
||||
#-- Gpodderproperties.on_comboPlayerApp_changed {
|
||||
def on_comboPlayerApp_changed(self, widget, *args):
|
||||
if libgpodder.isDebugging():
|
||||
print "on_comboPlayerApp_changed called with self.%s" % widget.get_name()
|
||||
|
||||
# find out which one
|
||||
iter = self.comboPlayerApp.get_active_iter()
|
||||
model = self.comboPlayerApp.get_model()
|
||||
command = model.get_value( iter, 1)
|
||||
if command == '':
|
||||
self.openApp.set_sensitive( True)
|
||||
self.openApp.show()
|
||||
self.labelCustomCommand.show()
|
||||
else:
|
||||
self.openApp.set_text( command)
|
||||
self.openApp.set_sensitive( False)
|
||||
self.openApp.hide()
|
||||
self.labelCustomCommand.hide()
|
||||
#-- Gpodderproperties.on_comboPlayerApp_changed }
|
||||
|
||||
#-- Gpodderproperties.on_btnOK_clicked {
|
||||
def on_btnOK_clicked(self, widget, *args):
|
||||
if libgpodder.isDebugging():
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# Python module src/gpodder/gpodder.py
|
||||
# Autogenerated from gpodder.glade
|
||||
# Generated on Wed Mar 29 16:56:31 2006
|
||||
# Generated on Thu Mar 30 00:02:27 2006
|
||||
|
||||
# Warning: Do not modify any context comment such as #--
|
||||
# They are required to keep user's code
|
||||
|
@ -220,6 +220,11 @@ class Gpodderproperties(SimpleGladeApp):
|
|||
print "on_gPodderProperties_destroy called with self.%s" % widget.get_name()
|
||||
#-- Gpodderproperties.on_gPodderProperties_destroy }
|
||||
|
||||
#-- Gpodderproperties.on_comboPlayerApp_changed {
|
||||
def on_comboPlayerApp_changed(self, widget, *args):
|
||||
print "on_comboPlayerApp_changed called with self.%s" % widget.get_name()
|
||||
#-- Gpodderproperties.on_comboPlayerApp_changed }
|
||||
|
||||
#-- Gpodderproperties.on_btnOK_clicked {
|
||||
def on_btnOK_clicked(self, widget, *args):
|
||||
print "on_btnOK_clicked called with self.%s" % widget.get_name()
|
||||
|
|
|
@ -37,7 +37,7 @@ from libpodcasts import podcastChannel
|
|||
|
||||
# global debugging variable, set to False on release
|
||||
# TODO: while developing a new version, set this to "True"
|
||||
debugging = False
|
||||
debugging = True
|
||||
|
||||
# global recursive lock for thread exclusion
|
||||
globalLock = threading.RLock()
|
||||
|
|
96
src/gpodder/libplayers.py
Normal file
96
src/gpodder/libplayers.py
Normal file
|
@ -0,0 +1,96 @@
|
|||
|
||||
#
|
||||
# gPodder
|
||||
# Copyright (c) 2005 Thomas Perl <thp@perli.net>
|
||||
# Released under the GNU General Public License (GPL)
|
||||
#
|
||||
|
||||
#
|
||||
# libplayers.py -- get list of potential playback apps
|
||||
# thomas perl <thp@perli.net> 20060329
|
||||
#
|
||||
#
|
||||
|
||||
from os import listdir
|
||||
from os.path import basename
|
||||
from os.path import splitext
|
||||
from os.path import exists
|
||||
|
||||
from ConfigParser import RawConfigParser
|
||||
|
||||
import gobject
|
||||
|
||||
from gtk import IconTheme
|
||||
from gtk import ListStore
|
||||
|
||||
from gtk.gdk import pixbuf_new_from_file_at_size
|
||||
from gtk.gdk import Pixbuf
|
||||
|
||||
import libgpodder
|
||||
|
||||
# where are the .desktop files located?
|
||||
userappsdir = '/usr/share/applications/'
|
||||
|
||||
# the name of the section in the .desktop files
|
||||
sect = 'Desktop Entry'
|
||||
|
||||
class UserApplication(object):
|
||||
def __init__( self, name, cmd, mime, icon):
|
||||
self.name = name
|
||||
self.cmd = cmd
|
||||
self.icon = icon
|
||||
self.theme = IconTheme()
|
||||
|
||||
def get_icon( self):
|
||||
if self.icon != None:
|
||||
if exists( self.icon):
|
||||
return pixbuf_new_from_file_at_size( self.icon, 24, 24)
|
||||
icon_name = splitext( basename( self.icon))[0]
|
||||
if self.theme.has_icon( icon_name):
|
||||
return self.theme.load_icon( icon_name, 24, 0)
|
||||
|
||||
def get_name( self):
|
||||
return self.name
|
||||
|
||||
def get_action( self):
|
||||
return self.cmd
|
||||
|
||||
|
||||
class UserAppsReader(object):
|
||||
def __init__( self):
|
||||
self.apps = []
|
||||
|
||||
def read( self):
|
||||
files = listdir( userappsdir)
|
||||
for file in files:
|
||||
self.parse_and_append( file)
|
||||
self.apps.append( UserApplication( 'Shell command', '', 'audio/*', 'gtk-execute'))
|
||||
|
||||
def parse_and_append( self, filename):
|
||||
parser = RawConfigParser()
|
||||
parser.read( [ userappsdir + filename ])
|
||||
if not parser.has_section( sect):
|
||||
return
|
||||
|
||||
try:
|
||||
app_name = parser.get( sect, 'Name')
|
||||
app_cmd = parser.get( sect, 'Exec')
|
||||
app_mime = parser.get( sect, 'MimeType')
|
||||
app_icon = parser.get( sect, 'Icon')
|
||||
if app_mime.find( 'audio/') != -1:
|
||||
if libgpodder.isDebugging():
|
||||
print "found app in " + userappsdir + filename + " ("+app_name+")"
|
||||
self.apps.append( UserApplication( app_name, app_cmd, app_mime, app_icon))
|
||||
except:
|
||||
return
|
||||
|
||||
def get_applications_as_model( self):
|
||||
result = ListStore( gobject.TYPE_STRING, gobject.TYPE_STRING, Pixbuf)
|
||||
for app in self.apps:
|
||||
iter = result.append()
|
||||
result.set_value( iter, 0, app.get_name())
|
||||
result.set_value( iter, 1, app.get_action())
|
||||
result.set_value( iter, 2, app.get_icon())
|
||||
return result
|
||||
# end of UserAppsReader
|
||||
|
Loading…
Reference in a new issue