Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/CeibalNotifica.py
diff options
context:
space:
mode:
Diffstat (limited to 'CeibalNotifica.py')
-rw-r--r--CeibalNotifica.py77
1 files changed, 31 insertions, 46 deletions
diff --git a/CeibalNotifica.py b/CeibalNotifica.py
index 6005128..59ff93e 100644
--- a/CeibalNotifica.py
+++ b/CeibalNotifica.py
@@ -23,26 +23,21 @@ import os
import gtk
import sys
import gobject
-
try:
from ceibal.notifier.store import *
except:
from store import *
-
+from sugar.activity import activity
+from sugar.activity.widgets import StopButton
BASE = os.path.dirname(__file__)
-pixbuf1 = gtk.gdk.pixbuf_new_from_file_at_size(os.path.join(BASE, "Iconos", "ceibal-gris.png"), 32, 32)
-pixbuf2 = gtk.gdk.pixbuf_new_from_file_at_size(os.path.join(BASE, "Iconos", "ceibal.png"), 32, 32)
-
+pixbuf1 = gtk.gdk.pixbuf_new_from_file_at_size(os.path.join(BASE, "Iconos", "ceibal-gris.png"), 32,32)
+pixbuf2 = gtk.gdk.pixbuf_new_from_file_at_size(os.path.join(BASE, "Iconos", "ceibal.png"), 32,32)
-class CeibalNotifica(gtk.Window):
- def __init__(self):
- super(CeibalNotifica, self).__init__()
+class CeibalNotifica(activity.Activity):
+ def __init__(self, handle):
+ activity.Activity.__init__(self, handle, False)
self.set_title("Ceibal Notifica")
- self.set_icon_from_file(os.path.join(BASE, "Iconos", "ceibal.png"))
- self.set_resizable(True)
- self.set_size_request(640, 480)
self.set_border_width(2)
- self.set_position(gtk.WIN_POS_CENTER)
self.text_buffer = None
self.text_view = None
self.store = None
@@ -61,6 +56,7 @@ class CeibalNotifica(gtk.Window):
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.control_toolbar.connect("exit", self.salir)
self.load_notify()
self.notify_store.columns_autosize()
@@ -71,8 +67,8 @@ class CeibalNotifica(gtk.Window):
self.text_buffer = gtk.TextBuffer()
self.text_view = gtk.TextView(buffer=self.text_buffer)
self.text_view.set_editable(False)
- self.text_view.set_wrap_mode(gtk.WRAP_WORD)
self.text_view.set_justification(gtk.JUSTIFY_LEFT)
+ self.text_view.set_wrap_mode(gtk.WRAP_WORD)
hpanel = gtk.HPaned()
try:
self.store = Store(db_filename="prueba.db")
@@ -93,7 +89,7 @@ class CeibalNotifica(gtk.Window):
vbox.pack_start(hpanel, True, True, 0)
vbox.pack_start(self.info_toolbar, False, False, 0)
hpanel.show_all()
- self.add(vbox)
+ self.set_canvas(vbox)
def get_filter(self, widget, value):
filtro_nivel2 = self.store.db.get_categories(value=value)
@@ -178,7 +174,6 @@ class CeibalNotifica(gtk.Window):
def salir(self, widget=None):
sys.exit(0)
-
class ListoreModel(gtk.ListStore):
def __init__(self):
gtk.ListStore.__init__(self, gtk.gdk.Pixbuf,
@@ -187,7 +182,6 @@ class ListoreModel(gtk.ListStore):
gobject.TYPE_STRING, gobject.TYPE_STRING,
gobject.TYPE_STRING, gobject.TYPE_BOOLEAN)
-
class Notify_Store(gtk.TreeView):
__gsignals__ = {"show_notify": (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_STRING)),
@@ -195,7 +189,6 @@ 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)
@@ -208,7 +201,6 @@ class Notify_Store(gtk.TreeView):
self.treeselection.set_mode(gtk.SELECTION_SINGLE)
self.treeselection.set_select_function(self.func_selections,
self.get_model(), True)
-
def set_columns(self):
self.append_column(self.make_column_mark('', 0, True))
self.append_column(self.make_column('id', 1, False))
@@ -219,20 +211,17 @@ class Notify_Store(gtk.TreeView):
self.append_column(self.make_column('Expira', 6, True))
self.append_column(self.make_column('Tipo', 7, True))
self.append_column(self.make_column('Favorito', 8, False))
-
def make_column_mark(self, text, index, visible):
render = gtk.CellRendererPixbuf()
column = gtk.TreeViewColumn(text, render, pixbuf = index)
column.set_property("visible", visible)
return column
-
def make_column(self, text, index, visible):
render = gtk.CellRendererText()
column = gtk.TreeViewColumn(text, render, text=index)
column.set_sort_column_id(index)
column.set_property('visible', visible)
return column
-
def func_selections(self, selection, model, path, is_selected, user_data):
iter = self.get_model().get_iter(path)
texto = self.get_model().get_value(iter, 4)
@@ -246,7 +235,6 @@ class Notify_Store(gtk.TreeView):
info = "id: %s Lanzamiento: %s Favorito: %s" % (nid, lanzamiento, fav)
self.emit("show_notify", texto, info)
return True
-
def handle_click(self, widget, event):
boton = event.button
pos = (int(event.x), int(event.y))
@@ -262,7 +250,6 @@ class Notify_Store(gtk.TreeView):
return
except:
pass
-
def get_menu(self, boton, pos, tiempo, path):
menu = gtk.Menu()
eliminar = gtk.MenuItem("Eliminar Notificación.")
@@ -276,7 +263,6 @@ class Notify_Store(gtk.TreeView):
marcar.connect_object("activate", self.emit_marcar_notify, path)
menu.show_all()
gtk.Menu.popup(menu, None, None, None, boton, tiempo)
-
def get_path_selected(self):
(model, iter) = self.get_selection().get_selected()
path = None
@@ -284,16 +270,12 @@ class Notify_Store(gtk.TreeView):
treemodelrow = model[iter]
path = treemodelrow.path
return path
-
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,
@@ -319,15 +301,15 @@ class ToolbarInfo(gtk.Toolbar):
def set_text(self, text=""):
self.info_label.set_text(text)
-
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, )),
"show_filter": (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE, []),
+ "exit": (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))
@@ -335,7 +317,6 @@ class ToolbarControl(gtk.Toolbar):
self.filter_combo2 = None
self.set_layout()
self.show_all()
-
self.filter_combo1.connect("change_selection", self.emit_get_filter)
self.filter_combo2.connect("change_selection", self.emit_make_filter)
@@ -345,21 +326,18 @@ class ToolbarControl(gtk.Toolbar):
separator.set_size_request(10, -1)
separator.set_expand(False)
self.insert(separator, -1)
-
item = gtk.ToolItem()
label = gtk.Label("Filtrar por:")
label.modify_fg(gtk.STATE_NORMAL,
- gtk.gdk.Color(65535, 65535, 65535,1))
+ gtk.gdk.Color(65535, 65535, 65535,1))
label.show()
item.add(label)
self.insert(item, -1)
-
separator = gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_size_request(10, -1)
separator.set_expand(False)
self.insert(separator, -1)
-
item = gtk.ToolItem()
self.filter_combo1 = Combo()
self.filter_combo1.set_items(["Tipo", "Prioridad",
@@ -367,27 +345,23 @@ class ToolbarControl(gtk.Toolbar):
self.filter_combo1.show()
item.add(self.filter_combo1)
self.insert(item, -1)
-
separator = gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_size_request(10, -1)
separator.set_expand(False)
self.insert(separator, -1)
-
item = gtk.ToolItem()
label = gtk.Label("Seleccionar:")
label.modify_fg(gtk.STATE_NORMAL,
- gtk.gdk.Color(65535, 65535, 65535,1))
+ gtk.gdk.Color(65535, 65535, 65535,1))
label.show()
item.add(label)
self.insert(item, -1)
-
separator = gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_size_request(10, -1)
separator.set_expand(False)
self.insert(separator, -1)
-
item = gtk.ToolItem()
self.filter_combo2 = Combo()
self.filter_combo2.set_items([])
@@ -395,13 +369,27 @@ class ToolbarControl(gtk.Toolbar):
self.filter_combo2.show()
item.add(self.filter_combo2)
self.insert(item, -1)
-
separator = gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_size_request(0, -1)
separator.set_expand(True)
self.insert(separator, -1)
+ stopbutton = gtk.ToolButton()
+ image = gtk.Image()
+ image.set_from_stock(gtk.STOCK_STOP, 32)
+ stopbutton.set_icon_widget(image)
+ image.show()
+ stopbutton.connect('clicked', self.emit_exit)
+ self.insert(stopbutton, -1)
+ stopbutton.show()
+
+ separator = gtk.SeparatorToolItem()
+ separator.props.draw = False
+ separator.set_size_request(10, -1)
+ separator.set_expand(False)
+ self.insert(separator, -1)
+
def emit_get_filter(self, widget, value):
self.emit("get_filter", value)
@@ -417,11 +405,12 @@ class ToolbarControl(gtk.Toolbar):
self.filter_combo2.get_model().clear()
self.emit('show_filter')
+ def emit_exit(self, widget):
+ self.emit('exit')
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()
@@ -451,7 +440,3 @@ class Combo(gtk.ComboBox):
value = self.get_model().get_value(iter, 0)
return value
-
-if __name__ == "__main__":
- CeibalNotifica()
- gtk.main()