Hello, Jérôme!
Jérôme Chabod wrote:
> I'm quite new with python and glade, and as a exercice, I tried to
> implement the "delete episodes in gPodder after sync to MP3 player"
> feature as I really need it.
After reviewing your patch, I'd say pretty good for a Python and Glade
newbie. I've changed some things, but most of your patch was fine :)
> You'll find a patch in attachment and inline after this mail (I hope it
> is OK), the patch apply to revision 495 from today. Fill free to include
> it into the svn or to throw it away if you think so, but comments are
> welcome, I could send you more patches on the future.
The patch was okay, but it was ~400k. Next time when the patch is
equally large, you might want to gzip it before attaching it to the
mail. If the patch is just some kbs, you can attach it directly.
I've attached a modified and stripped-down version of your patch in this
e-mail. If you want to try it, please svn revert -R your gPodder working
copy (possibly after backing up your changes with "svn diff >
~/gpodder-patch-backup") and then apply the attached patch.
My modifications re-arrange the widgets in the glade file a bit and also
make gPodder use the delete_from_disk() method of podcastItem. The
deletion is also not carried out before the episode gets copied to the
MP3 player/iPod, but only after a successful sync (this way, the episode
does not get deleted when sync fails for whatever reason).
The configuration option and GUI glue-ing was done very well, I didn't
have to change anything there.
In the preferences dialog, I also hided the "on_sync_leave" and
"label_after_sync" widgets when "None" was selected in the device
combobox, so all sync options (and their labels) are hidden when the
user has no device configured.
> I choose to replace the "mark as played" check box with 3 radio boxes
> ("leave episodes", "mark episodes as played", "delete episodes from
> download directory") since only one of this 3 actions can be performed
> simutaneously, but I might be wrong.
A very good idea! Even the configuration glue works with the
radiobuttons, so the configuration items are always set correctly and
the radio buttons perform their function well.
I'll give the patch some time to be reviewed here on the list, and after
that, I'm going to merge it into our SVN repository. Thank you very much
for your time and effort and for the patch :) And of course, you are
welcome to send in more patches if you decide to.
Thanks,
Thomas
Index: src/gpodder/config.py
===================================================================
--- src/gpodder/config.py (revision 497)
+++ src/gpodder/config.py (working copy)
@@ -59,6 +59,7 @@
'update_tags': ( bool, False ),
'fssync_channel_subfolders': ( bool, True ),
'on_sync_mark_played': ( bool, False ),
+ 'on_sync_delete': ( bool, False ),
'auto_remove_old_episodes': ( bool, False ),
# Settings that are updated directly in code
Index: src/gpodder/libpodcasts.py
===================================================================
--- src/gpodder/libpodcasts.py (revision 497)
+++ src/gpodder/libpodcasts.py (working copy)
@@ -598,7 +598,10 @@
return libgpodder.gPodderLib().history_is_locked(self.url)
def delete_from_disk( self):
- self.channel.delete_episode_by_url( self.url)
+ try:
+ self.channel.delete_episode_by_url( self.url)
+ except:
+ log('Cannot delete episode from disk: %s', self.title, traceback=True, sender=self)
def local_filename( self):
extension = util.file_extension_from_url( self.url)
Index: src/gpodder/libipodsync.py
===================================================================
--- src/gpodder/libipodsync.py (revision 497)
+++ src/gpodder/libipodsync.py (working copy)
@@ -141,13 +141,19 @@
if episodes == None:
episodes = channel
+ gl = libgpodder.gPodderLib()
max = len(episodes)
for pos, episode in enumerate(episodes):
if self.cancelled:
return False
self.set_progress( pos, max)
if episode.is_downloaded() and episode.file_type() in ( 'audio', 'video' ) and (sync_played_episodes or not episode.is_played()):
- if not self.add_episode_from_channel( channel, episode):
+ added = self.add_episode_from_channel( channel, episode)
+ if added:
+ if gl.config.on_sync_delete:
+ log('Removing episode after transfer: %s', episode.title, sender=self)
+ episode.delete_from_disk()
+ else:
return False
self.set_progress( pos, max)
Index: src/gpodder/gui.py
===================================================================
--- src/gpodder/gui.py (revision 497)
+++ src/gpodder/gui.py (working copy)
@@ -1498,6 +1498,7 @@
gl.config.connect_gtk_togglebutton( 'only_sync_not_played', self.only_sync_not_played)
gl.config.connect_gtk_togglebutton( 'fssync_channel_subfolders', self.cbChannelSubfolder)
gl.config.connect_gtk_togglebutton( 'on_sync_mark_played', self.on_sync_mark_played)
+ gl.config.connect_gtk_togglebutton( 'on_sync_delete', self.on_sync_delete)
gl.config.connect_gtk_spinbutton( 'max_downloads', self.spinMaxDownloads)
gl.config.connect_gtk_togglebutton( 'max_downloads_enabled', self.cbMaxDownloads)
gl.config.connect_gtk_spinbutton( 'limit_rate_value', self.spinLimitDownloads)
@@ -1625,7 +1626,8 @@
# None
sync_widgets = ( self.only_sync_not_played, self.labelSyncOptions,
self.imageSyncOptions, self. separatorSyncOptions,
- self.on_sync_mark_played )
+ self.on_sync_mark_played, self.on_sync_delete,
+ self.on_sync_leave, self.label_after_sync, )
for widget in sync_widgets:
if active_item == 0:
widget.hide_all()
Index: data/gpodder.glade
===================================================================
--- data/gpodder.glade (revision 497)
+++ data/gpodder.glade (working copy)
@@ -690,7 +690,7 @@
<property name="visible">True</property>
<property name="label" translatable="yes">Documentation Wiki</property>
<property name="use_underline">True</property>
- <signal name="activate" handler="on_wiki_activate" last_modification_time="Thu, 13 Dec 2007 08:01:04 +0100"/>
+ <signal name="activate" handler="on_wiki_activate" last_modification_time="Thu, 13 Dec 2007 08:01:04 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2871">
@@ -3516,40 +3516,134 @@
</child>
<child>
- <widget class="GtkCheckButton" id="on_sync_mark_played">
+ <widget class="GtkHSeparator" id="separatorSyncOptions">
<property name="visible">True</property>
- <property name="tooltip" translatable="yes">If checked, gPodder will update the status of the episode as if it has been played locally after copying it to your device</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Mark episodes as played after synchronization</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">False</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
</widget>
<packing>
- <property name="left_attach">1</property>
+ <property name="left_attach">0</property>
<property name="right_attach">4</property>
- <property name="top_attach">7</property>
- <property name="bottom_attach">8</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="y_padding">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkHSeparator" id="separatorSyncOptions">
+ <widget class="GtkTable" id="table11">
<property name="visible">True</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">5</property>
+ <property name="column_spacing">10</property>
+
+ <child>
+ <widget class="GtkLabel" id="label_after_sync">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">After synchronisation:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkRadioButton" id="on_sync_leave">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Do nothing</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkRadioButton" id="on_sync_delete">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Delete episode from gPodder</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">on_sync_leave</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkRadioButton" id="on_sync_mark_played">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">If checked, gPodder will update the status of the episode as if it has been played locally after copying it to your device</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Mark episode as played</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">on_sync_leave</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
</widget>
<packing>
- <property name="left_attach">0</property>
+ <property name="left_attach">1</property>
<property name="right_attach">4</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
- <property name="y_padding">3</property>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ <property name="y_padding">2</property>
<property name="x_options">fill</property>
- <property name="y_options"></property>
+ <property name="y_options">fill</property>
</packing>
</child>
</widget>
_______________________________________________
gpodder-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/gpodder-devel