2007-04-01 19:53:04 +02:00
# -*- coding: utf-8 -*-
2005-11-21 19:21:25 +01:00
#
2007-08-29 20:30:26 +02:00
# gPodder - A media aggregator and podcast client
2006-12-29 16:52:52 +01:00
# Copyright (C) 2005-2007 Thomas Perl <thp at perli.net>
2006-04-07 22:22:30 +02:00
#
2007-08-29 20:30:26 +02:00
# gPodder 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 3 of the License, or
# (at your option) any later version.
2006-04-07 22:22:30 +02:00
#
2007-08-29 20:30:26 +02:00
# gPodder is distributed in the hope that it will be useful,
2006-04-07 22:22:30 +02:00
# 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
2007-08-29 20:30:26 +02:00
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2005-11-21 19:21:25 +01:00
#
import os
import gtk
2007-01-28 10:21:39 +01:00
import gtk . gdk
2005-11-21 19:21:25 +01:00
import gobject
2006-11-20 12:51:20 +01:00
import pango
2005-11-21 19:21:25 +01:00
import sys
2007-04-23 17:18:31 +02:00
import shutil
2007-08-31 20:04:28 +02:00
import webbrowser
2006-03-04 21:45:01 +01:00
2007-07-05 23:07:16 +02:00
from xml . sax import saxutils
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
2007-08-07 20:11:31 +02:00
from gpodder import util
2007-08-19 16:28:24 +02:00
from gpodder import opml
2007-08-24 16:49:41 +02:00
from gpodder import services
2007-08-28 00:18:01 +02:00
from gpodder import SimpleGladeApp
2005-11-21 19:21:25 +01:00
from libpodcasts import podcastChannel
from libpodcasts import channelsToModel
2007-08-20 15:45:46 +02:00
from libpodcasts import load_channels
from libpodcasts import save_channels
2005-11-21 19:21:25 +01:00
from libwget import downloadThread
from libgpodder import gPodderLib
2006-11-17 15:26:10 +01:00
from liblogger import log
2005-11-21 19:21:25 +01:00
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
2006-12-17 02:21:36 +01:00
from libipodsync import gPodder_FSSync
2006-04-06 16:11:03 +02:00
from libipodsync import ipod_supported
2007-03-17 13:11:13 +01:00
from libtagupdate import tagging_supported
2005-11-21 19:21:25 +01:00
app_name = " gpodder "
app_version = " unknown " # will be set in main() call
2007-08-28 00:18:01 +02:00
app_authors = [ ' Thomas Perl <thp@perli.net ' ]
2006-12-29 16:52:52 +01:00
app_copyright = ' Copyright (c) 2005-2007 Thomas Perl '
app_website = ' http://gpodder.berlios.de/ '
2005-11-21 19:21:25 +01:00
2007-03-18 17:11:34 +01:00
# these will be filled with pathnames in bin/gpodder
glade_dir = [ ' share ' , ' gpodder ' ]
icon_dir = [ ' share ' , ' pixmaps ' , ' gpodder.png ' ]
2007-03-25 21:55:28 +02:00
scalable_dir = [ ' share ' , ' icons ' , ' hicolor ' , ' scalable ' , ' apps ' , ' gpodder.svg ' ]
2005-11-21 19:21:25 +01:00
2006-03-29 13:33:56 +02:00
2007-08-28 00:18:01 +02:00
class GladeWidget ( SimpleGladeApp . SimpleGladeApp ) :
gpodder_main_window = None
def __init__ ( self , * * kwargs ) :
path = os . path . join ( glade_dir , ' %s .glade ' % app_name )
root = self . __class__ . __name__
domain = app_name
SimpleGladeApp . SimpleGladeApp . __init__ ( self , path , root , domain , * * kwargs )
if root == ' gPodder ' :
GladeWidget . gpodder_main_window = self . gPodder
else :
# If we have a child window, set it transient for our main window
getattr ( self , root ) . set_transient_for ( GladeWidget . gpodder_main_window )
getattr ( self , root ) . set_position ( gtk . WIN_POS_CENTER_ON_PARENT )
def show_message ( self , message , title = None ) :
dlg = gtk . MessageDialog ( GladeWidget . gpodder_main_window , gtk . DIALOG_MODAL , gtk . MESSAGE_INFO , gtk . BUTTONS_OK )
if title :
dlg . set_title ( title )
dlg . set_markup ( ' <span weight= " bold " size= " larger " > %s </span> \n \n %s ' % ( title , message ) )
else :
dlg . set_markup ( ' <span weight= " bold " size= " larger " > %s </span> ' % ( message ) )
dlg . run ( )
dlg . destroy ( )
def show_confirmation ( self , message , title = None ) :
dlg = gtk . MessageDialog ( GladeWidget . gpodder_main_window , gtk . DIALOG_MODAL , gtk . MESSAGE_QUESTION , gtk . BUTTONS_YES_NO )
if title :
dlg . set_title ( title )
dlg . set_markup ( ' <span weight= " bold " size= " larger " > %s </span> \n \n %s ' % ( title , message ) )
else :
dlg . set_markup ( ' <span weight= " bold " size= " larger " > %s </span> ' % message )
response = dlg . run ( )
dlg . destroy ( )
return response == gtk . RESPONSE_YES
2006-03-31 18:20:18 +02:00
2005-11-21 19:21:25 +01:00
2007-08-28 00:18:01 +02:00
class gPodder ( GladeWidget ) :
2005-11-21 19:21:25 +01:00
def new ( self ) :
2007-08-28 00:18:01 +02:00
self . ldb = None
self . uar = None
2007-04-01 19:53:04 +02:00
gl = gPodderLib ( )
self . gPodder . resize ( gl . main_window_width , gl . main_window_height )
self . gPodder . move ( gl . main_window_x , gl . main_window_y )
2007-07-05 23:07:16 +02:00
self . channelPaned . set_position ( gl . paned_position )
2007-04-01 19:53:04 +02:00
while gtk . events_pending ( ) :
gtk . main_iteration ( False )
2007-03-07 15:53:05 +01:00
if app_version . rfind ( " svn " ) != - 1 :
2007-09-02 15:02:28 +02:00
self . gPodder . set_title ( ' gPodder %s ' % app_version )
self . default_title = self . gPodder . get_title ( )
2007-03-07 15:53:05 +01:00
2005-11-21 19:21:25 +01:00
# set up the rendering of the comboAvailable combobox
cellrenderer = gtk . CellRendererText ( )
2007-07-05 23:07:16 +02:00
self . comboAvailable . pack_start ( cellrenderer , False )
2005-11-21 19:21:25 +01:00
self . comboAvailable . add_attribute ( cellrenderer , ' text ' , 1 )
2007-07-05 23:07:16 +02:00
self . comboAvailable . add_attribute ( cellrenderer , ' weight ' , 4 )
# new episodes
cellrenderer = gtk . CellRendererText ( )
cellrenderer . set_property ( ' ellipsize ' , pango . ELLIPSIZE_END )
2007-08-10 15:00:43 +02:00
try :
cellrenderer . set_property ( ' alignment ' , pango . ALIGN_RIGHT )
except :
log ( ' Failed to set alignment property for CellRendererText - using old PyGTK? ' , sender = self )
2007-07-05 23:07:16 +02:00
cellrenderer . set_property ( ' foreground ' , ' gray ' )
self . comboAvailable . pack_end ( cellrenderer , True )
self . comboAvailable . add_attribute ( cellrenderer , ' text ' , 3 )
# cell renderers for channel tree
namecolumn = gtk . TreeViewColumn ( _ ( ' Channel ' ) )
namecolumn . set_resizable ( True )
namecolumn . set_reorderable ( True )
iconcell = gtk . CellRendererPixbuf ( )
namecolumn . pack_start ( iconcell , False )
namecolumn . add_attribute ( iconcell , ' pixbuf ' , 8 )
namecell = gtk . CellRendererText ( )
namecell . set_property ( ' ellipsize ' , pango . ELLIPSIZE_END )
namecolumn . pack_start ( namecell , True )
namecolumn . add_attribute ( namecell , ' markup ' , 7 )
namecolumn . add_attribute ( namecell , ' weight ' , 4 )
namecolumn . set_expand ( True )
newcell = gtk . CellRendererText ( )
namecolumn . pack_end ( newcell , False )
namecolumn . add_attribute ( newcell , ' text ' , 5 )
namecolumn . add_attribute ( newcell , ' weight ' , 4 )
namecolumn . set_expand ( False )
self . treeChannels . append_column ( namecolumn )
self . treeChannels . set_rules_hint ( True )
2005-11-21 19:21:25 +01:00
2007-04-03 08:27:46 +02:00
# enable alternating colors hint
self . treeAvailable . set_rules_hint ( True )
2007-08-26 17:20:46 +02:00
# Add our context menu to treeAvailable
self . treeAvailable . connect ( ' button-press-event ' , self . treeview_button_pressed )
2007-04-03 08:27:46 +02:00
iconcell = gtk . CellRendererPixbuf ( )
2007-08-25 08:11:19 +02:00
iconcolumn = gtk . TreeViewColumn ( _ ( " Status " ) , iconcell , pixbuf = 4 )
2007-04-03 13:21:12 +02:00
2005-11-22 14:30:28 +01:00
namecell = gtk . CellRendererText ( )
2007-04-01 19:53:04 +02:00
#namecell.set_property('ellipsize', pango.ELLIPSIZE_END)
2007-08-25 08:11:19 +02:00
namecolumn = gtk . TreeViewColumn ( _ ( " Episode " ) , namecell , text = 1 )
2007-04-01 19:53:04 +02:00
namecolumn . set_sizing ( gtk . TREE_VIEW_COLUMN_AUTOSIZE )
2005-11-22 14:30:28 +01:00
sizecell = gtk . CellRendererText ( )
2006-03-31 15:00:54 +02:00
sizecolumn = gtk . TreeViewColumn ( _ ( " Size " ) , sizecell , text = 2 )
2006-04-10 18:46:50 +02:00
releasecell = gtk . CellRendererText ( )
releasecolumn = gtk . TreeViewColumn ( _ ( " Released " ) , releasecell , text = 5 )
2005-11-22 14:30:28 +01:00
2006-11-20 12:51:20 +01:00
desccell = gtk . CellRendererText ( )
desccell . set_property ( ' ellipsize ' , pango . ELLIPSIZE_END )
desccolumn = gtk . TreeViewColumn ( _ ( " Description " ) , desccell , text = 6 )
2007-08-25 08:11:19 +02:00
for itemcolumn in ( iconcolumn , namecolumn , sizecolumn , releasecolumn , desccolumn ) :
2006-11-20 12:51:20 +01:00
itemcolumn . set_resizable ( True )
itemcolumn . set_reorderable ( True )
2005-11-21 19:21:25 +01:00
self . treeAvailable . append_column ( itemcolumn )
2006-06-22 23:41:32 +02:00
2007-04-03 08:27:46 +02:00
# enable search in treeavailable
self . treeAvailable . set_search_equal_func ( self . treeAvailable_search_equal )
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-02-04 18:29:17 +01:00
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 )
2007-08-24 16:49:41 +02:00
services . download_status_manager . register ( ' list-changed ' , self . download_status_updated )
services . download_status_manager . register ( ' progress-changed ' , self . download_progress_updated )
self . treeDownloads . set_model ( services . download_status_manager . tree_model )
2005-11-22 23:26:51 +01:00
2006-03-04 21:45:01 +01:00
# tooltips :)
self . tooltips = gtk . Tooltips ( )
2007-03-31 04:00:30 +02:00
self . tooltips . set_tip ( self . btnEditChannel , _ ( " Edit channel information " ) )
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-04-04 00:27:57 +02:00
2007-03-10 16:57:56 +01:00
# Subscribed channels
self . active_channel = None
2007-08-20 15:45:46 +02:00
self . channels = load_channels ( load_items = False )
2006-12-03 19:11:14 +01:00
2006-12-09 02:59:53 +01:00
# create a localDB object
self . ldb = localDB ( )
2006-12-09 03:04:32 +01:00
# load list of user applications
self . user_apps_reader = UserAppsReader ( )
self . user_apps_reader . read ( )
2006-12-03 19:11:14 +01:00
# Clean up old, orphaned download files
2007-02-03 11:48:32 +01:00
gl . clean_up_downloads ( delete_partial = True )
2007-05-25 12:06:43 +02:00
# Now, update the feed cache, when everything's in place
self . update_feed_cache ( force_update = gl . update_on_startup )
2005-11-21 19:21:25 +01:00
2007-08-26 17:20:46 +02:00
def treeview_button_pressed ( self , treeview , event ) :
if event . button == 3 :
( x , y ) = ( int ( event . x ) , int ( event . y ) )
( path , column , rx , ry ) = treeview . get_path_at_pos ( x , y ) or ( None , ) * 4
paths = [ ]
# Did the user right-click into a selection?
selection = self . treeAvailable . get_selection ( )
if selection . count_selected_rows ( ) and path :
( model , paths ) = selection . get_selected_rows ( )
if path not in paths :
# We have right-clicked, but not into the
# selection, assume we don't want to operate
# on the selection
paths = [ ]
# No selection or right click not in selection:
# Select the single item where we clicked
if not len ( paths ) and path :
treeview . grab_focus ( )
treeview . set_cursor ( path , column , 0 )
( model , paths ) = ( treeview . get_model ( ) , [ path ] )
# We did not find a selection, and the user didn't
# click on an item to select -- don't show the menu
if not len ( paths ) :
return True
2007-08-30 20:54:18 +02:00
first_url = model . get_value ( model . get_iter ( paths [ 0 ] ) , 0 )
2007-08-26 17:20:46 +02:00
menu = gtk . Menu ( )
( can_play , can_download , can_transfer , can_cancel ) = self . play_or_download ( )
2007-08-27 22:28:00 +02:00
if len ( paths ) == 1 :
# Single item, add episode information menu item
episode_title = model . get_value ( model . get_iter ( paths [ 0 ] ) , 1 )
if len ( episode_title ) > 30 :
episode_title = episode_title [ : 27 ] + ' ... '
item = gtk . ImageMenuItem ( ' ' )
( label , image ) = item . get_children ( )
label . set_text ( _ ( ' Episode information: %s ' ) % episode_title )
item . set_image ( gtk . image_new_from_stock ( gtk . STOCK_INFO , gtk . ICON_SIZE_MENU ) )
item . connect ( ' activate ' , lambda w : self . on_treeAvailable_row_activated ( self . treeAvailable ) )
menu . append ( item )
menu . append ( gtk . SeparatorMenuItem ( ) )
else :
episode_title = _ ( ' %d selected episodes ' ) % len ( paths )
2007-08-26 17:20:46 +02:00
if can_play :
2007-08-27 22:28:00 +02:00
item = gtk . ImageMenuItem ( _ ( ' Play %s ' ) % episode_title )
2007-08-26 17:20:46 +02:00
item . set_image ( gtk . image_new_from_stock ( gtk . STOCK_MEDIA_PLAY , gtk . ICON_SIZE_MENU ) )
item . connect ( ' activate ' , lambda w : self . on_treeAvailable_row_activated ( self . toolPlay ) )
menu . append ( item )
2007-08-27 22:28:00 +02:00
item = gtk . ImageMenuItem ( _ ( ' Remove %s ' ) % episode_title )
2007-08-26 21:58:29 +02:00
item . set_image ( gtk . image_new_from_stock ( gtk . STOCK_DELETE , gtk . ICON_SIZE_MENU ) )
item . connect ( ' activate ' , self . on_btnDownloadedDelete_clicked )
menu . append ( item )
2007-08-26 17:20:46 +02:00
if can_download :
2007-08-27 22:28:00 +02:00
item = gtk . ImageMenuItem ( _ ( ' Download %s ' ) % episode_title )
2007-08-26 17:20:46 +02:00
item . set_image ( gtk . image_new_from_stock ( gtk . STOCK_GO_DOWN , gtk . ICON_SIZE_MENU ) )
item . connect ( ' activate ' , lambda w : self . on_treeAvailable_row_activated ( self . toolDownload ) )
menu . append ( item )
2007-08-30 20:54:18 +02:00
menu . append ( gtk . SeparatorMenuItem ( ) )
is_downloaded = gPodderLib ( ) . history_is_downloaded ( first_url )
if is_downloaded :
item = gtk . ImageMenuItem ( _ ( ' Mark %s as not downloaded ' ) % episode_title )
item . set_image ( gtk . image_new_from_stock ( gtk . STOCK_UNDELETE , gtk . ICON_SIZE_MENU ) )
item . connect ( ' activate ' , lambda w : self . on_item_toggle_downloaded_activate ( w , False , False ) )
menu . append ( item )
else :
item = gtk . ImageMenuItem ( _ ( ' Mark %s as downloaded ' ) % episode_title )
item . set_image ( gtk . image_new_from_stock ( gtk . STOCK_DELETE , gtk . ICON_SIZE_MENU ) )
item . connect ( ' activate ' , lambda w : self . on_item_toggle_downloaded_activate ( w , False , True ) )
menu . append ( item )
2007-08-26 17:20:46 +02:00
if can_transfer :
2007-08-27 22:28:00 +02:00
item = gtk . ImageMenuItem ( _ ( ' Transfer %s to %s ' ) % ( episode_title , gPodderLib ( ) . get_device_name ( ) ) )
2007-08-26 17:20:46 +02:00
item . set_image ( gtk . image_new_from_stock ( gtk . STOCK_NETWORK , gtk . ICON_SIZE_MENU ) )
item . connect ( ' activate ' , lambda w : self . on_treeAvailable_row_activated ( self . toolTransfer ) )
menu . append ( item )
2007-08-30 20:54:18 +02:00
if can_play :
menu . append ( gtk . SeparatorMenuItem ( ) )
is_played = gPodderLib ( ) . history_is_played ( first_url )
if is_played :
item = gtk . ImageMenuItem ( _ ( ' Mark %s as unplayed ' ) % episode_title )
item . set_image ( gtk . image_new_from_stock ( gtk . STOCK_CANCEL , gtk . ICON_SIZE_MENU ) )
item . connect ( ' activate ' , lambda w : self . on_item_toggle_played_activate ( w , False , False ) )
menu . append ( item )
else :
item = gtk . ImageMenuItem ( _ ( ' Mark %s as played ' ) % episode_title )
item . set_image ( gtk . image_new_from_stock ( gtk . STOCK_APPLY , gtk . ICON_SIZE_MENU ) )
item . connect ( ' activate ' , lambda w : self . on_item_toggle_played_activate ( w , False , True ) )
menu . append ( item )
2007-08-26 17:20:46 +02:00
if can_cancel :
item = gtk . ImageMenuItem ( _ ( ' _Cancel download ' ) )
item . set_image ( gtk . image_new_from_stock ( gtk . STOCK_STOP , gtk . ICON_SIZE_MENU ) )
item . connect ( ' activate ' , lambda w : self . on_treeDownloads_row_activated ( self . toolCancel ) )
menu . append ( item )
menu . show_all ( )
menu . popup ( None , None , None , event . button , event . time )
return True
2007-08-24 16:49:41 +02:00
def download_progress_updated ( self , count , percentage ) :
title = [ self . default_title ]
if count == 1 :
title . append ( _ ( ' downloading one file ' ) )
elif count > 1 :
title . append ( _ ( ' downloading %d files ' ) % count )
if len ( title ) == 2 :
title [ 1 ] = ' ' . join ( [ title [ 1 ] , ' ( %d %% ) ' % ( percentage , ) ] )
self . gPodder . set_title ( ' - ' . join ( title ) )
2007-04-03 13:21:12 +02:00
def playback_episode ( self , current_channel , current_podcast ) :
2007-08-13 23:53:26 +02:00
( success , application ) = gPodderLib ( ) . playback_episode ( current_channel , current_podcast )
if not success :
self . show_message ( _ ( ' The selected player application cannot be found. Please check your media player settings in the preferences dialog. ' ) , _ ( ' Error opening player: %s ' ) % ( saxutils . escape ( application ) , ) )
2007-08-20 15:45:46 +02:00
self . download_status_updated ( )
2007-04-03 13:21:12 +02:00
2007-04-03 08:27:46 +02:00
def treeAvailable_search_equal ( self , model , column , key , iter , data = None ) :
if model == None :
return True
key = key . lower ( )
# columns, as defined in libpodcasts' get model method
# 1 = episode title, 7 = description
columns = ( 1 , 7 )
for column in columns :
value = model . get_value ( iter , column ) . lower ( )
if value . find ( key ) != - 1 :
return False
return True
2006-12-13 00:11:34 +01:00
def play_or_download ( self ) :
2007-03-31 04:00:30 +02:00
if self . wNotebook . get_current_page ( ) > 0 :
return
2007-08-26 17:20:46 +02:00
( can_play , can_download , can_transfer , can_cancel ) = ( False , ) * 4
2006-12-13 00:11:34 +01:00
2007-08-26 17:20:46 +02:00
selection = self . treeAvailable . get_selection ( )
if selection . count_selected_rows ( ) > 0 :
( model , paths ) = selection . get_selected_rows ( )
for path in paths :
url = model . get_value ( model . get_iter ( path ) , 0 )
local_filename = model . get_value ( model . get_iter ( path ) , 8 )
2006-12-13 00:11:34 +01:00
2007-08-26 17:20:46 +02:00
if os . path . exists ( local_filename ) :
can_play = True
else :
2007-08-25 18:05:03 +02:00
if services . download_status_manager . is_download_in_progress ( url ) :
2007-08-26 17:20:46 +02:00
can_cancel = True
else :
can_download = True
2006-12-13 00:11:34 +01:00
2007-08-26 17:20:46 +02:00
if util . file_type_by_extension ( util . file_extension_from_url ( url ) ) == ' torrent ' :
can_download = can_download or gPodderLib ( ) . use_gnome_bittorrent
can_download = can_download and not can_cancel
can_play = can_play and not can_cancel and not can_download
can_transfer = can_play and gPodderLib ( ) . device_type != ' none '
self . toolPlay . set_sensitive ( can_play )
self . toolDownload . set_sensitive ( can_download )
self . toolTransfer . set_sensitive ( can_transfer )
self . toolCancel . set_sensitive ( can_cancel )
return ( can_play , can_download , can_transfer , can_cancel )
2006-12-13 00:11:34 +01:00
2007-07-24 20:42:04 +02:00
def download_status_updated ( self ) :
2007-08-24 16:49:41 +02:00
count = services . download_status_manager . count ( )
2007-07-24 20:42:04 +02:00
if count :
self . labelDownloads . set_text ( _ ( ' Downloads ( %d ) ' ) % count )
else :
self . labelDownloads . set_text ( _ ( ' Downloads ' ) )
2007-08-20 15:45:46 +02:00
for channel in self . channels :
2007-08-24 16:49:41 +02:00
channel . update_model ( )
2007-08-20 15:45:46 +02:00
2007-07-24 20:42:04 +02:00
self . updateComboBox ( )
2005-11-21 19:21:25 +01:00
def updateComboBox ( self ) :
try :
2006-12-09 02:59:53 +01:00
old_active = self . comboAvailable . get_active ( )
if old_active < 0 :
old_active = 0
2006-12-13 02:06:32 +01:00
elif old_active > len ( self . channels ) - 1 :
old_active = len ( self . channels ) - 1
2007-08-24 16:49:41 +02:00
self . comboAvailable . set_model ( channelsToModel ( self . channels ) )
2006-12-09 02:59:53 +01:00
self . comboAvailable . set_active ( old_active )
2007-07-05 23:07:16 +02:00
self . treeChannels . set_model ( self . comboAvailable . get_model ( ) )
2007-07-11 13:05:02 +02:00
if old_active > - 1 :
self . treeChannels . get_selection ( ) . select_path ( old_active )
2005-11-21 19:21:25 +01:00
except :
2006-03-31 18:20:18 +02:00
pass
2005-11-21 19:21:25 +01:00
def updateTreeView ( self ) :
2007-04-03 13:21:12 +02:00
gl = gPodderLib ( )
2007-02-24 13:04:38 +01:00
rect = self . treeAvailable . get_visible_rect ( )
2006-12-06 21:25:26 +01:00
if self . channels :
2007-08-20 15:45:46 +02:00
self . treeAvailable . set_model ( self . active_channel . tree_model )
2007-02-24 13:04:38 +01:00
# now, reset the scrolling position
self . treeAvailable . scroll_to_point ( rect . x , rect . y )
while gtk . events_pending ( ) :
gtk . main_iteration ( False )
self . treeAvailable . scroll_to_point ( rect . x , rect . y )
2007-04-01 19:53:04 +02:00
self . treeAvailable . columns_autosize ( )
2007-03-18 19:28:17 +01:00
self . play_or_download ( )
2006-12-06 21:25:26 +01:00
else :
if self . treeAvailable . get_model ( ) :
self . treeAvailable . get_model ( ) . clear ( )
2007-07-05 23:07:16 +02:00
2007-07-11 13:05:02 +02:00
index = self . comboAvailable . get_active ( )
if index > - 1 :
self . treeChannels . get_selection ( ) . select_path ( index )
2005-11-21 19:21:25 +01:00
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 )
2007-07-11 20:12:02 +02:00
def add_new_channel ( self , result = None , ask_download_new = True ) :
2007-08-07 20:11:31 +02:00
result = util . normalize_feed_url ( result )
2007-07-19 14:44:12 +02:00
2007-03-07 15:53:05 +01:00
if result :
2006-06-13 23:00:31 +02:00
for old_channel in self . channels :
if old_channel . url == result :
2007-07-11 13:05:02 +02:00
self . show_message ( _ ( ' You have already subscribed to this channel: %s ' ) % ( saxutils . escape ( old_channel . title ) , ) , _ ( ' Already added ' ) )
2006-11-17 15:26:10 +01:00
log ( ' Channel already exists: %s ' , result )
2006-12-06 21:25:26 +01:00
# Select the existing channel in combo box
for i in range ( len ( self . channels ) ) :
if self . channels [ i ] == old_channel :
self . comboAvailable . set_active ( i )
2006-06-13 23:00:31 +02:00
return
2006-11-17 15:26:10 +01:00
log ( ' Adding new channel: %s ' , result )
2007-08-20 15:45:46 +02:00
try :
channel = podcastChannel . get_by_url ( url = result , force_update = True )
except :
channel = None
if channel :
self . channels . append ( channel )
save_channels ( self . channels )
# download changed channels
self . update_feed_cache ( force_update = False )
2007-08-07 20:11:31 +02:00
( username , password ) = util . username_password_from_url ( result )
2007-07-19 14:44:12 +02:00
if username and self . show_confirmation ( _ ( ' You have supplied <b> %s </b> as username and a password for this feed. Would you like to use the same authentication data for downloading episodes? ' ) % ( saxutils . escape ( username ) , ) , _ ( ' Password authentication ' ) ) :
channel . username = username
channel . password = password
log ( ' Saving authentication data for episode downloads.. ' , sender = self )
2007-08-20 15:45:46 +02:00
channel . save_settings ( )
2007-07-19 14:44:12 +02:00
2007-01-06 14:48:46 +01:00
# ask user to download some new episodes
self . comboAvailable . set_active ( len ( self . channels ) - 1 )
2007-07-11 20:12:02 +02:00
if ask_download_new :
self . on_btnDownloadNewer_clicked ( None )
2007-08-20 15:45:46 +02:00
else :
title = _ ( ' Error adding channel ' )
message = _ ( ' The channel could not be added. Please check the spelling of the URL or try again later. ' )
self . show_message ( message , title )
2005-11-22 14:23:50 +01:00
else :
2006-12-09 02:59:53 +01:00
if result :
2007-03-10 18:42:32 +01:00
title = _ ( ' URL scheme not supported ' )
message = _ ( ' gPodder currently only supports URLs starting with <b>http://</b>, <b>feed://</b> or <b>ftp://</b>. ' )
self . show_message ( message , title )
2006-03-31 18:20:18 +02:00
2007-03-18 19:28:17 +01:00
def sync_to_ipod_proc ( self , sync , episodes = None ) :
2006-04-07 20:11:31 +02:00
if not sync . open ( ) :
2007-03-22 17:35:51 +01:00
sync . close ( success = False , access_error = True )
2006-04-07 20:11:31 +02:00
return False
2006-12-09 02:59:53 +01:00
2007-03-18 19:28:17 +01:00
if episodes == None :
2007-03-19 20:08:00 +01:00
i = 0
2007-03-18 19:28:17 +01:00
for channel in self . ldb . channel_list :
2007-03-19 20:08:00 +01:00
sync . set_progress_overall ( i , len ( self . ldb . channel_list ) )
2007-08-20 15:45:46 +02:00
channel . load_settings ( )
2007-04-23 17:18:31 +02:00
sync . sync_channel ( channel , sync_played_episodes = not gPodderLib ( ) . only_sync_not_played )
2007-03-19 20:08:00 +01:00
i + = 1
sync . set_progress_overall ( i , len ( self . ldb . channel_list ) )
2007-03-18 19:28:17 +01:00
else :
2007-04-23 17:18:31 +02:00
sync . sync_channel ( self . active_channel , episodes , True )
2006-12-09 02:59:53 +01:00
2007-03-22 17:35:51 +01:00
sync . close ( success = not sync . cancelled )
2007-04-03 13:21:12 +02:00
gobject . idle_add ( self . updateTreeView )
2006-04-07 03:43:06 +02:00
2007-03-18 19:28:17 +01:00
def ipod_cleanup_proc ( self , sync ) :
2006-04-07 20:11:31 +02:00
if not sync . open ( ) :
2007-03-10 18:42:32 +01:00
gobject . idle_add ( self . show_message , message , title )
2007-03-22 17:35:51 +01:00
sync . close ( success = False , access_error = True )
2006-04-07 20:11:31 +02:00
return False
2006-12-09 02:59:53 +01:00
2006-04-07 03:43:06 +02:00
sync . clean_playlist ( )
2007-03-22 17:35:51 +01:00
sync . close ( success = not sync . cancelled , cleaned = True )
2007-04-03 13:21:12 +02:00
gobject . idle_add ( self . updateTreeView )
2006-05-01 23:12:34 +02:00
2007-03-10 16:57:56 +01:00
def update_feed_cache_callback ( self , label , progressbar , position , count ) :
if len ( self . channels ) > position :
2007-08-20 15:45:46 +02:00
title = _ ( ' Updating %s ' ) % saxutils . escape ( self . channels [ position ] . title )
else :
title = _ ( ' Please wait... ' )
2006-12-09 02:59:53 +01:00
2007-03-10 16:57:56 +01:00
label . set_markup ( ' <i> %s </i> ' % title )
2007-08-20 15:45:46 +02:00
2007-03-10 16:57:56 +01:00
progressbar . set_text ( _ ( ' %d of %d channels updated ' ) % ( position , count ) )
2007-07-11 13:05:02 +02:00
if count :
progressbar . set_fraction ( ( ( 1.00 * position ) / ( 1.00 * count ) ) )
2006-07-14 22:09:00 +02:00
2007-08-20 15:45:46 +02:00
def update_feed_cache_proc ( self , force_update , callback_proc = None , callback_error = None , finish_proc = None ) :
self . channels = load_channels ( force_update = force_update , callback_proc = callback_proc , callback_error = callback_error )
if finish_proc :
finish_proc ( )
2007-03-10 16:57:56 +01:00
def update_feed_cache ( self , force_update = True ) :
title = _ ( ' Downloading podcast feeds ' )
heading = _ ( ' Downloading feeds ' )
body = _ ( ' Podcast feeds contain channel metadata and information about current episodes. ' )
2007-08-20 15:45:46 +02:00
2007-03-10 16:57:56 +01:00
please_wait = gtk . Dialog ( title , self . gPodder , gtk . DIALOG_MODAL , ( gtk . STOCK_CANCEL , gtk . RESPONSE_CANCEL , ) )
please_wait . set_transient_for ( self . gPodder )
please_wait . set_position ( gtk . WIN_POS_CENTER_ON_PARENT )
2006-07-14 22:09:00 +02:00
please_wait . vbox . set_spacing ( 5 )
2007-03-10 16:57:56 +01:00
please_wait . set_border_width ( 10 )
please_wait . set_resizable ( False )
2007-08-20 15:45:46 +02:00
2007-03-10 16:57:56 +01:00
label_heading = gtk . Label ( )
label_heading . set_alignment ( 0.0 , 0.5 )
label_heading . set_markup ( ' <span weight= " bold " size= " larger " > %s </span> ' % heading )
2007-08-20 15:45:46 +02:00
2007-03-10 16:57:56 +01:00
label_body = gtk . Label ( )
label_body . set_text ( body )
label_body . set_alignment ( 0.0 , 0.5 )
label_body . set_line_wrap ( True )
2007-08-20 15:45:46 +02:00
2006-07-14 22:09:00 +02:00
myprogressbar = gtk . ProgressBar ( )
2007-08-20 15:45:46 +02:00
2007-03-10 16:57:56 +01:00
mylabel = gtk . Label ( )
mylabel . set_alignment ( 0.0 , 0.5 )
mylabel . set_ellipsize ( pango . ELLIPSIZE_END )
2007-08-20 15:45:46 +02:00
2006-07-14 22:09:00 +02:00
# put it all together
2007-03-10 16:57:56 +01:00
please_wait . vbox . pack_start ( label_heading )
please_wait . vbox . pack_start ( label_body )
please_wait . vbox . pack_start ( myprogressbar )
please_wait . vbox . pack_end ( mylabel )
2006-07-14 22:09:00 +02:00
please_wait . show_all ( )
2007-08-20 15:45:46 +02:00
2007-03-10 16:57:56 +01:00
# hide separator line
2006-07-14 22:09:00 +02:00
please_wait . set_has_separator ( False )
2007-08-20 15:45:46 +02:00
2006-07-14 22:09:00 +02:00
# let's get down to business..
2007-03-10 16:57:56 +01:00
callback_proc = lambda pos , count : gobject . idle_add ( self . update_feed_cache_callback , mylabel , myprogressbar , pos , count )
2007-03-10 18:42:32 +01:00
callback_error = lambda x : gobject . idle_add ( self . show_message , x )
2007-03-10 16:57:56 +01:00
finish_proc = lambda : gobject . idle_add ( please_wait . destroy )
2007-08-20 15:45:46 +02:00
args = ( force_update , callback_proc , callback_error , finish_proc , )
2007-03-10 16:57:56 +01:00
thread = Thread ( target = self . update_feed_cache_proc , args = args )
thread . start ( )
2007-08-20 15:45:46 +02:00
please_wait . run ( )
2006-05-01 23:12:34 +02:00
self . updateComboBox ( )
2007-03-08 15:04:05 +01:00
# download all new?
2007-03-10 16:57:56 +01:00
if force_update and gPodderLib ( ) . download_after_update :
2007-03-08 15:04:05 +01:00
self . on_itemDownloadAllNew_activate ( self . gPodder )
2006-05-01 23:12:34 +02:00
2006-06-22 23:41:32 +02:00
def download_podcast_by_url ( self , url , want_message_dialog = True , widget = None ) :
2007-08-26 17:20:46 +02:00
if self . active_channel == None :
return
2006-12-09 02:59:53 +01:00
current_channel = self . active_channel
2006-12-09 01:41:58 +01:00
current_podcast = current_channel . find_episode ( url )
2007-08-22 01:00:49 +02:00
filename = current_podcast . local_filename ( )
2006-12-09 02:59:53 +01:00
2006-12-13 00:11:34 +01:00
if widget :
2007-03-31 04:00:30 +02:00
if ( widget . get_name ( ) == ' itemPlaySelected ' or widget . get_name ( ) == ' toolPlay ' ) and os . path . exists ( filename ) :
2007-03-14 20:35:15 +01:00
# addDownloadedItem just to make sure the episode is marked correctly in localdb
2007-03-17 13:11:13 +01:00
if current_channel . addDownloadedItem ( current_podcast ) :
self . ldb . clear_cache ( )
2007-03-14 20:35:15 +01:00
# open the file now
2007-08-22 01:00:49 +02:00
if current_podcast . file_type ( ) != ' torrent ' :
2007-04-09 21:40:36 +02:00
self . playback_episode ( current_channel , current_podcast )
2006-12-13 00:11:34 +01:00
return
if widget . get_name ( ) == ' treeAvailable ' :
2007-08-27 22:28:00 +02:00
play_callback = lambda : self . playback_episode ( current_channel , current_podcast )
download_callback = lambda : self . download_podcast_by_url ( url , want_message_dialog , None )
2007-08-28 00:18:01 +02:00
gpe = gPodderEpisode ( episode = current_podcast , channel = current_channel , download_callback = download_callback , play_callback = play_callback )
2006-12-13 00:11:34 +01:00
return
2006-06-22 23:41:32 +02:00
2007-08-24 16:49:41 +02:00
if not os . path . exists ( filename ) and not services . download_status_manager . is_download_in_progress ( current_podcast . url ) :
downloadThread ( current_podcast . url , filename , None , current_podcast . title , current_channel , current_podcast , self . ldb ) . download ( )
2006-06-22 23:41:32 +02:00
else :
2007-08-22 01:00:49 +02:00
if want_message_dialog and os . path . exists ( filename ) and not current_podcast . file_type ( ) == ' torrent ' :
2007-03-10 18:42:32 +01:00
title = _ ( ' Episode already downloaded ' )
message = _ ( ' You have already downloaded this episode. Click on the episode to play it. ' )
self . show_message ( message , title )
2007-08-22 01:00:49 +02:00
elif want_message_dialog and not current_podcast . file_type ( ) == ' torrent ' :
2007-03-10 18:42:32 +01:00
title = _ ( ' Download in progress ' )
message = _ ( ' You are currently downloading this episode. Please check the download status tab to check when the download is finished. ' )
self . show_message ( message , title )
2006-12-09 02:59:53 +01:00
if os . path . exists ( filename ) :
2006-11-17 15:26:10 +01:00
log ( ' Episode has already been downloaded. ' )
2006-06-22 23:41:32 +02:00
if current_channel . addDownloadedItem ( current_podcast ) :
self . ldb . clear_cache ( )
2006-12-06 21:25:26 +01:00
# update tree view to mark the episode as being downloaded
2007-07-05 23:07:16 +02:00
self . updateComboBox ( )
2005-11-21 19:21:25 +01:00
def close_gpodder ( self , widget , * args ) :
2006-12-09 02:59:53 +01:00
if self . channels :
2007-08-20 15:45:46 +02:00
save_channels ( self . channels )
2005-11-21 19:21:25 +01:00
2007-08-24 16:49:41 +02:00
services . download_status_manager . cancel_all ( )
2005-11-23 20:53:18 +01:00
2007-04-01 19:53:04 +02:00
gl = gPodderLib ( )
size = self . gPodder . get_size ( )
pos = self . gPodder . get_position ( )
gl . main_window_width = size [ 0 ]
gl . main_window_height = size [ 1 ]
gl . main_window_x = pos [ 0 ]
gl . main_window_y = pos [ 1 ]
2007-07-05 23:07:16 +02:00
gl . paned_position = self . channelPaned . get_position ( )
2007-04-01 19:53:04 +02:00
gl . propertiesChanged ( )
2005-11-21 19:21:25 +01:00
self . gtk_main_quit ( )
2007-05-05 10:10:10 +02:00
sys . exit ( 0 )
2005-11-21 19:21:25 +01:00
2007-08-30 20:54:18 +02:00
def for_each_selected_episode_url ( self , callback ) :
( model , paths ) = self . treeAvailable . get_selection ( ) . get_selected_rows ( )
for path in paths :
url = model . get_value ( model . get_iter ( path ) , 0 )
try :
callback ( url )
except :
log ( ' Warning: Error in for_each_selected_episode_url for URL %s ' , url , sender = self )
self . active_channel . update_model ( )
self . updateComboBox ( )
def on_item_toggle_downloaded_activate ( self , widget , toggle = True , new_value = False ) :
if toggle :
callback = lambda url : gPodderLib ( ) . history_mark_downloaded ( url , not gPodderLib ( ) . history_is_downloaded ( url ) )
else :
callback = lambda url : gPodderLib ( ) . history_mark_downloaded ( url , new_value )
self . for_each_selected_episode_url ( callback )
def on_item_toggle_played_activate ( self , widget , toggle = True , new_value = False ) :
if toggle :
callback = lambda url : gPodderLib ( ) . history_mark_played ( url , not gPodderLib ( ) . history_is_played ( url ) )
else :
callback = lambda url : gPodderLib ( ) . history_mark_played ( url , new_value )
self . for_each_selected_episode_url ( callback )
2005-11-21 19:21:25 +01:00
def on_itemUpdate_activate ( self , widget , * args ) :
2006-12-06 21:25:26 +01:00
if self . channels :
self . update_feed_cache ( )
else :
2007-03-10 18:42:32 +01:00
title = _ ( ' No channels available ' )
message = _ ( ' You need to subscribe to some podcast feeds before you can start downloading podcasts. Use your favorite search engine to look for interesting podcasts. ' )
self . show_message ( message , title )
2005-11-21 19:21:25 +01:00
2006-12-20 20:44:29 +01:00
def on_itemDownloadAllNew_activate ( self , widget , * args ) :
gl = gPodderLib ( )
to_download = [ ]
message_part = ' '
2007-03-10 18:42:32 +01:00
new_sum = 0
2006-12-20 20:44:29 +01:00
for channel in self . channels :
2007-08-24 16:49:41 +02:00
new_episodes = channel . get_new_episodes ( )
2007-07-05 23:07:16 +02:00
for episode in new_episodes :
to_download . append ( ( channel , episode ) )
2007-03-10 18:42:32 +01:00
2007-07-05 23:07:16 +02:00
if len ( new_episodes ) :
if len ( new_episodes ) == 1 :
new_part = ' ' + _ ( ' <b>1</b> new episode in <b> %s </b> ' ) % ( saxutils . escape ( channel . title ) , )
else :
new_part = ' ' + _ ( ' <b> %d </b> new episodes in <b> %s </b> ' ) % ( len ( new_episodes ) , saxutils . escape ( channel . title ) , )
2007-03-10 18:42:32 +01:00
message_part + = new_part + " \n "
2007-07-05 23:07:16 +02:00
new_sum + = len ( new_episodes )
2006-12-20 20:44:29 +01:00
if to_download :
2007-03-10 18:42:32 +01:00
title = _ ( ' New episodes available ' )
if new_sum == 1 :
title = _ ( ' New episode available ' )
message = _ ( ' New episodes are available to be downloaded: \n \n %s \n Do you want to download these episodes now? ' ) % ( message_part , )
if self . show_confirmation ( message , title ) :
2006-12-20 20:44:29 +01:00
for channel , episode in to_download :
2007-08-22 01:00:49 +02:00
filename = episode . local_filename ( )
2007-08-24 16:49:41 +02:00
if not os . path . exists ( filename ) and not services . download_status_manager . is_download_in_progress ( episode . url ) :
downloadThread ( episode . url , filename , None , episode . title , channel , episode , self . ldb ) . download ( )
2006-12-20 20:44:29 +01:00
else :
2007-03-10 18:42:32 +01:00
title = _ ( ' No new episodes ' )
message = _ ( ' There are no new episodes to download from your podcast subscriptions. Please check for new episodes later. ' )
self . show_message ( message , title )
2006-12-20 20:44:29 +01:00
2007-07-05 23:07:16 +02:00
self . updateComboBox ( )
2006-12-20 20:44:29 +01:00
2006-04-07 03:43:06 +02:00
def on_sync_to_ipod_activate ( self , widget , * args ) :
2006-12-06 21:25:26 +01:00
gl = gPodderLib ( )
if gl . device_type == ' none ' :
2007-03-10 18:42:32 +01:00
title = _ ( ' No device configured ' )
message = _ ( ' To use the synchronization feature, please configure your device in the preferences dialog first. ' )
self . show_message ( message , title )
2007-03-18 19:28:17 +01:00
return
if gl . device_type == ' ipod ' and not ipod_supported ( ) :
title = _ ( ' Libraries needed: gpod, pymad ' )
message = _ ( ' To use the iPod synchronization feature, you need to install the <b>python-gpod</b> and <b>python-pymad</b> libraries from your distribution vendor. More information about the needed libraries can be found on the gPodder website. ' )
self . show_message ( message , title )
return
if gl . device_type in [ ' ipod ' , ' filesystem ' ] :
sync_class = None
if gl . device_type == ' filesystem ' :
sync_class = gPodder_FSSync
elif gl . device_type == ' ipod ' :
sync_class = gPodder_iPodSync
if not sync_class :
2006-12-06 21:25:26 +01:00
return
2007-03-18 19:28:17 +01:00
2007-08-28 00:18:01 +02:00
sync_win = gPodderSync ( )
2007-03-18 19:28:17 +01:00
sync = sync_class ( callback_status = sync_win . set_status , callback_progress = sync_win . set_progress , callback_done = sync_win . close )
2007-03-22 17:35:51 +01:00
sync_win . set_sync_object ( sync )
2007-03-18 19:28:17 +01:00
thread_args = [ sync ]
if widget == None :
thread_args . append ( args [ 0 ] )
thread = Thread ( target = self . sync_to_ipod_proc , args = thread_args )
2006-12-17 02:21:36 +01:00
thread . start ( )
2006-04-07 03:43:06 +02:00
2006-04-06 16:11:03 +02:00
def on_cleanup_ipod_activate ( self , widget , * args ) :
2006-12-06 21:25:26 +01:00
gl = gPodderLib ( )
if gl . device_type == ' none ' :
2007-03-10 18:42:32 +01:00
title = _ ( ' No device configured ' )
message = _ ( ' To use the synchronization feature, please configure your device in the preferences dialog first. ' )
self . show_message ( message , title )
2007-03-18 19:28:17 +01:00
return
if gl . device_type == ' ipod ' and not ipod_supported ( ) :
title = _ ( ' Libraries needed: gpod, pymad ' )
message = _ ( ' To use the iPod synchronization feature, you need to install the <b>python-gpod</b> and <b>python-pymad</b> libraries from your distribution vendor. More information about the needed libraries can be found on the gPodder website. ' )
self . show_message ( message , title )
return
if gl . device_type in [ ' ipod ' , ' filesystem ' ] :
sync_class = None
if gl . device_type == ' filesystem ' :
title = _ ( ' Delete podcasts from MP3 player? ' )
message = _ ( ' Do you really want to completely remove all episodes from your MP3 player? ' )
if self . show_confirmation ( message , title ) :
sync_class = gPodder_FSSync
elif gl . device_type == ' ipod ' :
title = _ ( ' Delete podcasts on iPod? ' )
message = _ ( ' Do you really want to completely remove all episodes in the <b>Podcasts</b> playlist on your iPod? ' )
if self . show_confirmation ( message , title ) :
sync_class = gPodder_iPodSync
if not sync_class :
return
2007-03-03 14:10:21 +01:00
2007-08-28 00:18:01 +02:00
sync_win = gPodderSync ( )
2007-03-18 19:28:17 +01:00
sync = sync_class ( callback_status = sync_win . set_status , callback_progress = sync_win . set_progress , callback_done = sync_win . close )
2007-03-22 17:35:51 +01:00
sync_win . set_sync_object ( sync )
2007-03-18 19:28:17 +01:00
thread = Thread ( target = self . ipod_cleanup_proc , args = ( sync , ) )
2006-12-06 21:25:26 +01:00
thread . start ( )
2006-04-06 16:11:03 +02:00
2005-11-21 19:21:25 +01:00
def on_itemPreferences_activate ( self , widget , * args ) :
2007-08-28 00:18:01 +02:00
prop = gPodderProperties ( )
2006-12-09 02:59:53 +01:00
prop . set_uar ( self . user_apps_reader )
2007-07-05 23:07:16 +02:00
prop . set_callback_finished ( self . updateComboBox )
2005-11-21 19:21:25 +01:00
def on_itemAddChannel_activate ( self , widget , * args ) :
2007-07-11 13:05:02 +02:00
if self . channelPaned . get_position ( ) < 200 :
self . channelPaned . set_position ( 200 )
self . entryAddChannel . set_text ( _ ( ' Enter podcast URL ' ) )
self . entryAddChannel . grab_focus ( )
2005-11-21 19:21:25 +01:00
def on_itemEditChannel_activate ( self , widget , * args ) :
2007-03-29 21:24:39 +02:00
if self . active_channel == None :
2007-03-10 18:42:32 +01:00
title = _ ( ' No channel selected ' )
message = _ ( ' Please select a channel in the channels list to edit. ' )
self . show_message ( message , title )
2006-04-06 16:11:03 +02:00
return
2007-07-11 20:28:09 +02:00
2007-08-28 00:18:01 +02:00
gPodderChannel ( channel = self . active_channel , callback_closed = self . updateComboBox )
2007-07-11 13:05:02 +02:00
2005-11-21 19:21:25 +01:00
def on_itemRemoveChannel_activate ( self , widget , * args ) :
try :
2007-03-10 18:42:32 +01:00
title = _ ( ' Remove channel and episodes? ' )
message = _ ( ' Do you really want to remove <b> %s </b> and all downloaded episodes? ' ) % ( self . active_channel . title , )
if self . show_confirmation ( message , title ) :
2006-12-09 02:59:53 +01:00
self . active_channel . remove_downloaded ( )
2007-02-03 11:48:32 +01:00
# only delete partial files if we do not have any downloads in progress
2007-08-24 16:49:41 +02:00
delete_partial = not services . download_status_manager . has_items ( )
2007-02-03 11:48:32 +01:00
gPodderLib ( ) . clean_up_downloads ( delete_partial )
2006-12-09 02:59:53 +01:00
self . channels . remove ( self . active_channel )
2007-08-20 15:45:46 +02:00
save_channels ( self . channels )
2007-03-10 16:57:56 +01:00
self . update_feed_cache ( force_update = False )
2005-11-21 19:21:25 +01:00
except :
2006-12-06 21:25:26 +01:00
pass
2005-11-21 19:21:25 +01:00
def on_itemExportChannels_activate ( self , widget , * args ) :
2006-12-09 02:59:53 +01:00
if not self . channels :
2007-03-10 18:42:32 +01:00
title = _ ( ' Nothing to export ' )
message = _ ( ' Your list of channel subscriptions is empty. Please subscribe to some podcasts first before trying to export your subscription list. ' )
self . show_message ( message , title )
2006-12-09 02:59:53 +01: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 :
2007-08-19 16:28:24 +02:00
filename = dlg . get_filename ( )
exporter = opml . Exporter ( filename )
if not exporter . write ( self . channels ) :
self . show_message ( _ ( ' Could not export OPML to file. Please check your permissions. ' ) , _ ( ' OPML export failed ' ) )
2006-12-09 02:59:53 +01:00
2005-12-08 20:47:35 +01:00
dlg . destroy ( )
2005-11-21 19:21:25 +01:00
2006-06-13 23:00:31 +02:00
def on_itemImportChannels_activate ( self , widget , * args ) :
2007-08-28 00:18:01 +02:00
gPodderOpmlLister ( ) . get_channels_from_url ( gPodderLib ( ) . opml_url , lambda url : self . add_new_channel ( url , False ) , lambda : self . on_itemDownloadAllNew_activate ( self . gPodder ) )
2006-06-13 23:00:31 +02:00
2007-03-18 19:28:17 +01:00
def on_btnTransfer_clicked ( self , widget , * args ) :
self . on_treeAvailable_row_activated ( widget , args )
2006-12-04 14:06:42 +01:00
def on_homepage_activate ( self , widget , * args ) :
2007-08-31 20:04:28 +02:00
Thread ( target = webbrowser . open , args = ( app_website , ) ) . start ( )
2006-12-04 14:06:42 +01:00
def on_wishlist_activate ( self , widget , * args ) :
2007-08-31 20:04:28 +02:00
Thread ( target = webbrowser . open , args = ( ' http://www.amazon.de/gp/registry/2PD2MYGHE6857 ' , ) ) . start ( )
2006-12-04 14:06:42 +01:00
def on_mailinglist_activate ( self , widget , * args ) :
2007-08-31 20:04:28 +02:00
Thread ( target = webbrowser . open , args = ( ' http://lists.berlios.de/mailman/listinfo/gpodder-devel ' , ) ) . start ( )
2006-12-04 14:06:42 +01:00
2005-11-21 19:21:25 +01:00
def on_itemAbout_activate ( self , widget , * args ) :
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 ' ) )
2007-08-28 00:18:01 +02:00
dlg . connect ( ' response ' , lambda dlg , response : dlg . destroy ( ) )
2006-12-04 14:06:42 +01:00
2006-02-04 18:29:17 +01:00
try :
2007-03-25 21:55:28 +02:00
dlg . set_logo ( gtk . gdk . pixbuf_new_from_file_at_size ( scalable_dir , 200 , 200 ) )
2006-02-04 18:29:17 +01:00
except :
2006-12-09 02:59:53 +01:00
pass
2006-12-04 14:06:42 +01:00
2005-11-21 19:21:25 +01:00
dlg . run ( )
2006-11-29 00:23:16 +01:00
2006-02-04 18:29:17 +01:00
def on_wNotebook_switch_page ( self , widget , * args ) :
2007-03-31 04:00:30 +02:00
page_num = args [ 1 ]
if page_num == 0 :
2007-08-25 18:05:03 +02:00
self . updateComboBox ( )
2007-03-31 04:00:30 +02:00
self . play_or_download ( )
else :
self . toolDownload . set_sensitive ( False )
self . toolPlay . set_sensitive ( False )
self . toolTransfer . set_sensitive ( False )
2007-08-24 16:49:41 +02:00
self . toolCancel . set_sensitive ( services . download_status_manager . has_items ( ) )
2006-02-04 18:29:17 +01:00
2007-07-05 23:07:16 +02:00
def on_treeChannels_row_activated ( self , widget , * args ) :
self . on_itemEditChannel_activate ( self . treeChannels )
def on_treeChannels_cursor_changed ( self , widget , * args ) :
( model , iter ) = self . treeChannels . get_selection ( ) . get_selected ( )
pos = model . get_value ( iter , 6 )
self . comboAvailable . set_active ( pos )
2007-07-11 13:05:02 +02:00
def on_entryAddChannel_changed ( self , widget , * args ) :
active = self . entryAddChannel . get_text ( ) not in ( ' ' , _ ( ' Enter podcast URL ' ) )
self . btnAddChannel . set_sensitive ( active )
def on_btnAddChannel_clicked ( self , widget , * args ) :
url = self . entryAddChannel . get_text ( )
self . entryAddChannel . set_text ( ' ' )
self . add_new_channel ( url )
2005-11-21 19:21:25 +01:00
def on_comboAvailable_changed ( self , widget , * args ) :
2006-12-09 02:59:53 +01:00
try :
self . active_channel = self . channels [ self . comboAvailable . get_active ( ) ]
except :
self . active_channel = None
2007-03-29 21:24:39 +02:00
if self . active_channel != None :
2006-12-16 18:44:13 +01:00
self . itemEditChannel . get_child ( ) . set_text ( _ ( ' Edit " %s " ' ) % ( self . active_channel . title , ) )
self . itemRemoveChannel . get_child ( ) . set_text ( _ ( ' Remove " %s " ' ) % ( self . active_channel . title , ) )
self . itemEditChannel . show_all ( )
self . itemRemoveChannel . show_all ( )
else :
self . itemEditChannel . hide_all ( )
self . itemRemoveChannel . hide_all ( )
2005-11-21 19:21:25 +01:00
self . updateTreeView ( )
2006-03-04 21:45:01 +01:00
def on_btnEditChannel_clicked ( self , widget , * args ) :
self . on_itemEditChannel_activate ( widget , args )
2005-11-21 19:21:25 +01:00
def on_treeAvailable_row_activated ( self , widget , * args ) :
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 ( )
2007-03-18 19:28:17 +01:00
transfer_files = False
episodes = [ ]
2006-12-09 02:59:53 +01:00
2006-06-22 23:41:32 +02:00
if selection . count_selected_rows ( ) > 1 :
widget_to_send = None
show_message_dialog = False
else :
widget_to_send = widget
show_message_dialog = True
2006-12-09 02:59:53 +01:00
2007-03-31 04:00:30 +02:00
if widget . get_name ( ) == ' itemTransferSelected ' or widget . get_name ( ) == ' toolTransfer ' :
2007-03-18 19:28:17 +01:00
transfer_files = True
2006-06-22 23:41:32 +02:00
for apath in selection_tuple [ 1 ] :
2006-12-09 02:59:53 +01:00
selection_iter = self . treeAvailable . get_model ( ) . get_iter ( apath )
url = self . treeAvailable . get_model ( ) . get_value ( selection_iter , 0 )
2007-03-18 19:28:17 +01:00
if transfer_files :
episodes . append ( self . active_channel . find_episode ( url ) )
else :
self . download_podcast_by_url ( url , show_message_dialog , widget_to_send )
if transfer_files and len ( episodes ) :
self . on_sync_to_ipod_activate ( None , episodes )
2006-03-29 16:40:08 +02:00
except :
2007-03-10 18:42:32 +01:00
title = _ ( ' Nothing selected ' )
message = _ ( ' Please select an episode that you want to download and then click on the download button to start downloading the selected episode. ' )
self . show_message ( message , title )
2005-11-21 19:21:25 +01:00
def on_btnDownload_clicked ( self , widget , * args ) :
self . on_treeAvailable_row_activated ( widget , args )
2006-12-13 00:11:34 +01:00
def on_treeAvailable_button_release_event ( self , widget , * args ) :
self . play_or_download ( )
2006-12-06 21:25:26 +01:00
def on_btnDownloadNewer_clicked ( self , widget , * args ) :
2006-12-09 02:59:53 +01:00
channel = self . active_channel
2007-08-24 16:49:41 +02:00
episodes_to_download = channel . get_new_episodes ( )
2006-12-06 21:25:26 +01:00
2007-07-05 23:07:16 +02:00
if not episodes_to_download :
title = _ ( ' No episodes to download ' )
message = _ ( ' You have already downloaded the most recent episodes from <b> %s </b>. ' ) % ( channel . title , )
self . show_message ( message , title )
2006-12-06 21:25:26 +01:00
else :
2007-07-05 23:07:16 +02:00
if len ( episodes_to_download ) > 1 :
if len ( episodes_to_download ) < 10 :
e_str = ' \n ' . join ( [ ' <b> ' + saxutils . escape ( e . title ) + ' </b> ' for e in episodes_to_download ] )
2007-03-10 18:42:32 +01:00
else :
2007-07-05 23:07:16 +02:00
e_str = ' \n ' . join ( [ ' <b> ' + saxutils . escape ( e . title ) + ' </b> ' for e in episodes_to_download [ : 7 ] ] )
e_str_2 = _ ( ' (... %d more episodes...) ' ) % ( len ( episodes_to_download ) - 7 , )
e_str = ' %s \n <i> %s </i> ' % ( e_str , e_str_2 , )
title = _ ( ' Download new episodes? ' )
message = _ ( ' New episodes are available for download. If you want, you can download these episodes to your computer now. ' )
message = ' %s \n \n %s ' % ( message , e_str , )
else :
title = _ ( ' Download %s ? ' ) % saxutils . escape ( episodes_to_download [ 0 ] . title )
message = _ ( ' A new episode is available for download. If you want, you can download this episode to your computer now. ' )
2007-03-10 18:42:32 +01:00
2007-07-05 23:07:16 +02:00
if not self . show_confirmation ( message , title ) :
return
2006-12-06 21:25:26 +01:00
for episode in episodes_to_download :
self . download_podcast_by_url ( episode . url , False )
2006-07-20 15:19:19 +02:00
def on_btnSelectAllAvailable_clicked ( self , widget , * args ) :
self . treeAvailable . get_selection ( ) . select_all ( )
2007-03-31 04:00:30 +02:00
self . on_treeAvailable_row_activated ( self . toolDownload , args )
2006-07-20 15:19:19 +02:00
self . treeAvailable . get_selection ( ) . unselect_all ( )
2005-11-23 20:53:18 +01:00
def on_treeDownloads_row_activated ( self , widget , * args ) :
2007-08-25 18:05:03 +02:00
cancel_urls = [ ]
if self . wNotebook . get_current_page ( ) > 0 :
# Use the download list treeview + model
( tree , column ) = ( self . treeDownloads , 3 )
else :
# Use the available podcasts treeview + model
( tree , column ) = ( self . treeAvailable , 0 )
2006-07-14 22:09:00 +02:00
2007-08-26 17:20:46 +02:00
selection = tree . get_selection ( )
( model , paths ) = selection . get_selected_rows ( )
2007-08-25 18:05:03 +02:00
for path in paths :
url = model . get_value ( model . get_iter ( path ) , column )
cancel_urls . append ( url )
2007-03-10 18:42:32 +01:00
2007-08-25 18:05:03 +02:00
if len ( cancel_urls ) == 0 :
log ( ' Nothing selected. ' , sender = self )
return
if len ( cancel_urls ) == 1 :
2007-03-10 18:42:32 +01:00
title = _ ( ' Cancel download? ' )
message = _ ( " Cancelling this download will remove the partially downloaded file and stop the download. " )
2007-08-25 18:05:03 +02:00
else :
title = _ ( ' Cancel downloads? ' )
message = _ ( " Cancelling the download will stop the %d selected downloads and remove partially downloaded files. " ) % selection . count_selected_rows ( )
2007-03-10 18:42:32 +01:00
if self . show_confirmation ( message , title ) :
2007-08-25 18:05:03 +02:00
for url in cancel_urls :
services . download_status_manager . cancel_by_url ( url )
2005-11-23 20:53:18 +01:00
def on_btnCancelDownloadStatus_clicked ( self , widget , * args ) :
self . on_treeDownloads_row_activated ( widget , None )
2006-07-20 15:19:19 +02:00
def on_btnCancelAll_clicked ( self , widget , * args ) :
self . treeDownloads . get_selection ( ) . select_all ( )
2007-03-31 04:00:30 +02:00
self . on_treeDownloads_row_activated ( self . toolCancel , None )
2006-07-20 15:19:19 +02:00
self . treeDownloads . get_selection ( ) . unselect_all ( )
2006-02-04 18:29:17 +01:00
def on_btnDownloadedExecute_clicked ( self , widget , * args ) :
2006-12-09 02:59:53 +01:00
self . on_treeAvailable_row_activated ( widget , args )
2006-02-04 18:29:17 +01:00
2006-03-24 20:08:59 +01:00
def on_btnDownloadedDelete_clicked ( self , widget , * args ) :
2007-08-26 17:20:46 +02:00
if self . active_channel == None :
return
2006-12-09 02:59:53 +01:00
channel_url = self . active_channel . url
selection = self . treeAvailable . get_selection ( )
2006-07-14 21:10:47 +02:00
selection_tuple = selection . get_selected_rows ( )
2006-12-09 02:59:53 +01:00
model = self . treeAvailable . get_model ( )
2006-07-14 22:09:00 +02:00
if selection . count_selected_rows ( ) == 0 :
2006-11-17 15:26:10 +01:00
log ( ' Nothing selected - will not remove any downloaded episode. ' )
2006-07-14 22:09:00 +02:00
return
2006-07-14 21:10:47 +02:00
2007-03-10 18:42:32 +01:00
title = _ ( ' Remove %d episodes? ' ) % selection . count_selected_rows ( )
message = _ ( ' If you remove these episodes, they will be deleted from your computer. If you want to listen to any of these episodes again, you will have to re-download the episodes in question. ' )
2006-07-14 21:10:47 +02:00
if selection . count_selected_rows ( ) == 1 :
2007-03-10 18:42:32 +01:00
title = _ ( ' Remove %s ? ' ) % model . get_value ( model . get_iter ( selection_tuple [ 1 ] [ 0 ] ) , 1 )
message = _ ( " If you remove this episode, it will be deleted from your computer. If you want to listen to this episode again, you will have to re-download it. " )
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 ;)
2007-03-10 18:42:32 +01:00
if self . show_confirmation ( message , title ) :
2007-02-03 11:48:32 +01:00
try :
2006-07-14 21:10:47 +02:00
# 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 )
2007-03-14 20:35:15 +01:00
self . active_channel . delete_episode_by_url ( url )
2006-07-14 21:10:47 +02:00
# 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 ( )
2007-02-03 11:48:32 +01:00
except :
log ( ' Error while deleting (some) downloads. ' )
# only delete partial files if we do not have any downloads in progress
2007-08-24 16:49:41 +02:00
delete_partial = not services . download_status_manager . has_items ( )
2007-02-03 11:48:32 +01:00
gPodderLib ( ) . clean_up_downloads ( delete_partial )
2007-08-20 15:45:46 +02:00
self . active_channel . force_update_tree_model ( )
self . updateTreeView ( )
2006-03-24 20:08:59 +01:00
2006-07-20 15:19:19 +02:00
def on_btnDeleteAll_clicked ( self , widget , * args ) :
2006-12-09 02:59:53 +01:00
self . treeAvailable . get_selection ( ) . select_all ( )
2006-07-20 15:19:19 +02:00
self . on_btnDownloadedDelete_clicked ( widget , args )
2006-12-09 02:59:53 +01:00
self . treeAvailable . get_selection ( ) . unselect_all ( )
2007-07-11 13:05:02 +02:00
2007-08-28 00:18:01 +02:00
class gPodderChannel ( GladeWidget ) :
2005-11-21 19:21:25 +01:00
def new ( self ) :
2007-08-28 00:18:01 +02:00
self . gPodderChannel . set_title ( self . channel . title )
self . entryTitle . set_text ( self . channel . title )
self . entryURL . set_text ( self . channel . url )
self . LabelDownloadTo . set_text ( self . channel . save_dir )
self . LabelWebsite . set_text ( self . channel . link )
self . channel . load_settings ( )
self . cbNoSync . set_active ( not self . channel . sync_to_devices )
self . musicPlaylist . set_text ( self . channel . device_playlist_name )
self . cbMusicChannel . set_active ( self . channel . is_music_channel )
if self . channel . username :
self . FeedUsername . set_text ( self . channel . username )
if self . channel . password :
self . FeedPassword . set_text ( self . channel . password )
gPodderLib ( ) . get_image_from_url ( self . channel . image , self . imgCover . set_from_pixbuf , self . labelCoverStatus . set_text , self . labelCoverStatus . hide , self . channel . cover_file )
2006-03-31 18:20:18 +02:00
2006-03-04 21:45:01 +01:00
b = gtk . TextBuffer ( )
2007-08-28 00:18:01 +02:00
b . set_text ( self . channel . description )
2006-03-04 21:45:01 +01:00
self . channel_description . set_buffer ( b )
2007-07-11 13:05:02 +02:00
2005-11-21 19:21:25 +01:00
def on_gPodderChannel_destroy ( self , widget , * args ) :
2007-08-28 00:18:01 +02:00
self . callback_closed ( )
2005-11-21 19:21:25 +01:00
2006-04-08 11:09:15 +02:00
def on_cbMusicChannel_toggled ( self , widget , * args ) :
self . musicPlaylist . set_sensitive ( self . cbMusicChannel . get_active ( ) )
2005-11-21 19:21:25 +01:00
def on_btnOK_clicked ( self , widget , * args ) :
2007-07-11 13:05:02 +02:00
self . channel . sync_to_devices = not self . cbNoSync . get_active ( )
self . channel . is_music_channel = self . cbMusicChannel . get_active ( )
self . channel . device_playlist_name = self . musicPlaylist . get_text ( )
self . channel . set_custom_title ( self . entryTitle . get_text ( ) )
2007-07-19 14:44:12 +02:00
self . channel . username = self . FeedUsername . get_text ( ) . strip ( )
self . channel . password = self . FeedPassword . get_text ( )
2007-08-20 15:45:46 +02:00
self . channel . save_settings ( )
2005-11-21 19:21:25 +01:00
2007-07-11 13:05:02 +02:00
self . gPodderChannel . destroy ( )
2005-11-21 19:21:25 +01:00
2007-08-28 00:18:01 +02:00
class gPodderProperties ( GladeWidget ) :
2006-01-09 00:52:40 +01:00
def new ( self ) :
2007-01-28 10:21:39 +01:00
self . callback_finished = None
2006-01-09 00:52:40 +01:00
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-12-06 21:25:26 +01:00
self . iPodMountpoint . set_label ( gl . ipod_mount )
2007-03-07 11:56:46 +01:00
self . ipodIcon . set_from_icon_name ( ' gnome-dev-ipod ' , gtk . ICON_SIZE_BUTTON )
2006-12-06 21:25:26 +01:00
self . filesystemMountpoint . set_label ( gl . mp3_player_folder )
2006-06-13 23:00:31 +02:00
self . opmlURL . set_text ( gl . opml_url )
2007-01-06 14:08:23 +01:00
if gl . downloaddir :
self . chooserDownloadTo . set_filename ( gl . downloaddir )
2007-04-09 21:40:36 +02:00
if gl . torrentdir :
self . chooserBitTorrentTo . set_filename ( gl . torrentdir )
self . radio_copy_torrents . set_active ( not gl . use_gnome_bittorrent )
self . radio_gnome_bittorrent . set_active ( gl . use_gnome_bittorrent )
2006-05-01 23:12:34 +02:00
self . updateonstartup . set_active ( gl . update_on_startup )
2007-03-08 15:04:05 +01:00
self . downloadnew . set_active ( gl . download_after_update )
2007-04-09 21:40:36 +02:00
self . cbLimitDownloads . set_active ( gl . limit_rate )
self . spinLimitDownloads . set_value ( gl . limit_rate_value )
2007-05-01 22:01:51 +02:00
self . cbMaxDownloads . set_active ( gl . max_downloads_enabled )
self . spinMaxDownloads . set_value ( gl . max_downloads )
2007-04-23 17:18:31 +02:00
self . only_sync_not_played . set_active ( gl . only_sync_not_played )
2007-03-17 13:11:13 +01:00
if tagging_supported ( ) :
self . updatetags . set_active ( gl . update_tags )
else :
self . updatetags . set_sensitive ( False )
new_label = ' %s ( %s ) ' % ( self . updatetags . get_label ( ) , _ ( ' needs python-eyed3 ' ) )
self . updatetags . set_label ( new_label )
2006-12-06 21:25:26 +01:00
# device type
self . comboboxDeviceType . set_active ( 0 )
if gl . device_type == ' ipod ' :
self . comboboxDeviceType . set_active ( 1 )
elif gl . device_type == ' filesystem ' :
self . comboboxDeviceType . set_active ( 2 )
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-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 )
2006-03-31 18:20:18 +02:00
2006-04-09 18:18:47 +02:00
def update_mountpoint ( self , ipod ) :
if ipod == None or ipod . mount_point == None :
2006-12-06 21:25:26 +01:00
self . iPodMountpoint . set_label ( ' ' )
2006-04-09 18:18:47 +02:00
else :
2006-12-06 21:25:26 +01:00
self . iPodMountpoint . set_label ( ipod . mount_point )
2006-04-09 18:18:47 +02:00
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 )
2007-01-28 10:21:39 +01:00
def set_callback_finished ( self , cb ) :
self . callback_finished = cb
2006-03-31 18:20:18 +02:00
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
2006-12-20 17:38:36 +01:00
def set_download_dir ( self , new_download_dir , event = None ) :
gl = gPodderLib ( )
gl . downloaddir = self . chooserDownloadTo . get_filename ( )
2007-08-28 00:18:01 +02:00
if gl . downloaddir != self . chooserDownloadTo . get_filename ( ) :
gobject . idle_add ( self . show_message , _ ( ' There has been an error moving your downloads to the specified location. The old download directory will be used instead. ' ) , _ ( ' Error moving downloads ' ) )
2006-12-20 17:38:36 +01:00
if event :
event . set ( )
2006-01-09 00:52:40 +01:00
def on_gPodderProperties_destroy ( self , widget , * args ) :
2007-03-17 13:31:37 +01:00
self . on_btnOK_clicked ( widget , * args )
2006-01-09 00:52:40 +01:00
2006-03-30 00:07:27 +02:00
def on_comboPlayerApp_changed ( self , widget , * args ) :
# 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 ( )
2007-05-05 10:10:10 +02:00
def on_cbMaxDownloads_toggled ( self , widget , * args ) :
self . spinMaxDownloads . set_sensitive ( self . cbMaxDownloads . get_active ( ) )
def on_cbLimitDownloads_toggled ( self , widget , * args ) :
self . spinLimitDownloads . set_sensitive ( self . cbLimitDownloads . get_active ( ) )
def on_cbEnvironmentVariables_toggled ( self , widget , * args ) :
sens = not self . cbEnvironmentVariables . get_active ( )
self . httpProxy . set_sensitive ( sens )
self . ftpProxy . set_sensitive ( sens )
2006-12-06 21:25:26 +01:00
def on_comboboxDeviceType_changed ( self , widget , * args ) :
active_item = self . comboboxDeviceType . get_active ( )
# iPod
if active_item == 1 :
self . ipodLabel . show ( )
self . btn_iPodMountpoint . set_sensitive ( True )
self . btn_iPodMountpoint . show_all ( )
else :
self . ipodLabel . hide ( )
self . btn_iPodMountpoint . set_sensitive ( False )
self . btn_iPodMountpoint . hide ( )
# filesystem-based MP3 player
if active_item == 2 :
self . filesystemLabel . show ( )
self . btn_filesystemMountpoint . set_sensitive ( True )
self . btn_filesystemMountpoint . show_all ( )
else :
self . filesystemLabel . hide ( )
self . btn_filesystemMountpoint . set_sensitive ( False )
self . btn_filesystemMountpoint . hide ( )
def on_btn_iPodMountpoint_clicked ( self , widget , * args ) :
fs = gtk . FileChooserDialog ( title = _ ( ' Select iPod mountpoint ' ) , action = gtk . FILE_CHOOSER_ACTION_SELECT_FOLDER )
fs . add_button ( gtk . STOCK_CANCEL , gtk . RESPONSE_CANCEL )
fs . add_button ( gtk . STOCK_OPEN , gtk . RESPONSE_OK )
gl = gPodderLib ( )
fs . set_filename ( self . iPodMountpoint . get_label ( ) )
if fs . run ( ) == gtk . RESPONSE_OK :
self . iPodMountpoint . set_label ( fs . get_filename ( ) )
fs . destroy ( )
def on_btn_FilesystemMountpoint_clicked ( self , widget , * args ) :
fs = gtk . FileChooserDialog ( title = _ ( ' Select folder for MP3 player ' ) , action = gtk . FILE_CHOOSER_ACTION_SELECT_FOLDER )
fs . add_button ( gtk . STOCK_CANCEL , gtk . RESPONSE_CANCEL )
fs . add_button ( gtk . STOCK_OPEN , gtk . RESPONSE_OK )
gl = gPodderLib ( )
fs . set_filename ( self . filesystemMountpoint . get_label ( ) )
if fs . run ( ) == gtk . RESPONSE_OK :
self . filesystemMountpoint . set_label ( fs . get_filename ( ) )
fs . destroy ( )
2006-01-09 00:52:40 +01:00
def on_btnOK_clicked ( self , widget , * args ) :
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-12-06 21:25:26 +01:00
gl . ipod_mount = self . iPodMountpoint . get_label ( )
gl . mp3_player_folder = self . filesystemMountpoint . get_label ( )
2006-06-13 23:00:31 +02:00
gl . opml_url = self . opmlURL . get_text ( )
2006-12-20 17:38:36 +01:00
if gl . downloaddir != self . chooserDownloadTo . get_filename ( ) :
new_download_dir = self . chooserDownloadTo . get_filename ( )
2007-08-07 20:11:31 +02:00
download_dir_size = util . calculate_size ( gl . downloaddir )
download_dir_size_string = util . format_filesize ( download_dir_size , ' MB ' )
2006-12-20 17:38:36 +01:00
event = Event ( )
dlg = gtk . Dialog ( _ ( ' Moving downloads folder ' ) , self . gPodderProperties )
dlg . vbox . set_spacing ( 5 )
dlg . set_border_width ( 5 )
label = gtk . Label ( )
label . set_line_wrap ( True )
label . set_markup ( _ ( ' Moving downloads from <b> %s </b> to <b> %s </b>... ' ) % ( gl . downloaddir , new_download_dir , ) )
myprogressbar = gtk . ProgressBar ( )
# put it all together
dlg . vbox . pack_start ( label )
dlg . vbox . pack_end ( myprogressbar )
# switch windows
dlg . show_all ( )
self . gPodderProperties . hide_all ( )
# hide action area and separator line
dlg . action_area . hide ( )
dlg . set_has_separator ( False )
args = ( new_download_dir , event , )
thread = Thread ( target = self . set_download_dir , args = args )
thread . start ( )
while not event . isSet ( ) :
2007-08-07 20:11:31 +02:00
new_download_dir_size = util . calculate_size ( new_download_dir )
2006-12-20 17:38:36 +01:00
fract = ( 1.00 * new_download_dir_size ) / ( 1.00 * download_dir_size )
if fract < 0.99 :
2007-08-07 20:11:31 +02:00
myprogressbar . set_text ( _ ( ' %s of %s ' ) % ( util . format_filesize ( new_download_dir_size , ' MB ' ) , download_dir_size_string , ) )
2006-12-20 17:38:36 +01:00
else :
myprogressbar . set_text ( _ ( ' Finishing... please wait. ' ) )
myprogressbar . set_fraction ( fract )
event . wait ( 0.1 )
while gtk . events_pending ( ) :
gtk . main_iteration ( False )
dlg . destroy ( )
2007-04-09 21:40:36 +02:00
gl . torrentdir = self . chooserBitTorrentTo . get_filename ( )
gl . use_gnome_bittorrent = self . radio_gnome_bittorrent . get_active ( )
2006-05-01 23:12:34 +02:00
gl . update_on_startup = self . updateonstartup . get_active ( )
2007-03-08 15:04:05 +01:00
gl . download_after_update = self . downloadnew . get_active ( )
2007-04-09 21:40:36 +02:00
gl . limit_rate = self . cbLimitDownloads . get_active ( )
gl . limit_rate_value = self . spinLimitDownloads . get_value ( )
2007-05-01 22:01:51 +02:00
gl . max_downloads_enabled = self . cbMaxDownloads . get_active ( )
gl . max_downloads = int ( self . spinMaxDownloads . get_value ( ) )
2007-03-15 22:33:23 +01:00
gl . update_tags = self . updatetags . get_active ( )
2007-04-23 17:18:31 +02:00
gl . only_sync_not_played = self . only_sync_not_played . get_active ( )
2006-12-06 21:25:26 +01:00
device_type = self . comboboxDeviceType . get_active ( )
if device_type == 0 :
gl . device_type = ' none '
elif device_type == 1 :
gl . device_type = ' ipod '
elif device_type == 2 :
gl . device_type = ' filesystem '
2006-01-09 00:52:40 +01:00
gl . propertiesChanged ( )
self . gPodderProperties . destroy ( )
2007-01-28 10:21:39 +01:00
if self . callback_finished :
self . callback_finished ( )
2007-08-28 00:18:01 +02:00
class gPodderEpisode ( GladeWidget ) :
2006-03-31 18:20:18 +02:00
def new ( self ) :
2007-08-28 00:18:01 +02:00
services . download_status_manager . register ( ' list-changed ' , self . on_download_status_changed )
services . download_status_manager . register ( ' progress-detail ' , self . on_download_status_progress )
self . episode_title . set_markup ( ' <span weight= " bold " size= " larger " > %s </span> ' % saxutils . escape ( self . episode . title ) )
b = gtk . TextBuffer ( )
b . set_text ( strip ( self . episode . description ) )
self . episode_description . set_buffer ( b )
self . gPodderEpisode . set_title ( self . episode . title )
self . LabelDownloadLink . set_text ( self . episode . url )
self . LabelWebsiteLink . set_text ( self . episode . link )
self . labelPubDate . set_markup ( self . episode . pubDate )
self . channel_title . set_markup ( _ ( ' <i>from %s </i> ' ) % self . channel . title )
self . hide_show_widgets ( )
services . download_status_manager . request_progress_detail ( self . episode . url )
2006-03-04 21:45:01 +01:00
2007-08-27 22:28:00 +02:00
def on_btnCancel_clicked ( self , widget ) :
services . download_status_manager . cancel_by_url ( self . episode . url )
def on_gPodderEpisode_destroy ( self , widget ) :
services . download_status_manager . unregister ( ' list-changed ' , self . on_download_status_changed )
services . download_status_manager . unregister ( ' progress-detail ' , self . on_download_status_progress )
def on_download_status_changed ( self ) :
self . hide_show_widgets ( )
def on_download_status_progress ( self , url , progress , speed ) :
if url == self . episode . url :
self . progress_bar . set_fraction ( 1.0 * progress / 100.0 )
self . progress_bar . set_text ( ' Downloading: %d %% ( %s ) ' % ( progress , speed , ) )
def hide_show_widgets ( self ) :
is_downloading = services . download_status_manager . is_download_in_progress ( self . episode . url )
if is_downloading :
self . progress_bar . show_all ( )
self . btnCancel . show_all ( )
self . btnPlay . hide_all ( )
2007-08-28 00:18:01 +02:00
self . btnSaveFile . hide_all ( )
2007-08-27 22:28:00 +02:00
self . btnDownload . hide_all ( )
else :
self . progress_bar . hide_all ( )
self . btnCancel . hide_all ( )
if os . path . exists ( self . episode . local_filename ( ) ) :
self . btnPlay . show_all ( )
2007-08-28 00:18:01 +02:00
self . btnSaveFile . show_all ( )
self . btnDownload . hide_all ( )
2007-08-27 22:28:00 +02:00
else :
2007-08-28 00:18:01 +02:00
self . btnPlay . hide_all ( )
self . btnSaveFile . hide_all ( )
2007-08-27 22:28:00 +02:00
self . btnDownload . show_all ( )
2006-03-04 21:45:01 +01:00
def on_btnCloseWindow_clicked ( self , widget , * args ) :
self . gPodderEpisode . destroy ( )
2006-07-14 22:30:30 +02:00
def on_btnDownload_clicked ( self , widget , * args ) :
2006-12-09 02:59:53 +01:00
if self . download_callback :
2006-07-14 22:30:30 +02:00
self . download_callback ( )
2006-12-09 02:59:53 +01:00
def on_btnPlay_clicked ( self , widget , * args ) :
if self . play_callback :
self . play_callback ( )
self . gPodderEpisode . destroy ( )
2007-04-23 17:18:31 +02:00
def on_btnSaveFile_clicked ( self , widget , * args ) :
2007-08-22 01:00:49 +02:00
fn = self . episode . local_filename ( )
2007-04-23 17:18:31 +02:00
ext = os . path . splitext ( fn ) [ 1 ]
suggestion = self . channel . title + ' - ' + self . episode . title + ext
dlg = gtk . FileChooserDialog ( title = _ ( " Save episode as file " ) , parent = self . gPodderEpisode , action = gtk . FILE_CHOOSER_ACTION_SAVE )
dlg . set_current_name ( suggestion )
dlg . set_current_folder ( os . path . expanduser ( ' ~ ' ) )
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 [ - len ( ext ) : ] != ext :
foutname = foutname + ext
log ( ' Saving episode as: %s ' , foutname , sender = self )
try :
shutil . copyfile ( fn , foutname )
except :
log ( ' Error saving file :/ ' , sender = self )
dlg . destroy ( )
2006-03-04 21:45:01 +01:00
2007-08-28 00:18:01 +02:00
class gPodderSync ( GladeWidget ) :
def new ( self ) :
2007-03-19 20:08:00 +01:00
self . pos_overall = 0
self . max_overall = 1
self . pos_episode = 0
self . max_episode = 1
2007-03-22 17:35:51 +01:00
self . cancel_button . set_sensitive ( False )
self . sync = None
self . default_title = self . gPodderSync . get_title ( )
self . default_header = self . label_header . get_text ( )
self . default_body = self . label_text . get_text ( )
2006-04-07 03:43:06 +02:00
2007-03-19 20:08:00 +01:00
self . imageSync . set_from_icon_name ( ' gnome-dev-ipod ' , gtk . ICON_SIZE_DIALOG )
2006-04-07 03:43:06 +02:00
2007-03-22 17:35:51 +01:00
def set_sync_object ( self , sync ) :
self . sync = sync
if self . sync . can_cancel :
self . cancel_button . set_sensitive ( True )
2007-03-19 20:08:00 +01:00
def set_progress ( self , pos , max , is_overall = False , is_sub_episode = False ) :
2007-03-22 17:35:51 +01:00
pos = min ( pos , max )
2007-03-19 20:08:00 +01:00
if is_sub_episode :
fraction_episode = 1.0 * ( self . pos_episode + 1.0 * pos / max ) / self . max_episode
self . pbEpisode . set_fraction ( fraction_episode )
self . pbSync . set_fraction ( 1.0 * ( self . pos_overall + fraction_episode ) / self . max_overall )
return
if is_overall :
progressbar = self . pbSync
self . pos_overall = pos
self . max_overall = max
progressbar . set_fraction ( 1.0 * pos / max )
else :
progressbar = self . pbEpisode
self . pos_episode = pos
self . max_episode = max
progressbar . set_fraction ( 1.0 * pos / max )
self . pbSync . set_fraction ( 1.0 * ( self . pos_overall + 1.0 * pos / max ) / self . max_overall )
percent = _ ( ' %d of %d done ' ) % ( pos , max )
progressbar . set_text ( percent )
2006-04-07 03:43:06 +02:00
2007-03-22 17:35:51 +01:00
def set_status ( self , episode = None , channel = None , progressbar = None , title = None , header = None , body = None ) :
2006-04-07 03:43:06 +02:00
if episode != None :
2007-03-19 20:08:00 +01:00
self . labelEpisode . set_markup ( ' <i> %s </i> ' % episode )
2006-04-07 03:43:06 +02:00
if channel != None :
2007-03-19 20:08:00 +01:00
self . labelChannel . set_markup ( ' <i> %s </i> ' % channel )
2006-04-07 03:43:06 +02:00
if progressbar != None :
self . pbSync . set_text ( progressbar )
2007-03-22 17:35:51 +01:00
if title != None :
self . gPodderSync . set_title ( title )
else :
self . gPodderSync . set_title ( self . default_title )
if header != None :
self . label_header . set_markup ( ' <b><big> %s </big></b> ' % header )
else :
self . label_header . set_markup ( ' <b><big> %s </big></b> ' % self . default_header )
if body != None :
self . label_text . set_markup ( body )
else :
self . label_text . set_markup ( self . default_body )
2007-07-12 15:52:54 +02:00
def close ( self , success = True , access_error = False , cleaned = False , error_messages = [ ] ) :
2007-03-22 17:35:51 +01:00
if self . sync :
self . sync . cancelled = True
self . cancel_button . set_label ( gtk . STOCK_CLOSE )
self . cancel_button . set_use_stock ( True )
self . cancel_button . set_sensitive ( True )
self . gPodderSync . set_resizable ( True )
self . pbSync . hide_all ( )
self . pbEpisode . hide_all ( )
self . labelChannel . hide_all ( )
self . labelEpisode . hide_all ( )
self . gPodderSync . set_resizable ( False )
if success and not cleaned :
title = _ ( ' Synchronization finished ' )
header = _ ( ' Copied Podcasts ' )
body = _ ( ' The selected episodes have been copied to your device. You can now unplug the device. ' )
elif access_error :
title = _ ( ' Synchronization error ' )
header = _ ( ' Cannot access device ' )
body = _ ( ' Make sure your device is connected to your computer and mounted. Please also make sure you have set the correct path to your device in the preferences dialog. ' )
elif cleaned :
title = _ ( ' Device cleaned ' )
header = _ ( ' Podcasts removed ' )
body = _ ( ' Synchronized Podcasts have been removed from your device. ' )
2007-07-12 15:52:54 +02:00
elif len ( error_messages ) :
title = _ ( ' Synchronization error ' )
header = _ ( ' An error has occurred ' )
body = ' \n ' . join ( error_messages )
2007-03-22 17:35:51 +01:00
else :
title = _ ( ' Synchronization aborted ' )
header = _ ( ' Aborted ' )
body = _ ( ' The synchronization progress has been interrupted by the user. Please retry synchronization at a later time. ' )
self . gPodderSync . set_title ( title )
self . label_header . set_markup ( ' <big><b> %s </b></big> ' % header )
self . label_text . set_text ( body )
2006-04-07 03:43:06 +02:00
def on_gPodderSync_destroy ( self , widget , * args ) :
2006-11-17 15:26:10 +01:00
pass
2006-04-07 03:43:06 +02:00
2007-03-22 17:35:51 +01:00
def on_cancel_button_clicked ( self , widget , * args ) :
if self . sync :
if self . sync . cancelled :
self . gPodderSync . destroy ( )
else :
self . sync . cancelled = True
self . cancel_button . set_sensitive ( False )
else :
self . gPodderSync . destroy ( )
2006-04-07 03:43:06 +02:00
2007-08-28 00:18:01 +02:00
class gPodderOpmlLister ( GladeWidget ) :
2006-06-13 23:00:31 +02:00
def new ( self ) :
# initiate channels list
self . channels = [ ]
self . callback_for_channel = None
2007-07-11 20:12:02 +02:00
self . callback_finished = None
2006-06-13 23:00:31 +02:00
togglecell = gtk . CellRendererToggle ( )
togglecell . set_property ( ' activatable ' , True )
togglecell . connect ( ' toggled ' , self . callback_edited )
2007-07-11 20:12:02 +02:00
togglecolumn = gtk . TreeViewColumn ( ' ' , togglecell , active = 0 )
2006-06-13 23:00:31 +02:00
titlecell = gtk . CellRendererText ( )
2007-07-11 20:12:02 +02:00
titlecolumn = gtk . TreeViewColumn ( _ ( ' Channel ' ) , titlecell , markup = 1 )
2006-06-13 23:00:31 +02:00
for itemcolumn in ( togglecolumn , titlecolumn ) :
self . treeviewChannelChooser . append_column ( itemcolumn )
def callback_edited ( self , cell , path ) :
model = self . treeviewChannelChooser . get_model ( )
2007-07-11 20:12:02 +02:00
url = model [ path ] [ 2 ]
2006-06-13 23:00:31 +02:00
2007-07-11 20:12:02 +02:00
model [ path ] [ 0 ] = not model [ path ] [ 0 ]
if model [ path ] [ 0 ] :
2006-06-13 23:00:31 +02:00
self . channels . append ( url )
else :
self . channels . remove ( url )
2007-07-11 20:12:02 +02:00
self . btnOK . set_sensitive ( bool ( len ( self . channels ) ) )
def thread_func ( self ) :
2007-08-19 16:28:24 +02:00
url = self . entryURL . get_text ( )
importer = opml . Importer ( url )
model = importer . get_model ( )
gobject . idle_add ( self . treeviewChannelChooser . set_model , model )
2007-07-11 20:12:02 +02:00
gobject . idle_add ( self . labelStatus . set_label , ' ' )
gobject . idle_add ( self . btnDownloadOpml . set_sensitive , True )
gobject . idle_add ( self . entryURL . set_sensitive , True )
gobject . idle_add ( self . treeviewChannelChooser . set_sensitive , True )
self . channels = [ ]
def get_channels_from_url ( self , url , callback_for_channel = None , callback_finished = None ) :
if callback_for_channel :
self . callback_for_channel = callback_for_channel
if callback_finished :
self . callback_finished = callback_finished
self . labelStatus . set_label ( _ ( ' Downloading, please wait... ' ) )
self . entryURL . set_text ( url )
self . btnDownloadOpml . set_sensitive ( False )
self . entryURL . set_sensitive ( False )
self . btnOK . set_sensitive ( False )
self . treeviewChannelChooser . set_sensitive ( False )
Thread ( target = self . thread_func ) . start ( )
2006-06-13 23:00:31 +02:00
def on_gPodderOpmlLister_destroy ( self , widget , * args ) :
2006-11-17 15:26:10 +01:00
pass
2006-06-13 23:00:31 +02:00
2007-07-11 20:12:02 +02:00
def on_btnDownloadOpml_clicked ( self , widget , * args ) :
self . get_channels_from_url ( self . entryURL . get_text ( ) )
2006-06-13 23:00:31 +02:00
def on_btnOK_clicked ( self , widget , * args ) :
self . gPodderOpmlLister . destroy ( )
2007-07-11 20:12:02 +02:00
2006-06-13 23:00:31 +02:00
# add channels that have been selected
for url in self . channels :
2007-07-11 20:12:02 +02:00
if self . callback_for_channel :
self . callback_for_channel ( url )
if self . callback_finished :
self . callback_finished ( )
2006-06-13 23:00:31 +02:00
def on_btnCancel_clicked ( self , widget , * args ) :
self . gPodderOpmlLister . destroy ( )
2005-11-21 19:21:25 +01:00
2007-08-28 00:18:01 +02:00
def main ( ) :
2006-04-03 22:59:10 +02:00
gobject . threads_init ( )
2007-03-25 21:55:28 +02:00
gtk . window_set_default_icon_name ( ' gpodder ' )
2005-11-21 19:21:25 +01:00
2007-08-28 00:18:01 +02:00
gPodder ( ) . run ( )
2005-11-21 19:21:25 +01:00