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

« back to all changes in this revision

Viewing changes to emesene/gui/gtkui/Header.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 3 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
 
 
21
import Renderers
 
22
 
 
23
class Header(gtk.HBox):
 
24
    '''a widget used to display some information about the conversation'''
 
25
    INFO_TPL = '%s[$nl]'
 
26
    INFO_TPL += '[$small]%s[$/small]'
 
27
 
 
28
    NAME = 'Header'
 
29
    DESCRIPTION = 'The widget that displays information about the conversation'
 
30
    AUTHOR = 'Mariano Guerra, Ivan25'
 
31
    WEBSITE = 'www.emesene.org'
 
32
 
 
33
    def __init__(self, session, members):
 
34
        '''constructor'''
 
35
        gtk.HBox.__init__(self)
 
36
        self.set_border_width(2)
 
37
        self._information = Renderers.SmileyLabel()
 
38
 
 
39
        self.eventBox = gtk.EventBox()
 
40
        self.eventBox.set_visible_window(False)
 
41
        self.eventBox.add(self._information)
 
42
        self.eventBox.connect('button-press-event', self.on_clicked)
 
43
 
 
44
        self.pack_start(self.eventBox, True, True)
 
45
 
 
46
        self.session = session
 
47
        self.members = members
 
48
 
 
49
        self.menu = gtk.Menu()
 
50
        copynick = gtk.ImageMenuItem(_('Copy nick to clipboard'))
 
51
        copynick.set_image(gtk.image_new_from_stock(gtk.STOCK_COPY, gtk.ICON_SIZE_MENU))
 
52
        copypm = gtk.ImageMenuItem(_('Copy personal message to clipboard'))
 
53
        copypm.set_image(gtk.image_new_from_stock(gtk.STOCK_COPY, gtk.ICON_SIZE_MENU))
 
54
        copymail = gtk.ImageMenuItem(_('Copy mail to clipboard'))
 
55
        copymail.set_image(gtk.image_new_from_stock(gtk.STOCK_COPY, gtk.ICON_SIZE_MENU))
 
56
        self.menu.append(copynick)
 
57
        self.menu.append(copypm)
 
58
        self.menu.append(copymail)
 
59
        copynick.connect('activate', self.copy_nick)
 
60
        copypm.connect('activate', self.copy_pm)
 
61
        copymail.connect('activate', self.copy_mail)
 
62
        copynick.show()
 
63
        copypm.show()
 
64
        copymail.show()
 
65
 
 
66
    def _set_information(self, lines):
 
67
        '''set the text on the information, lines is a tuple of size 3 with 3
 
68
        strings that will be replaced on the template'''
 
69
        self._information.set_markup(Renderers.msnplus_to_list(Header.INFO_TPL % lines))
 
70
        
 
71
    def _get_information(self):
 
72
        '''return the text on the information'''
 
73
        return self._information.get_markup()
 
74
 
 
75
    def copy_nick(self, data, widget=None):
 
76
        account = self.members[0]
 
77
        contact = self.session.contacts.get(account)
 
78
 
 
79
        clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
 
80
        clipboard.set_text(contact.display_name)
 
81
 
 
82
    def copy_pm(self, data, widget=None):
 
83
        account = self.members[0]
 
84
        contact = self.session.contacts.get(account)
 
85
 
 
86
        clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
 
87
        clipboard.set_text(contact.message)
 
88
 
 
89
    def copy_mail(self, data, widget=None):
 
90
        account = self.members[0]
 
91
 
 
92
        clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
 
93
        clipboard.set_text(account)
 
94
 
 
95
    def on_clicked(self, widget, event):
 
96
        '''called when the header clicked'''
 
97
        self.menu.popup(None, None, None, event.button, event.time, None)
 
98
 
 
99
    information = property(fget=_get_information, fset=_set_information)