1
# -*- Mode: python; coding: utf-8; tab-width: 8; indent-tabs-mode: t; -*-
3
# Copyright (C) 2007 James Livingston
4
# Copyright (C) 2007 Sirio Bolaños Puchet
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2, or (at your option)
11
# The Rhythmbox authors hereby grant permission for non-GPL compatible
12
# GStreamer plugins to be used and distributed together with GStreamer
13
# and Rhythmbox. This permission is above and beyond the permissions granted
14
# by the GPL license by which Rhythmbox is covered. If you modify this code
15
# you may extend this exception to your version of the code, but you are not
16
# obligated to do so. If you do not wish to do so, delete this exception
17
# statement from your version.
19
# This program is distributed in the hope that it will be useful,
20
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
# GNU General Public License for more details.
24
# You should have received a copy of the GNU General Public License
25
# along with this program; if not, write to the Free Software
26
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28
from LyricsSites import lyrics_sites
31
from os import system, path
34
from gi.repository import Gtk, Gio, GObject, PeasGtk
36
class LyricsConfigureDialog (GObject.Object, PeasGtk.Configurable):
37
__gtype_name__ = 'LyricsConfigureDialog'
38
object = GObject.property(type=GObject.Object)
41
GObject.Object.__init__(self)
42
self.settings = Gio.Settings("org.gnome.rhythmbox.plugins.lyrics")
44
def do_create_configure_widget(self):
45
builder = Gtk.Builder()
46
builder.add_from_file(rb.find_plugin_file(self, "lyrics-prefs.ui"))
48
self.config = builder.get_object("config")
50
self.choose_button = builder.get_object("choose_button")
51
self.path_display = builder.get_object("path_display")
53
self.choose_button.connect("clicked", self.choose_callback)
55
engines, self.folder = self.get_prefs()
56
if self.folder is None:
57
self.folder = '~/.lyrics'
58
self.path_display.set_text(self.folder)
61
site_box = builder.get_object("sites")
63
for s in lyrics_sites:
65
checkbutton = Gtk.CheckButton(label = s['name'])
66
checkbutton.set_active(s['id'] in engines)
67
self.site_checks[site_id] = checkbutton
68
site_box.pack_start(checkbutton, True, True, 0)
76
for s in lyrics_sites:
77
check = self.site_checks[s['id']]
81
if check.get_active():
84
if len(self.path_display.get_text()) is not 0:
85
self.folder = self.path_display.get_text()
87
self.settings['sites'] = sites
88
self.settings['folder'] = self.folder
90
def choose_callback(self, widget):
91
def response_handler(widget, response):
92
if response == Gtk.ResponseType.OK:
93
path = self.chooser.get_filename()
94
self.chooser.destroy()
95
self.path_display.set_text(path)
97
self.chooser.destroy()
99
buttons = (Gtk.STOCK_CLOSE, Gtk.ResponseTypeCLOSE,
100
Gtk.STOCK_OK, Gtk.ResponseType.OK)
101
self.chooser = Gtk.FileChooserDialog(title=_("Choose lyrics folder..."),
103
action=Gtk.FileChooserAction.SELECT_FOLDER,
105
self.chooser.connect("response", response_handler)
106
self.chooser.set_modal(True)
107
self.chooser.set_transient_for(self.dialog)
108
self.chooser.present()
110
def get_prefs (self):
112
sites = self.settings['sites']
113
except gobject.GError, e:
116
folder = self.settings['folder']
118
print "lyric sites: " + str (sites)
119
print "lyric folder: " + folder
120
return (sites, folder)