~ubuntu-branches/ubuntu/oneiric/emesene/oneiric-proposed

« back to all changes in this revision

Viewing changes to emesene/plugins/ye_old_status_combo/StatusCombo.py

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2011-03-03 14:49:13 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20110303144913-0adl9cmw2s35lvzo
Tags: 2.0~git20110303-0ubuntu1
* New upstream git revision (LP: #728469).
* Remove debian/watch, debian/emesene.xpm, debian/install and
  debian/README.source files.
* Remove 21_svn2451_fix_avatar and 20_dont_build_own_libmimic patches.
* debian/control: modify python to python (>= 2.5) in Build-Depends field.
* debian/control: remove python-libmimic from Recommends field.
* debian/control: modify python-gtk2 (>= 2.10) to python-gtk2 (>= 2.12) in
  Depends field.
* debian/control: add python-appindicator and python-xmpp to Recommends
  field.
* debian/control: add python-papyon (>= 0.5.4) and python-webkit to Depends
  field.
* debian/control: update Description field.
* debian/control: add python-setuptools to Build-Depends field.
* debian/control: move python-dbus and python-notify to Depends field.
* Update debian/copyright file.
* Update debian/links file.
* debian/menu: update description field.
* Bump Standards-Version to 3.9.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
'''module to define the StatusCombo class, used by plugin.py'''
 
2
import gtk
 
3
import gobject
 
4
 
 
5
import e3
 
6
import gui
 
7
from gui.gtkui import utils
 
8
 
 
9
class StatusCombo(gtk.ComboBox):
 
10
    """a widget to select the status like the one in emesene 1.0"""
 
11
    NAME = 'Status Combo'
 
12
    DESCRIPTION = 'A combo to select the status like emesene 1.0'
 
13
    AUTHOR = 'Mariano Guerra'
 
14
    WEBSITE = 'www.emesene.org'
 
15
 
 
16
    def __init__(self, main_window):
 
17
        """constructor"""
 
18
        self.model = gtk.ListStore(gtk.gdk.Pixbuf, \
 
19
                      gobject.TYPE_INT, gobject.TYPE_STRING)
 
20
 
 
21
        gtk.ComboBox.__init__(self, self.model)
 
22
        self.main_window = main_window
 
23
        self.status = None
 
24
 
 
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)
 
38
 
 
39
        current_status = main_window.session.account.status
 
40
 
 
41
        active = 0
 
42
        count = 0
 
43
 
 
44
        for stat in e3.status.ORDERED:
 
45
            status_name = e3.status.STATUS[stat]
 
46
 
 
47
            if stat == current_status:
 
48
                active = count
 
49
 
 
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
 
53
 
 
54
            count += 1
 
55
 
 
56
        self.set_active(active)
 
57
 
 
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)
 
62
 
 
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]
 
66
 
 
67
        if self.status != stat:
 
68
            self.status = stat
 
69
            self.main_window.session.set_status(stat)
 
70
 
 
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:
 
74
            self.status = stat
 
75
            index = e3.status.ORDERED.index(stat)
 
76
            self.set_active(index)
 
77
 
 
78
    def on_scroll_event(self, button, event):
 
79
        """called when a scroll is made over the combo"""
 
80
        self.popup()
 
81
        return True