1
'''module to define the StatusCombo class, used by plugin.py'''
7
from gui.gtkui import utils
9
class StatusCombo(gtk.ComboBox):
10
"""a widget to select the status like the one in emesene 1.0"""
12
DESCRIPTION = 'A combo to select the status like emesene 1.0'
13
AUTHOR = 'Mariano Guerra'
14
WEBSITE = 'www.emesene.org'
16
def __init__(self, main_window):
18
self.model = gtk.ListStore(gtk.gdk.Pixbuf, \
19
gobject.TYPE_INT, gobject.TYPE_STRING)
21
gtk.ComboBox.__init__(self, self.model)
22
self.main_window = main_window
25
status_pixbuf_cell = gtk.CellRendererPixbuf()
26
status_text_cell = gtk.CellRendererText()
27
self.pack_start(status_pixbuf_cell, False)
28
self.pack_start(status_text_cell, False)
29
status_pixbuf_cell.set_property('xalign', 0.0)
30
status_pixbuf_cell.set_property('xpad', 5)
31
status_text_cell.set_property('xalign', 0.0)
32
status_text_cell.set_property('xpad', 5)
33
status_text_cell.set_property('width', 158)
34
self.add_attribute(status_pixbuf_cell, 'pixbuf', 0)
35
self.add_attribute(status_text_cell, 'text', 2)
36
self.set_resize_mode(0)
37
self.set_wrap_width(1)
39
current_status = main_window.session.account.status
44
for stat in e3.status.ORDERED:
45
status_name = e3.status.STATUS[stat]
47
if stat == current_status:
50
pixbuf = utils.safe_gtk_pixbuf_load(gui.theme.status_icons[stat])
51
pixbuf.scale_simple(20, 20, gtk.gdk.INTERP_BILINEAR)
52
self.model.append([pixbuf, stat, status_name]) # re-gettext-it
56
self.set_active(active)
58
self.connect('scroll-event', self.on_scroll_event)
59
self.connect('changed', self.on_status_changed)
60
main_window.session.signals.status_change_succeed.subscribe(
61
self.on_status_change_succeed)
63
def on_status_changed(self , *args):
64
"""called when a status is selected"""
65
stat = self.model.get(self.get_active_iter(), 1)[0]
67
if self.status != stat:
69
self.main_window.session.set_status(stat)
71
def on_status_change_succeed(self, stat):
72
"""called when the status was changed on another place"""
73
if stat in e3.status.ORDERED:
75
index = e3.status.ORDERED.index(stat)
76
self.set_active(index)
78
def on_scroll_event(self, button, event):
79
"""called when a scroll is made over the combo"""