Permalink
Browse files

merged pandora one changes from glennimoss

  • Loading branch information...
TingPing committed Jun 29, 2012
1 parent 00dd804 commit 302bf2a338587f5f35c4af20d52ac7654f4d3500

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -170,7 +170,7 @@ class PithosWindow(gtk.Window):
self.show_preferences(is_startup=True)
self.set_proxy()
- self.set_audio_format()
+ self.set_audio_quality()
self.pandora_connect()
def init_core(self):
@@ -304,20 +304,21 @@ class PithosWindow(gtk.Window):
def set_proxy(self):
self.worker_run('set_proxy', (self.preferences['proxy'],))
- def set_audio_format(self):
- self.worker_run('set_audio_format', (self.preferences['audio_format'],))
+ def set_audio_quality(self):
+ self.worker_run('set_audio_quality', (self.preferences['audio_quality'],))
def pandora_connect(self, message="Logging in...", callback=None):
args = (self.preferences['username'],
- self.preferences['password'])
+ self.preferences['password'],
+ self.preferences['pandora_one'])
def pandora_ready(*ignore):
logging.info("Pandora connected")
self.process_stations(self)
if callback:
callback()
- self.worker_run('connect', args, pandora_ready, message, 'login')
+ self.worker_run('connect', (self.preferences,), pandora_ready, message, 'login')
def process_stations(self, *ignore):
self.stations_model.clear()
@@ -758,10 +759,11 @@ class PithosWindow(gtk.Window):
if not is_startup:
if self.preferences['proxy'] != old_prefs['proxy']:
self.set_proxy()
- if self.preferences['audio_format'] != old_prefs['audio_format']:
- self.set_audio_format()
+ if self.preferences['audio_quality'] != old_prefs['audio_quality']:
+ self.set_audio_quality()
if ( self.preferences['username'] != old_prefs['username']
- or self.preferences['password'] != old_prefs['password']):
+ or self.preferences['password'] != old_prefs['password']
+ or self.preferences['pandora_one'] != old_prefs['pandora_one']):
self.pandora_connect()
load_plugins(self)
@@ -830,7 +832,7 @@ if __name__ == "__main__":
if options.verbose:
logging.basicConfig(level=logging.INFO, format='%(levelname)s - %(module)s:%(funcName)s:%(lineno)d - %(message)s', filename=logfile)
else:
- logging.basicConfig(level=logging.WARNING, filename=logfile)
+ logging.basicConfig(level=logging.WARNING)
logging.info("Pithos %s"%VERSION)
@@ -55,14 +55,14 @@ def finish_initializing(self, builder):
self.builder.connect_signals(self)
# initialize the "Audio format" combobox backing list
- audio_format_combo = self.builder.get_object('prefs_audio_format')
+ audio_quality_combo = self.builder.get_object('prefs_audio_quality')
fmt_store = gtk.ListStore(gobject.TYPE_STRING)
- for audio_format in valid_audio_formats:
- fmt_store.append((audio_format,))
- audio_format_combo.set_model(fmt_store)
+ for audio_format, quality in valid_audio_formats:
+ fmt_store.append((quality,))
+ audio_quality_combo.set_model(fmt_store)
render_text = gtk.CellRendererText()
- audio_format_combo.pack_start(render_text, expand=True)
- audio_format_combo.add_attribute(render_text, "text", 0)
+ audio_quality_combo.pack_start(render_text, expand=True)
+ audio_quality_combo.add_attribute(render_text, "text", 0)
self.__load_preferences()
@@ -78,6 +78,7 @@ def __load_preferences(self):
self.__preferences = {
"username":'',
"password":'',
+ "pandora_one":False,
"notify":False,
"growl":False,
"last_station_id":None,
@@ -87,7 +88,7 @@ def __load_preferences(self):
"enable_mediakeys": False,
"enable_screensaverpause":False,
"volume": 0.5,
- "audio_format": valid_audio_formats[1],
+ "audio_quality": valid_audio_formats[0][0],
}
try:
@@ -98,11 +99,12 @@ def __load_preferences(self):
for line in f:
sep = line.find('=')
key = line[:sep]
- val = line[sep+1:].strip()
- if val == 'None': val=None
- elif val == 'False': val=False
- elif val == 'True': val=True
- self.__preferences[key]=val
+ if key in self.__preferences:
+ val = line[sep+1:].strip()
+ if val == 'None': val=None
+ elif val == 'False': val=False
+ elif val == 'True': val=True
+ self.__preferences[key]=val
self.setup_fields()
def save(self):
@@ -123,11 +125,15 @@ def save(self):
def setup_fields(self):
self.builder.get_object('prefs_username').set_text(self.__preferences["username"])
self.builder.get_object('prefs_password').set_text(self.__preferences["password"])
+ self.builder.get_object('checkbutton_pandora_one').set_active(self.__preferences["pandora_one"])
self.builder.get_object('prefs_proxy').set_text(self.__preferences["proxy"])
- audio_format_combo = self.builder.get_object('prefs_audio_format')
- audio_pref_idx = list(valid_audio_formats).index(self.__preferences["audio_format"])
- audio_format_combo.set_active(audio_pref_idx)
+ audio_quality_combo = self.builder.get_object('prefs_audio_quality')
+ try:
+ audio_pref_idx = list(audio_format for audio_format, quality in valid_audio_formats).index(self.__preferences["audio_quality"])
+ except ValueError:
+ audio_pref_idx = 0
+ audio_quality_combo.set_active(audio_pref_idx)
self.builder.get_object('checkbutton_icon').set_active(self.__preferences["show_icon"])
self.builder.get_object('checkbutton_growl').set_active(self.__preferences["growl"])
@@ -141,8 +147,9 @@ def ok(self, widget, data=None):
self.__preferences["username"] = self.builder.get_object('prefs_username').get_text()
self.__preferences["password"] = self.builder.get_object('prefs_password').get_text()
+ self.__preferences["pandora_one"] = self.builder.get_object('checkbutton_pandora_one').get_active()
self.__preferences["proxy"] = self.builder.get_object('prefs_proxy').get_text()
- self.__preferences["audio_format"] = valid_audio_formats[self.builder.get_object('prefs_audio_format').get_active()]
+ self.__preferences["audio_quality"] = valid_audio_formats[self.builder.get_object('prefs_audio_quality').get_active()][0]
self.__preferences["show_icon"] = self.builder.get_object('checkbutton_icon').get_active()
self.save()
@@ -14,12 +14,11 @@
#with this program. If not, see <http://www.gnu.org/licenses/>.
### END LICENSE
-#from pithos.pandora.pandora import *
-from pandora import *
+from pithos.pandora.pandora import *
def make_pandora(testing=False):
if testing:
- from fake import FakePandora
+ from pithos.pandora.fake import FakePandora
return FakePandora()
else:
return Pandora()
Oops, something went wrong.

0 comments on commit 302bf2a

Please sign in to comment.