forked from v-ko/rhythmbox-plugin-playlists-import-export
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playlists_ie_prefs.py
72 lines (54 loc) · 2.89 KB
/
playlists_ie_prefs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import rb
from gi.repository import RB, Gtk, Gio, GObject, PeasGtk
class PlaylistsIOConfigureDialog (GObject.Object, PeasGtk.Configurable):
__gtype_name__ = 'PlaylistsIOConfigureDialog'
object = GObject.property(type=GObject.Object)
def __init__(self):
GObject.Object.__init__(self)
self.config = None
self.choose_button = None
self.path_display = None
def do_create_configure_widget(self):
builder = Gtk.Builder()
builder.add_from_file(rb.find_plugin_file(self, "playlists_ie_prefs.ui"))
self.config = builder.get_object("config")
self.choose_button = builder.get_object("choose_button")
self.path_display = builder.get_object("path_display")
self.choose_button.connect("clicked", self.choose_callback)
self.path_display.connect("changed", self.path_changed_callback)
settings = Gio.Settings.new("org.gnome.rhythmbox.plugins.playlists_ie")
folder = settings.get_string("ie-folder") # get the import-export folder
self.path_display.set_text(folder)
return self.config
def choose_callback(self, widget):
def response_handler(widget, response):
if response == Gtk.ResponseType.OK:
path = self.chooser.get_filename()
self.chooser.destroy()
self.path_display.set_text(path)
else:
self.chooser.destroy()
buttons = (Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE,
Gtk.STOCK_OK, Gtk.ResponseType.OK)
self.chooser = Gtk.FileChooserDialog(title="Choose folder for import/export...",
parent=None,
action=Gtk.FileChooserAction.SELECT_FOLDER,
buttons=buttons)
self.chooser.connect("response", response_handler)
self.chooser.set_modal(True)
self.chooser.set_transient_for(self.config.get_toplevel())
self.chooser.present()
def path_changed_callback(self, widget):
path = self.path_display.get_text()
settings = Gio.Settings.new("org.gnome.rhythmbox.plugins.playlists_ie")
settings.set_string("ie-folder", path) # get the import-export folder