2006-05-17 23:04:42 +02:00
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk
|
|
|
|
import gobject
|
2006-05-18 21:58:42 +02:00
|
|
|
import cairo
|
2006-05-17 23:04:42 +02:00
|
|
|
|
|
|
|
class NotificationBar(gtk.HBox):
|
|
|
|
__gsignals__ = {
|
|
|
|
'action': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
|
|
|
([gobject.TYPE_STRING]))
|
|
|
|
}
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
gtk.HBox.__init__(self)
|
2006-05-18 21:58:42 +02:00
|
|
|
|
|
|
|
self.set_name("notif bar")
|
|
|
|
self.set_border_width(3)
|
|
|
|
|
2006-05-17 23:04:42 +02:00
|
|
|
self._text_label = gtk.Label()
|
2006-05-18 21:58:42 +02:00
|
|
|
self._text_label.set_alignment(0.0, 0.5)
|
2006-05-17 23:04:42 +02:00
|
|
|
self.pack_start(self._text_label)
|
|
|
|
self._text_label.show()
|
2006-05-18 21:58:42 +02:00
|
|
|
|
2006-05-17 23:04:42 +02:00
|
|
|
self._action_button = gtk.Button()
|
2006-05-17 23:14:36 +02:00
|
|
|
self._action_button.connect('clicked', self.__button_clicked)
|
2006-05-17 23:04:42 +02:00
|
|
|
self.pack_start(self._action_button, False)
|
|
|
|
self._action_button.show()
|
2006-05-18 21:58:42 +02:00
|
|
|
|
|
|
|
self.connect('expose_event', self.expose)
|
|
|
|
|
|
|
|
def expose(self, widget, event):
|
|
|
|
rect = self.get_allocation()
|
|
|
|
ctx = widget.window.cairo_create()
|
|
|
|
|
|
|
|
ctx.new_path()
|
|
|
|
ctx.rectangle(rect.x, rect.y, rect.width, rect.height)
|
|
|
|
ctx.set_source_rgb(0.56 , 0.75 , 1)
|
|
|
|
ctx.fill_preserve()
|
|
|
|
ctx.set_source_rgb(0.16 , 0.35 , 0.6)
|
|
|
|
ctx.stroke()
|
|
|
|
|
|
|
|
return False
|
2006-05-17 23:04:42 +02:00
|
|
|
|
|
|
|
def set_text(self, text):
|
2006-05-18 21:58:42 +02:00
|
|
|
self._text_label.set_markup('<b>' + text + '</b>')
|
2006-05-17 23:04:42 +02:00
|
|
|
|
|
|
|
def set_action(self, action_id, action_text):
|
|
|
|
self._action_id = action_id
|
|
|
|
self._action_button.set_label(action_text)
|
|
|
|
|
2006-05-17 23:21:18 +02:00
|
|
|
def __button_clicked(self, button):
|
2006-05-17 23:04:42 +02:00
|
|
|
self.emit("action", self._action_id)
|