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
30 class Selection(gtk.HBox):
33 'changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,(gobject.TYPE_STRING,gobject.TYPE_STRING)),
34 #'changedCategory': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,(gobject.TYPE_STRING,gobject.TYPE_STRING))
38 model=self.comboList.get_model()
40 #self.comboList.remove(0)
43 sql="SELECT DISTINCT list FROM items ORDER BY list"
44 rows=self.db.ladeSQL(sql)
45 if ((rows!=None)and(len(rows)>0)):
47 self.comboList.append_text(row[0])
49 self.comboList.append_text("default")
51 s=self.db.ladeDirekt("comboListText")
53 self.comboList.get_child().set_text(s)
55 self.comboList.set_active(0)
57 def comboList_changed(self, widget=None, data=None):
58 #self.comboCategory.set_model(None)
59 #print "reload categories"
60 while len(self.comboCategory.get_model())>0:
61 self.comboCategory.remove_text(0)
63 sql="SELECT DISTINCT category FROM items WHERE list=? ORDER BY category"
64 rows=self.db.ladeSQL(sql,(self.get_list(),))
66 self.comboCategory.append_text(_("all"))
67 if ((rows!=None)and(len(rows)>0)):
69 if (row[0]!=_("all")):
70 self.comboCategory.append_text(row[0])
72 s=self.db.ladeDirekt("comboCategoryText"+self.comboList.get_child().get_text())
74 self.comboCategory.get_child().set_text(s)
76 self.comboCategory.set_active(0)
78 self.emit("changed","list","")
79 self.db.speichereDirekt("comboListText",self.comboList.get_child().get_text())
83 def comboCategory_changed(self, widget=None, data=None):
84 #logging.info("Klasse geaendert zu ")
85 #self.hauptRegister.set_current_page(0)
86 self.emit("changed","category","")
87 if self.comboCategory.get_active()>-1:
88 self.db.speichereDirekt("comboCategoryText"+self.comboList.get_child().get_text(),self.comboCategory.get_child().get_text())
90 def radioActive_changed(self, widget, data=None):
91 self.emit("changed","radio","")
93 def comboLists_check_for_update(self):
94 if self.comboCategory.get_active()==-1:
95 model=self.comboCategory.get_model()
97 cat=self.get_category()
102 self.comboCategory.append_text(self.get_category())
103 self.comboCategory.set_active(len(self.comboCategory.get_model())-1)
104 if self.comboList.get_active()==-1:
105 model=self.comboList.get_model()
112 self.comboList.append_text(self.get_list())
113 self.comboList.set_active(len(self.comboList.get_model())-1)
117 logging.warning("Laden der aktuellen position noch nicht implementiert")
121 logging.warning("Speichern der aktuellen position noch nicht implementiert")
124 def getIsHildon(self):
127 def get_category(self,select=False):
128 s=self.comboCategory.get_child().get_text()
136 def set_category(self,category):
137 self.comboCategory.get_child().set_text(category)
139 def set_list(self,listname):
140 self.comboList.get_child().set_text(listname)
143 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:
155 def __init__(self,db,isHildon):
156 gtk.HBox.__init__(self,homogeneous=False, spacing=3)
159 self.isHildon=isHildon
161 logging.info("libSelection, init")
164 label=gtk.Label(_("List:"))
165 self.pack_start(label, expand=False, fill=True, padding=0)
167 self.comboList = gtk.combo_box_entry_new_text()
168 self.comboList.set_size_request(180,-1)
169 self.pack_start(self.comboList, expand=False, fill=True, padding=0)
171 label=gtk.Label(_(" Category:"))
172 self.pack_start(label, expand=False, fill=True, padding=0)
174 self.comboCategory = gtk.combo_box_entry_new_text()
175 self.comboCategory.set_size_request(180,-1)
176 self.pack_start(self.comboCategory, expand=False, fill=True, padding=0)
178 self.comboList.connect("changed", self.comboList_changed, None)
179 self.comboCategory.connect("changed", self.comboCategory_changed, None)
181 label=gtk.Label(_(" View:"))
182 self.pack_start(label, expand=False, fill=True, padding=0)
184 self.radio_all=gtk.RadioButton(group=None, label=_("All"), use_underline=True)
185 self.pack_start(self.radio_all, expand=False, fill=True, padding=0)
186 self.radio_active=gtk.RadioButton(group=self.radio_all, label=_("Active"), use_underline=True)
187 self.pack_start(self.radio_active, expand=False, fill=True, padding=0)
188 self.radio_all.connect("toggled",self.radioActive_changed, None)