2 # -*- coding: utf-8 -*-
5 This file is part of Multilist.
7 Multilist 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 3 of the License, or
10 (at your option) any later version.
12 Multilist 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.
17 You should have received a copy of the GNU General Public License
18 along with Multilist. If not, see <http://www.gnu.org/licenses/>.
20 Copyright (C) 2008 Christoph Würstle
36 _moduleLogger = logging.getLogger(__name__)
39 class SettingsDialog(object):
41 def __init__(self, parent):
44 self.__isPortraitCheckbutton = gtk.CheckButton("Portrait Mode")
46 self.__rotationSection = gtk.VBox()
47 self.__rotationSection.pack_start(self.__isPortraitCheckbutton, False, True)
49 rotationFrame = gtk.Frame("Rotation")
50 rotationFrame.add(self.__rotationSection)
52 self.__audioBooksPath = gtk.Entry()
53 self.__audioBooksPathButton = gtk.Button("Choose")
54 self.__audioBooksPathButton.connect("clicked", self._on_path_choose)
56 self.__audiobookPathSection = gtk.HBox()
57 self.__audiobookPathSection.pack_start(self.__audioBooksPath, True, True)
58 self.__audiobookPathSection.pack_start(self.__audioBooksPathButton, False, True)
60 self.__audiobookSection = gtk.VBox()
61 self.__audiobookSection.pack_start(self.__audiobookPathSection)
63 audiobookFrame = gtk.Frame("Audiobooks")
64 audiobookFrame.add(self.__audiobookSection)
66 settingsBox = gtk.VBox()
67 settingsBox.pack_start(rotationFrame, False, True)
68 settingsBox.pack_start(audiobookFrame, False, True)
69 settingsView = gtk.Viewport()
70 settingsView.add(settingsBox)
71 settingsScrollView = gtk.ScrolledWindow()
72 settingsScrollView.add(settingsView)
73 settingsScrollView.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
74 parent.pack_start(settingsScrollView, True, True)
76 settingsScrollView = hildonize.hildonize_scrollwindow(settingsScrollView)
78 def set_portrait_state(self, isPortrait):
79 self.__isPortraitCheckbutton.set_active(isPortrait)
81 def is_portrait(self):
82 return self.__isPortraitCheckbutton.get_active()
84 def set_audiobook_path(self, path):
85 self.__audioBooksPath.set_text(path)
87 def get_audiobook_path(self):
88 return self.__audioBooksPath.get_text()
90 @gtk_toolbox.log_exception(_moduleLogger)
91 def _on_path_choose(self, *args):
92 fileChooser = gtk.FileChooserDialog(
94 action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
97 fileChooser.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
98 fileChooser.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
99 fileChooser.set_filename(self.__audioBooksPath.get_text())
100 userResponse = fileChooser.run()
102 if userResponse == gtk.RESPONSE_OK:
103 filename = fileChooser.get_filename()
104 self.__audioBooksPath.set_text(filename)