1
# -*- coding: utf-8 -*-
3
# This file is part of emesene.
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.
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.
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
23
class Header(gtk.HBox):
24
'''a widget used to display some information about the conversation'''
26
INFO_TPL += '[$small]%s[$/small]'
29
DESCRIPTION = 'The widget that displays information about the conversation'
30
AUTHOR = 'Mariano Guerra, Ivan25'
31
WEBSITE = 'www.emesene.org'
33
def __init__(self, session, members):
35
gtk.HBox.__init__(self)
36
self.set_border_width(2)
37
self._information = Renderers.SmileyLabel()
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)
44
self.pack_start(self.eventBox, True, True)
46
self.session = session
47
self.members = members
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)
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))
71
def _get_information(self):
72
'''return the text on the information'''
73
return self._information.get_markup()
75
def copy_nick(self, data, widget=None):
76
account = self.members[0]
77
contact = self.session.contacts.get(account)
79
clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
80
clipboard.set_text(contact.display_name)
82
def copy_pm(self, data, widget=None):
83
account = self.members[0]
84
contact = self.session.contacts.get(account)
86
clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
87
clipboard.set_text(contact.message)
89
def copy_mail(self, data, widget=None):
90
account = self.members[0]
92
clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
93
clipboard.set_text(account)
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)
99
information = property(fget=_get_information, fset=_set_information)