Maemo 5: Add OPML export to settings (Maemo bug 11504)

Conflicts:

	src/gpodder/gui.py
This commit is contained in:
Thomas Perl 2011-02-25 16:31:46 +01:00
parent 6ec217c876
commit ddf6b3c450
4 changed files with 39 additions and 5 deletions

View file

@ -217,6 +217,27 @@
<signal name="value-changed" handler="on_expiration_value_changed"/>
</object>
</child>
<child>
<object class="GtkLabel" id="placeholder4">
<property name="label"></property>
<property name="visible">True</property>
</object>
</child>
<child>
<object class="GtkFrame" id="frame_opml">
<property name="label" translatable="yes">Subscriptions</property>
<property name="visible">True</property>
</object>
</child>
<child>
<object class="HildonButton" id="button_export_opml">
<property name="title" translatable="yes">Export to OPML file</property>
<property name="arrangement">HILDON_BUTTON_ARRANGEMENT_VERTICAL</property>
<property name="size">HILDON_SIZE_FINGER_HEIGHT</property>
<property name="visible">True</property>
<signal name="clicked" handler="on_button_export_opml_clicked"/>
</object>
</child>
</object>
</child>
</object>

View file

@ -183,6 +183,9 @@ class gPodderPreferences(BuilderWidget):
self.gPodderPreferences.show_all()
def on_button_export_opml_clicked(self, button):
self.on_itemExportChannels_activate(button)
def on_picker_orientation_value_changed(self, *args):
self._config.rotation_mode = self.touch_selector_orientation.get_active(0)

View file

@ -3254,7 +3254,8 @@ class gPodder(BuilderWidget, dbus.service.Object):
user_apps_reader=self.user_apps_reader, \
parent_window=self.main_window, \
mygpo_client=self.mygpo_client, \
on_send_full_subscriptions=self.on_send_full_subscriptions)
on_send_full_subscriptions=self.on_send_full_subscriptions, \
on_itemExportChannels_activate=self.on_itemExportChannels_activate)
# Initial message to relayout window (in case it's opened in portrait mode
self.preferences_dialog.on_window_orientation_changed(self._last_orientation)
@ -3438,18 +3439,21 @@ class gPodder(BuilderWidget, dbus.service.Object):
self.show_message(message, title, widget=self.treeChannels)
return
if gpodder.ui.desktop or gpodder.ui.fremantle:
# FIXME: Hildonization on Fremantle
if gpodder.ui.desktop:
dlg = gtk.FileChooserDialog(title=_('Export to OPML'), parent=self.gPodder, action=gtk.FILE_CHOOSER_ACTION_SAVE)
dlg.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
dlg.add_button(gtk.STOCK_SAVE, gtk.RESPONSE_OK)
elif gpodder.ui.maemo:
dlg = gobject.new(hildon.FileChooserDialog, \
action=gtk.FILE_CHOOSER_ACTION_SAVE)
dlg.set_title(_('Export to OPML'))
dlg.set_filter(self.get_opml_filter())
response = dlg.run()
if response == gtk.RESPONSE_OK:
filename = dlg.get_filename()
dlg.destroy()
exporter = opml.Exporter( filename)
if exporter.write(self.channels):
if filename is not None and exporter.write(self.channels):
count = len(self.channels)
title = N_('%(count)d subscription exported', '%(count)d subscriptions exported', count) % {'count':count}
self.show_message(_('Your podcast list has been successfully exported.'), title, widget=self.treeChannels)

View file

@ -110,7 +110,10 @@ class Exporter(object):
FEED_TYPE = 'rss'
def __init__( self, filename):
if filename.endswith( '.opml') or filename.endswith( '.xml'):
if filename is None:
log('OPML Exporter with None filename', sender=self)
self.filename = None
elif filename.endswith( '.opml') or filename.endswith( '.xml'):
self.filename = filename
else:
self.filename = '%s.opml' % ( filename, )
@ -148,6 +151,9 @@ class Exporter(object):
Returns True on success or False when there was an
error writing the file.
"""
if self.filename is None:
return False
doc = xml.dom.minidom.Document()
opml = doc.createElement('opml')