2005-08-15 01:52:12 +02:00
|
|
|
## tooltips.py
|
|
|
|
##
|
2005-12-09 18:15:30 +01:00
|
|
|
## Contributors for this file:
|
2005-08-15 01:52:12 +02:00
|
|
|
## - Yann Le Boulanger <asterix@lagaule.org>
|
|
|
|
## - Nikos Kouremenos <kourem@gmail.com>
|
|
|
|
## - Dimitur Kirov <dkirov@gmail.com>
|
|
|
|
##
|
2005-12-10 00:30:28 +01:00
|
|
|
## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org>
|
|
|
|
## Vincent Hanquez <tab@snarc.org>
|
|
|
|
## Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org>
|
|
|
|
## Vincent Hanquez <tab@snarc.org>
|
|
|
|
## Nikos Kouremenos <nkour@jabber.org>
|
|
|
|
## Dimitur Kirov <dkirov@gmail.com>
|
|
|
|
## Travis Shirk <travis@pobox.com>
|
|
|
|
## Norman Rasmussen <norman@rasmussen.co.za>
|
2005-08-15 01:52:12 +02:00
|
|
|
##
|
|
|
|
## This program is free software; you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published
|
|
|
|
## by the Free Software Foundation; version 2 only.
|
|
|
|
##
|
|
|
|
## This program is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
|
|
|
|
import gtk
|
|
|
|
import gobject
|
|
|
|
import os
|
|
|
|
|
|
|
|
import gtkgui_helpers
|
2006-01-11 09:31:00 +01:00
|
|
|
import message_control
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
from common import gajim
|
|
|
|
from common import helpers
|
|
|
|
from common import i18n
|
|
|
|
|
|
|
|
_ = i18n._
|
|
|
|
APP = i18n.APP
|
|
|
|
|
|
|
|
class BaseTooltip:
|
2005-10-08 18:47:35 +02:00
|
|
|
''' Base Tooltip; Usage:
|
2005-08-15 01:52:12 +02:00
|
|
|
tooltip = BaseTooltip()
|
|
|
|
....
|
2005-10-08 18:47:35 +02:00
|
|
|
tooltip.show_tooltip('', window_positions, widget_positions)
|
|
|
|
#FIXME: what is window, what is widget?
|
2005-08-15 01:52:12 +02:00
|
|
|
....
|
|
|
|
if tooltip.timeout != 0:
|
|
|
|
tooltip.hide_tooltip()
|
|
|
|
'''
|
|
|
|
def __init__(self):
|
|
|
|
self.timeout = 0
|
|
|
|
self.prefered_position = [0, 0]
|
|
|
|
self.win = None
|
|
|
|
self.id = None
|
|
|
|
|
|
|
|
def populate(self, data):
|
|
|
|
''' this method must be overriden by all extenders '''
|
|
|
|
self.create_window()
|
|
|
|
self.win.add(gtk.Label(data))
|
|
|
|
|
|
|
|
def create_window(self):
|
|
|
|
''' create a popup window each time tooltip is requested '''
|
|
|
|
self.win = gtk.Window(gtk.WINDOW_POPUP)
|
|
|
|
self.win.set_border_width(3)
|
|
|
|
self.win.set_resizable(False)
|
|
|
|
self.win.set_name('gtk-tooltips')
|
|
|
|
|
|
|
|
|
|
|
|
self.win.set_events(gtk.gdk.POINTER_MOTION_MASK)
|
|
|
|
self.win.connect_after('expose_event', self.expose)
|
|
|
|
self.win.connect('size-request', self.size_request)
|
|
|
|
self.win.connect('motion-notify-event', self.motion_notify_event)
|
|
|
|
|
|
|
|
def motion_notify_event(self, widget, event):
|
|
|
|
self.hide_tooltip()
|
|
|
|
|
|
|
|
def size_request(self, widget, requisition):
|
|
|
|
screen = self.win.get_screen()
|
|
|
|
half_width = requisition.width / 2 + 1
|
|
|
|
if self.prefered_position[0] < half_width:
|
|
|
|
self.prefered_position[0] = 0
|
|
|
|
elif self.prefered_position[0] + requisition.width > screen.get_width() \
|
|
|
|
+ half_width:
|
|
|
|
self.prefered_position[0] = screen.get_width() - requisition.width
|
|
|
|
else:
|
|
|
|
self.prefered_position[0] -= half_width
|
|
|
|
screen.get_height()
|
|
|
|
if self.prefered_position[1] + requisition.height > screen.get_height():
|
|
|
|
# flip tooltip up
|
2006-02-05 17:22:25 +01:00
|
|
|
self.prefered_position[1] -= requisition.height + self.widget_height \
|
|
|
|
+ 8
|
2005-08-15 01:52:12 +02:00
|
|
|
if self.prefered_position[1] < 0:
|
|
|
|
self.prefered_position[1] = 0
|
|
|
|
self.win.move(self.prefered_position[0], self.prefered_position[1])
|
|
|
|
|
|
|
|
def expose(self, widget, event):
|
|
|
|
style = self.win.get_style()
|
|
|
|
size = self.win.get_size()
|
2006-02-05 17:22:25 +01:00
|
|
|
style.paint_flat_box(self.win.window, gtk.STATE_NORMAL, gtk.SHADOW_OUT,
|
|
|
|
None, self.win, 'tooltip', 0, 0, -1, 1)
|
|
|
|
style.paint_flat_box(self.win.window, gtk.STATE_NORMAL, gtk.SHADOW_OUT,
|
|
|
|
None, self.win, 'tooltip', 0, size[1] - 1, -1, 1)
|
|
|
|
style.paint_flat_box(self.win.window, gtk.STATE_NORMAL, gtk.SHADOW_OUT,
|
|
|
|
None, self.win, 'tooltip', 0, 0, 1, -1)
|
|
|
|
style.paint_flat_box(self.win.window, gtk.STATE_NORMAL, gtk.SHADOW_OUT,
|
|
|
|
None, self.win, 'tooltip', size[0] - 1, 0, 1, -1)
|
2005-08-15 01:52:12 +02:00
|
|
|
return True
|
|
|
|
|
|
|
|
def show_tooltip(self, data, widget_pos, win_size):
|
|
|
|
self.populate(data)
|
|
|
|
new_x = win_size[0] + widget_pos[0]
|
|
|
|
new_y = win_size[1] + widget_pos[1] + 4
|
|
|
|
self.prefered_position = [new_x, new_y]
|
|
|
|
self.widget_height = widget_pos[1]
|
|
|
|
self.win.ensure_style()
|
|
|
|
self.win.show_all()
|
|
|
|
|
|
|
|
def hide_tooltip(self):
|
2005-10-08 18:47:35 +02:00
|
|
|
if self.timeout > 0:
|
2005-08-15 01:52:12 +02:00
|
|
|
gobject.source_remove(self.timeout)
|
|
|
|
self.timeout = 0
|
|
|
|
if self.win:
|
|
|
|
self.win.destroy()
|
|
|
|
self.win = None
|
|
|
|
self.id = None
|
|
|
|
|
|
|
|
class StatusTable:
|
|
|
|
''' Contains methods for creating status table. This
|
|
|
|
is used in Roster and NotificationArea tooltips '''
|
|
|
|
def __init__(self):
|
|
|
|
self.current_row = 1
|
|
|
|
self.table = None
|
2005-12-01 22:18:12 +01:00
|
|
|
self.text_label = None
|
2005-11-09 22:05:55 +01:00
|
|
|
self.spacer_label = ' '
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
def create_table(self):
|
|
|
|
self.table = gtk.Table(3, 1)
|
2005-08-26 18:31:22 +02:00
|
|
|
self.table.set_property('column-spacing', 2)
|
2005-12-01 22:18:12 +01:00
|
|
|
self.text_label = gtk.Label()
|
|
|
|
self.text_label.set_line_wrap(True)
|
|
|
|
self.text_label.set_alignment(0, 0)
|
|
|
|
self.text_label.set_selectable(False)
|
|
|
|
self.table.attach(self.text_label, 1, 4, 1, 2)
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
def get_status_info(self, resource, priority, show, status):
|
2005-08-26 02:52:44 +02:00
|
|
|
str_status = resource + ' (' + unicode(priority) + ')'
|
2005-08-15 01:52:12 +02:00
|
|
|
if status:
|
|
|
|
status = status.strip()
|
|
|
|
if status != '':
|
2005-08-17 16:14:32 +02:00
|
|
|
# make sure 'status' is unicode before we send to to reduce_chars...
|
2005-09-11 15:56:38 +02:00
|
|
|
if isinstance(status, str):
|
2005-08-17 16:14:32 +02:00
|
|
|
status = unicode(status, encoding='utf-8')
|
2005-09-11 15:56:38 +02:00
|
|
|
status = gtkgui_helpers.reduce_chars_newlines(status, 0, 1)
|
2005-08-15 01:52:12 +02:00
|
|
|
str_status += ' - ' + status
|
|
|
|
return gtkgui_helpers.escape_for_pango_markup(str_status)
|
|
|
|
|
|
|
|
def add_status_row(self, file_path, show, str_status):
|
|
|
|
''' appends a new row with status icon to the table '''
|
|
|
|
self.current_row += 1
|
|
|
|
state_file = show.replace(' ', '_')
|
|
|
|
files = []
|
|
|
|
files.append(os.path.join(file_path, state_file + '.png'))
|
|
|
|
files.append(os.path.join(file_path, state_file + '.gif'))
|
|
|
|
image = gtk.Image()
|
|
|
|
image.set_from_pixbuf(None)
|
|
|
|
for file in files:
|
|
|
|
if os.path.exists(file):
|
|
|
|
image.set_from_file(file)
|
|
|
|
break
|
2005-11-09 22:05:55 +01:00
|
|
|
spacer = gtk.Label(self.spacer_label)
|
2005-12-01 22:18:12 +01:00
|
|
|
image.set_alignment(0, 1.)
|
2005-08-15 01:52:12 +02:00
|
|
|
self.table.attach(spacer, 1, 2, self.current_row,
|
|
|
|
self.current_row + 1, 0, 0, 0, 0)
|
2005-08-26 18:31:22 +02:00
|
|
|
self.table.attach(image, 2, 3, self.current_row,
|
2005-08-15 01:52:12 +02:00
|
|
|
self.current_row + 1, 0, 0, 3, 0)
|
|
|
|
status_label = gtk.Label()
|
|
|
|
status_label.set_markup(str_status)
|
2005-12-01 22:18:12 +01:00
|
|
|
status_label.set_alignment(0, 0)
|
2005-08-15 01:52:12 +02:00
|
|
|
self.table.attach(status_label, 3, 4, self.current_row,
|
|
|
|
self.current_row + 1, gtk.EXPAND | gtk.FILL, 0, 0, 0)
|
|
|
|
|
|
|
|
class NotificationAreaTooltip(BaseTooltip, StatusTable):
|
|
|
|
''' Tooltip that is shown in the notification area '''
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self):
|
2005-08-15 01:52:12 +02:00
|
|
|
BaseTooltip.__init__(self)
|
|
|
|
StatusTable.__init__(self)
|
|
|
|
|
2005-11-09 22:05:55 +01:00
|
|
|
def get_accounts_info(self):
|
|
|
|
accounts = []
|
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 21:06:26 +01:00
|
|
|
for account in gajim.contacts.get_accounts():
|
|
|
|
status_idx = gajim.connections[account].connected
|
|
|
|
# uncomment the following to hide offline accounts
|
|
|
|
# if status_idx == 0: continue
|
|
|
|
status = gajim.SHOW_LIST[status_idx]
|
|
|
|
message = gajim.connections[account].status
|
|
|
|
single_line = helpers.get_uf_show(status)
|
|
|
|
if message is None:
|
|
|
|
message = ''
|
|
|
|
else:
|
|
|
|
message = message.strip()
|
|
|
|
if message != '':
|
|
|
|
single_line += ': ' + message
|
|
|
|
# the other solution is to hide offline accounts
|
|
|
|
elif status == 'offline':
|
|
|
|
message = helpers.get_uf_show(status)
|
|
|
|
accounts.append({'name': account, 'status_line': single_line,
|
|
|
|
'show': status, 'message': message})
|
2005-11-09 22:05:55 +01:00
|
|
|
return accounts
|
|
|
|
|
|
|
|
def fill_table_with_accounts(self, accounts):
|
|
|
|
iconset = gajim.config.get('iconset')
|
|
|
|
if not iconset:
|
2005-12-12 16:14:58 +01:00
|
|
|
iconset = 'dcraven'
|
2005-11-09 22:05:55 +01:00
|
|
|
file_path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
|
|
|
|
for acct in accounts:
|
|
|
|
message = acct['message']
|
|
|
|
# before reducing the chars we should assure we send unicode, else
|
|
|
|
# there are possible pango TBs on 'set_markup'
|
|
|
|
if isinstance(message, str):
|
|
|
|
message = unicode(message, encoding = 'utf-8')
|
|
|
|
message = gtkgui_helpers.reduce_chars_newlines(message, 50, 1)
|
|
|
|
message = gtkgui_helpers.escape_for_pango_markup(message)
|
|
|
|
if message:
|
2006-02-05 17:22:25 +01:00
|
|
|
self.add_status_row(file_path, acct['show'], '<span weight="bold">'\
|
|
|
|
+ gtkgui_helpers.escape_for_pango_markup(acct['name']) + \
|
|
|
|
'</span>' + ' - ' + message)
|
2005-11-09 22:05:55 +01:00
|
|
|
else:
|
2006-02-05 17:22:25 +01:00
|
|
|
self.add_status_row(file_path, acct['show'], '<span weight="bold">'\
|
|
|
|
+ gtkgui_helpers.escape_for_pango_markup(acct['name']) + \
|
|
|
|
'</span>')
|
2005-11-09 22:05:55 +01:00
|
|
|
|
|
|
|
def populate(self, data):
|
|
|
|
self.create_window()
|
|
|
|
self.create_table()
|
|
|
|
self.hbox = gtk.HBox()
|
|
|
|
self.table.set_property('column-spacing', 1)
|
|
|
|
text, single_line = '', ''
|
2005-08-24 14:23:35 +02:00
|
|
|
|
2005-10-20 13:17:17 +02:00
|
|
|
unread_chat = gajim.interface.roster.nb_unread
|
2005-09-24 12:24:14 +02:00
|
|
|
unread_single_chat = 0
|
|
|
|
unread_gc = 0
|
|
|
|
unread_pm = 0
|
|
|
|
|
2005-11-09 22:05:55 +01:00
|
|
|
accounts = self.get_accounts_info()
|
|
|
|
|
2005-09-24 12:24:14 +02:00
|
|
|
for acct in gajim.connections:
|
2006-01-31 05:03:34 +01:00
|
|
|
# Count unread chat messages
|
|
|
|
chat_t = message_control.TYPE_CHAT
|
|
|
|
for ctrl in gajim.interface.msg_win_mgr.get_controls(chat_t, acct):
|
|
|
|
unread_chat += ctrl.nb_unread
|
|
|
|
|
|
|
|
# Count unread PM messages for which we have a control
|
|
|
|
chat_t = message_control.TYPE_PM
|
|
|
|
for ctrl in gajim.interface.msg_win_mgr.get_controls(chat_t, acct):
|
|
|
|
unread_pm += ctrl.nb_unread
|
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 21:06:26 +01:00
|
|
|
|
2005-09-24 12:24:14 +02:00
|
|
|
# we count unread gc/pm messages
|
2006-01-06 07:59:55 +01:00
|
|
|
chat_t = message_control.TYPE_GC
|
2006-01-31 05:03:34 +01:00
|
|
|
for ctrl in gajim.interface.msg_win_mgr.get_controls(chat_t, acct):
|
2006-02-05 17:22:25 +01:00
|
|
|
# These are PMs for which the PrivateChatControl has not yet been
|
|
|
|
# created
|
2006-01-31 05:03:34 +01:00
|
|
|
pm_msgs = ctrl.get_specific_unread()
|
|
|
|
unread_gc += ctrl.nb_unread
|
2006-01-06 07:59:55 +01:00
|
|
|
unread_gc -= pm_msgs
|
|
|
|
unread_pm += pm_msgs
|
2005-09-24 12:24:14 +02:00
|
|
|
|
|
|
|
if unread_chat or unread_single_chat or unread_gc or unread_pm:
|
|
|
|
text = ''
|
|
|
|
if unread_chat:
|
|
|
|
text += i18n.ngettext(
|
2005-09-03 14:58:29 +02:00
|
|
|
'Gajim - %d unread message',
|
2005-08-24 14:23:35 +02:00
|
|
|
'Gajim - %d unread messages',
|
2005-09-24 12:24:14 +02:00
|
|
|
unread_chat, unread_chat, unread_chat)
|
|
|
|
text += '\n'
|
|
|
|
if unread_single_chat:
|
|
|
|
text += i18n.ngettext(
|
|
|
|
'Gajim - %d unread single message',
|
|
|
|
'Gajim - %d unread single messages',
|
|
|
|
unread_single_chat, unread_single_chat, unread_single_chat)
|
|
|
|
text += '\n'
|
|
|
|
if unread_gc:
|
|
|
|
text += i18n.ngettext(
|
|
|
|
'Gajim - %d unread group chat message',
|
|
|
|
'Gajim - %d unread group chat messages',
|
|
|
|
unread_gc, unread_gc, unread_gc)
|
|
|
|
text += '\n'
|
|
|
|
if unread_pm:
|
|
|
|
text += i18n.ngettext(
|
|
|
|
'Gajim - %d unread private message',
|
|
|
|
'Gajim - %d unread private messages',
|
|
|
|
unread_pm, unread_pm, unread_pm)
|
|
|
|
text += '\n'
|
|
|
|
text = text[:-1] # remove latest \n
|
2005-08-15 01:52:12 +02:00
|
|
|
elif len(accounts) > 1:
|
|
|
|
text = _('Gajim')
|
|
|
|
self.current_row = 1
|
2005-09-13 00:27:36 +02:00
|
|
|
self.table.resize(2, 1)
|
2005-11-09 22:05:55 +01:00
|
|
|
self.fill_table_with_accounts(accounts)
|
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
elif len(accounts) == 1:
|
2005-11-09 22:05:55 +01:00
|
|
|
message = accounts[0]['status_line']
|
|
|
|
message = gtkgui_helpers.reduce_chars_newlines(message, 50, 1)
|
2005-08-15 01:52:12 +02:00
|
|
|
message = gtkgui_helpers.escape_for_pango_markup(message)
|
|
|
|
text = _('Gajim - %s') % message
|
|
|
|
else:
|
|
|
|
text = _('Gajim - %s') % helpers.get_uf_show('offline')
|
2005-12-01 22:18:12 +01:00
|
|
|
self.text_label.set_markup(text)
|
2005-08-15 01:52:12 +02:00
|
|
|
self.hbox.add(self.table)
|
|
|
|
self.win.add(self.hbox)
|
2005-08-24 19:29:35 +02:00
|
|
|
|
2005-12-01 22:18:12 +01:00
|
|
|
class GCTooltip(BaseTooltip):
|
2005-08-24 14:58:03 +02:00
|
|
|
''' Tooltip that is shown in the GC treeview '''
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self):
|
2005-08-24 14:58:03 +02:00
|
|
|
self.account = None
|
2005-09-03 19:30:49 +02:00
|
|
|
|
2005-12-01 22:18:12 +01:00
|
|
|
self.text_label = gtk.Label()
|
|
|
|
self.text_label.set_line_wrap(True)
|
|
|
|
self.text_label.set_alignment(0, 0)
|
|
|
|
self.text_label.set_selectable(False)
|
2005-09-03 19:30:49 +02:00
|
|
|
|
2005-08-24 14:58:03 +02:00
|
|
|
BaseTooltip.__init__(self)
|
|
|
|
|
|
|
|
def populate(self, contact):
|
2005-08-24 19:29:35 +02:00
|
|
|
if not contact:
|
2005-08-24 14:58:03 +02:00
|
|
|
return
|
|
|
|
self.create_window()
|
2005-08-25 17:10:53 +02:00
|
|
|
hbox = gtk.HBox()
|
2005-09-03 19:30:49 +02:00
|
|
|
|
|
|
|
if contact.jid.strip() != '':
|
|
|
|
info = '<span size="large" weight="bold">' + contact.jid + '</span>'
|
|
|
|
else:
|
2006-02-05 17:22:25 +01:00
|
|
|
info = '<span size="large" weight="bold">' + contact.get_shown_name() \
|
|
|
|
+ '</span>'
|
2005-09-03 19:30:49 +02:00
|
|
|
|
2005-08-24 14:58:03 +02:00
|
|
|
info += '\n<span weight="bold">' + _('Role: ') + '</span>' + \
|
2005-08-24 16:08:35 +02:00
|
|
|
helpers.get_uf_role(contact.role)
|
2005-08-24 14:58:03 +02:00
|
|
|
|
|
|
|
info += '\n<span weight="bold">' + _('Affiliation: ') + '</span>' + \
|
2005-08-24 16:08:35 +02:00
|
|
|
contact.affiliation.capitalize()
|
2005-08-24 14:58:03 +02:00
|
|
|
|
|
|
|
info += '\n<span weight="bold">' + _('Status: ') + \
|
|
|
|
'</span>' + helpers.get_uf_show(contact.show)
|
2005-08-15 01:52:12 +02:00
|
|
|
|
2005-08-24 14:58:03 +02:00
|
|
|
if contact.status:
|
|
|
|
status = contact.status.strip()
|
|
|
|
if status != '':
|
2005-08-24 16:08:35 +02:00
|
|
|
# escape markup entities
|
2005-08-24 14:58:03 +02:00
|
|
|
info += ' - ' + gtkgui_helpers.escape_for_pango_markup(status)
|
2005-09-03 19:30:49 +02:00
|
|
|
|
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 21:06:26 +01:00
|
|
|
if hasattr(contact, 'resource') and contact.resource.strip() != '':
|
2005-09-03 19:30:49 +02:00
|
|
|
info += '\n<span weight="bold">' + _('Resource: ') + \
|
|
|
|
'</span>' + gtkgui_helpers.escape_for_pango_markup(
|
|
|
|
contact.resource)
|
2005-08-24 16:08:35 +02:00
|
|
|
|
2005-12-01 22:18:12 +01:00
|
|
|
self.text_label.set_markup(info)
|
|
|
|
hbox.add(self.text_label)
|
2005-08-25 17:10:53 +02:00
|
|
|
self.win.add(hbox)
|
2005-08-24 14:58:03 +02:00
|
|
|
|
2005-11-09 22:05:55 +01:00
|
|
|
class RosterTooltip(NotificationAreaTooltip):
|
2005-08-15 01:52:12 +02:00
|
|
|
''' Tooltip that is shown in the roster treeview '''
|
2005-10-20 13:17:17 +02:00
|
|
|
def __init__(self):
|
2005-08-15 01:52:12 +02:00
|
|
|
self.account = None
|
|
|
|
self.image = gtk.Image()
|
2005-12-01 22:18:12 +01:00
|
|
|
self.image.set_alignment(0, 0)
|
2005-08-26 18:31:22 +02:00
|
|
|
# padding is independent of the total length and better than alignment
|
|
|
|
self.image.set_padding(1, 2)
|
2006-02-05 17:47:25 +01:00
|
|
|
self.avatar_image = gtk.Image()
|
2005-11-09 22:05:55 +01:00
|
|
|
NotificationAreaTooltip.__init__(self)
|
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
def populate(self, contacts):
|
|
|
|
self.create_window()
|
|
|
|
self.hbox = gtk.HBox()
|
|
|
|
self.hbox.set_homogeneous(False)
|
2005-08-26 18:31:22 +02:00
|
|
|
self.hbox.set_spacing(0)
|
2005-08-15 01:52:12 +02:00
|
|
|
self.create_table()
|
2005-11-09 22:05:55 +01:00
|
|
|
if not contacts or len(contacts) == 0:
|
2005-11-12 21:07:46 +01:00
|
|
|
# Tooltip for merged accounts row
|
2005-11-09 22:05:55 +01:00
|
|
|
accounts = self.get_accounts_info()
|
|
|
|
self.current_row = 0
|
|
|
|
self.table.resize(2, 1)
|
|
|
|
self.spacer_label = ''
|
|
|
|
self.fill_table_with_accounts(accounts)
|
|
|
|
self.hbox.add(self.table)
|
|
|
|
self.win.add(self.hbox)
|
|
|
|
return
|
2005-08-15 01:52:12 +02:00
|
|
|
# primary contact
|
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 21:06:26 +01:00
|
|
|
prim_contact = gajim.contacts.get_highest_prio_contact_from_contacts(
|
|
|
|
contacts)
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
# try to find the image for the contact status
|
2005-11-12 21:07:46 +01:00
|
|
|
icon_name = helpers.get_icon_name_to_show(prim_contact)
|
|
|
|
state_file = icon_name.replace(' ', '_')
|
2005-08-26 15:11:20 +02:00
|
|
|
transport = gajim.get_transport_name_from_jid(prim_contact.jid)
|
2005-08-15 01:52:12 +02:00
|
|
|
if transport:
|
|
|
|
file_path = os.path.join(gajim.DATA_DIR, 'iconsets', 'transports',
|
|
|
|
transport , '16x16')
|
|
|
|
else:
|
|
|
|
iconset = gajim.config.get('iconset')
|
|
|
|
if not iconset:
|
2005-12-12 16:14:58 +01:00
|
|
|
iconset = 'dcraven'
|
2005-08-15 01:52:12 +02:00
|
|
|
file_path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
|
|
|
|
|
|
|
|
files = []
|
|
|
|
file_full_path = os.path.join(file_path, state_file)
|
|
|
|
files.append(file_full_path + '.png')
|
|
|
|
files.append(file_full_path + '.gif')
|
|
|
|
self.image.set_from_pixbuf(None)
|
|
|
|
for file in files:
|
|
|
|
if os.path.exists(file):
|
|
|
|
self.image.set_from_file(file)
|
|
|
|
break
|
|
|
|
|
|
|
|
info = '<span size="large" weight="bold">' + prim_contact.jid + '</span>'
|
|
|
|
info += '\n<span weight="bold">' + _('Name: ') + '</span>' + \
|
2006-01-10 19:30:57 +01:00
|
|
|
gtkgui_helpers.escape_for_pango_markup(prim_contact.get_shown_name())
|
2005-09-13 23:13:40 +02:00
|
|
|
if prim_contact.sub:
|
|
|
|
info += '\n<span weight="bold">' + _('Subscription: ') + '</span>' + \
|
|
|
|
gtkgui_helpers.escape_for_pango_markup(prim_contact.sub)
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
if prim_contact.keyID:
|
|
|
|
keyID = None
|
|
|
|
if len(prim_contact.keyID) == 8:
|
|
|
|
keyID = prim_contact.keyID
|
|
|
|
elif len(prim_contact.keyID) == 16:
|
|
|
|
keyID = prim_contact.keyID[8:]
|
|
|
|
if keyID:
|
|
|
|
info += '\n<span weight="bold">' + _('OpenPGP: ') + \
|
|
|
|
'</span>' + gtkgui_helpers.escape_for_pango_markup(keyID)
|
|
|
|
|
|
|
|
num_resources = 0
|
|
|
|
for contact in contacts:
|
|
|
|
if contact.resource:
|
|
|
|
num_resources += 1
|
|
|
|
if num_resources > 1:
|
|
|
|
self.current_row = 1
|
|
|
|
self.table.resize(2,1)
|
|
|
|
info += '\n<span weight="bold">' + _('Status: ') + '</span>'
|
|
|
|
for contact in contacts:
|
|
|
|
if contact.resource:
|
2006-02-05 17:22:25 +01:00
|
|
|
status_line = self.get_status_info(contact.resource,
|
|
|
|
contact.priority, contact.show, contact.status)
|
2005-11-12 21:07:46 +01:00
|
|
|
icon_name = helpers.get_icon_name_to_show(contact)
|
|
|
|
self.add_status_row(file_path, icon_name, status_line)
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
else: # only one resource
|
|
|
|
if contact.resource:
|
|
|
|
info += '\n<span weight="bold">' + _('Resource: ') + \
|
|
|
|
'</span>' + gtkgui_helpers.escape_for_pango_markup(
|
2005-08-26 02:52:44 +02:00
|
|
|
contact.resource) + ' (' + unicode(contact.priority) + ')'
|
2005-08-15 01:52:12 +02:00
|
|
|
if contact.show:
|
|
|
|
info += '\n<span weight="bold">' + _('Status: ') + \
|
|
|
|
'</span>' + helpers.get_uf_show(contact.show)
|
|
|
|
if contact.status:
|
|
|
|
status = contact.status.strip()
|
|
|
|
if status != '':
|
2005-09-04 03:40:17 +02:00
|
|
|
# reduce long status
|
|
|
|
# (no more than 130 chars on line and no more than 5 lines)
|
2005-08-25 17:10:53 +02:00
|
|
|
status = gtkgui_helpers.reduce_chars_newlines(status, 130, 5)
|
|
|
|
# escape markup entities.
|
2005-08-15 01:52:12 +02:00
|
|
|
info += ' - ' + gtkgui_helpers.escape_for_pango_markup(status)
|
|
|
|
|
2006-02-05 17:47:25 +01:00
|
|
|
for type_ in ('jpeg', 'png'):
|
|
|
|
file = os.path.join(gajim.AVATAR_PATH, prim_contact.jid + '.' + type_)
|
|
|
|
if os.path.exists(file):
|
|
|
|
self.avatar_image.set_from_file(file)
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.avatar_image.set_from_pixbuf(None)
|
2005-12-01 22:18:12 +01:00
|
|
|
self.text_label.set_markup(info)
|
2005-08-15 01:52:12 +02:00
|
|
|
self.hbox.pack_start(self.image, False, False)
|
|
|
|
self.hbox.pack_start(self.table, True, True)
|
2006-02-05 17:47:25 +01:00
|
|
|
self.hbox.pack_start(self.avatar_image, False, False)
|
2005-08-15 01:52:12 +02:00
|
|
|
self.win.add(self.hbox)
|
|
|
|
|
|
|
|
class FileTransfersTooltip(BaseTooltip):
|
|
|
|
''' Tooltip that is shown in the notification area '''
|
|
|
|
def __init__(self):
|
2005-12-01 22:18:12 +01:00
|
|
|
self.text_label = gtk.Label()
|
|
|
|
self.text_label.set_line_wrap(True)
|
|
|
|
self.text_label.set_alignment(0, 0)
|
|
|
|
self.text_label.set_selectable(False)
|
2005-08-15 01:52:12 +02:00
|
|
|
BaseTooltip.__init__(self)
|
|
|
|
|
|
|
|
def populate(self, file_props):
|
|
|
|
self.create_window()
|
|
|
|
self.hbox = gtk.HBox()
|
|
|
|
text = '<b>' + _('Name: ') + '</b>'
|
|
|
|
name = file_props['name']
|
2005-08-23 23:50:18 +02:00
|
|
|
if file_props['type'] == 'r':
|
|
|
|
(file_path, file_name) = os.path.split(file_props['file-name'])
|
|
|
|
else:
|
|
|
|
file_name = file_props['name']
|
|
|
|
text += gtkgui_helpers.escape_for_pango_markup(file_name)
|
2005-08-15 01:52:12 +02:00
|
|
|
text += '\n<b>' + _('Type: ') + '</b>'
|
|
|
|
if file_props['type'] == 'r':
|
|
|
|
text += _('Download')
|
|
|
|
text += '\n<b>' + _('Sender: ') + '</b>'
|
2005-08-26 02:52:44 +02:00
|
|
|
sender = unicode(file_props['sender']).split('/')[0]
|
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 21:06:26 +01:00
|
|
|
name = gajim.contacts.get_first_contact_from_jid(
|
2006-01-10 19:30:57 +01:00
|
|
|
file_props['tt_account'], sender).get_shown_name()
|
2005-08-15 01:52:12 +02:00
|
|
|
else:
|
2006-01-21 00:12:12 +01:00
|
|
|
text += _('Upload')
|
2005-08-15 01:52:12 +02:00
|
|
|
text += '\n<b>' + _('Recipient: ') + '</b>'
|
|
|
|
receiver = file_props['receiver']
|
|
|
|
if hasattr(receiver, 'name'):
|
2006-01-21 00:12:12 +01:00
|
|
|
name = receiver.get_shown_name()
|
2005-08-15 01:52:12 +02:00
|
|
|
else:
|
2006-01-21 00:12:12 +01:00
|
|
|
name = receiver.split('/')[0]
|
2005-08-15 01:52:12 +02:00
|
|
|
text += gtkgui_helpers.escape_for_pango_markup(name)
|
|
|
|
text += '\n<b>' + _('Size: ') + '</b>'
|
|
|
|
text += helpers.convert_bytes(file_props['size'])
|
|
|
|
text += '\n<b>' + _('Transferred: ') + '</b>'
|
|
|
|
transfered_len = 0
|
|
|
|
if file_props.has_key('received-len'):
|
|
|
|
transfered_len = file_props['received-len']
|
|
|
|
text += helpers.convert_bytes(transfered_len)
|
|
|
|
text += '\n<b>' + _('Status: ') + '</b>'
|
|
|
|
status = ''
|
|
|
|
if not file_props.has_key('started') or not file_props['started']:
|
2005-08-24 13:57:14 +02:00
|
|
|
status = _('Not started')
|
2005-08-15 01:52:12 +02:00
|
|
|
elif file_props.has_key('connected'):
|
|
|
|
if file_props.has_key('stopped') and \
|
|
|
|
file_props['stopped'] == True:
|
2005-08-24 13:57:14 +02:00
|
|
|
status = _('Stopped')
|
2005-08-15 01:52:12 +02:00
|
|
|
elif file_props['completed']:
|
2005-08-24 13:57:14 +02:00
|
|
|
status = _('Completed')
|
2005-08-15 01:52:12 +02:00
|
|
|
elif file_props['connected'] == False:
|
|
|
|
if file_props['completed']:
|
2005-08-24 13:57:14 +02:00
|
|
|
status = _('Completed')
|
2005-08-15 01:52:12 +02:00
|
|
|
else:
|
|
|
|
if file_props.has_key('paused') and \
|
|
|
|
file_props['paused'] == True:
|
2005-08-24 13:57:14 +02:00
|
|
|
status = _('Paused')
|
2005-08-15 01:52:12 +02:00
|
|
|
elif file_props.has_key('stalled') and \
|
|
|
|
file_props['stalled'] == True:
|
2005-08-17 14:17:09 +02:00
|
|
|
#stalled is not paused. it is like 'frozen' it stopped alone
|
2005-08-24 13:57:14 +02:00
|
|
|
status = _('Stalled')
|
2005-08-15 01:52:12 +02:00
|
|
|
else:
|
2005-08-24 13:57:14 +02:00
|
|
|
status = _('Transferring')
|
2005-08-15 01:52:12 +02:00
|
|
|
else:
|
2005-08-24 13:57:14 +02:00
|
|
|
status = _('Not started')
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
text += status
|
2005-12-01 22:18:12 +01:00
|
|
|
self.text_label.set_markup(text)
|
|
|
|
self.hbox.add(self.text_label)
|
2005-09-03 19:44:51 +02:00
|
|
|
self.win.add(self.hbox)
|
2005-10-30 15:33:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ServiceDiscoveryTooltip(BaseTooltip):
|
|
|
|
''' Tooltip that is shown when hovering over a service discovery row '''
|
|
|
|
def populate(self, status):
|
|
|
|
self.create_window()
|
|
|
|
label = gtk.Label()
|
|
|
|
label.set_line_wrap(True)
|
|
|
|
label.set_alignment(0, 0)
|
|
|
|
label.set_selectable(False)
|
|
|
|
if status == 1:
|
2006-02-05 17:22:25 +01:00
|
|
|
label.set_text(
|
|
|
|
_('This service has not yet responded with detailed information'))
|
2005-10-30 15:33:25 +01:00
|
|
|
elif status == 2:
|
2006-02-05 17:22:25 +01:00
|
|
|
label.set_text(
|
|
|
|
_('This service could not respond with detailed information.\n'
|
|
|
|
'It is most likely legacy or broken'))
|
2005-10-30 15:33:25 +01:00
|
|
|
self.win.add(label)
|