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, db, liststorehandler):
42 self.__listStore = liststorehandler
44 self.__columnsSection = gtk.VBox()
45 for i, name in enumerate(self._iter_columns()):
46 checkbutton = gtk.CheckButton(name)
52 if db.ladeDirekt("showcol_"+name, default) == "1":
53 checkbutton.set_active(True)
55 self.__columnsSection.pack_start(checkbutton)
57 columnsFrame = gtk.Frame(_("Visible Columns"))
58 columnsFrame.add(self.__columnsSection)
60 self.__rotationSection = gtk.VBox()
62 self.__isPortraitCheckbutton = gtk.CheckButton(_("Portrait Mode"))
63 self.__rotationSection.pack_start(self.__isPortraitCheckbutton)
65 rotationFrame = gtk.Frame(_("Rotation"))
66 rotationFrame.add(self.__rotationSection)
68 settingsBox = gtk.VBox()
69 settingsBox.pack_start(rotationFrame)
70 settingsBox.pack_start(columnsFrame)
71 settingsView = gtk.Viewport()
72 settingsView.add(settingsBox)
73 settingsScrollView = gtk.ScrolledWindow()
74 settingsScrollView.add(settingsView)
75 settingsScrollView.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
76 parent.pack_start(settingsScrollView)
78 settingsScrollView = hildonize.hildonize_scrollwindow(settingsScrollView)
80 def set_portrait_state(self, isPortrait):
81 self.__isPortraitCheckbutton.set_active(isPortrait)
83 def is_portrait(self):
84 return self.__isPortraitCheckbutton.get_active()
86 def is_col_selected(self, icol):
87 children = self.__columnsSection.get_children()
88 if icol < len(children):
89 return children[icol].get_active()
94 for i, name in enumerate(self._iter_columns()):
95 if self.is_col_selected(i) == True:
96 db.speichereDirekt("showcol_"+name, "1")
98 db.speichereDirekt("showcol_"+name, "0")
100 def _iter_columns(self):
101 for i in xrange(self.__listStore.get_colcount()):
102 name = self.__listStore.get_colname(i)
103 assert name is not None