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

« back to all changes in this revision

Viewing changes to StatusMenu.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
 
# -*- coding: utf-8 -*-
2
 
 
3
 
#   This file is part of emesene.
4
 
#
5
 
#    Emesene is free software; you can redistribute it and/or modify
6
 
#    it under the terms of the GNU General Public License as published by
7
 
#    the Free Software Foundation; either version 2 of the License, or
8
 
#    (at your option) any later version.
9
 
#
10
 
#    emesene is distributed in the hope that it will be useful,
11
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
#    GNU General Public License for more details.
14
 
#
15
 
#    You should have received a copy of the GNU General Public License
16
 
#    along with emesene; if not, write to the Free Software
17
 
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 
19
 
import gtk
20
 
import emesenelib.common
21
 
import os
22
 
 
23
 
class StatusMenu(gtk.Menu):
24
 
    '''This class represents the status menu where you can select a given
25
 
    status and it will be changed. This is a standalone class because
26
 
    it is used in two classes (MainMenu and TrayIcon)'''
27
 
 
28
 
    def __init__(self, controller):
29
 
        '''Contructor'''
30
 
        gtk.Menu.__init__(self)
31
 
 
32
 
        self.controller = controller
33
 
        self.theme = self.controller.theme
34
 
        
35
 
        j = 0
36
 
        for i in self.controller.status_ordered[0]:
37
 
            if i not in self.controller.bad_statuses:
38
 
                menuItem = self.newImageMenuItem (
39
 
                    self.controller.status_ordered[3][j], None,
40
 
                    self.controller.theme.statusToPixbuf(i))
41
 
                self.add(menuItem)
42
 
                if os.name == "nt":
43
 
                    menuItem.connect("button-release-event", self.activateNT, i)
44
 
                else:
45
 
                    menuItem.connect("activate", self.activate, i)
46
 
            j += 1
47
 
 
48
 
    def newImageMenuItem(self, label, stock = None, img = None):
49
 
        mi = gtk.ImageMenuItem(_(label))
50
 
 
51
 
        if stock:
52
 
            mi.set_image(gtk.image_new_from_stock(stock, gtk.ICON_SIZE_MENU))
53
 
        elif img:
54
 
            image = gtk.Image()
55
 
            image.set_from_pixbuf(img.scale_simple(16,16,gtk.gdk.INTERP_BILINEAR))
56
 
            mi.set_image(image)
57
 
        return mi
58
 
 
59
 
    def newCheckMenuItem(self, label, checked):
60
 
        mi = gtk.CheckMenuItem(_(label))
61
 
        mi.set_active(checked)
62
 
        return mi
63
 
 
64
 
    def activate(self, menuitem, status):
65
 
        '''change the status with the userparam'''
66
 
        self.controller.msn.changeStatus(status)
67
 
 
68
 
    def activateNT(self, menuitem, event, status):
69
 
        '''change the status with the userparam, ugly windows hack'''
70
 
        self.controller.msn.changeStatus(status)
71