2005-11-21 19:21:25 +01:00
|
|
|
# -*- coding: UTF8 -*-
|
|
|
|
|
|
|
|
# Python module src/gpodder/gpodder.py
|
|
|
|
# Autogenerated from gpodder.glade
|
|
|
|
|
|
|
|
# Warning: Do not modify any context comment such as #--
|
|
|
|
# They are required to keep user's code
|
|
|
|
|
|
|
|
#
|
2006-04-07 22:22:30 +02:00
|
|
|
# gPodder (a media aggregator / podcast client)
|
|
|
|
# Copyright (C) 2005-2006 Thomas Perl <thp at perli.net>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
# MA 02110-1301, USA.
|
2005-11-21 19:21:25 +01:00
|
|
|
#
|
|
|
|
|
|
|
|
import os
|
|
|
|
import gtk
|
|
|
|
import gobject
|
|
|
|
import sys
|
2006-03-04 21:45:01 +01:00
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
from threading import Event
|
2006-04-07 03:43:06 +02:00
|
|
|
from threading import Thread
|
2006-03-04 21:45:01 +01:00
|
|
|
from string import strip
|
2005-11-21 19:21:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
from SimpleGladeApp import SimpleGladeApp
|
|
|
|
from SimpleGladeApp import bindtextdomain
|
|
|
|
|
|
|
|
from libpodcasts import podcastChannel
|
|
|
|
from libpodcasts import podcastItem
|
|
|
|
|
|
|
|
from libpodcasts import channelsToModel
|
|
|
|
|
|
|
|
from librssreader import rssReader
|
2005-12-08 20:47:35 +01:00
|
|
|
from libopmlwriter import opmlWriter
|
2006-06-13 23:00:31 +02:00
|
|
|
from libopmlreader import opmlReader
|
2005-11-21 19:21:25 +01:00
|
|
|
from libwget import downloadThread
|
2005-11-22 23:04:58 +01:00
|
|
|
from libwget import downloadStatusManager
|
2005-11-21 19:21:25 +01:00
|
|
|
|
|
|
|
from libgpodder import gPodderLib
|
|
|
|
from libgpodder import gPodderChannelReader
|
|
|
|
from libgpodder import gPodderChannelWriter
|
|
|
|
|
2006-02-04 18:29:17 +01:00
|
|
|
from liblocaldb import localDB
|
|
|
|
|
2006-03-30 00:07:27 +02:00
|
|
|
from libplayers import UserAppsReader
|
|
|
|
|
2006-04-06 16:11:03 +02:00
|
|
|
from libipodsync import gPodder_iPodSync
|
|
|
|
from libipodsync import ipod_supported
|
|
|
|
|
2005-11-21 22:17:54 +01:00
|
|
|
# for isDebugging:
|
|
|
|
import libgpodder
|
2005-11-21 19:21:25 +01:00
|
|
|
|
|
|
|
app_name = "gpodder"
|
|
|
|
app_version = "unknown" # will be set in main() call
|
2006-03-29 14:04:18 +02:00
|
|
|
app_authors = [
|
2006-03-31 18:20:18 +02:00
|
|
|
'Thomas Perl <thp@perli.net>', '',
|
|
|
|
_('Contributors / patch writers:'),
|
|
|
|
'Peter Hoffmann <tosh@cs.tu-berlin.de>',
|
|
|
|
'Adrien Beaucreux <informancer@web.de>',
|
|
|
|
'Alain Tauch <contrib@maisondubonheur.com>', '',
|
|
|
|
_('See the AUTHORS file for all contributors')
|
2006-03-29 14:04:18 +02:00
|
|
|
]
|
2006-03-31 18:20:18 +02:00
|
|
|
app_copyright = 'Copyright (c) 2005-2006 Thomas Perl'
|
|
|
|
app_website = 'http://perli.net/projekte/gpodder/'
|
2005-11-21 19:21:25 +01:00
|
|
|
|
2006-03-31 18:20:18 +02:00
|
|
|
glade_dir = '/usr/share/gpodder/'
|
|
|
|
icon_dir = '/usr/share/gpodder/images/gpodder.png'
|
2006-04-07 03:43:06 +02:00
|
|
|
artwork_dir = '/usr/share/gpodder/images/'
|
2006-03-31 18:20:18 +02:00
|
|
|
locale_dir = '/usr/share/locale/'
|
2005-11-21 19:21:25 +01:00
|
|
|
|
|
|
|
class Gpodder(SimpleGladeApp):
|
|
|
|
channels = []
|
|
|
|
|
|
|
|
active_item = None
|
|
|
|
items_model = None
|
|
|
|
|
|
|
|
active_channel = None
|
|
|
|
channels_model = None
|
|
|
|
|
|
|
|
channels_loaded = False
|
|
|
|
|
2005-11-22 23:04:58 +01:00
|
|
|
download_status_manager = None
|
2006-03-04 21:45:01 +01:00
|
|
|
tooltips = None
|
2005-11-22 23:04:58 +01:00
|
|
|
|
2006-03-29 13:33:56 +02:00
|
|
|
# Local DB
|
|
|
|
ldb = None
|
|
|
|
|
2006-03-31 18:20:18 +02:00
|
|
|
# User Apps Reader
|
|
|
|
uar = None
|
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
def __init__(self, path="gpodder.glade",
|
|
|
|
root="gPodder",
|
|
|
|
domain=app_name, **kwargs):
|
|
|
|
path = os.path.join(glade_dir, path)
|
|
|
|
SimpleGladeApp.__init__(self, path, root, domain, **kwargs)
|
|
|
|
|
|
|
|
#-- Gpodder.new {
|
|
|
|
def new(self):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "A new %s has been created" % self.__class__.__name__
|
2006-04-04 00:27:57 +02:00
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
#self.gPodder.set_title( self.gPodder.get_title())
|
|
|
|
#self.statusLabel.set_text( "Welcome to gPodder! Suggestions? Mail to: thp@perli.net")
|
|
|
|
# set up the rendering of the comboAvailable combobox
|
|
|
|
cellrenderer = gtk.CellRendererText()
|
|
|
|
self.comboAvailable.pack_start( cellrenderer, True)
|
|
|
|
self.comboAvailable.add_attribute( cellrenderer, 'text', 1)
|
|
|
|
|
2006-02-04 18:29:17 +01:00
|
|
|
# set up the rendering of the comboDownloaded combobox
|
|
|
|
cellrenderer = gtk.CellRendererText()
|
|
|
|
self.comboDownloaded.pack_start( cellrenderer, True)
|
|
|
|
self.comboDownloaded.add_attribute( cellrenderer, 'text', 1)
|
2005-11-22 14:30:28 +01:00
|
|
|
|
|
|
|
#See http://www.pygtk.org/pygtk2tutorial/sec-CellRenderers.html
|
|
|
|
#gtk.TreeViewColumn( "", gtk.CellRendererToggle(), active=3),
|
|
|
|
namecell = gtk.CellRendererText()
|
|
|
|
namecell.set_property('cell-background', 'white')
|
2006-03-31 15:00:54 +02:00
|
|
|
namecolumn = gtk.TreeViewColumn( _("Episode"), namecell, text=1)
|
2005-11-22 14:30:28 +01:00
|
|
|
namecolumn.add_attribute(namecell, "cell-background", 4)
|
|
|
|
|
|
|
|
sizecell = gtk.CellRendererText()
|
|
|
|
sizecell.set_property('cell-background', 'white')
|
2006-03-31 15:00:54 +02:00
|
|
|
sizecolumn = gtk.TreeViewColumn( _("Size"), sizecell, text=2)
|
2005-11-22 14:30:28 +01:00
|
|
|
sizecolumn.add_attribute(sizecell, "cell-background", 4)
|
2006-04-10 18:46:50 +02:00
|
|
|
|
|
|
|
releasecell = gtk.CellRendererText()
|
|
|
|
releasecell.set_property('cell-background', 'white')
|
|
|
|
releasecolumn = gtk.TreeViewColumn( _("Released"), releasecell, text=5)
|
|
|
|
releasecolumn.add_attribute(releasecell, "cell-background", 4)
|
2005-11-22 14:30:28 +01:00
|
|
|
|
2006-04-10 18:46:50 +02:00
|
|
|
for itemcolumn in ( namecolumn, sizecolumn, releasecolumn ):
|
2005-11-21 19:21:25 +01:00
|
|
|
self.treeAvailable.append_column( itemcolumn)
|
2006-06-22 23:41:32 +02:00
|
|
|
|
|
|
|
# enable multiple selection support
|
|
|
|
self.treeAvailable.get_selection().set_mode( gtk.SELECTION_MULTIPLE)
|
2006-07-06 20:56:43 +02:00
|
|
|
self.treeDownloads.get_selection().set_mode( gtk.SELECTION_MULTIPLE)
|
2006-07-14 21:10:47 +02:00
|
|
|
self.treeDownloaded.get_selection().set_mode( gtk.SELECTION_MULTIPLE)
|
2005-11-22 23:04:58 +01:00
|
|
|
|
2006-02-04 18:29:17 +01:00
|
|
|
# columns and renderers for the "downloaded" tab
|
|
|
|
# more information: see above..
|
|
|
|
namecell = gtk.CellRendererText()
|
|
|
|
namecell.set_property('cell-background', 'white')
|
2006-03-31 15:00:54 +02:00
|
|
|
namecolumn = gtk.TreeViewColumn( _("Episode"), namecell, text=1)
|
2006-02-04 18:29:17 +01:00
|
|
|
namecolumn.add_attribute(namecell, "cell-background", 4)
|
|
|
|
self.treeDownloaded.append_column( namecolumn)
|
|
|
|
|
2005-11-22 23:26:51 +01:00
|
|
|
# columns and renderers for "download progress" tab
|
2005-11-22 23:04:58 +01:00
|
|
|
episodecell = gtk.CellRendererText()
|
2006-03-31 15:00:54 +02:00
|
|
|
episodecolumn = gtk.TreeViewColumn( _("Episode"), episodecell, text=0)
|
2005-11-22 23:26:51 +01:00
|
|
|
|
2005-11-22 23:04:58 +01:00
|
|
|
speedcell = gtk.CellRendererText()
|
2006-03-31 15:00:54 +02:00
|
|
|
speedcolumn = gtk.TreeViewColumn( _("Speed"), speedcell, text=1)
|
2005-11-22 23:26:51 +01:00
|
|
|
|
|
|
|
progresscell = gtk.CellRendererProgress()
|
2006-03-31 15:00:54 +02:00
|
|
|
progresscolumn = gtk.TreeViewColumn( _("Progress"), progresscell, value=2)
|
2005-11-22 23:26:51 +01:00
|
|
|
|
|
|
|
for itemcolumn in ( episodecolumn, speedcolumn, progresscolumn ):
|
2005-11-22 23:04:58 +01:00
|
|
|
self.treeDownloads.append_column( itemcolumn)
|
|
|
|
|
|
|
|
new_model = gtk.ListStore( gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_INT)
|
2005-11-22 23:26:51 +01:00
|
|
|
self.download_status_manager = downloadStatusManager()
|
2005-11-22 23:04:58 +01:00
|
|
|
self.treeDownloads.set_model( self.download_status_manager.getModel())
|
2005-11-22 23:26:51 +01:00
|
|
|
|
2006-03-31 18:20:18 +02:00
|
|
|
# read and display subscribed channels
|
2005-11-21 19:21:25 +01:00
|
|
|
reader = gPodderChannelReader()
|
|
|
|
self.channels = reader.read( False)
|
|
|
|
self.channels_loaded = True
|
2006-03-24 20:08:59 +01:00
|
|
|
|
|
|
|
# keep Downloaded channels list
|
|
|
|
self.downloaded_channels = None
|
|
|
|
self.active_downloaded_channels = 0
|
2005-11-21 19:21:25 +01:00
|
|
|
|
|
|
|
# update view
|
|
|
|
self.updateComboBox()
|
2006-02-04 18:29:17 +01:00
|
|
|
self.updateDownloadedComboBox()
|
2006-03-04 21:45:01 +01:00
|
|
|
|
|
|
|
# tooltips :)
|
|
|
|
self.tooltips = gtk.Tooltips()
|
2006-03-31 15:00:54 +02:00
|
|
|
self.tooltips.set_tip( self.btnEditChannel, _("Channel Info"))
|
2005-11-22 14:23:50 +01:00
|
|
|
|
|
|
|
#Add Drag and Drop Support
|
|
|
|
targets = [("text/plain", 0, 2), ('STRING', 0, 3), ('TEXT', 0, 4)]
|
|
|
|
self.main_widget.drag_dest_set(gtk.DEST_DEFAULT_ALL, targets, \
|
|
|
|
gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_COPY | \
|
|
|
|
gtk.gdk.ACTION_DEFAULT)
|
|
|
|
self.main_widget.connect("drag_data_received", self.drag_data_received)
|
2006-03-28 20:33:40 +02:00
|
|
|
self.wNotebook.connect("switch-page", self.switched_notebook)
|
2006-04-04 00:27:57 +02:00
|
|
|
|
2006-04-06 16:11:03 +02:00
|
|
|
# disable iPod sync features if not supported
|
|
|
|
if not ipod_supported():
|
2006-04-09 21:53:31 +02:00
|
|
|
self.ipod_functions( False)
|
2006-04-09 18:18:47 +02:00
|
|
|
else:
|
2006-06-13 20:23:09 +02:00
|
|
|
self.ipod_functions( True)
|
2006-04-06 16:11:03 +02:00
|
|
|
|
2006-04-04 00:27:57 +02:00
|
|
|
# if we are running a SVN-based version, notify the user :)
|
|
|
|
if app_version.rfind( "svn") != -1:
|
|
|
|
self.showMessage( _("<b>gPodder development version %s</b>\nUse at your own risk, but also enjoy new features :)") % app_version)
|
2006-05-01 23:12:34 +02:00
|
|
|
# Update the feed list if the user has set it up
|
|
|
|
if gPodderLib().update_on_startup:
|
|
|
|
self.update_feed_cache()
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodder.new }
|
|
|
|
|
|
|
|
#-- Gpodder custom methods {
|
2006-04-09 18:18:47 +02:00
|
|
|
def ipod_functions( self, enable = True):
|
|
|
|
self.cleanup_ipod.set_sensitive( enable)
|
|
|
|
self.sync_to_ipod.set_sensitive( enable)
|
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
def updateComboBox( self):
|
|
|
|
self.channels_model = channelsToModel( self.channels)
|
|
|
|
|
|
|
|
self.comboAvailable.set_model( self.channels_model)
|
|
|
|
try:
|
|
|
|
self.comboAvailable.set_active( 0)
|
|
|
|
except:
|
2006-03-31 18:20:18 +02:00
|
|
|
pass
|
2005-11-21 19:21:25 +01:00
|
|
|
#self.updateTreeView()
|
2006-02-04 18:29:17 +01:00
|
|
|
|
|
|
|
def updateDownloadedComboBox( self):
|
|
|
|
# now, update downloaded feeds tab:
|
2006-03-29 13:33:56 +02:00
|
|
|
if self.ldb == None:
|
|
|
|
self.ldb = localDB()
|
2006-03-24 20:08:59 +01:00
|
|
|
# update downloaded_channels list
|
2006-03-29 13:33:56 +02:00
|
|
|
self.downloaded_channels = self.ldb.getDownloadedChannelsList()
|
|
|
|
self.comboDownloaded.set_model( self.ldb.getDownloadedChannelsModel())
|
2006-02-04 18:29:17 +01:00
|
|
|
try:
|
2006-03-24 20:08:59 +01:00
|
|
|
self.comboDownloaded.set_active( self.active_downloaded_channels)
|
2006-02-04 18:29:17 +01:00
|
|
|
except:
|
2006-03-24 20:08:59 +01:00
|
|
|
self.active_downloaded_channels = 0
|
2006-02-04 18:29:17 +01:00
|
|
|
if libgpodder.isDebugging():
|
2006-03-31 18:20:18 +02:00
|
|
|
print _('No downloaded podcasts found.')
|
2006-02-04 18:29:17 +01:00
|
|
|
# end of self.updateDownloadedComboBox()
|
2005-11-21 19:21:25 +01:00
|
|
|
|
|
|
|
def updateTreeView( self):
|
|
|
|
try:
|
2006-03-29 16:40:08 +02:00
|
|
|
self.items_model = self.channels[self.active_channel].getItemsModel()
|
|
|
|
self.treeAvailable.set_model( self.items_model)
|
2005-11-21 19:21:25 +01:00
|
|
|
except:
|
2006-03-29 16:40:08 +02:00
|
|
|
if self.items_model != None:
|
|
|
|
self.items_model.clear()
|
2006-03-31 15:00:54 +02:00
|
|
|
self.showMessage( _("<b>No channels found</b>\n\nClick on <b><i>Channels</i></b> > <b><i>Add channel..</i></b> to add a new channel."))
|
2005-11-21 19:21:25 +01:00
|
|
|
|
2006-03-31 18:20:18 +02:00
|
|
|
def showMessage( self, message, title = _('gPodder message')):
|
2005-11-21 19:21:25 +01:00
|
|
|
dlg = gtk.MessageDialog( self.gPodder, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK)
|
2006-03-29 14:41:34 +02:00
|
|
|
dlg.set_title( title)
|
|
|
|
dlg.set_markup( message)
|
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
dlg.run()
|
|
|
|
dlg.destroy()
|
2005-11-22 14:18:57 +01:00
|
|
|
|
2006-03-31 18:20:18 +02:00
|
|
|
def showConfirmation( self, message = _('Do you really want to do this?'), title = _('gPodder confirmation')):
|
2006-03-29 15:49:10 +02:00
|
|
|
myresult = False
|
|
|
|
dlg = gtk.MessageDialog( self.gPodder, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO)
|
|
|
|
dlg.set_title( title)
|
|
|
|
dlg.set_markup( message)
|
|
|
|
|
|
|
|
if gtk.RESPONSE_YES == dlg.run():
|
|
|
|
myresult = True
|
|
|
|
|
|
|
|
dlg.destroy()
|
|
|
|
if libgpodder.isDebugging():
|
2006-03-31 18:20:18 +02:00
|
|
|
print "I Asked: %s" % message
|
|
|
|
print "User answered: %s" % str(myresult)
|
2006-03-29 15:49:10 +02:00
|
|
|
return myresult
|
|
|
|
|
2005-11-22 14:18:57 +01:00
|
|
|
def set_icon(self):
|
|
|
|
icon = self.get_icon('gpodder')
|
|
|
|
self.main_widget.set_icon(icon)
|
|
|
|
|
|
|
|
def get_icon(self, entry, size=24):
|
|
|
|
#path = self.custom_handler.getIconPath(entry, size)
|
2006-03-31 18:20:18 +02:00
|
|
|
path = icon_dir
|
2005-11-22 14:18:57 +01:00
|
|
|
if path == None:
|
|
|
|
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, size, size)
|
|
|
|
pb.fill(0x00000000)
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
pb = gtk.gdk.pixbuf_new_from_file_at_size(path, size, size)
|
|
|
|
except:
|
|
|
|
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, size, size)
|
|
|
|
pb.fill(0x00000000)
|
|
|
|
return pb
|
2005-11-22 14:23:50 +01:00
|
|
|
|
2006-03-28 20:33:40 +02:00
|
|
|
def switched_notebook( self, notebook, page, page_num):
|
|
|
|
# if we are NOT on the "available downloads" page, disable menu items
|
|
|
|
if page_num != 0:
|
|
|
|
is_available = False
|
|
|
|
else:
|
|
|
|
is_available = True
|
|
|
|
|
|
|
|
# disable/enable menu items related to only the first notebook tab
|
|
|
|
self.itemRemoveChannel.set_sensitive( is_available)
|
|
|
|
self.itemEditChannel.set_sensitive( is_available)
|
|
|
|
|
|
|
|
# when switching to last page, update the "downloaded" combo box
|
|
|
|
if page_num == 2:
|
|
|
|
self.updateDownloadedComboBox()
|
|
|
|
|
2005-11-22 14:23:50 +01:00
|
|
|
def drag_data_received(self, widget, context, x, y, sel, ttype, time):
|
|
|
|
result = sel.data
|
2006-03-31 18:20:18 +02:00
|
|
|
self.add_new_channel( result)
|
|
|
|
|
|
|
|
def refetch_channel_list( self):
|
|
|
|
channels_should_be = len( self.channels)
|
|
|
|
|
|
|
|
# fetch metadata for that channel
|
|
|
|
gPodderChannelWriter().write( self.channels)
|
|
|
|
self.channels = gPodderChannelReader().read( False)
|
|
|
|
|
|
|
|
# fetch feed for that channel
|
|
|
|
gPodderChannelWriter().write( self.channels)
|
|
|
|
self.channels = gPodderChannelReader().read( False)
|
|
|
|
|
|
|
|
# check if gPodderChannelReader has successfully added the channel
|
|
|
|
if channels_should_be > len( self.channels):
|
|
|
|
self.showMessage( _("There has been an error adding the channel.\nMaybe the URL is wrong?"))
|
|
|
|
|
|
|
|
def add_new_channel( self, result = None):
|
2005-11-22 14:23:50 +01:00
|
|
|
if result != None and result != "" and (result[:4] == "http" or result[:3] == "ftp"):
|
2006-06-13 23:00:31 +02:00
|
|
|
for old_channel in self.channels:
|
|
|
|
if old_channel.url == result:
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print 'channel already exists in my list :)'
|
|
|
|
return
|
2006-03-31 18:20:18 +02:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print ("Will add channel :%s") % result
|
2006-03-31 15:00:54 +02:00
|
|
|
self.statusLabel.set_text( _("Fetching channel index..."))
|
2005-11-22 14:23:50 +01:00
|
|
|
channel_new = podcastChannel( result)
|
|
|
|
channel_new.shortname = "__unknown__"
|
|
|
|
self.channels.append( channel_new)
|
|
|
|
|
2006-03-31 18:20:18 +02:00
|
|
|
# download changed channels
|
|
|
|
self.refetch_channel_list()
|
|
|
|
|
|
|
|
# try to update combo box
|
2005-11-22 14:23:50 +01:00
|
|
|
self.updateComboBox()
|
|
|
|
self.statusLabel.set_text( "")
|
|
|
|
else:
|
2006-03-31 18:20:18 +02:00
|
|
|
if result != None and result != "":
|
|
|
|
self.showMessage( _("Could not add new channel.\nOnly <b>http://</b> and <b>ftp://</b> URLs supported at the moment."))
|
|
|
|
|
|
|
|
def get_current_channel_downloaded( self):
|
|
|
|
iter = self.comboDownloaded.get_active_iter()
|
|
|
|
return self.comboDownloaded.get_model().get_value( iter, 0)
|
2006-04-07 03:43:06 +02:00
|
|
|
|
|
|
|
def sync_to_ipod_proc( self, sync_win):
|
2006-06-13 20:23:09 +02:00
|
|
|
gpl = gPodderLib()
|
|
|
|
gpl.loadConfig()
|
|
|
|
sync = gPodder_iPodSync( ipod_mount = gpl.ipod_mount, callback_status = sync_win.set_status, callback_progress = sync_win.set_progress, callback_done = sync_win.close)
|
2006-04-07 20:11:31 +02:00
|
|
|
if not sync.open():
|
2006-06-13 20:23:09 +02:00
|
|
|
gobject.idle_add( self.showMessage, _('Cannot access iPod.\nMake sure your iPod is connected and mounted.'))
|
2006-04-07 20:11:31 +02:00
|
|
|
sync.close()
|
|
|
|
return False
|
2006-04-07 03:43:06 +02:00
|
|
|
for channel in self.downloaded_channels:
|
|
|
|
channel.set_metadata_from_localdb()
|
|
|
|
sync.copy_channel_to_ipod( channel)
|
|
|
|
sync.close()
|
|
|
|
|
|
|
|
def ipod_cleanup_proc( self, sync_win):
|
2006-06-13 20:23:09 +02:00
|
|
|
gpl = gPodderLib()
|
|
|
|
gpl.loadConfig()
|
|
|
|
sync = gPodder_iPodSync( ipod_mount = gpl.ipod_mount, callback_status = sync_win.set_status, callback_progress = sync_win.set_progress, callback_done = sync_win.close)
|
2006-04-07 20:11:31 +02:00
|
|
|
if not sync.open():
|
2006-04-09 18:18:47 +02:00
|
|
|
gobject.idle_add( self.showMessage, _('Cannot access iPod.\nMake sure your iPod is connected.'))
|
2006-04-07 20:11:31 +02:00
|
|
|
sync.close()
|
|
|
|
return False
|
2006-04-07 03:43:06 +02:00
|
|
|
sync.clean_playlist()
|
|
|
|
sync.close()
|
2006-05-01 23:12:34 +02:00
|
|
|
|
|
|
|
def update_feed_cache(self):
|
|
|
|
reader = gPodderChannelReader()
|
|
|
|
#self.channels = reader.read( True)
|
|
|
|
#self.labelStatus.set_text( "Updating feed cache...")
|
|
|
|
please_wait = gtk.MessageDialog()
|
|
|
|
please_wait.set_markup( _("<big><b>Updating feed cache</b></big>\n\nPlease wait while gPodder is\nupdating the feed cache..."))
|
|
|
|
please_wait.show()
|
|
|
|
self.channels = reader.read( True)
|
|
|
|
please_wait.destroy()
|
|
|
|
#self.labelStatus.set_text( "")
|
|
|
|
self.updateComboBox()
|
|
|
|
|
2006-06-22 23:41:32 +02:00
|
|
|
def download_podcast_by_url( self, url, want_message_dialog = True, widget = None):
|
|
|
|
self.active_item = self.channels[self.active_channel].getActiveByUrl( url)
|
|
|
|
|
|
|
|
current_channel = self.channels[self.active_channel]
|
|
|
|
current_podcast = current_channel[self.active_item]
|
|
|
|
filename = current_channel.getPodcastFilename( current_podcast.url)
|
|
|
|
if widget != None and widget.get_name() == "treeAvailable":
|
|
|
|
Gpodderepisode().set_episode( current_podcast, current_channel)
|
|
|
|
return
|
|
|
|
|
|
|
|
if os.path.exists( filename) == False and self.download_status_manager.is_download_in_progress( current_podcast.url) == False:
|
|
|
|
downloadThread( current_podcast.url, filename, None, self.download_status_manager, current_podcast.title, current_channel, current_podcast, self.ldb).download()
|
|
|
|
else:
|
|
|
|
if want_message_dialog:
|
|
|
|
self.showMessage( _("You have already downloaded this episode\nor you are currently downloading it."))
|
|
|
|
# if we're not downloading it, but it exists: add to localdb (if not already done so)
|
|
|
|
if os.path.exists( filename) == True:
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "already downloaded, trying to add to localDB if needed"
|
|
|
|
if current_channel.addDownloadedItem( current_podcast):
|
|
|
|
self.ldb.clear_cache()
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodder custom methods }
|
|
|
|
|
|
|
|
#-- Gpodder.close_gpodder {
|
|
|
|
def close_gpodder(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "close_gpodder called with self.%s" % widget.get_name()
|
2005-11-21 19:21:25 +01:00
|
|
|
|
|
|
|
if self.channels_loaded:
|
|
|
|
gPodderChannelWriter().write( self.channels)
|
|
|
|
|
2005-11-23 20:53:18 +01:00
|
|
|
# cancel downloads by killing all threads in the list
|
|
|
|
if self.download_status_manager:
|
|
|
|
self.download_status_manager.cancelAll()
|
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
self.gtk_main_quit()
|
|
|
|
#-- Gpodder.close_gpodder }
|
|
|
|
|
|
|
|
#-- Gpodder.on_itemUpdate_activate {
|
|
|
|
def on_itemUpdate_activate(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_itemUpdate_activate called with self.%s" % widget.get_name()
|
2006-05-01 23:12:34 +02:00
|
|
|
self.update_feed_cache()
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodder.on_itemUpdate_activate }
|
|
|
|
|
2006-04-07 03:43:06 +02:00
|
|
|
#-- Gpodder.on_sync_to_ipod_activate {
|
|
|
|
def on_sync_to_ipod_activate(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_sync_to_ipod_activate called with self.%s" % widget.get_name()
|
|
|
|
sync_win = Gpoddersync()
|
|
|
|
while gtk.events_pending():
|
|
|
|
gtk.main_iteration( False)
|
|
|
|
args = ( sync_win, )
|
|
|
|
thread = Thread( target = self.sync_to_ipod_proc, args = args)
|
|
|
|
thread.start()
|
|
|
|
#-- Gpodder.on_sync_to_ipod_activate }
|
|
|
|
|
2006-04-06 16:11:03 +02:00
|
|
|
#-- Gpodder.on_cleanup_ipod_activate {
|
|
|
|
def on_cleanup_ipod_activate(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_cleanup_ipod_activate called with self.%s" % widget.get_name()
|
2006-04-08 11:09:15 +02:00
|
|
|
if not self.showConfirmation( _('Do you really want to truncate the Podcasts playlist on your iPod?')):
|
|
|
|
return
|
2006-04-07 03:43:06 +02:00
|
|
|
sync_win = Gpoddersync()
|
|
|
|
while gtk.events_pending():
|
|
|
|
gtk.main_iteration( False)
|
|
|
|
args = ( sync_win, )
|
|
|
|
thread = Thread( target = self.ipod_cleanup_proc, args = args)
|
|
|
|
thread.start()
|
2006-04-06 16:11:03 +02:00
|
|
|
#-- Gpodder.on_cleanup_ipod_activate }
|
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodder.on_itemPreferences_activate {
|
|
|
|
def on_itemPreferences_activate(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_itemPreferences_activate called with self.%s" % widget.get_name()
|
2006-03-31 18:20:18 +02:00
|
|
|
if self.uar == None:
|
|
|
|
self.uar = UserAppsReader()
|
|
|
|
self.uar.read()
|
2006-03-29 15:24:44 +02:00
|
|
|
prop = Gpodderproperties()
|
2006-03-31 18:20:18 +02:00
|
|
|
prop.set_uar( self.uar)
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodder.on_itemPreferences_activate }
|
|
|
|
|
|
|
|
#-- Gpodder.on_itemAddChannel_activate {
|
|
|
|
def on_itemAddChannel_activate(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_itemAddChannel_activate called with self.%s" % widget.get_name()
|
2006-03-29 14:41:34 +02:00
|
|
|
ch = Gpodderchannel()
|
|
|
|
ch.entryURL.set_text( "http://")
|
|
|
|
result = ch.requestURL()
|
2006-03-31 18:20:18 +02:00
|
|
|
self.add_new_channel( result)
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodder.on_itemAddChannel_activate }
|
|
|
|
|
|
|
|
#-- Gpodder.on_itemEditChannel_activate {
|
|
|
|
def on_itemEditChannel_activate(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_itemEditChannel_activate called with self.%s" % widget.get_name()
|
2006-03-31 18:20:18 +02:00
|
|
|
channel = None
|
2006-03-29 16:40:08 +02:00
|
|
|
try:
|
2006-04-06 16:11:03 +02:00
|
|
|
channel = self.channels[self.active_channel]
|
2006-03-29 16:40:08 +02:00
|
|
|
except:
|
2006-04-06 16:11:03 +02:00
|
|
|
self.showMessage( _("Cannot edit this channel.\n\nNo channel found."))
|
|
|
|
return
|
2005-12-08 20:47:35 +01:00
|
|
|
|
2006-03-31 18:20:18 +02:00
|
|
|
result = Gpodderchannel().requestURL( channel)
|
|
|
|
if result != channel.url and result != None and result != "" and (result[:4] == "http" or result[:3] == "ftp"):
|
2005-12-08 20:47:35 +01:00
|
|
|
if libgpodder.isDebugging():
|
2006-03-31 18:20:18 +02:00
|
|
|
print 'Changing ID %d from "%s" to "%s"' % (active, channel.url, result)
|
2006-03-31 15:00:54 +02:00
|
|
|
self.statusLabel.set_text( _("Fetching channel index..."))
|
2005-12-08 20:47:35 +01:00
|
|
|
channel_new = podcastChannel( result)
|
|
|
|
channel_new.shortname = "__unknown__"
|
|
|
|
new_channels = self.channels[0:active]
|
|
|
|
new_channels.append( channel_new)
|
|
|
|
new_channels.extend( self.channels[active+1:])
|
|
|
|
self.channels = new_channels
|
2006-03-31 18:20:18 +02:00
|
|
|
|
|
|
|
# fetch new channels
|
|
|
|
self.refetch_channel_list()
|
|
|
|
|
2005-12-08 20:47:35 +01:00
|
|
|
self.updateComboBox()
|
|
|
|
self.statusLabel.set_text( "")
|
|
|
|
# end if result != None etc etc
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodder.on_itemEditChannel_activate }
|
|
|
|
|
|
|
|
#-- Gpodder.on_itemRemoveChannel_activate {
|
|
|
|
def on_itemRemoveChannel_activate(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_itemRemoveChannel_activate called with self.%s" % widget.get_name()
|
2006-03-29 15:49:10 +02:00
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
try:
|
2006-03-31 15:00:54 +02:00
|
|
|
if self.showConfirmation( _("Do you really want to remove this channel?\n\n %s") % self.channels[self.active_channel].title) == False:
|
2006-03-29 15:49:10 +02:00
|
|
|
return
|
2005-11-21 19:21:25 +01:00
|
|
|
self.channels.remove( self.channels[self.active_channel])
|
|
|
|
gPodderChannelWriter().write( self.channels)
|
|
|
|
self.channels = gPodderChannelReader().read( False)
|
|
|
|
self.updateComboBox()
|
|
|
|
except:
|
2006-03-31 15:00:54 +02:00
|
|
|
self.showMessage( _("Could not delete channel.\nProbably no channel is selected."))
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodder.on_itemRemoveChannel_activate }
|
|
|
|
|
|
|
|
#-- Gpodder.on_itemExportChannels_activate {
|
|
|
|
def on_itemExportChannels_activate(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_itemExportChannels_activate called with self.%s" % widget.get_name()
|
2006-03-29 16:40:08 +02:00
|
|
|
if len( self.channels) == 0:
|
2006-03-31 18:20:18 +02:00
|
|
|
self.showMessage( _("Your channel list is empty. Nothing to export."))
|
2006-03-29 16:40:08 +02:00
|
|
|
return
|
2006-03-31 18:20:18 +02:00
|
|
|
dlg = gtk.FileChooserDialog( title=_("Export to OPML"), parent = None, action = gtk.FILE_CHOOSER_ACTION_SAVE)
|
2005-12-08 20:47:35 +01:00
|
|
|
dlg.add_button( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
|
|
|
|
dlg.add_button( gtk.STOCK_SAVE, gtk.RESPONSE_OK)
|
|
|
|
response = dlg.run()
|
|
|
|
if response == gtk.RESPONSE_OK:
|
|
|
|
foutname = dlg.get_filename()
|
|
|
|
if foutname[-5:] != ".opml" and foutname[-4:] != ".xml":
|
|
|
|
foutname = foutname + ".opml"
|
|
|
|
if libgpodder.isDebugging():
|
2006-03-31 18:20:18 +02:00
|
|
|
print 'Exporting channels list to: %s' % foutname
|
2005-12-08 20:47:35 +01:00
|
|
|
w = opmlWriter( foutname)
|
|
|
|
for ch in self.channels:
|
|
|
|
w.addChannel( ch)
|
|
|
|
w.close()
|
|
|
|
# end response is ok
|
|
|
|
dlg.destroy()
|
|
|
|
# end dlg.run()
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodder.on_itemExportChannels_activate }
|
|
|
|
|
2006-06-13 23:00:31 +02:00
|
|
|
#-- Gpodder.on_itemImportChannels_activate {
|
|
|
|
def on_itemImportChannels_activate(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging:
|
|
|
|
print "on_itemImportChannels_activate called with self.%s" % widget.get_name()
|
|
|
|
opml_lister = Gpodderopmllister()
|
|
|
|
|
|
|
|
gl = gPodderLib()
|
|
|
|
url = gl.opml_url
|
|
|
|
|
|
|
|
opml_lister.get_channels_from_url( url, self.add_new_channel)
|
|
|
|
#-- Gpodder.on_itemImportChannels_activate }
|
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodder.on_itemAbout_activate {
|
|
|
|
def on_itemAbout_activate(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_itemAbout_activate called with self.%s" % widget.get_name()
|
2005-11-21 19:21:25 +01:00
|
|
|
dlg = gtk.AboutDialog()
|
|
|
|
dlg.set_name( app_name)
|
|
|
|
dlg.set_version( app_version)
|
|
|
|
dlg.set_authors( app_authors)
|
|
|
|
dlg.set_copyright( app_copyright)
|
|
|
|
dlg.set_website( app_website)
|
2006-04-06 16:11:03 +02:00
|
|
|
dlg.set_translator_credits( _('translator-credits'))
|
2006-02-04 18:29:17 +01:00
|
|
|
#
|
|
|
|
try:
|
|
|
|
dlg.set_logo( gtk.gdk.pixbuf_new_from_file_at_size( icon_dir, 164, 164))
|
|
|
|
except:
|
|
|
|
None
|
|
|
|
#
|
2005-11-21 19:21:25 +01:00
|
|
|
dlg.run()
|
|
|
|
#-- Gpodder.on_itemAbout_activate }
|
|
|
|
|
2006-02-04 18:29:17 +01:00
|
|
|
#-- Gpodder.on_wNotebook_switch_page {
|
|
|
|
def on_wNotebook_switch_page(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_wNotebook_switch_page called with self.%s" % widget.get_name()
|
|
|
|
#-- Gpodder.on_wNotebook_switch_page }
|
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodder.on_comboAvailable_changed {
|
|
|
|
def on_comboAvailable_changed(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_comboAvailable_changed called with self.%s" % widget.get_name()
|
2005-11-21 19:21:25 +01:00
|
|
|
self.active_channel = self.comboAvailable.get_active()
|
|
|
|
self.updateTreeView()
|
|
|
|
#-- Gpodder.on_comboAvailable_changed }
|
|
|
|
|
2006-03-04 21:45:01 +01:00
|
|
|
#-- Gpodder.on_btnEditChannel_clicked {
|
|
|
|
def on_btnEditChannel_clicked(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_btnEditChannel_clicked called with self.%s" % widget.get_name()
|
|
|
|
self.on_itemEditChannel_activate( widget, args)
|
|
|
|
#-- Gpodder.on_btnEditChannel_clicked }
|
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodder.on_treeAvailable_row_activated {
|
|
|
|
def on_treeAvailable_row_activated(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_treeAvailable_row_activated called with self.%s" % widget.get_name()
|
2006-03-29 16:40:08 +02:00
|
|
|
try:
|
2006-06-22 23:41:32 +02:00
|
|
|
selection = self.treeAvailable.get_selection()
|
|
|
|
selection_tuple = selection.get_selected_rows()
|
|
|
|
if selection.count_selected_rows() > 1:
|
|
|
|
widget_to_send = None
|
|
|
|
show_message_dialog = False
|
|
|
|
else:
|
|
|
|
widget_to_send = widget
|
|
|
|
show_message_dialog = True
|
|
|
|
for apath in selection_tuple[1]:
|
|
|
|
selection_iter = self.items_model.get_iter( apath)
|
|
|
|
url = self.items_model.get_value( selection_iter, 0)
|
|
|
|
self.download_podcast_by_url( url, show_message_dialog, widget_to_send)
|
2006-03-29 16:40:08 +02:00
|
|
|
except:
|
2006-03-31 18:20:18 +02:00
|
|
|
self.showMessage( _("You have not selected an episode to download."))
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodder.on_treeAvailable_row_activated }
|
|
|
|
|
|
|
|
#-- Gpodder.on_btnDownload_clicked {
|
|
|
|
def on_btnDownload_clicked(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_btnDownload_clicked called with self.%s" % widget.get_name()
|
2005-11-21 19:21:25 +01:00
|
|
|
self.on_treeAvailable_row_activated( widget, args)
|
|
|
|
#-- Gpodder.on_btnDownload_clicked }
|
|
|
|
|
2005-11-23 20:53:18 +01:00
|
|
|
#-- Gpodder.on_treeDownloads_row_activated {
|
|
|
|
def on_treeDownloads_row_activated(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_treeDownloads_row_activated called with self.%s" % widget.get_name()
|
2006-07-06 20:56:43 +02:00
|
|
|
selection = self.treeDownloads.get_selection()
|
|
|
|
selection_tuple = selection.get_selected_rows()
|
|
|
|
if selection.count_selected_rows() == 1:
|
|
|
|
msg = _("Do you really want to cancel this download?")
|
2006-03-29 14:41:34 +02:00
|
|
|
else:
|
2006-07-06 20:56:43 +02:00
|
|
|
msg = _("Do you really want to cancel %d downloads?") % selection.count_selected_rows()
|
|
|
|
if self.showConfirmation( msg):
|
|
|
|
# cancel downloads one by one
|
|
|
|
try:
|
|
|
|
for apath in selection_tuple[1]:
|
|
|
|
selection_iter = self.treeDownloads.get_model().get_iter( apath)
|
|
|
|
url = self.download_status_manager.get_url_by_iter( selection_iter)
|
|
|
|
self.download_status_manager.cancel_by_url( url)
|
|
|
|
except:
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "error while cancelling downloads"
|
2005-11-23 20:53:18 +01:00
|
|
|
#-- Gpodder.on_treeDownloads_row_activated }
|
|
|
|
|
|
|
|
#-- Gpodder.on_btnCancelDownloadStatus_clicked {
|
|
|
|
def on_btnCancelDownloadStatus_clicked(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_btnCancelDownloadStatus_clicked called with self.%s" % widget.get_name()
|
|
|
|
self.on_treeDownloads_row_activated( widget, None)
|
|
|
|
#-- Gpodder.on_btnCancelDownloadStatus_clicked }
|
|
|
|
|
2006-02-04 18:29:17 +01:00
|
|
|
#-- Gpodder.on_comboDownloaded_changed {
|
|
|
|
def on_comboDownloaded_changed(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_comboDownloaded_changed called with self.%s" % widget.get_name()
|
2006-03-24 20:08:59 +01:00
|
|
|
self.active_downloaded_channels = self.comboDownloaded.get_active()
|
2006-03-29 16:40:08 +02:00
|
|
|
try:
|
2006-03-31 18:20:18 +02:00
|
|
|
filename = self.get_current_channel_downloaded()
|
|
|
|
new_model = self.ldb.getDownloadedEpisodesModelByFilename( filename)
|
2006-03-29 16:40:08 +02:00
|
|
|
self.treeDownloaded.set_model( new_model)
|
|
|
|
except:
|
|
|
|
# silently ignore the fact that we do not have any downloads
|
|
|
|
pass
|
2006-02-04 18:29:17 +01:00
|
|
|
#-- Gpodder.on_comboDownloaded_changed }
|
|
|
|
|
|
|
|
#-- Gpodder.on_treeDownloaded_row_activated {
|
|
|
|
def on_treeDownloaded_row_activated(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_treeDownloaded_row_activated called with self.%s" % widget.get_name()
|
2006-03-29 16:40:08 +02:00
|
|
|
try:
|
2006-03-31 18:20:18 +02:00
|
|
|
channel_filename = self.get_current_channel_downloaded()
|
2006-03-29 16:40:08 +02:00
|
|
|
|
|
|
|
selection_tuple = self.treeDownloaded.get_selection().get_selected()
|
|
|
|
selection_iter = selection_tuple[1]
|
|
|
|
url = self.treeDownloaded.get_model().get_value( selection_iter, 0)
|
2006-04-08 16:40:19 +02:00
|
|
|
if widget.get_name() == "treeDownloaded":
|
|
|
|
podcast = self.ldb.get_podcast_by_podcast_url( channel_filename, url)
|
|
|
|
Gpodderepisode().set_episode( podcast)
|
|
|
|
return
|
|
|
|
filename_final = self.ldb.getLocalFilenameByPodcastURL( channel_filename, url)
|
2006-03-31 18:20:18 +02:00
|
|
|
filename_final = self.ldb.getLocalFilenameByPodcastURL( channel_filename, url)
|
2006-03-29 16:40:08 +02:00
|
|
|
gPodderLib().openFilename( filename_final)
|
|
|
|
except:
|
2006-03-31 18:20:18 +02:00
|
|
|
self.showMessage( _("No episode selected."))
|
2006-02-04 18:29:17 +01:00
|
|
|
#-- Gpodder.on_treeDownloaded_row_activated }
|
|
|
|
|
|
|
|
#-- Gpodder.on_btnDownloadedExecute_clicked {
|
|
|
|
def on_btnDownloadedExecute_clicked(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_btnDownloadedExecute_clicked called with self.%s" % widget.get_name()
|
|
|
|
self.on_treeDownloaded_row_activated( widget, args)
|
|
|
|
#-- Gpodder.on_btnDownloadedExecute_clicked }
|
|
|
|
|
2006-03-24 20:08:59 +01:00
|
|
|
#-- Gpodder.on_btnDownloadedDelete_clicked {
|
|
|
|
def on_btnDownloadedDelete_clicked(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_btnDownloadedDelete_clicked called with self.%s" % widget.get_name()
|
2006-07-14 21:10:47 +02:00
|
|
|
|
|
|
|
channel_filename = self.get_current_channel_downloaded()
|
|
|
|
selection = self.treeDownloaded.get_selection()
|
|
|
|
selection_tuple = selection.get_selected_rows()
|
|
|
|
model = self.treeDownloaded.get_model()
|
|
|
|
|
|
|
|
if selection.count_selected_rows() == 1:
|
|
|
|
msg = _("Do you really want to remove this episode?")
|
|
|
|
else:
|
|
|
|
msg = _("Do you really want to remove %d episodes?" % ( selection.count_selected_rows() ))
|
2006-03-29 15:49:10 +02:00
|
|
|
|
2006-07-14 21:10:47 +02:00
|
|
|
# if user confirms deletion, let's remove some stuff ;)
|
|
|
|
if self.showConfirmation( msg):
|
|
|
|
try:
|
|
|
|
# iterate over the selection, see also on_treeDownloads_row_activated
|
|
|
|
for apath in selection_tuple[1]:
|
|
|
|
selection_iter = model.get_iter( apath)
|
|
|
|
url = model.get_value( selection_iter, 0)
|
|
|
|
title = model.get_value( selection_iter, 1)
|
|
|
|
filename_final = self.ldb.getLocalFilenameByPodcastURL( channel_filename, url)
|
|
|
|
current_channel = self.downloaded_channels[self.comboDownloaded.get_active()]
|
|
|
|
if current_channel.deleteDownloadedItemByUrlAndTitle( url, title):
|
|
|
|
gPodderLib().deleteFilename( filename_final)
|
|
|
|
|
|
|
|
# now, clear local db cache so we can re-read it
|
2006-03-29 14:41:34 +02:00
|
|
|
self.ldb.clear_cache()
|
|
|
|
self.updateComboBox()
|
|
|
|
self.updateDownloadedComboBox()
|
2006-07-14 21:10:47 +02:00
|
|
|
except:
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "error while deleting (some) downloads"
|
2006-03-24 20:08:59 +01:00
|
|
|
#-- Gpodder.on_btnDownloadedDelete_clicked }
|
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
|
2006-03-31 18:20:18 +02:00
|
|
|
class Gpodderchannel(SimpleGladeApp):
|
2005-11-21 19:21:25 +01:00
|
|
|
event = None
|
|
|
|
channel = None
|
|
|
|
podcast = None
|
|
|
|
thread = None
|
|
|
|
|
|
|
|
def __init__(self, path="gpodder.glade",
|
|
|
|
root="gPodderChannel",
|
|
|
|
domain=app_name, **kwargs):
|
2006-03-03 21:04:25 +01:00
|
|
|
waiting = None
|
|
|
|
url = ""
|
|
|
|
result = False
|
2005-11-21 19:21:25 +01:00
|
|
|
path = os.path.join(glade_dir, path)
|
|
|
|
SimpleGladeApp.__init__(self, path, root, domain, **kwargs)
|
|
|
|
|
|
|
|
#-- Gpodderchannel.new {
|
|
|
|
def new(self):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "A new %s has been created" % self.__class__.__name__
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodderchannel.new }
|
|
|
|
|
|
|
|
#-- Gpodderchannel custom methods {
|
2006-03-31 18:20:18 +02:00
|
|
|
def requestURL( self, channel = None):
|
|
|
|
if channel != None:
|
|
|
|
self.entryURL.set_text( channel.url)
|
|
|
|
self.downloadTo.set_text( channel.save_dir)
|
|
|
|
self.channel_title.set_markup( "<b>%s</b>" % channel.title)
|
2006-04-07 03:43:06 +02:00
|
|
|
channel.set_metadata_from_localdb()
|
|
|
|
self.cbNoSync.set_active( not channel.sync_to_devices)
|
2006-04-08 11:09:15 +02:00
|
|
|
self.musicPlaylist.set_text( channel.device_playlist_name)
|
|
|
|
self.cbMusicChannel.set_active( channel.is_music_channel)
|
2006-03-31 18:20:18 +02:00
|
|
|
description = channel.description
|
|
|
|
if channel.image != None:
|
|
|
|
# load image in background
|
|
|
|
gPodderLib().get_image_from_url( channel.image, self.imgCover.set_from_pixbuf, self.labelCoverStatus.set_text, self.labelCoverStatus.hide, channel.cover_file)
|
|
|
|
else:
|
|
|
|
self.channel_title.set_markup( "<b>%s</b>" % _("(unknown)"))
|
|
|
|
description = _("(unknown)")
|
|
|
|
|
2006-03-04 21:45:01 +01:00
|
|
|
b = gtk.TextBuffer()
|
|
|
|
b.set_text( description)
|
|
|
|
self.channel_description.set_buffer( b)
|
2005-12-08 20:47:35 +01:00
|
|
|
|
2005-12-25 10:08:25 +01:00
|
|
|
self.waiting = Event()
|
|
|
|
while self.waiting.isSet() == False:
|
|
|
|
self.waiting.wait( 0.01)
|
|
|
|
while gtk.events_pending():
|
|
|
|
gtk.main_iteration( False)
|
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
if self.result == True:
|
2006-04-07 20:36:43 +02:00
|
|
|
if channel != None:
|
|
|
|
channel.sync_to_devices = not self.cbNoSync.get_active()
|
2006-04-08 11:09:15 +02:00
|
|
|
channel.is_music_channel = self.cbMusicChannel.get_active()
|
|
|
|
channel.device_playlist_name = self.musicPlaylist.get_text()
|
2006-04-07 20:36:43 +02:00
|
|
|
channel.save_metadata_to_localdb()
|
2005-11-21 19:21:25 +01:00
|
|
|
return self.url
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
#-- Gpodderchannel custom methods }
|
|
|
|
|
|
|
|
#-- Gpodderchannel.on_gPodderChannel_destroy {
|
|
|
|
def on_gPodderChannel_destroy(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_gPodderChannel_destroy called with self.%s" % widget.get_name()
|
2005-11-21 19:21:25 +01:00
|
|
|
self.result = False
|
|
|
|
#-- Gpodderchannel.on_gPodderChannel_destroy }
|
|
|
|
|
2006-04-08 11:09:15 +02:00
|
|
|
#-- Gpodderchannel.on_cbMusicChannel_toggled {
|
|
|
|
def on_cbMusicChannel_toggled(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_cbMusicChannel_toggled called with self.%s" % widget.get_name()
|
|
|
|
self.musicPlaylist.set_sensitive( self.cbMusicChannel.get_active())
|
|
|
|
#-- Gpodderchannel.on_cbMusicChannel_toggled }
|
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- Gpodderchannel.on_btnOK_clicked {
|
|
|
|
def on_btnOK_clicked(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_btnOK_clicked called with self.%s" % widget.get_name()
|
2005-12-25 10:08:25 +01:00
|
|
|
self.url = self.entryURL.get_text()
|
2005-11-21 19:21:25 +01:00
|
|
|
self.gPodderChannel.destroy()
|
|
|
|
self.result = True
|
|
|
|
|
|
|
|
if self.waiting != None:
|
|
|
|
self.waiting.set()
|
|
|
|
#-- Gpodderchannel.on_btnOK_clicked }
|
|
|
|
|
|
|
|
#-- Gpodderchannel.on_btnCancel_clicked {
|
|
|
|
def on_btnCancel_clicked(self, widget, *args):
|
2005-11-21 22:17:54 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_btnCancel_clicked called with self.%s" % widget.get_name()
|
2005-11-21 19:21:25 +01:00
|
|
|
self.gPodderChannel.destroy()
|
|
|
|
self.result = False
|
|
|
|
|
|
|
|
if self.waiting != None:
|
|
|
|
self.waiting.set()
|
|
|
|
#-- Gpodderchannel.on_btnCancel_clicked }
|
|
|
|
|
|
|
|
|
2006-01-09 00:52:40 +01:00
|
|
|
class Gpodderproperties(SimpleGladeApp):
|
|
|
|
def __init__(self, path="gpodder.glade",
|
|
|
|
root="gPodderProperties",
|
|
|
|
domain=app_name, **kwargs):
|
|
|
|
path = os.path.join(glade_dir, path)
|
|
|
|
SimpleGladeApp.__init__(self, path, root, domain, **kwargs)
|
|
|
|
|
|
|
|
#-- Gpodderproperties.new {
|
|
|
|
def new(self):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "A new %s has been created" % self.__class__.__name__
|
|
|
|
gl = gPodderLib()
|
|
|
|
self.httpProxy.set_text( gl.http_proxy)
|
|
|
|
self.ftpProxy.set_text( gl.ftp_proxy)
|
2006-02-04 18:29:17 +01:00
|
|
|
self.openApp.set_text( gl.open_app)
|
2006-04-07 20:11:31 +02:00
|
|
|
self.iPodMountpoint.set_text( gl.ipod_mount)
|
2006-06-13 23:00:31 +02:00
|
|
|
self.opmlURL.set_text( gl.opml_url)
|
2006-05-01 23:12:34 +02:00
|
|
|
self.updateonstartup.set_active(gl.update_on_startup)
|
2006-04-05 21:07:05 +02:00
|
|
|
# the use proxy env vars check box
|
|
|
|
self.cbEnvironmentVariables.set_active( gl.proxy_use_environment)
|
2006-03-29 15:24:44 +02:00
|
|
|
# if the symlink exists, set the checkbox active
|
2006-04-05 21:07:05 +02:00
|
|
|
self.cbDesktopSymlink.set_active( gl.getDesktopSymlink())
|
2006-03-30 00:07:27 +02:00
|
|
|
# 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
|
2006-04-09 18:18:47 +02:00
|
|
|
self.on_close = None
|
2006-03-31 18:20:18 +02:00
|
|
|
#-- Gpodderproperties.new }
|
|
|
|
|
|
|
|
#-- Gpodderproperties custom methods {
|
2006-04-09 18:18:47 +02:00
|
|
|
def update_mountpoint( self, ipod):
|
|
|
|
if ipod == None or ipod.mount_point == None:
|
|
|
|
self.iPodMountpoint.set_text( '')
|
|
|
|
else:
|
|
|
|
self.iPodMountpoint.set_text( ipod.mount_point)
|
|
|
|
|
2006-03-31 18:20:18 +02:00
|
|
|
def set_uar( self, uar):
|
2006-03-30 00:07:27 +02:00
|
|
|
self.comboPlayerApp.set_model( uar.get_applications_as_model())
|
|
|
|
# try to activate an item
|
|
|
|
index = self.find_active()
|
|
|
|
self.comboPlayerApp.set_active( index)
|
2006-03-31 18:20:18 +02:00
|
|
|
# end set_uar
|
|
|
|
|
2006-03-30 00:07:27 +02:00
|
|
|
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
|
2006-01-09 00:52:40 +01:00
|
|
|
#-- Gpodderproperties custom methods }
|
|
|
|
|
|
|
|
#-- Gpodderproperties.on_gPodderProperties_destroy {
|
|
|
|
def on_gPodderProperties_destroy(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_gPodderProperties_destroy called with self.%s" % widget.get_name()
|
2006-04-09 18:18:47 +02:00
|
|
|
if self.on_close != None:
|
|
|
|
self.on_close()
|
2006-01-09 00:52:40 +01:00
|
|
|
#-- Gpodderproperties.on_gPodderProperties_destroy }
|
|
|
|
|
2006-03-30 00:07:27 +02:00
|
|
|
#-- Gpodderproperties.on_comboPlayerApp_changed {
|
|
|
|
def on_comboPlayerApp_changed(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
2006-03-31 18:20:18 +02:00
|
|
|
print "on_comboPlayerApp_changed called with self.%s" % widget.get_name()
|
|
|
|
|
2006-03-30 00:07:27 +02:00
|
|
|
# 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 }
|
|
|
|
|
2006-04-05 21:07:05 +02:00
|
|
|
#-- Gpodderproperties.on_cbEnvironmentVariables_toggled {
|
|
|
|
def on_cbEnvironmentVariables_toggled(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_cbEnvironmentVariables_toggled called with self.%s" % widget.get_name()
|
|
|
|
sens = not self.cbEnvironmentVariables.get_active()
|
|
|
|
self.httpProxy.set_sensitive( sens)
|
|
|
|
self.ftpProxy.set_sensitive( sens)
|
|
|
|
#-- Gpodderproperties.on_cbEnvironmentVariables_toggled }
|
|
|
|
|
2006-01-09 00:52:40 +01:00
|
|
|
#-- Gpodderproperties.on_btnOK_clicked {
|
|
|
|
def on_btnOK_clicked(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_btnOK_clicked called with self.%s" % widget.get_name()
|
|
|
|
gl = gPodderLib()
|
|
|
|
gl.http_proxy = self.httpProxy.get_text()
|
|
|
|
gl.ftp_proxy = self.ftpProxy.get_text()
|
2006-02-04 18:29:17 +01:00
|
|
|
gl.open_app = self.openApp.get_text()
|
2006-04-05 21:07:05 +02:00
|
|
|
gl.proxy_use_environment = self.cbEnvironmentVariables.get_active()
|
2006-04-07 20:11:31 +02:00
|
|
|
gl.ipod_mount = self.iPodMountpoint.get_text()
|
2006-06-13 23:00:31 +02:00
|
|
|
gl.opml_url = self.opmlURL.get_text()
|
2006-05-01 23:12:34 +02:00
|
|
|
gl.update_on_startup = self.updateonstartup.get_active()
|
2006-01-09 00:52:40 +01:00
|
|
|
gl.propertiesChanged()
|
2006-03-29 15:24:44 +02:00
|
|
|
# create or remove symlink to download dir on desktop
|
|
|
|
if self.cbDesktopSymlink.get_active():
|
|
|
|
gl.createDesktopSymlink()
|
|
|
|
else:
|
|
|
|
gl.removeDesktopSymlink()
|
2006-01-09 00:52:40 +01:00
|
|
|
self.gPodderProperties.destroy()
|
|
|
|
#-- Gpodderproperties.on_btnOK_clicked }
|
|
|
|
|
|
|
|
#-- Gpodderproperties.on_btnCancel_clicked {
|
|
|
|
def on_btnCancel_clicked(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_btnCancel_clicked called with self.%s" % widget.get_name()
|
|
|
|
self.gPodderProperties.destroy()
|
|
|
|
#-- Gpodderproperties.on_btnCancel_clicked }
|
|
|
|
|
|
|
|
|
2006-03-04 21:45:01 +01:00
|
|
|
class Gpodderepisode(SimpleGladeApp):
|
|
|
|
def __init__(self, path="gpodder.glade",
|
|
|
|
root="gPodderEpisode",
|
|
|
|
domain=app_name, **kwargs):
|
|
|
|
path = os.path.join(glade_dir, path)
|
|
|
|
SimpleGladeApp.__init__(self, path, root, domain, **kwargs)
|
|
|
|
|
|
|
|
#-- Gpodderepisode.new {
|
2006-03-31 18:20:18 +02:00
|
|
|
def new(self):
|
2006-03-04 21:45:01 +01:00
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "A new %s has been created" % self.__class__.__name__
|
|
|
|
#-- Gpodderepisode.new }
|
|
|
|
|
|
|
|
#-- Gpodderepisode custom methods {
|
|
|
|
# Write your own methods here
|
2006-04-08 16:40:19 +02:00
|
|
|
def set_episode( self, episode, channel = None):
|
2006-03-04 21:45:01 +01:00
|
|
|
self.episode_title.set_markup( '<big><b>%s</b></big>' % episode.title)
|
|
|
|
b = gtk.TextBuffer()
|
|
|
|
b.set_text( strip( episode.description))
|
|
|
|
self.episode_description.set_buffer( b)
|
2006-04-08 16:40:19 +02:00
|
|
|
self.entryURL.set_text(episode.url)
|
|
|
|
self.entryLink.set_text(episode.link)
|
|
|
|
if episode.link == '' and channel != None:
|
|
|
|
self.entryLink.set_text( channel.link)
|
|
|
|
self.labelPubDate.set_markup( '<b>%s</b>' % ( episode.pubDate ))
|
2006-03-04 21:45:01 +01:00
|
|
|
#-- Gpodderepisode custom methods }
|
|
|
|
|
|
|
|
#-- Gpodderepisode.on_btnCloseWindow_clicked {
|
|
|
|
def on_btnCloseWindow_clicked(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_btnCloseWindow_clicked called with self.%s" % widget.get_name()
|
|
|
|
self.gPodderEpisode.destroy()
|
|
|
|
#-- Gpodderepisode.on_btnCloseWindow_clicked }
|
|
|
|
|
|
|
|
|
2006-04-07 03:43:06 +02:00
|
|
|
class Gpoddersync(SimpleGladeApp):
|
|
|
|
|
|
|
|
def __init__(self, path="gpodder.glade",
|
|
|
|
root="gPodderSync",
|
|
|
|
domain=app_name, **kwargs):
|
|
|
|
path = os.path.join(glade_dir, path)
|
|
|
|
SimpleGladeApp.__init__(self, path, root, domain, **kwargs)
|
|
|
|
|
|
|
|
#-- Gpoddersync.new {
|
|
|
|
def new(self):
|
|
|
|
global artwork_dir
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "A new %s has been created" % self.__class__.__name__
|
|
|
|
self.imageSyncServer.set_from_file( artwork_dir + 'computer.png')
|
|
|
|
self.imageSyncAnimation.set_from_file( artwork_dir + 'sync-anim.gif')
|
|
|
|
self.imageSyncClient.set_from_file( artwork_dir + 'ipod-mini.png')
|
|
|
|
#-- Gpoddersync.new }
|
|
|
|
|
|
|
|
#-- Gpoddersync custom methods {
|
|
|
|
def set_progress( self, pos, max):
|
|
|
|
self.pbSync.set_fraction( 1.0*pos/max)
|
|
|
|
percent = _('%d of %d') % ( pos, max )
|
|
|
|
self.pbSync.set_text( percent)
|
|
|
|
|
|
|
|
def set_status( self, episode = None, channel = None, progressbar = None):
|
|
|
|
if episode != None:
|
|
|
|
self.labelEpisode.set_text( episode)
|
|
|
|
|
|
|
|
if channel != None:
|
|
|
|
self.labelChannel.set_text( channel)
|
|
|
|
|
|
|
|
if progressbar != None:
|
|
|
|
self.pbSync.set_text( progressbar)
|
|
|
|
|
|
|
|
def close( self):
|
|
|
|
self.gPodderSync.destroy()
|
|
|
|
#-- Gpoddersync custom methods }
|
|
|
|
|
|
|
|
#-- Gpoddersync.on_gPodderSync_destroy {
|
|
|
|
def on_gPodderSync_destroy(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_gPodderSync_destroy called with self.%s" % widget.get_name()
|
|
|
|
#-- Gpoddersync.on_gPodderSync_destroy }
|
|
|
|
|
|
|
|
|
2006-06-13 23:00:31 +02:00
|
|
|
class Gpodderopmllister(SimpleGladeApp):
|
|
|
|
|
|
|
|
def __init__(self, path="gpodder.glade",
|
|
|
|
root="gPodderOpmlLister",
|
|
|
|
domain=app_name, **kwargs):
|
|
|
|
path = os.path.join(glade_dir, path)
|
|
|
|
SimpleGladeApp.__init__(self, path, root, domain, **kwargs)
|
|
|
|
|
|
|
|
#-- Gpodderopmllister.new {
|
|
|
|
def new(self):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "A new %s has been created" % self.__class__.__name__
|
|
|
|
|
|
|
|
# initiate channels list
|
|
|
|
self.channels = []
|
|
|
|
self.callback_for_channel = None
|
|
|
|
|
|
|
|
togglecell = gtk.CellRendererToggle()
|
|
|
|
togglecell.set_property( 'activatable', True)
|
|
|
|
togglecell.connect( 'toggled', self.callback_edited)
|
|
|
|
togglecolumn = gtk.TreeViewColumn( _("Subscribe"), togglecell, active=0)
|
|
|
|
|
|
|
|
titlecell = gtk.CellRendererText()
|
|
|
|
titlecolumn = gtk.TreeViewColumn( _("Channel name"), titlecell, text=1)
|
|
|
|
|
|
|
|
for itemcolumn in ( togglecolumn, titlecolumn ):
|
|
|
|
self.treeviewChannelChooser.append_column( itemcolumn)
|
|
|
|
#-- Gpodderopmllister.new }
|
|
|
|
|
|
|
|
#-- Gpodderopmllister custom methods {
|
|
|
|
# Write your own methods here
|
|
|
|
def callback_edited( self, cell, path):
|
|
|
|
model = self.treeviewChannelChooser.get_model()
|
|
|
|
activated = not model[path][0]
|
|
|
|
url = model[path][2]
|
|
|
|
|
|
|
|
model[path][0] = activated
|
|
|
|
|
|
|
|
if activated:
|
|
|
|
self.channels.append( url)
|
|
|
|
else:
|
|
|
|
self.channels.remove( url)
|
|
|
|
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print url
|
|
|
|
|
|
|
|
def get_channels_from_url( self, url, callback):
|
|
|
|
reader = opmlReader()
|
|
|
|
reader.parseXML( url)
|
|
|
|
self.treeviewChannelChooser.set_model( reader.get_model())
|
|
|
|
self.callback_for_channel = callback
|
|
|
|
#-- Gpodderopmllister custom methods }
|
|
|
|
|
|
|
|
#-- Gpodderopmllister.on_gPodderOpmlLister_destroy {
|
|
|
|
def on_gPodderOpmlLister_destroy(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_gPodderOpmlLister_destroy called with self.%s" % widget.get_name()
|
|
|
|
#-- Gpodderopmllister.on_gPodderOpmlLister_destroy }
|
|
|
|
|
|
|
|
#-- Gpodderopmllister.on_btnOK_clicked {
|
|
|
|
def on_btnOK_clicked(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_btnOK_clicked called with self.%s" % widget.get_name()
|
|
|
|
self.gPodderOpmlLister.destroy()
|
|
|
|
# add channels that have been selected
|
|
|
|
for url in self.channels:
|
|
|
|
if self.callback_for_channel != None:
|
|
|
|
self.callback_for_channel (url)
|
|
|
|
#-- Gpodderopmllister.on_btnOK_clicked }
|
|
|
|
|
|
|
|
#-- Gpodderopmllister.on_btnCancel_clicked {
|
|
|
|
def on_btnCancel_clicked(self, widget, *args):
|
|
|
|
if libgpodder.isDebugging():
|
|
|
|
print "on_btnCancel_clicked called with self.%s" % widget.get_name()
|
|
|
|
self.gPodderOpmlLister.destroy()
|
|
|
|
#-- Gpodderopmllister.on_btnCancel_clicked }
|
|
|
|
|
|
|
|
|
2005-11-21 19:21:25 +01:00
|
|
|
#-- main {
|
|
|
|
|
|
|
|
def main( __version__ = None):
|
|
|
|
global app_version
|
2006-03-04 21:45:01 +01:00
|
|
|
|
2006-04-03 22:59:10 +02:00
|
|
|
#gtk.gdk.threads_init()
|
|
|
|
gobject.threads_init()
|
2006-03-31 15:00:54 +02:00
|
|
|
bindtextdomain( app_name, locale_dir)
|
2005-11-21 19:21:25 +01:00
|
|
|
app_version = __version__
|
|
|
|
g_podder = Gpodder()
|
|
|
|
#g_podder_channel = Gpodderchannel()
|
2006-01-09 00:52:40 +01:00
|
|
|
#g_podder_properties = Gpodderproperties()
|
2006-03-04 21:45:01 +01:00
|
|
|
#g_podder_episode = Gpodderepisode()
|
2006-04-07 03:43:06 +02:00
|
|
|
#g_podder_sync = Gpoddersync()
|
2006-06-13 23:00:31 +02:00
|
|
|
#g_podder_opml_lister = Gpodderopmllister()
|
2005-11-21 19:21:25 +01:00
|
|
|
|
2005-11-22 14:18:57 +01:00
|
|
|
g_podder.set_icon()
|
2005-11-21 19:21:25 +01:00
|
|
|
g_podder.run()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2006-03-31 18:20:18 +02:00
|
|
|
print _("Please do not call gpodder.py directly. Instead, call the gpodder binary.")
|
2005-11-21 19:21:25 +01:00
|
|
|
sys.exit( -1)
|
|
|
|
|
|
|
|
#-- main }
|