[rhythmbox] Get streaming downloads to work.
- From: Adam Zimmerman <adamz src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rhythmbox] Get streaming downloads to work.
- Date: Thu, 11 Feb 2010 18:54:30 +0000 (UTC)
commit 578cf1d5f976af7345b600f88f9b58f9ba2ee8b4
Author: Adam Zimmerman <adam zimmerman85 gmail com>
Date: Thu Dec 24 17:08:17 2009 -0800
Get streaming downloads to work.
The preferences for download accounts are in place, but the API stuff hasn't
been connected yet. Streaming accounts work just fine.
data/rhythmbox.schemas | 33 +++
plugins/magnatune/magnatune-prefs.ui | 330 ++++++-----------------
plugins/magnatune/magnatune/MagnatuneSource.py | 4 +-
plugins/magnatune/magnatune/TrackListHandler.py | 17 +-
plugins/magnatune/magnatune/__init__.py | 173 ++++--------
5 files changed, 191 insertions(+), 366 deletions(-)
---
diff --git a/data/rhythmbox.schemas b/data/rhythmbox.schemas
index 66b0b1d..99eb1aa 100644
--- a/data/rhythmbox.schemas
+++ b/data/rhythmbox.schemas
@@ -1176,6 +1176,39 @@
<long>The size of the browser.</long>
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/rhythmbox/plugins/magnatune/account_type</key>
+ <applyto>/apps/rhythmbox/plugins/magnatune/account_type</applyto>
+ <owner>rhythmbox</owner>
+ <type>string</type>
+ <default>none</default>
+ <locale name="C">
+ <short>Magnatune account type.</short>
+ <long>Magnatune account type.</long>
+ </locale>
+ </schema>
+ <schema>
+ <key>/schemas/apps/rhythmbox/plugins/magnatune/username</key>
+ <applyto>/apps/rhythmbox/plugins/magnatune/username</applyto>
+ <owner>rhythmbox</owner>
+ <type>string</type>
+ <default></default>
+ <locale name="C">
+ <short>Magnatune account username.</short>
+ <long>Magnatune account username.</long>
+ </locale>
+ </schema>
+ <schema>
+ <key>/schemas/apps/rhythmbox/plugins/magnatune/password</key>
+ <applyto>/apps/rhythmbox/plugins/magnatune/password</applyto>
+ <owner>rhythmbox</owner>
+ <type>string</type>
+ <default></default>
+ <locale name="C">
+ <short>Magnatune account password.</short>
+ <long>Magnatune account password.</long>
+ </locale>
+ </schema>
<schema>
<key>/schemas/apps/rhythmbox/plugins/daap/active</key>
<applyto>/apps/rhythmbox/plugins/daap/active</applyto>
diff --git a/plugins/magnatune/magnatune-prefs.ui b/plugins/magnatune/magnatune-prefs.ui
index 914f8ea..1866741 100644
--- a/plugins/magnatune/magnatune-prefs.ui
+++ b/plugins/magnatune/magnatune-prefs.ui
@@ -141,7 +141,8 @@
</packing>
</child>
<child>
- <object class="GtkVBox" id="cc_details_box">
+ <object class="GtkVBox" id="account_details_box">
+ <property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="magnatune_label">
@@ -156,221 +157,104 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox14">
+ <object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkLabel" id="label20">
+ <object class="GtkRadioButton" id="no_account_radio">
+ <property name="label" translatable="yes">I don't have a Magnatune account</property>
<property name="visible">True</property>
- <property name="xpad">8</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="rb_magnatune_radio_account_toggled_cb"/>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkFrame" id="frame1">
+ <object class="GtkRadioButton" id="stream_account_radio">
+ <property name="label" translatable="yes">I have a streaming account</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">no_account_radio</property>
+ <signal name="toggled" handler="rb_magnatune_radio_account_toggled_cb"/>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="download_account_radio">
+ <property name="label" translatable="yes">I have a download account</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">no_account_radio</property>
+ <signal name="toggled" handler="rb_magnatune_radio_account_toggled_cb"/>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTable" id="table1">
<property name="visible">True</property>
- <property name="label_xalign">0</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <child>
+ <object class="GtkLabel" id="username_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Username:</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="password_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Password:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
<child>
- <object class="GtkAlignment" id="alignment1">
+ <object class="GtkEntry" id="username_entry">
<property name="visible">True</property>
- <property name="top_padding">6</property>
- <property name="bottom_padding">6</property>
- <property name="left_padding">12</property>
- <property name="right_padding">6</property>
- <child>
- <object class="GtkTable" id="table1">
- <property name="visible">True</property>
- <property name="n_rows">4</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">12</property>
- <property name="row_spacing">6</property>
- <child>
- <object class="GtkLabel" id="username_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Name:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">name_entry</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="name_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <signal name="changed" handler="rb_magnatune_name_entry_changed_cb"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="email_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <signal name="changed" handler="rb_magnatune_email_entry_changed_cb"/>
- </object>
- <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="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="password_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">_Email:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">email_entry</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="cc_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">C_redit Card:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">cc_entry</property>
- </object>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="cc_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- <signal name="changed" handler="rb_magnatune_cc_entry_changed_cb"/>
- </object>
- <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="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox20">
- <property name="visible">True</property>
- <child>
- <object class="GtkLabel" id="mm_label">
- <property name="visible">True</property>
- <property name="xpad">8</property>
- <property name="label" translatable="yes">_Month:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">mm_entry</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="mm_entry">
- <property name="visible">True</property>
- <property name="model">model1</property>
- <signal name="changed" handler="rb_magnatune_mm_entry_changed_cb"/>
- <child>
- <object class="GtkCellRendererText" id="renderer1"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="yy_label">
- <property name="visible">True</property>
- <property name="xpad">8</property>
- <property name="label" translatable="yes">_Year:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">yy_entry</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="yy_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="max_length">2</property>
- <property name="invisible_char">●</property>
- <signal name="changed" handler="rb_magnatune_yy_entry_changed_cb"/>
- </object>
- <packing>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="exp_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Expiry:</property>
- </object>
- <packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- </object>
- </child>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <signal name="changed" handler="rb_magnatune_username_changed_cb"/>
</object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
</child>
- <child type="label">
- <object class="GtkCheckButton" id="remember_cc_details">
- <property name="label" translatable="yes">Remember my credit card details</property>
+ <child>
+ <object class="GtkEntry" id="password_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="rb_magnatune_remember_cc_details_toggled_cb"/>
+ <property name="visibility">False</property>
+ <property name="invisible_char">●</property>
+ <signal name="changed" handler="rb_magnatune_password_changed_cb"/>
</object>
+ <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>
+ </packing>
</child>
</object>
<packing>
- <property name="position">1</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
@@ -386,48 +270,6 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox22">
- <property name="visible">True</property>
- <child>
- <object class="GtkLabel" id="pay_label">
- <property name="visible">True</property>
- <property name="xpad">8</property>
- <property name="label" translatable="yes">Default _amount to pay:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">pay_combobox</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="pay_combobox">
- <property name="visible">True</property>
- <property name="model">model2</property>
- <signal name="changed" handler="rb_magnatune_pay_combobox_changed_cb"/>
- <child>
- <object class="GtkCellRendererText" id="renderer2"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
<object class="GtkHBox" id="hbox21">
<property name="visible">True</property>
<child>
@@ -463,7 +305,7 @@
</child>
</object>
<packing>
- <property name="position">3</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -573,19 +415,17 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="cc_expired_label">
- <property name="label" translatable="yes"><span weight="bold" foreground="red">Your credit card is past the expiration date listed.</span></property>
- <property name="use_markup">True</property>
+ <object class="GtkLabel" id="account_changed_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Your account details have changed. Changes will be applied the next time you start Rhythmbox.</property>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
- <property name="position">4</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
diff --git a/plugins/magnatune/magnatune/MagnatuneSource.py b/plugins/magnatune/magnatune/MagnatuneSource.py
index 359a13e..d7aacba 100644
--- a/plugins/magnatune/magnatune/MagnatuneSource.py
+++ b/plugins/magnatune/magnatune/MagnatuneSource.py
@@ -128,7 +128,7 @@ class MagnatuneSource(rb.BrowserSource):
def do_impl_get_ui_actions(self):
return ["MagnatunePurchaseAlbum",
- "MagnatunePurchaseCD",
+ "MagnatuneDownloadAlbum",
"MagnatuneArtistInfo",
"MagnatuneCancelDownload"]
@@ -340,7 +340,7 @@ class MagnatuneSource(rb.BrowserSource):
self.__has_loaded = True
parser = xml.sax.make_parser()
- parser.setContentHandler(TrackListHandler(self.__db, self.__entry_type, self.__sku_dict, self.__home_dict, self.__art_dict))
+ parser.setContentHandler(TrackListHandler(self.__db, self.__entry_type, self.__sku_dict, self.__home_dict, self.__art_dict, self.__plugin))
self.__catalogue_loader = rb.ChunkLoader()
self.__catalogue_loader.get_url_chunks(magnatune_song_info, 64*1024, True, self.__catalogue_chunk_cb, parser)
diff --git a/plugins/magnatune/magnatune/TrackListHandler.py b/plugins/magnatune/magnatune/TrackListHandler.py
index cab3db9..3294fb4 100644
--- a/plugins/magnatune/magnatune/TrackListHandler.py
+++ b/plugins/magnatune/magnatune/TrackListHandler.py
@@ -27,11 +27,11 @@
import rhythmdb
import xml.sax, xml.sax.handler
-import datetime
+import datetime, re, urllib
class TrackListHandler(xml.sax.handler.ContentHandler):
- def __init__(self, db, entry_type, sku_dict, home_dict, art_dict):
+ def __init__(self, db, entry_type, sku_dict, home_dict, art_dict, plugin):
xml.sax.handler.ContentHandler.__init__(self)
self.__db = db
self.__entry_type = entry_type
@@ -39,10 +39,20 @@ class TrackListHandler(xml.sax.handler.ContentHandler):
self.__home_dict = home_dict
self.__art_dict = art_dict
self.__track = {}
+ self.__plugin = plugin
+ self.__user = urllib.quote(self.__plugin.client.get_string(self.__plugin.gconf_keys['username']))
+ self.__pw = urllib.quote(self.__plugin.client.get_string(self.__plugin.gconf_keys['password']))
+ self.__URIre = re.compile(r'^http://[^.]+\.magnatune\.com/')
+ self.__nsre = re.compile(r'\.(mp3|ogg)$')
def startElement(self, name, attrs):
self.__text = ""
+ def fix_trackurl(self, trackurl):
+ trackurl = self.__URIre.sub("http://%s:%s stream magnatune com/" % (self.__user, self.__pw), trackurl)
+ trackurl = self.__nsre.sub(r"_nospeech.\1", trackurl)
+ return trackurl
+
def endElement(self, name):
if name == "Track":
try:
@@ -51,6 +61,9 @@ class TrackListHandler(xml.sax.handler.ContentHandler):
trackurl = self.__track['oggurl']
else:
trackurl = self.__track['url']
+ # use ad-free tracks if available
+ if self.__plugin.client.get_string(self.__plugin.gconf_keys['account_type']) != 'none':
+ trackurl = self.fix_trackurl(trackurl)
# add the track to the source
entry = self.__db.entry_lookup_by_location (trackurl)
diff --git a/plugins/magnatune/magnatune/__init__.py b/plugins/magnatune/magnatune/__init__.py
index 2a19ced..dae929e 100644
--- a/plugins/magnatune/magnatune/__init__.py
+++ b/plugins/magnatune/magnatune/__init__.py
@@ -39,18 +39,12 @@ import string
from MagnatuneSource import MagnatuneSource
-has_gnome_keyring = False
-#try:
-# import gnomekeyring
-# has_gnome_keyring = True
-#except:
-# pass
-
popup_ui = """
<ui>
<popup name="MagnatuneSourceViewPopup">
<menuitem name="AddToQueueLibraryPopup" action="AddToQueue"/>
<menuitem name="MagnatunePurchaseAlbum" action="MagnatunePurchaseAlbum"/>
+ <menuitem name="MagnatuneDownloadAlbum" action="MagnatuneDownloadAlbum"/>
<menuitem name="MagnatuneArtistInfo" action="MagnatuneArtistInfo"/>
<menuitem name="MagnatuneCancelDownload" action="MagnatuneCancelDownload"/>
<separator/>
@@ -73,7 +67,11 @@ class Magnatune(rb.Plugin):
gconf_keys = {
'format': "/apps/rhythmbox/plugins/magnatune/format",
'pay': "/apps/rhythmbox/plugins/magnatune/pay",
- 'ccauthtoken': "/apps/rhythmbox/plugins/magnatune/ccauthtoken"
+ 'ccauthtoken': "/apps/rhythmbox/plugins/magnatune/ccauthtoken",
+ 'continue': "/apps/rhythmbox/plugins/magnatune/continue",
+ 'account_type': "/apps/rhythmbox/plugins/magnatune/account_type",
+ 'username': "/apps/rhythmbox/plugins/magnatune/username",
+ 'password': "/apps/rhythmbox/plugins/magnatune/password"
}
@@ -87,7 +85,6 @@ class Magnatune(rb.Plugin):
def activate(self, shell):
self.shell = shell # so the source can update the progress bar
self.db = shell.get_property("db")
- self.keyring = None
self.entry_type = self.db.entry_register_type("MagnatuneEntryType")
# allow changes which don't do anything
@@ -117,6 +114,11 @@ class Magnatune(rb.Plugin):
action = gtk.Action('MagnatunePurchaseAlbum', _('Purchase Album'),
_("Purchase this album from Magnatune"),
+ 'gtk-add')
+ action.connect('activate', lambda a: self.shell.get_property("selected-source").purchase_album())
+ self.action_group.add_action(action)
+ action = gtk.Action('MagnatuneDownloadAlbum', _('Download Album'),
+ _("Download this album from Magnatune"),
'gtk-save')
action.connect('activate', lambda a: self.shell.get_property("selected-source").purchase_album())
self.action_group.add_action(action)
@@ -157,130 +159,67 @@ class Magnatune(rb.Plugin):
def playing_entry_changed (self, sp, entry):
self.source.playing_entry_changed (entry)
-
- def get_keyring(self):
- if self.keyring is None:
- self.keyring = gnomekeyring.get_default_keyring_sync()
- return self.keyring
-
- def store_cc_details(self, *details):
- if has_gnome_keyring:
- print "storing CC details"
- try:
- id = gnomekeyring.item_create_sync(self.get_keyring(),
- gnomekeyring.ITEM_GENERIC_SECRET,
- "Magnatune credit card info", keyring_attributes,
- string.join (details, '\n'), True)
- except Exception, e:
- print e
-
- def clear_cc_details(self):
- if has_gnome_keyring:
- print "clearing CC details"
- try:
- ids = gnomekeyring.find_items_sync (gnomekeyring.ITEM_GENERIC_SECRET, keyring_attributes)
- gnomekeyring.item_delete_sync (self.get_keyring(), id[0])
- except Exception, e:
- print e
-
- def get_cc_details(self):
- if has_gnome_keyring:
- print "getting CC details"
- try:
- ids = gnomekeyring.find_items_sync (gnomekeyring.ITEM_GENERIC_SECRET, keyring_attributes)
- data = gnomekeyring.item_get_info_sync(self.get_keyring(), ids[0]).get_secret()
- return string.split(data, "\n")
- except Exception, e:
- print e
- return ("", "", 0, "", "")
def create_configure_dialog(self, dialog=None):
if dialog == None:
- def fill_cc_details():
- try:
- (ccnumber, ccyear, ccmonth, name, email) = self.get_cc_details()
- builder.get_object("cc_entry").set_text(ccnumber)
- builder.get_object("yy_entry").set_text(ccyear)
- builder.get_object("mm_entry").set_active(int(ccmonth)-1)
- builder.get_object("name_entry").set_text(name)
- builder.get_object("email_entry").set_text(email)
- builder.get_object("remember_cc_details").set_active(True)
- except Exception, e:
- print e
-
- builder.get_object("cc_entry").set_text("")
- builder.get_object("yy_entry").set_text("")
- builder.get_object("mm_entry").set_active(0)
- builder.get_object("name_entry").set_text("")
- builder.get_object("email_entry").set_text("")
- builder.get_object("remember_cc_details").set_active(False)
-
- def update_expired():
- mm = builder.get_object("mm_entry").get_active() + 1
- yy = 0
- try:
- yy = int(builder.get_object("yy_entry").get_text())
- except Exception, e:
- print e
- builder.get_object("cc_expired_label").hide()
- return
-
- if yy < (datetime.date.today().year % 100):
- builder.get_object("cc_expired_label").show()
- elif (yy == (datetime.date.today().year % 100) and mm < datetime.date.today().month):
- builder.get_object("cc_expired_label").show()
- else:
- builder.get_object("cc_expired_label").hide()
+ def fill_account_details():
+ account_type = self.client.get_string(self.gconf_keys['account_type'])
+ builder.get_object("no_account_radio").set_active(account_type == "none")
+ builder.get_object("stream_account_radio").set_active(account_type == "stream")
+ builder.get_object("download_account_radio").set_active(account_type == "download")
+
+ builder.get_object("username_entry").set_text(self.client.get_string(self.gconf_keys['username']))
+ builder.get_object("password_entry").set_text(self.client.get_string(self.gconf_keys['password']))
+
+ has_account = account_type != "none"
+ builder.get_object("username_entry").set_sensitive(has_account)
+ builder.get_object("password_entry").set_sensitive(has_account)
+ builder.get_object("username_label").set_sensitive(has_account)
+ builder.get_object("password_label").set_sensitive(has_account)
+
+ builder.get_object("account_changed_label").hide()
+
+ def account_type_toggled (button):
+ print "account type radiobutton toggled: " + button.props.name
+ account_type = {"no_account_radio": "none", "stream_account_radio": "stream", "download_account_radio": "download"}
+ if button.get_active():
+ self.client.set_string(self.gconf_keys['account_type'], account_type[button.props.name])
+ if account_type[button.props.name] == 'none':
+ builder.get_object("username_label").set_sensitive(False)
+ builder.get_object("username_entry").set_sensitive(False)
+ builder.get_object("password_label").set_sensitive(False)
+ builder.get_object("password_entry").set_sensitive(False)
+ else:
+ builder.get_object("username_label").set_sensitive(True)
+ builder.get_object("username_entry").set_sensitive(True)
+ builder.get_object("password_label").set_sensitive(True)
+ builder.get_object("password_entry").set_sensitive(True)
+ builder.get_object("account_changed_label").show()
- def remember_checkbox_toggled (button):
- print "remember CC details toggled " + str(button.get_active())
- builder.get_object("cc_entry").set_sensitive(button.get_active())
- builder.get_object("mm_entry").set_sensitive(button.get_active())
- builder.get_object("yy_entry").set_sensitive(button.get_active())
- builder.get_object("name_entry").set_sensitive(button.get_active())
- builder.get_object("email_entry").set_sensitive(button.get_active())
+ def account_details_changed(entry):
+ self.client.set_string(self.gconf_keys['username'], builder.get_object("username_entry").get_text())
+ self.client.set_string(self.gconf_keys['password'], builder.get_object("password_entry").get_text())
+ builder.get_object("account_changed_label").show()
- if not button.get_active():
- try:
- self.clear_cc_details ()
- except Exception, e:
- print e
-# fill_cc_details()
-
-
- # shit
self.configure_callback_dic = {
-# "rb_magnatune_yy_entry_changed_cb" : lambda w: update_expired(),
-# "rb_magnatune_mm_entry_changed_cb" : lambda w: update_expired(),
-# "rb_magnatune_name_entry_changed_cb" : lambda w: None,
-# "rb_magnatune_cc_entry_changed_cb" : lambda w: None,
-# "rb_magnatune_email_entry_changed_cb" : lambda w: None,
- "rb_magnatune_pay_combobox_changed_cb" : lambda w: self.client.set_int(self.gconf_keys['pay'], w.get_active() + 5),
"rb_magnatune_audio_combobox_changed_cb" : lambda w: self.client.set_string(self.gconf_keys['format'], self.format_list[w.get_active()]),
- "rb_magnatune_remember_cc_details_toggled_cb" : remember_checkbox_toggled
+
+ "rb_magnatune_radio_account_toggled_cb" : account_type_toggled,
+ "rb_magnatune_username_changed_cb" : account_details_changed,
+ "rb_magnatune_password_changed_cb" : account_details_changed
}
builder = gtk.Builder()
builder.add_from_file(self.find_file("magnatune-prefs.ui"))
- # gladexml.signal_autoconnect(self.configure_callback_dic)
# FIXME this bit should be in builder too (what?)
dialog = builder.get_object('preferences_dialog')
- def dialog_response (dialog, response):
- if builder.get_object("remember_cc_details").get_active():
- ccnumber = builder.get_object("cc_entry").get_text()
- ccyear = builder.get_object("yy_entry").get_text()
- ccmonth = str(builder.get_object("mm_entry").get_active() + 1)
- name = builder.get_object("name_entry").get_text()
- email = builder.get_object("email_entry").get_text()
- self.store_cc_details(ccnumber, ccyear, ccmonth, name, email)
- dialog.hide()
- dialog.connect("response", dialog_response)
- builder.get_object("cc_details_box").props.visible = has_gnome_keyring
- builder.get_object("pay_combobox").set_active(self.client.get_int(self.gconf_keys['pay']) - 5)
builder.get_object("audio_combobox").set_active(self.format_list.index(self.client.get_string(self.gconf_keys['format'])))
- fill_cc_details()
+ fill_account_details()
+
+ builder.connect_signals(self.configure_callback_dic)
+ dialog.connect("response", lambda x,y: dialog.hide())
dialog.present()
return dialog
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]