Thomas
I have found a bug in the code I sent you, you cannot delete a single
unlocked episode!
As I am not sure how to create a patch of a patch, I created a patch
file for gui.py from rev 484 so it includes all previous changes. But
just in case I have created the patch incorrectly, the relevant section
is in function on_btnDownloadedDelete_clicked, and the following line is
added prior to counting the number of locked episodes.
+ if selection.count_selected_rows() > 1:
Basically the logic to handle multiple selections stopped a single
selection from working! Sorry!
Paul
On Mon, 2007-12-10 at 00:23 +0100, Thomas Perl wrote:
> Hello, Paul!
>
> Paul Rudkin wrote:
> > Since the introduction of the new episode selection dialog and the
> > option to remove old episodes I have been wanting to have the ability to
> > lock episodes so that they cannot be deleted. This is because some
> > podcasts I would like to keep and I don't want to have to deselect them
> > each time in the remove old episodes dialog selection list.
> >
> > I have attached a patch that achieves this, you can lock/unlock episodes
> > in all the ways that you can mark them as played, unplayed etc. They
> > will have a 'padlock' as an icon to signify that the episode is locked.
> >
> > I would appreciate your feedback and comments, and if positive perhaps
> > this can be rolled into the next release?
>
> A great idea, and the patch is very good, only had to change some small
> parts and re-factor and re-fine the patch at certain spots. I've
> attached your patch with some changes I've made. Please apply this patch
> to your working copy and tell me how it works for you.
>
> After I've got some feedback for your patch here, I'd be glad to merge
> it into our SVN repository.
>
> Thanks,
> Thomas
> _______________________________________________
> gpodder-devel mailing list
> [email protected]
> https://lists.berlios.de/mailman/listinfo/gpodder-devel
Index: /home/paul/Source/gpodder-dev/gPodder/src/gpodder/gui.py
===================================================================
--- /home/paul/Source/gpodder-dev/gPodder/src/gpodder/gui.py (revision 484)
+++ /home/paul/Source/gpodder-dev/gPodder/src/gpodder/gui.py (working copy)
@@ -430,10 +430,13 @@
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)
- item = gtk.ImageMenuItem( _('Remove %s') % episode_title)
- 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)
+
+ is_locked = gPodderLib().history_is_locked( first_url)
+ if not is_locked:
+ item = gtk.ImageMenuItem( _('Remove %s') % episode_title)
+ 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)
if can_download:
item = gtk.ImageMenuItem( _('Download %s') % episode_title)
@@ -474,6 +477,19 @@
item.connect( 'activate', lambda w: self.on_item_toggle_played_activate( w, False, True))
menu.append( item)
+ menu.append(gtk.SeparatorMenuItem())
+ is_locked = gPodderLib().history_is_locked( first_url)
+ if is_locked:
+ item = gtk.ImageMenuItem( _('Unlock %s') % episode_title)
+ item.set_image( gtk.image_new_from_stock( gtk.STOCK_DIALOG_AUTHENTICATION, gtk.ICON_SIZE_MENU))
+ item.connect( 'activate', self.on_item_toggle_lock_activate)
+ menu.append( item)
+ else:
+ item = gtk.ImageMenuItem( _('Lock %s') % episode_title)
+ item.set_image( gtk.image_new_from_stock( gtk.STOCK_DIALOG_AUTHENTICATION, gtk.ICON_SIZE_MENU))
+ item.connect( 'activate', self.on_item_toggle_lock_activate)
+ menu.append( item)
+
if can_cancel:
item = gtk.ImageMenuItem( _('_Cancel download'))
item.set_image( gtk.image_new_from_stock( gtk.STOCK_STOP, gtk.ICON_SIZE_MENU))
@@ -866,7 +882,7 @@
selected = []
for channel in self.channels:
for episode in channel:
- if episode.is_downloaded():
+ if episode.is_downloaded() and not episode.is_locked():
episodes.append( episode)
selected.append( channel.is_played( episode))
@@ -891,6 +907,13 @@
self.for_each_selected_episode_url( callback)
+ def on_item_toggle_lock_activate( self, widget, toggle = True, new_value = False):
+ if toggle:
+ callback = lambda url: gPodderLib().history_mark_locked( url, not gPodderLib().history_is_locked( url))
+ else:
+ callback = lambda url: gPodderLib().history_mark_locked( url, new_value)
+
+ self.for_each_selected_episode_url( callback)
def on_itemUpdate_activate(self, widget, *args):
if self.channels:
self.update_feed_cache()
@@ -1275,7 +1298,14 @@
return
if selection.count_selected_rows() == 1:
- title = _('Remove %s?') % model.get_value( model.get_iter( paths[0]), 1)
+ episode_title = saxutils.escape(model.get_value(model.get_iter(paths[0]), 1))
+ locked = gPodderLib().history_is_locked(model.get_value(model.get_iter(paths[0]), 0))
+ if locked:
+ title = _('%s is locked') % episode_title
+ message = _('You cannot delete this locked episode. You must unlock it before you can delete it.')
+ self.notification(message, title)
+ return
+ title = _('Remove %s?') % episode_title
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.")
else:
title = _('Remove %d episodes?') % selection.count_selected_rows()
@@ -1280,7 +1310,23 @@
else:
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.')
-
+
+ if selection.count_selected_rows() > 1:
+ locked_count = 0
+ for path in paths:
+ url = model.get_value(model.get_iter(path), 0)
+ if gPodderLib().history_is_locked(url):
+ locked_count += 1
+
+ if locked_count > 0 and selection.count_selected_rows() > locked_count:
+ title = _('Remove %d out of %d episodes?') % (selection.count_selected_rows() - locked_count, selection.count_selected_rows())
+ message = ('The selection contains locked episodes. These will not be deleted. If you want to listen to any of these episodes again, then you will have to re-download them.')
+ else:
+ title = _('Episodes are locked')
+ message = _('The selected episodes are locked. Please unlock the episodes that you want to delete before trying to delete them.')
+ self.notification( message, title)
+ return
+
# if user confirms deletion, let's remove some stuff ;)
if self.show_confirmation( message, title):
try:
_______________________________________________
gpodder-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/gpodder-devel