Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflavio <fdanesse@gmail.com>2012-04-28 22:32:52 (GMT)
committer flavio <fdanesse@gmail.com>2012-04-28 22:32:52 (GMT)
commit955d443c0c43a06eb04f5ac870ae40e676765157 (patch)
treefe0d428c85c904a93ce3fed5ce0db9133201e39d
parentb7d431cf773992b9e8a2058faf3c5894c28eb581 (diff)
Filtro Completado
-rw-r--r--CeibalNotifica.py72
-rw-r--r--base.py6
-rw-r--r--prueba.dbbin6144 -> 6144 bytes
-rw-r--r--store.py4
4 files changed, 40 insertions, 42 deletions
diff --git a/CeibalNotifica.py b/CeibalNotifica.py
index 62d0894..0cf8126 100644
--- a/CeibalNotifica.py
+++ b/CeibalNotifica.py
@@ -55,6 +55,7 @@ class CeibalNotifica(gtk.Window):
self.notify_store.connect("marcar_notify", self.marcar_notify)
self.control_toolbar.connect("get_filter", self.get_filter)
self.control_toolbar.connect("make_filter", self.make_filter)
+ self.control_toolbar.connect("show_filter", self.show_filter)
self.load_notify()
self.notify_store.columns_autosize()
@@ -86,33 +87,14 @@ class CeibalNotifica(gtk.Window):
self.add(vbox)
def get_filter(self, widget, value):
- # En value viene el primer valor para el filtro,
- # a saber: ["Tipo", "Prioridad", "Lanzamiento", "Expiración"]
- # Con este valor se obtienen todos los valores en la base,
- # en ese campo, mediante:
- # filtro_nivel2 = self.store.db.get_categories()
- # y se llena con ellos el segundo combo en la toolbar, mediante:
- # widget.set_filter(filtro_nivel2)
-
- # cuando el usuario selecciona algún valor allí, se realiza el
- # filtro sobre los datos en la base.
-
- # obtener valores posibles para el 1º filtro y
- # llamar a set_filter(lista) de esta misma toolbar
- # El filtro final será [tipo, valor]
- # Ejemplo:
-
filtro_nivel2 = self.store.db.get_categories(value=value)
widget.set_filter(filtro_nivel2)
def make_filter(self, widget, value):
- if value[1] == "Ninguno":
- self.filter = None
- return
- else:
- self.filter = value
- self.load_notify()
-
+ self.filter = value
+ self.load_notify()
+ widget.make_filter(self.filter)
+
def show_notify(self, widget, text, info):
self.text_buffer.set_text(text)
self.info_toolbar.set_text(info)
@@ -124,7 +106,22 @@ class CeibalNotifica(gtk.Window):
iter = self.listore_model.get_iter(path)
self.listore_model.remove(iter)
self.update_view()
-
+
+ def show_filter(self, widget):
+ if self.filter[0] == 'Ninguno' and self.filter[1] == 'Ninguno': return
+ valor = 0
+ if self.filter[0] == 'Prioridad': valor = 2
+ if self.filter[0] == 'Lanzamiento': valor = 5
+ if self.filter[0] == 'Expiración': valor = 6
+ if self.filter[0] == 'Tipo': valor = 7
+ iter = self.listore_model.get_iter_first()
+ while iter:
+ val = self.listore_model.get_value(iter, valor)
+ path = self.listore_model.get_path(iter)
+ iter = self.listore_model.iter_next(self.listore_model.get_iter(path))
+ if val != self.filter[1]:
+ self.listore_model.remove(self.listore_model.get_iter(path))
+
def marcar_notify(self, widget, path):
iter = widget.get_model().get_iter(path)
id_registro = int(widget.get_model().get_value(iter, 1))
@@ -148,20 +145,18 @@ class CeibalNotifica(gtk.Window):
except:
self.text_buffer.set_text('')
self.info_toolbar.set_text('')
-
+
def load_notify(self):
notificaciones = self.store.db.get_messages([])
self.listore_model.clear()
for notif in notificaciones:
self.add_notify(notif)
-
+
def add_notify(self, notify):
mark = pixbuf1
if bool(notify['fav']): mark = pixbuf2
notify = [mark, notify['id'], notify['priority'], notify['title'], notify['text'],
notify['launched'], notify['expires'], notify['type'], bool(notify['fav'])]
- # Filtrado
- print self.filter
io = self.modelsort.get_model().append(notify)
sel = self.notify_store.get_selection()
il = self.modelsort.convert_child_iter_to_iter(None, io)
@@ -312,11 +307,12 @@ class ToolbarControl(gtk.Toolbar):
__gsignals__ = {"get_filter": (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, (gobject.TYPE_STRING, )),
"make_filter": (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, ))}
+ gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, )),
+ "show_filter": (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE, [])}
def __init__(self):
gtk.Toolbar.__init__(self)
- #self.modify_bg(gtk.STATE_NORMAL,
- # gtk.gdk.Color(0, 0, 0, 1))
+ self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 20000, 0, 1))
self.filter_combo1 = None
self.filter_combo2 = None
self.set_layout()
@@ -334,8 +330,8 @@ class ToolbarControl(gtk.Toolbar):
item = gtk.ToolItem()
label = gtk.Label("Filtrar por:")
- #label.modify_fg(gtk.STATE_NORMAL,
- # gtk.gdk.Color(65535, 65535, 65535,1))
+ label.modify_fg(gtk.STATE_NORMAL,
+ gtk.gdk.Color(65535, 65535, 65535,1))
label.show()
item.add(label)
self.insert(item, -1)
@@ -362,8 +358,8 @@ class ToolbarControl(gtk.Toolbar):
item = gtk.ToolItem()
label = gtk.Label("Seleccionar:")
- #label.modify_fg(gtk.STATE_NORMAL,
- # gtk.gdk.Color(65535, 65535, 65535,1))
+ label.modify_fg(gtk.STATE_NORMAL,
+ gtk.gdk.Color(65535, 65535, 65535,1))
label.show()
item.add(label)
self.insert(item, -1)
@@ -377,6 +373,7 @@ class ToolbarControl(gtk.Toolbar):
item = gtk.ToolItem()
self.filter_combo2 = Combo()
self.filter_combo2.set_items([])
+ self.filter_combo2.get_model().clear()
self.filter_combo2.show()
item.add(self.filter_combo2)
self.insert(item, -1)
@@ -395,6 +392,11 @@ class ToolbarControl(gtk.Toolbar):
def set_filter(self, lista):
self.filter_combo2.set_items(lista)
+
+ def make_filter(self, filter):
+ if filter[0] == 'Ninguno':
+ self.filter_combo2.get_model().clear()
+ self.emit('show_filter')
class Combo(gtk.ComboBox):
__gsignals__ = {"change_selection": (gobject.SIGNAL_RUN_FIRST,
diff --git a/base.py b/base.py
index 9cccae3..a46be89 100644
--- a/base.py
+++ b/base.py
@@ -50,7 +50,7 @@ Está atravesada por la línea ecuatorial en su extremo norte, quedando así con
Está situada entre el océano Atlántico y el océano Pacífico quienes delimitan los extremos Este y Oeste respectivamente, mientras que el Mar Caribe delimita por el norte y el Océano Antártico su extremo sur.
Ocupa una superficie de 17,8 millones de km², lo que representa un 42% del continente americano y un 12% de las tierras emergidas,9 y está habitada por el 6% de la población mundial.'''
d['priority'] = 2
-d['launched'] = datetime.date(1972, 6, 21)
+d['launched'] = datetime.date(1973, 6, 21)
d['expires'] = datetime.date(2013, 6, 21)
d['type'] = "Geografía"
d['fav'] = 1
@@ -63,7 +63,7 @@ d['title'] = "Nueva Imagen Para tu xo"
d['text'] = '''Está disponible la nueva imagen para tu XO!
Para tenerla entrar al sitio www.ceibal.edu.uy'''
d['priority'] = 0
-d['launched'] = datetime.date(1972, 6, 21)
+d['launched'] = datetime.date(1974, 6, 21)
d['expires'] = datetime.date(2013, 6, 21)
d['type'] = "Actualización"
d['fav'] = 1
@@ -76,7 +76,7 @@ d['title'] = "Actividades"
d['text'] = '''En setiembre se viene la Liga de Primavera de Cazaproblemas.
En breve podrás inscribirte y participar por grandes premios'''
d['priority'] = 3
-d['launched'] = datetime.date(1972, 6, 21)
+d['launched'] = datetime.date(1975, 6, 21)
d['expires'] = datetime.date(2013, 6, 21)
d['type'] = "Actividades"
d['fav'] = 0
diff --git a/prueba.db b/prueba.db
index bd6e391..6797616 100644
--- a/prueba.db
+++ b/prueba.db
Binary files differ
diff --git a/store.py b/store.py
index 1c54f48..e5ef897 100644
--- a/store.py
+++ b/store.py
@@ -79,9 +79,7 @@ class Db:
order = "ASC"
else:
order = "DESC"
-
mappedValue = "type"
-
if value == "Tipo":
mappedValue = "type"
elif value == "Prioridad":
@@ -90,9 +88,7 @@ class Db:
mappedValue = "launched"
elif value == u"Expiración":
mappedValue = "expires"
-
query = "select distinct " + mappedValue + " from notifications order by type " + order
-
return map(lambda x:x[mappedValue],self.run_query(query))
def set_fav(self, id_msg, fav=True):