diff options
author | Ariel Calzada <aricalso@000netbook000.(none)> | 2012-05-04 16:01:09 (GMT) |
---|---|---|
committer | Ariel Calzada <aricalso@000netbook000.(none)> | 2012-05-04 16:01:09 (GMT) |
commit | 86d01b38fa7be408a1eec394d5dba21923b2f9db (patch) | |
tree | 60f1b6b056800d3819788c2b800e933221ed3c0c /CeibalNotifica.py | |
parent | d183f722a7b4752bf860fd46a1deddeb509b968a (diff) |
Added try-except for allowing running in both environments
Diffstat (limited to 'CeibalNotifica.py')
-rw-r--r-- | CeibalNotifica.py | 77 |
1 files changed, 41 insertions, 36 deletions
diff --git a/CeibalNotifica.py b/CeibalNotifica.py index 84ac98c..5cb91d6 100644 --- a/CeibalNotifica.py +++ b/CeibalNotifica.py @@ -23,8 +23,11 @@ import os import gtk import sys import gobject -#from store import * -from ceibal.notifier.store import * + +try: + from ceibal.notifier.store import * +except: + from store import * BASE = os.path.dirname(__file__) pixbuf1 = gtk.gdk.pixbuf_new_from_file_at_size(os.path.join(BASE, "Iconos", "ceibal-gris.png"), 32, 32) @@ -70,8 +73,10 @@ class CeibalNotifica(gtk.Window): self.text_view.set_editable(False) self.text_view.set_justification(gtk.JUSTIFY_LEFT) hpanel = gtk.HPaned() - #self.store = Store(db_filename="prueba.db") - self.store = Store() + try: + self.store = Store(db_filename="prueba.db") + except: + self.store = Store() scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.add_with_viewport(self.notify_store) @@ -94,10 +99,10 @@ class CeibalNotifica(gtk.Window): widget.set_filter(filtro_nivel2) def make_filter(self, widget, value): - self.filter = value - self.load_notify() - widget.make_filter(self.filter) - + 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) @@ -109,22 +114,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)) - + 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,13 +153,13 @@ 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 @@ -189,7 +194,7 @@ class Notify_Store(gtk.TreeView): gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, )), "marcar_notify": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, ))} - + def __init__(self, model): gtk.TreeView.__init__(self, model) self.set_property("rules-hint", True) @@ -281,13 +286,13 @@ class Notify_Store(gtk.TreeView): def emit_delete_notify(self, path): self.emit("delete_notify", path) - + def emit_marcar_notify(self, path): self.emit("marcar_notify", path) class ToolbarInfo(gtk.Toolbar): - + def __init__(self): gtk.Toolbar.__init__(self) self.modify_bg(gtk.STATE_NORMAL, @@ -309,7 +314,7 @@ class ToolbarInfo(gtk.Toolbar): separator.set_size_request(0, -1) separator.set_expand(True) self.insert(separator, -1) - + def set_text(self, text=""): self.info_label.set_text(text) @@ -321,7 +326,7 @@ class ToolbarControl(gtk.Toolbar): 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)) @@ -398,24 +403,24 @@ class ToolbarControl(gtk.Toolbar): def emit_get_filter(self, widget, value): self.emit("get_filter", value) - + def emit_make_filter(self, widget, value): val1 = self.filter_combo1.get_value_select() self.emit("make_filter", [val1,value]) 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') + 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, gobject.TYPE_NONE, (gobject.TYPE_STRING, ))} - + def __init__(self): gtk.ComboBox.__init__(self, gtk.ListStore(str)) cell = gtk.CellRendererText() |