Code cleanups, showMessage function, getPodcastFilename moved to podcastChannel
git-svn-id: svn://svn.berlios.de/gpodder@50 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
parent
0d6dd9a597
commit
a9277c6d74
|
@ -4,6 +4,10 @@ Wed, 29 Mar 2006 13:29:51 +0200 <thp@perli.net>
|
|||
* localDB cache is cleared when a download is completed
|
||||
* Applied patch from Alain Tauch (bad URL "Add channel.." fix)
|
||||
* Updated AUTHORS, TODO, contributors list, pushed version date
|
||||
* Moved getPodcastFilename/podcastFilenameExists into podcastChannel
|
||||
* Added showMessage function to main gPodder window
|
||||
* Use showMessage function to show error messages GUI-wise
|
||||
* Removed orphaned code parts for "not_implemented" function
|
||||
|
||||
Tue, 28 Mar 2006 20:30:00 +0200 <thp@perli.net>
|
||||
* Disable some menu items when not on "available" tab
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
|
||||
.TH GPODDER "1" "February 2006" "gpodder 0.6-svn 2006-02-26" "User Commands"
|
||||
.TH GPODDER "1" "March 2006" "gpodder 0.6-svn 2006-03-29" "User Commands"
|
||||
.SH NAME
|
||||
gpodder \- manual page for gpodder 0.6-svn 2006-02-26
|
||||
gpodder \- manual page for gpodder 0.6-svn 2006-03-29
|
||||
.SH DESCRIPTION
|
||||
usage: gpodder [options] arg1 arg2
|
||||
.PP
|
||||
|
|
|
@ -82,7 +82,7 @@ def run():
|
|||
|
||||
for channel in updated_channels:
|
||||
for item in channel.items:
|
||||
filename = gPodderLib().getPodcastFilename(channel, item.url)
|
||||
filename = channel.getPodcastFilename( item.url)
|
||||
if not channel.isDownloaded( item):
|
||||
while not pool.may_download():
|
||||
time.sleep(3)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# Python module src/gpodder/gpodder.py
|
||||
# Autogenerated from gpodder.glade
|
||||
# Generated on Wed Mar 29 13:29:26 2006
|
||||
# Generated on Wed Mar 29 14:07:45 2006
|
||||
|
||||
# Warning: Do not modify any context comment such as #--
|
||||
# They are required to keep user's code
|
||||
|
@ -214,11 +214,11 @@ class Gpodder(SimpleGladeApp):
|
|||
dlg.destroy()
|
||||
print "probably no feeds or channels found"
|
||||
|
||||
def not_implemented( self, message = "some unknown function"):
|
||||
def showMessage( self, message = "some unknown function", title = "gPodder message"):
|
||||
dlg = gtk.MessageDialog( self.gPodder, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK)
|
||||
dlg.set_title( "Release early, release often!")
|
||||
dlg.set_markup( "<big>Woohoo! You've found a secret..</big>\n\nSorry, but due to the fact that this is just a pre-release, the lazy programmer has just forgotten to implement\n\n<b>" + message + "</b>\n\nHe promises he will in the next release!")
|
||||
|
||||
dlg.set_title( title)
|
||||
dlg.set_markup( message)
|
||||
|
||||
dlg.run()
|
||||
dlg.destroy()
|
||||
|
||||
|
@ -317,7 +317,6 @@ class Gpodder(SimpleGladeApp):
|
|||
def on_itemPreferences_activate(self, widget, *args):
|
||||
if libgpodder.isDebugging():
|
||||
print "on_itemPreferences_activate called with self.%s" % widget.get_name()
|
||||
#self.not_implemented( "the preferences dialog")
|
||||
Gpodderproperties()
|
||||
#-- Gpodder.on_itemPreferences_activate }
|
||||
|
||||
|
@ -325,7 +324,9 @@ class Gpodder(SimpleGladeApp):
|
|||
def on_itemAddChannel_activate(self, widget, *args):
|
||||
if libgpodder.isDebugging():
|
||||
print "on_itemAddChannel_activate called with self.%s" % widget.get_name()
|
||||
result = Gpodderchannel().requestURL()
|
||||
ch = Gpodderchannel()
|
||||
ch.entryURL.set_text( "http://")
|
||||
result = ch.requestURL()
|
||||
if result != None and result != "" and (result[:4] == "http" or result[:3] == "ftp"):
|
||||
if libgpodder.isDebugging():
|
||||
print "will ADD: " + result
|
||||
|
@ -333,6 +334,7 @@ class Gpodder(SimpleGladeApp):
|
|||
channel_new = podcastChannel( result)
|
||||
channel_new.shortname = "__unknown__"
|
||||
self.channels.append( channel_new)
|
||||
channels_should_be = len( self.channels)
|
||||
|
||||
# fetch metadata for that channel
|
||||
gPodderChannelWriter().write( self.channels)
|
||||
|
@ -342,15 +344,21 @@ class Gpodder(SimpleGladeApp):
|
|||
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?")
|
||||
|
||||
self.updateComboBox()
|
||||
self.statusLabel.set_text( "")
|
||||
else:
|
||||
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.")
|
||||
#-- Gpodder.on_itemAddChannel_activate }
|
||||
|
||||
#-- Gpodder.on_itemEditChannel_activate {
|
||||
def on_itemEditChannel_activate(self, widget, *args):
|
||||
if libgpodder.isDebugging():
|
||||
print "on_itemEditChannel_activate called with self.%s" % widget.get_name()
|
||||
# IMPLEMENTED 20051208 self.not_implemented( "the edit channel dialog")
|
||||
active = self.active_channel
|
||||
url_old = self.channels[active].url
|
||||
title_old = self.channels[active].title
|
||||
|
@ -395,14 +403,13 @@ class Gpodder(SimpleGladeApp):
|
|||
self.channels = gPodderChannelReader().read( False)
|
||||
self.updateComboBox()
|
||||
except:
|
||||
print "could not delete - nothing selected, probably"
|
||||
self.showMessage( "Could not delete channel.\nProbably no channel is selected.")
|
||||
#-- Gpodder.on_itemRemoveChannel_activate }
|
||||
|
||||
#-- Gpodder.on_itemExportChannels_activate {
|
||||
def on_itemExportChannels_activate(self, widget, *args):
|
||||
if libgpodder.isDebugging():
|
||||
print "on_itemExportChannels_activate called with self.%s" % widget.get_name()
|
||||
#self.not_implemented( "the export feature") IMPLEMENTED AS OF 20051208
|
||||
dlg = gtk.FileChooserDialog( title="Export to OPML...", parent = None, action = gtk.FILE_CHOOSER_ACTION_SAVE)
|
||||
dlg.add_button( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
|
||||
dlg.add_button( gtk.STOCK_SAVE, gtk.RESPONSE_OK)
|
||||
|
@ -474,7 +481,7 @@ class Gpodder(SimpleGladeApp):
|
|||
|
||||
current_channel = self.channels[self.active_channel]
|
||||
current_podcast = current_channel.items[self.active_item]
|
||||
filename = gPodderLib().getPodcastFilename( current_channel, current_podcast.url)
|
||||
filename = current_channel.getPodcastFilename( current_podcast.url)
|
||||
if widget.get_name() == "treeAvailable":
|
||||
Gpodderepisode().set_episode( current_podcast)
|
||||
return
|
||||
|
@ -482,10 +489,7 @@ class Gpodder(SimpleGladeApp):
|
|||
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:
|
||||
message_dialog = gtk.MessageDialog( self.gPodder, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK)
|
||||
message_dialog.set_markup( "<big><b>Already downloaded</b></big>\n\nYou have already downloaded this episode.\nOr you are currently downloading it.")
|
||||
message_dialog.run()
|
||||
message_dialog.destroy()
|
||||
self.showMessage( "<big><b>Already downloaded</b></big>\n\nYou have already downloaded this episode.\nOr you are currently downloading it.")
|
||||
#-- Gpodder.on_treeAvailable_row_activated }
|
||||
|
||||
#-- Gpodder.on_btnDownload_clicked {
|
||||
|
@ -504,6 +508,8 @@ class Gpodder(SimpleGladeApp):
|
|||
if selection_iter != None:
|
||||
url = self.download_status_manager.tree_model.get_value( selection_iter, 3)
|
||||
self.download_status_manager.cancel_by_url( url)
|
||||
else:
|
||||
self.showMessage( "No episode selected - nothing cancelled.")
|
||||
#-- Gpodder.on_treeDownloads_row_activated }
|
||||
|
||||
#-- Gpodder.on_btnCancelDownloadStatus_clicked {
|
||||
|
@ -558,15 +564,19 @@ class Gpodder(SimpleGladeApp):
|
|||
|
||||
selection_tuple = self.treeDownloaded.get_selection().get_selected()
|
||||
selection_iter = selection_tuple[1]
|
||||
url = self.treeDownloaded.get_model().get_value( selection_iter, 0)
|
||||
title = self.treeDownloaded.get_model().get_value( selection_iter, 1)
|
||||
filename_final = localDB().getLocalFilenameByPodcastURL( channel_filename, url)
|
||||
|
||||
current_channel = self.downloaded_channels[self.comboDownloaded.get_active()]
|
||||
if current_channel.deleteDownloadedItemByUrlAndTitle( url, title):
|
||||
gPodderLib().deleteFilename( filename_final)
|
||||
self.updateComboBox()
|
||||
self.updateDownloadedComboBox()
|
||||
try:
|
||||
url = self.treeDownloaded.get_model().get_value( selection_iter, 0)
|
||||
title = self.treeDownloaded.get_model().get_value( selection_iter, 1)
|
||||
filename_final = localDB().getLocalFilenameByPodcastURL( channel_filename, url)
|
||||
current_channel = self.downloaded_channels[self.comboDownloaded.get_active()]
|
||||
if current_channel.deleteDownloadedItemByUrlAndTitle( url, title):
|
||||
gPodderLib().deleteFilename( filename_final)
|
||||
# clear local db cache so we can re-read it
|
||||
self.ldb.clear_cache()
|
||||
self.updateComboBox()
|
||||
self.updateDownloadedComboBox()
|
||||
except:
|
||||
self.showMessage( "Could not delete selected item.\nHave you selected an episode to delete?")
|
||||
#-- Gpodder.on_btnDownloadedDelete_clicked }
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# Python module src/gpodder/gpodder.py
|
||||
# Autogenerated from gpodder.glade
|
||||
# Generated on Wed Mar 29 13:29:26 2006
|
||||
# Generated on Wed Mar 29 14:07:45 2006
|
||||
|
||||
# Warning: Do not modify any context comment such as #--
|
||||
# They are required to keep user's code
|
||||
|
|
|
@ -19,7 +19,6 @@ from xml.sax.saxutils import DefaultHandler
|
|||
from xml.sax import make_parser
|
||||
from string import strip
|
||||
from os.path import expanduser
|
||||
from os.path import basename
|
||||
from os.path import exists
|
||||
from os.path import dirname
|
||||
from os import mkdir
|
||||
|
@ -137,19 +136,6 @@ class gPodderLib( object):
|
|||
# silently ignore
|
||||
pass
|
||||
|
||||
def getPodcastFilename( self, channel, url):
|
||||
# strip question mark (and everything behind it), fix %20 errors
|
||||
filename = basename( url).replace( "%20", " ")
|
||||
indexOfQuestionMark = filename.rfind( "?")
|
||||
if indexOfQuestionMark != -1:
|
||||
filename = filename[:indexOfQuestionMark]
|
||||
# end strip questionmark
|
||||
channel.download_dir
|
||||
return channel.save_dir + filename
|
||||
|
||||
def podcastFilenameExists( self, channel, url):
|
||||
return exists( self.getPodcastFilename( channel, url))
|
||||
|
||||
class gPodderChannelWriter( object):
|
||||
def write( self, channels):
|
||||
filename = gPodderLib().getChannelsFilename()
|
||||
|
|
|
@ -104,7 +104,7 @@ class localDB( object):
|
|||
rdb.parseXML( channel_filename)
|
||||
self.localdbs[channel_filename] = rdb
|
||||
|
||||
return gPodderLib().getPodcastFilename( rdb.channel, url)
|
||||
return rdb.channel.getPodcastFilename( url)
|
||||
|
||||
def clear_cache( self):
|
||||
# clear cached data, so it is re-read next time
|
||||
|
|
|
@ -18,6 +18,7 @@ import htmlentitydefs
|
|||
import libgpodder
|
||||
|
||||
from os.path import exists
|
||||
from os.path import basename
|
||||
|
||||
from liblocdbwriter import writeLocalDB
|
||||
from liblocdbreader import readLocalDB
|
||||
|
@ -88,7 +89,7 @@ class podcastChannel(object):
|
|||
print '-- Item: "' + item.title + '"'
|
||||
|
||||
def isDownloaded( self, item):
|
||||
return libgpodder.gPodderLib().podcastFilenameExists( self, item.url)
|
||||
return self.podcastFilenameExists( item.url)
|
||||
|
||||
def getItemsModel( self):
|
||||
new_model = gtk.ListStore( gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, gobject.TYPE_STRING)
|
||||
|
@ -171,7 +172,20 @@ class podcastChannel(object):
|
|||
return self.save_dir + "index.xml"
|
||||
|
||||
index_file = property(fget=get_index_file)
|
||||
|
||||
|
||||
def getPodcastFilename( self, url):
|
||||
# strip question mark (and everything behind it), fix %20 errors
|
||||
filename = basename( url).replace( "%20", " ")
|
||||
indexOfQuestionMark = filename.rfind( "?")
|
||||
if indexOfQuestionMark != -1:
|
||||
filename = filename[:indexOfQuestionMark]
|
||||
# end strip questionmark
|
||||
self.download_dir
|
||||
return self.save_dir + filename
|
||||
|
||||
def podcastFilenameExists( self, url):
|
||||
return exists( self.getPodcastFilename( url))
|
||||
|
||||
def deleteDownloadedItemByUrlAndTitle(self, url, title):
|
||||
if libgpodder.isDebugging():
|
||||
print "deleteDownloadedItemByUrlAndTitle: " + title + " (" + url + ")"
|
||||
|
|
Loading…
Reference in New Issue