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
35 _moduleLogger = logging.getLogger(__name__)
38 class Selection(gtk.HBox):
41 'changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_STRING)),
42 #'changedCategory': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_STRING))
46 model = self.comboList.get_model()
48 #self.comboList.remove(0)
50 sql = "SELECT DISTINCT list FROM items ORDER BY list"
51 rows = self.db.ladeSQL(sql)
52 if ((rows is not None)and(len(rows)>0)):
54 self.comboList.append_text(row[0])
56 self.comboList.append_text("default")
58 s = self.db.ladeDirekt("comboListText")
60 self.comboList.get_child().set_text(s)
62 self.comboList.set_active(0)
64 def comboList_changed(self, widget = None, data = None):
65 #self.comboCategory.set_model(None)
66 #print "reload categories"
67 while len(self.comboCategory.get_model())>0:
68 self.comboCategory.remove_text(0)
70 sql = "SELECT DISTINCT category FROM items WHERE list = ? ORDER BY category"
71 rows = self.db.ladeSQL(sql, (self.get_list(), ))
73 self.comboCategory.append_text(_("all"))
74 if ((rows is not None)and(len(rows)>0)):
76 if (row[0] != _("all")):
77 self.comboCategory.append_text(row[0])
79 s = self.db.ladeDirekt("comboCategoryText"+self.comboList.get_child().get_text())
81 self.comboCategory.get_child().set_text(s)
83 self.comboCategory.set_active(0)
85 self.emit("changed", "list", "")
86 self.db.speichereDirekt("comboListText", self.comboList.get_child().get_text())
88 def comboCategory_changed(self, widget = None, data = None):
89 #_moduleLogger.info("Klasse geaendert zu ")
90 #self.hauptRegister.set_current_page(0)
91 self.emit("changed", "category", "")
92 if self.comboCategory.get_active()>-1:
93 self.db.speichereDirekt("comboCategoryText"+self.comboList.get_child().get_text(), self.comboCategory.get_child().get_text())
95 def radioActive_changed(self, widget, data = None):
96 self.emit("changed", "radio", "")
98 def comboLists_check_for_update(self):
99 if self.comboCategory.get_active() == -1:
100 model = self.comboCategory.get_model()
102 cat = self.get_category()
107 self.comboCategory.append_text(self.get_category())
108 self.comboCategory.set_active(len(self.comboCategory.get_model())-1)
109 if self.comboList.get_active() == -1:
110 model = self.comboList.get_model()
112 list = self.get_list()
117 self.comboList.append_text(self.get_list())
118 self.comboList.set_active(len(self.comboList.get_model())-1)
121 _moduleLogger.warning("Laden der aktuellen position noch nicht implementiert")
124 _moduleLogger.warning("Speichern der aktuellen position noch nicht implementiert")
126 def getIsHildon(self):
129 def get_category(self, select = False):
130 s = self.comboCategory.get_child().get_text()
132 if (select == False):
138 def set_category(self, category):
139 self.comboCategory.get_child().set_text(category)
141 def set_list(self, listname):
142 self.comboList.get_child().set_text(listname)
145 return self.comboList.get_child().get_text()
147 def get_status(self):
148 #return self.comboCategory.get_child().get_text()
149 if self.radio_all.get_active() == True:
154 def __init__(self, db, isHildon):
155 gtk.HBox.__init__(self, homogeneous = False, spacing = 3)
158 self.isHildon = isHildon
160 _moduleLogger.info("libSelection, init")
162 label = gtk.Label(_("List:"))
163 self.pack_start(label, expand = False, fill = True, padding = 0)
165 self.comboList = gtk.combo_box_entry_new_text()
166 self.comboList.set_size_request(180, -1)
167 self.pack_start(self.comboList, expand = False, fill = True, padding = 0)
169 label = gtk.Label(_(" Category:"))
170 self.pack_start(label, expand = False, fill = True, padding = 0)
172 self.comboCategory = gtk.combo_box_entry_new_text()
173 self.comboCategory.set_size_request(180, -1)
174 self.pack_start(self.comboCategory, expand = False, fill = True, padding = 0)
176 self.comboList.connect("changed", self.comboList_changed, None)
177 self.comboCategory.connect("changed", self.comboCategory_changed, None)
179 label = gtk.Label(_(" View:"))
180 self.pack_start(label, expand = False, fill = True, padding = 0)
182 self.radio_all = gtk.RadioButton(group = None, label = _("All"), use_underline = True)
183 self.pack_start(self.radio_all, expand = False, fill = True, padding = 0)
184 self.radio_active = gtk.RadioButton(group = self.radio_all, label = _("Active"), use_underline = True)
185 self.pack_start(self.radio_active, expand = False, fill = True, padding = 0)
186 self.radio_all.connect("toggled", self.radioActive_changed, None)