home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / rhythmbox / plugins / jamendo / JamendoConfigureDialog.py < prev    next >
Encoding:
Python Source  |  2009-04-07  |  1.9 KB  |  59 lines

  1. # -*- coding: utf-8 -*-
  2.  
  3. # JamendoConfigureDialog.py
  4. #
  5. # Copyright (C) 2007 - Guillaume Desmottes
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2, or (at your option)
  10. # any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20.  
  21. import gobject
  22. import gtk, gtk.glade
  23. import gconf, gnome
  24.  
  25. gconf_keys = {    'format' : '/apps/rhythmbox/plugins/jamendo/format',
  26.         'sorting': '/apps/rhythmbox/plugins/jamendo/sorting'
  27.          }
  28. format_list = ['ogg3', 'mp32']
  29.  
  30. class JamendoConfigureDialog (object):
  31.     def __init__(self, glade_file):
  32.         self.gconf = gconf.client_get_default()
  33.         gladexml = gtk.glade.XML(glade_file)
  34.  
  35.         self.dialog = gladexml.get_widget('preferences_dialog')
  36.         self.audio_combobox = gladexml.get_widget("audio_combobox")
  37.  
  38.         format_text = self.gconf.get_string(gconf_keys['format'])
  39.         if not format_text:
  40.             format_text = "ogg3"
  41.         try:
  42.             format = format_list.index(format_text)
  43.         except ValueError:
  44.             format = 0
  45.         self.audio_combobox.set_active(format)
  46.  
  47.         self.dialog.connect("response", self.dialog_response)
  48.         self.audio_combobox.connect("changed", self.audio_combobox_changed)
  49.  
  50.     def get_dialog (self):
  51.         return self.dialog
  52.  
  53.     def dialog_response (self, dialog, response):
  54.         dialog.hide()
  55.  
  56.     def audio_combobox_changed (self, combobox):
  57.         format = self.audio_combobox.get_active()
  58.         self.gconf.set_string(gconf_keys['format'], format_list[format])
  59.