2007-04-01 11:02:04 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2005-08-15 01:52:12 +02:00
|
|
|
## tooltips.py
|
|
|
|
##
|
2006-03-25 12:12:31 +01:00
|
|
|
## Copyright (C) 2005-2006 Dimitur Kirov <dkirov@gmail.com>
|
2007-01-17 00:26:38 +01:00
|
|
|
## Copyright (C) 2005-2007 Nikos Kouremenos <kourem@gmail.com>
|
2007-12-12 09:44:46 +01:00
|
|
|
## Copyright (C) 2005-2006 Yann Leboulanger <asterix@lagaule.org>
|
2007-08-09 17:39:18 +02:00
|
|
|
## Copyright (C) 2007 Julien Pivotto <roidelapluie@gmail.com>
|
2005-08-15 01:52:12 +02:00
|
|
|
##
|
2007-12-12 09:44:46 +01:00
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
|
|
|
## Gajim is free software; you can redistribute it and/or modify
|
2005-08-15 01:52:12 +02:00
|
|
|
## it under the terms of the GNU General Public License as published
|
2007-12-12 09:44:46 +01:00
|
|
|
## by the Free Software Foundation; version 3 only.
|
2005-08-15 01:52:12 +02:00
|
|
|
##
|
2007-12-12 09:44:46 +01:00
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
2005-08-15 01:52:12 +02:00
|
|
|
## 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.
|
|
|
|
##
|
2007-12-12 09:44:46 +01:00
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
import gtk
|
|
|
|
import gobject
|
|
|
|
import os
|
2006-02-22 15:31:01 +01:00
|
|
|
import time
|
2006-02-24 13:37:29 +01:00
|
|
|
import locale
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
import gtkgui_helpers
|
|
|
|
|
|
|
|
from common import gajim
|
|
|
|
from common import helpers
|
|
|
|
|
|
|
|
class BaseTooltip:
|
2006-02-28 11:13:42 +01:00
|
|
|
''' Base Tooltip class;
|
|
|
|
Usage:
|
|
|
|
tooltip = BaseTooltip()
|
|
|
|
....
|
|
|
|
tooltip.show_tooltip(data, widget_height, widget_y_position)
|
|
|
|
....
|
|
|
|
if tooltip.timeout != 0:
|
|
|
|
tooltip.hide_tooltip()
|
|
|
|
|
|
|
|
* data - the text to be displayed (extenders override this argument and
|
2006-10-05 02:06:57 +02:00
|
|
|
display more complex contents)
|
2006-02-28 11:13:42 +01:00
|
|
|
* widget_height - the height of the widget on which we want to show tooltip
|
|
|
|
* widget_y_position - the vertical position of the widget on the screen
|
|
|
|
|
|
|
|
Tooltip is displayed aligned centered to the mouse poiner and 4px below the widget.
|
|
|
|
In case tooltip goes below the visible area it is shown above the widget.
|
2005-08-15 01:52:12 +02:00
|
|
|
'''
|
|
|
|
def __init__(self):
|
|
|
|
self.timeout = 0
|
2006-02-28 11:13:42 +01:00
|
|
|
self.preferred_position = [0, 0]
|
2005-08-15 01:52:12 +02:00
|
|
|
self.win = None
|
|
|
|
self.id = None
|
|
|
|
|
|
|
|
def populate(self, data):
|
2006-02-28 11:13:42 +01:00
|
|
|
''' this method must be overriden by all extenders
|
|
|
|
This is the most simple implementation: show data as value of a label
|
|
|
|
'''
|
2005-08-15 01:52:12 +02:00
|
|
|
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')
|
2007-12-12 09:44:46 +01:00
|
|
|
if gtk.gtk_version >= (2, 10, 0) and gtk.pygtk_version >= (2, 10, 0):
|
|
|
|
self.win.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_TOOLTIP)
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
self.win.set_events(gtk.gdk.POINTER_MOTION_MASK)
|
|
|
|
self.win.connect_after('expose_event', self.expose)
|
2006-02-28 11:13:42 +01:00
|
|
|
self.win.connect('size-request', self.on_size_request)
|
2005-08-15 01:52:12 +02:00
|
|
|
self.win.connect('motion-notify-event', self.motion_notify_event)
|
2006-02-28 11:13:42 +01:00
|
|
|
self.screen = self.win.get_screen()
|
2005-08-15 01:52:12 +02:00
|
|
|
|
2006-02-28 17:12:59 +01:00
|
|
|
def _get_icon_name_for_tooltip(self, contact):
|
|
|
|
''' helper function used for tooltip contacts/acounts
|
|
|
|
Tooltip on account has fake contact with sub == '', in this case we show
|
|
|
|
real status of the account
|
|
|
|
'''
|
|
|
|
if contact.ask == 'subscribe':
|
|
|
|
return 'requested'
|
|
|
|
elif contact.sub in ('both', 'to', ''):
|
|
|
|
return contact.show
|
|
|
|
return 'not in roster'
|
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
def motion_notify_event(self, widget, event):
|
|
|
|
self.hide_tooltip()
|
|
|
|
|
2006-02-28 11:13:42 +01:00
|
|
|
def on_size_request(self, widget, requisition):
|
2006-02-28 11:15:42 +01:00
|
|
|
half_width = requisition.width / 2 + 1
|
|
|
|
if self.preferred_position[0] < half_width:
|
2006-02-28 11:13:42 +01:00
|
|
|
self.preferred_position[0] = 0
|
2007-12-12 09:44:46 +01:00
|
|
|
elif self.preferred_position[0] + requisition.width > \
|
2006-02-28 11:13:42 +01:00
|
|
|
self.screen.get_width() + half_width:
|
|
|
|
self.preferred_position[0] = self.screen.get_width() - \
|
|
|
|
requisition.width
|
2005-08-15 01:52:12 +02:00
|
|
|
else:
|
2006-02-28 11:13:42 +01:00
|
|
|
self.preferred_position[0] -= half_width
|
2006-02-28 11:15:42 +01:00
|
|
|
self.screen.get_height()
|
2006-02-28 11:13:42 +01:00
|
|
|
if self.preferred_position[1] + requisition.height > \
|
|
|
|
self.screen.get_height():
|
2005-08-15 01:52:12 +02:00
|
|
|
# flip tooltip up
|
2007-12-12 09:44:46 +01:00
|
|
|
self.preferred_position[1] -= requisition.height + \
|
2006-02-28 11:13:42 +01:00
|
|
|
self.widget_height + 8
|
|
|
|
if self.preferred_position[1] < 0:
|
|
|
|
self.preferred_position[1] = 0
|
|
|
|
self.win.move(self.preferred_position[0], self.preferred_position[1])
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2006-02-28 11:13:42 +01:00
|
|
|
def show_tooltip(self, data, widget_height, widget_y_position):
|
|
|
|
''' show tooltip on widget.
|
|
|
|
data contains needed data for tooltip contents
|
|
|
|
widget_height is the height of the widget on which we show the tooltip
|
|
|
|
widget_y_position is vertical position of the widget on the screen
|
|
|
|
'''
|
|
|
|
# set tooltip contents
|
2005-08-15 01:52:12 +02:00
|
|
|
self.populate(data)
|
2006-02-28 11:13:42 +01:00
|
|
|
|
|
|
|
# get the X position of mouse pointer on the screen
|
|
|
|
pointer_x = self.screen.get_display().get_pointer()[1]
|
|
|
|
|
|
|
|
# get the prefered X position of the tooltip on the screen in case this position is >
|
|
|
|
# than the height of the screen, tooltip will be shown above the widget
|
|
|
|
preferred_y = widget_y_position + widget_height + 4
|
|
|
|
|
|
|
|
self.preferred_position = [pointer_x, preferred_y]
|
2006-10-05 02:06:57 +02:00
|
|
|
self.widget_height = widget_height
|
2005-08-15 01:52:12 +02:00
|
|
|
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):
|
2006-03-21 21:52:25 +01:00
|
|
|
self.table = gtk.Table(4, 1)
|
2005-08-26 18:31:22 +02:00
|
|
|
self.table.set_property('column-spacing', 2)
|
2006-03-21 16:44:36 +01:00
|
|
|
|
2007-08-09 17:39:18 +02:00
|
|
|
def add_text_row(self, text, col_inc = 0):
|
|
|
|
self.current_row += 1
|
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)
|
2006-03-21 16:44:36 +01:00
|
|
|
self.text_label.set_markup(text)
|
2007-08-09 17:39:18 +02:00
|
|
|
self.table.attach(self.text_label, 1 + col_inc, 4, self.current_row,
|
|
|
|
self.current_row + 1)
|
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 != '':
|
2006-02-28 11:13:42 +01: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')
|
2006-09-26 16:40:13 +02:00
|
|
|
# reduce to 100 chars, 1 line
|
2006-10-06 16:52:25 +02:00
|
|
|
status = helpers.reduce_chars_newlines(status, 100, 1)
|
2007-01-17 00:26:38 +01:00
|
|
|
str_status = gobject.markup_escape_text(str_status)
|
|
|
|
status = gobject.markup_escape_text(status)
|
2006-09-28 00:56:50 +02:00
|
|
|
str_status += ' - <i>' + status + '</i>'
|
2006-09-26 04:41:47 +02:00
|
|
|
return str_status
|
2005-08-15 01:52:12 +02:00
|
|
|
|
2006-04-15 11:24:07 +02:00
|
|
|
def add_status_row(self, file_path, show, str_status, status_time = None, show_lock = False):
|
2005-08-15 01:52:12 +02:00
|
|
|
''' 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)
|
2006-03-21 21:52:25 +01:00
|
|
|
image.set_alignment(1, 0.5)
|
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,
|
2006-03-21 21:52:25 +01:00
|
|
|
self.current_row + 1, gtk.FILL, gtk.FILL, 2, 0)
|
2005-08-15 01:52:12 +02:00
|
|
|
status_label = gtk.Label()
|
|
|
|
status_label.set_markup(str_status)
|
2005-12-01 22:18:12 +01:00
|
|
|
status_label.set_alignment(0, 0)
|
2006-03-21 21:52:25 +01:00
|
|
|
status_label.set_line_wrap(True)
|
|
|
|
self.table.attach(status_label, 3, 4, self.current_row,
|
2006-03-21 16:44:36 +01:00
|
|
|
self.current_row + 1, gtk.FILL | gtk.EXPAND, 0, 0, 0)
|
2006-04-15 11:24:07 +02:00
|
|
|
if show_lock:
|
|
|
|
lock_image = gtk.Image()
|
|
|
|
lock_image.set_from_stock(gtk.STOCK_DIALOG_AUTHENTICATION,
|
|
|
|
gtk.ICON_SIZE_MENU)
|
|
|
|
self.table.attach(lock_image, 4, 5, self.current_row,
|
|
|
|
self.current_row + 1, 0, 0, 0, 0)
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
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 fill_table_with_accounts(self, accounts):
|
|
|
|
iconset = gajim.config.get('iconset')
|
|
|
|
if not iconset:
|
2005-12-12 16:14:58 +01:00
|
|
|
iconset = 'dcraven'
|
2007-08-09 17:39:18 +02:00
|
|
|
file_path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
|
2005-11-09 22:05:55 +01:00
|
|
|
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')
|
2006-10-06 16:52:25 +02:00
|
|
|
message = helpers.reduce_chars_newlines(message, 100, 1)
|
2007-01-17 00:26:38 +01:00
|
|
|
message = gobject.markup_escape_text(message)
|
2006-04-15 11:24:07 +02:00
|
|
|
if gajim.con_types.has_key(acct['name']) and \
|
|
|
|
gajim.con_types[acct['name']] in ('tls', 'ssl'):
|
|
|
|
show_lock = True
|
|
|
|
else:
|
|
|
|
show_lock = False
|
2005-11-09 22:05:55 +01:00
|
|
|
if message:
|
2006-04-21 15:48:27 +02:00
|
|
|
self.add_status_row(file_path, acct['show'],
|
2007-01-17 00:26:38 +01:00
|
|
|
gobject.markup_escape_text(acct['name']) + \
|
2006-04-21 15:48:27 +02:00
|
|
|
' - ' + message, show_lock=show_lock)
|
2005-11-09 22:05:55 +01:00
|
|
|
else:
|
2006-04-21 15:48:27 +02:00
|
|
|
self.add_status_row(file_path, acct['show'],
|
2007-01-17 00:26:38 +01:00
|
|
|
gobject.markup_escape_text(acct['name'])
|
2006-04-21 15:48:27 +02:00
|
|
|
, show_lock=show_lock)
|
2007-08-09 17:39:18 +02:00
|
|
|
for line in acct['event_lines']:
|
|
|
|
self.add_text_row(' ' + line, 2)
|
2005-11-09 22:05:55 +01:00
|
|
|
|
|
|
|
def populate(self, data):
|
|
|
|
self.create_window()
|
|
|
|
self.create_table()
|
2007-08-09 17:39:18 +02:00
|
|
|
|
|
|
|
accounts = helpers.get_notification_icon_tooltip_dict()
|
|
|
|
self.table.resize(2, 1)
|
|
|
|
self.fill_table_with_accounts(accounts)
|
2006-10-05 02:06:57 +02:00
|
|
|
self.hbox = gtk.HBox()
|
|
|
|
self.table.set_property('column-spacing', 1)
|
2005-11-09 22:05:55 +01:00
|
|
|
|
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-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)
|
2006-03-17 16:26:58 +01:00
|
|
|
self.avatar_image = gtk.Image()
|
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()
|
2006-03-21 22:33:56 +01:00
|
|
|
vcard_table = gtk.Table(3, 1)
|
|
|
|
vcard_table.set_property('column-spacing', 2)
|
|
|
|
vcard_table.set_homogeneous(False)
|
|
|
|
vcard_current_row = 1
|
|
|
|
properties = []
|
2006-09-24 22:37:02 +02:00
|
|
|
|
2006-09-28 00:56:50 +02:00
|
|
|
nick_markup = '<b>' + \
|
2007-01-17 00:26:38 +01:00
|
|
|
gobject.markup_escape_text(contact.get_shown_name()) \
|
2006-09-28 00:56:50 +02:00
|
|
|
+ '</b>'
|
2006-09-26 04:41:47 +02:00
|
|
|
properties.append((nick_markup, None))
|
2006-09-24 22:37:02 +02:00
|
|
|
|
2006-09-26 04:41:47 +02:00
|
|
|
if contact.status: # status message
|
|
|
|
status = contact.status.strip()
|
|
|
|
if status != '':
|
2005-08-24 16:08:35 +02:00
|
|
|
# escape markup entities
|
2007-08-09 17:39:18 +02:00
|
|
|
status = helpers.reduce_chars_newlines(status, 300, 5)
|
2006-09-28 00:56:50 +02:00
|
|
|
status = '<i>' +\
|
2007-02-04 14:01:04 +01:00
|
|
|
gobject.markup_escape_text(status) + '</i>'
|
2006-09-26 04:41:47 +02:00
|
|
|
properties.append((status, None))
|
|
|
|
else: # no status message, show SHOW instead
|
|
|
|
show = helpers.get_uf_show(contact.show)
|
2006-09-28 00:56:50 +02:00
|
|
|
show = '<i>' + show + '</i>'
|
2006-09-26 04:41:47 +02:00
|
|
|
properties.append((show, None))
|
2006-09-24 22:37:02 +02:00
|
|
|
|
|
|
|
if contact.jid.strip() != '':
|
2006-11-21 19:46:33 +01:00
|
|
|
properties.append((_('Jabber ID: '), contact.jid))
|
2006-10-12 04:44:15 +02:00
|
|
|
|
2006-09-24 22:37:02 +02:00
|
|
|
if hasattr(contact, 'resource') and contact.resource.strip() != '':
|
|
|
|
properties.append((_('Resource: '),
|
2007-01-17 00:26:38 +01:00
|
|
|
gobject.markup_escape_text(contact.resource) ))
|
2006-09-26 04:41:47 +02:00
|
|
|
if contact.affiliation != 'none':
|
2006-09-27 18:05:15 +02:00
|
|
|
uf_affiliation = helpers.get_uf_affiliation(contact.affiliation)
|
2006-10-12 04:12:10 +02:00
|
|
|
affiliation_str = \
|
|
|
|
_('%(owner_or_admin_or_member)s of this group chat') %\
|
2006-09-27 18:05:15 +02:00
|
|
|
{'owner_or_admin_or_member': uf_affiliation}
|
|
|
|
properties.append((affiliation_str, None))
|
2006-03-21 22:33:56 +01:00
|
|
|
|
2006-03-17 16:26:58 +01:00
|
|
|
# Add avatar
|
2006-03-26 13:46:04 +02:00
|
|
|
puny_name = helpers.sanitize_filename(contact.name)
|
|
|
|
puny_room = helpers.sanitize_filename(contact.room_jid)
|
2007-06-03 12:04:20 +02:00
|
|
|
file = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, puny_room,
|
|
|
|
puny_name))
|
|
|
|
if file:
|
|
|
|
self.avatar_image.set_from_file(file)
|
|
|
|
pix = self.avatar_image.get_pixbuf()
|
|
|
|
pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip')
|
|
|
|
self.avatar_image.set_from_pixbuf(pix)
|
2006-03-17 16:26:58 +01:00
|
|
|
else:
|
|
|
|
self.avatar_image.set_from_pixbuf(None)
|
2006-03-21 22:33:56 +01:00
|
|
|
while properties:
|
|
|
|
property = properties.pop(0)
|
|
|
|
vcard_current_row += 1
|
|
|
|
vertical_fill = gtk.FILL
|
|
|
|
if not properties:
|
|
|
|
vertical_fill |= gtk.EXPAND
|
|
|
|
label = gtk.Label()
|
|
|
|
label.set_alignment(0, 0)
|
|
|
|
if property[1]:
|
2006-04-21 15:48:27 +02:00
|
|
|
label.set_markup(property[0])
|
2006-09-28 00:56:50 +02:00
|
|
|
vcard_table.attach(label, 1, 2, vcard_current_row,
|
|
|
|
vcard_current_row + 1, gtk.FILL, vertical_fill, 0, 0)
|
2006-03-21 22:33:56 +01:00
|
|
|
label = gtk.Label()
|
|
|
|
label.set_alignment(0, 0)
|
|
|
|
label.set_markup(property[1])
|
|
|
|
label.set_line_wrap(True)
|
2006-09-28 00:56:50 +02:00
|
|
|
vcard_table.attach(label, 2, 3, vcard_current_row,
|
|
|
|
vcard_current_row + 1, gtk.EXPAND | gtk.FILL,
|
|
|
|
vertical_fill, 0, 0)
|
2006-03-21 22:33:56 +01:00
|
|
|
else:
|
|
|
|
label.set_markup(property[0])
|
2007-08-09 17:39:18 +02:00
|
|
|
label.set_line_wrap(True)
|
2006-09-28 00:56:50 +02:00
|
|
|
vcard_table.attach(label, 1, 3, vcard_current_row,
|
|
|
|
vcard_current_row + 1, gtk.FILL, vertical_fill, 0)
|
2006-03-21 22:33:56 +01:00
|
|
|
|
|
|
|
self.avatar_image.set_alignment(0, 0)
|
2006-09-28 00:56:50 +02:00
|
|
|
vcard_table.attach(self.avatar_image, 3, 4, 2, vcard_current_row + 1,
|
|
|
|
gtk.FILL, gtk.FILL | gtk.EXPAND, 3, 3)
|
2006-03-21 22:33:56 +01:00
|
|
|
self.win.add(vcard_table)
|
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()
|
2007-06-03 12:04:20 +02:00
|
|
|
|
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
|
2007-08-09 17:39:18 +02:00
|
|
|
accounts = helpers.get_notification_icon_tooltip_dict()
|
2005-11-09 22:05:55 +01:00
|
|
|
self.table.resize(2, 1)
|
|
|
|
self.spacer_label = ''
|
|
|
|
self.fill_table_with_accounts(accounts)
|
2006-03-21 22:33:56 +01:00
|
|
|
self.win.add(self.table)
|
2005-11-09 22:05:55 +01:00
|
|
|
return
|
2006-03-21 21:22:16 +01:00
|
|
|
|
2006-03-21 16:44:36 +01:00
|
|
|
|
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)
|
2006-03-21 16:44:36 +01:00
|
|
|
|
2006-03-26 13:46:04 +02:00
|
|
|
puny_jid = helpers.sanitize_filename(prim_contact.jid)
|
2006-03-21 21:22:16 +01:00
|
|
|
table_size = 3
|
2007-06-03 12:04:20 +02:00
|
|
|
|
|
|
|
file = helpers.get_avatar_path(os.path.join(gajim.AVATAR_PATH, puny_jid))
|
|
|
|
if file:
|
|
|
|
self.avatar_image.set_from_file(file)
|
|
|
|
pix = self.avatar_image.get_pixbuf()
|
|
|
|
pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip')
|
|
|
|
self.avatar_image.set_from_pixbuf(pix)
|
|
|
|
table_size = 4
|
2006-03-21 21:22:16 +01:00
|
|
|
else:
|
|
|
|
self.avatar_image.set_from_pixbuf(None)
|
|
|
|
vcard_table = gtk.Table(table_size, 1)
|
|
|
|
vcard_table.set_property('column-spacing', 2)
|
|
|
|
vcard_table.set_homogeneous(False)
|
|
|
|
vcard_current_row = 1
|
2006-03-21 17:39:26 +01:00
|
|
|
properties = []
|
2006-10-11 04:12:56 +02:00
|
|
|
|
2006-10-12 04:44:15 +02:00
|
|
|
name_markup = u'<span weight="bold">' + \
|
2007-01-17 00:26:38 +01:00
|
|
|
gobject.markup_escape_text(prim_contact.get_shown_name())\
|
2006-10-12 04:44:15 +02:00
|
|
|
+ '</span>'
|
2007-06-03 12:04:20 +02:00
|
|
|
if self.account and prim_contact.jid in gajim.connections[
|
|
|
|
self.account].blocked_contacts:
|
|
|
|
name_markup += _(' [blocked]')
|
|
|
|
if self.account and \
|
|
|
|
gajim.interface.minimized_controls.has_key(self.account) and \
|
|
|
|
prim_contact.jid in gajim.interface.minimized_controls[self.account]:
|
|
|
|
name_markup += _(' [minimized]')
|
2006-10-12 04:44:15 +02:00
|
|
|
properties.append((name_markup, None))
|
2007-06-03 12:04:20 +02:00
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
num_resources = 0
|
2006-05-26 22:41:03 +02:00
|
|
|
# put contacts in dict, where key is priority
|
|
|
|
contacts_dict = {}
|
2005-08-15 01:52:12 +02:00
|
|
|
for contact in contacts:
|
|
|
|
if contact.resource:
|
|
|
|
num_resources += 1
|
2006-05-26 22:41:03 +02:00
|
|
|
if contact.priority in contacts_dict:
|
|
|
|
contacts_dict[contact.priority].append(contact)
|
|
|
|
else:
|
|
|
|
contacts_dict[contact.priority] = [contact]
|
2006-09-14 18:48:03 +02:00
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
if num_resources > 1:
|
2006-03-21 21:52:25 +01:00
|
|
|
properties.append((_('Status: '), ' '))
|
2006-09-28 03:51:32 +02:00
|
|
|
transport = gajim.get_transport_name_from_jid(
|
|
|
|
prim_contact.jid)
|
2006-09-28 03:47:30 +02:00
|
|
|
if transport:
|
2007-12-12 09:44:46 +01:00
|
|
|
file_path = os.path.join(helpers.get_transport_path(transport),
|
|
|
|
'16x16')
|
2006-09-28 03:47:30 +02:00
|
|
|
else:
|
|
|
|
iconset = gajim.config.get('iconset')
|
|
|
|
if not iconset:
|
|
|
|
iconset = 'dcraven'
|
2007-08-09 17:39:18 +02:00
|
|
|
file_path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
|
2006-09-28 03:47:30 +02:00
|
|
|
|
2006-05-26 22:41:03 +02:00
|
|
|
contact_keys = contacts_dict.keys()
|
2006-05-31 08:36:49 +02:00
|
|
|
contact_keys.sort()
|
|
|
|
contact_keys.reverse()
|
2006-05-26 22:41:03 +02:00
|
|
|
for priority in contact_keys:
|
|
|
|
for contact in contacts_dict[priority]:
|
2006-03-21 21:52:25 +01:00
|
|
|
status_line = self.get_status_info(contact.resource,
|
|
|
|
contact.priority, contact.show, contact.status)
|
|
|
|
|
|
|
|
icon_name = self._get_icon_name_for_tooltip(contact)
|
|
|
|
self.add_status_row(file_path, icon_name, status_line,
|
|
|
|
contact.last_status_time)
|
|
|
|
properties.append((self.table, None))
|
2006-03-21 21:22:16 +01:00
|
|
|
else: # only one resource
|
2007-08-10 01:05:43 +02:00
|
|
|
|
|
|
|
#FIXME: User {Mood, Activity, Tune} not shown if there are
|
|
|
|
#multiple resources
|
|
|
|
#FIXME: User {Mood, Activity, Tune} not shown for self
|
2005-08-15 01:52:12 +02:00
|
|
|
if contact.show:
|
2006-03-21 16:44:36 +01:00
|
|
|
show = helpers.get_uf_show(contact.show)
|
2006-09-26 04:41:47 +02:00
|
|
|
if contact.last_status_time:
|
|
|
|
vcard_current_row += 1
|
|
|
|
if contact.show == 'offline':
|
2006-09-28 00:56:50 +02:00
|
|
|
text = ' - ' + _('Last status: %s')
|
2006-09-26 04:41:47 +02:00
|
|
|
else:
|
|
|
|
text = _(' since %s')
|
|
|
|
|
|
|
|
if time.strftime('%j', time.localtime())== \
|
|
|
|
time.strftime('%j', contact.last_status_time):
|
|
|
|
# it's today, show only the locale hour representation
|
2006-09-28 00:56:50 +02:00
|
|
|
local_time = time.strftime('%X',
|
|
|
|
contact.last_status_time)
|
2006-09-26 04:41:47 +02:00
|
|
|
else:
|
|
|
|
# time.strftime returns locale encoded string
|
2006-09-28 00:56:50 +02:00
|
|
|
local_time = time.strftime('%c',
|
|
|
|
contact.last_status_time)
|
|
|
|
local_time = local_time.decode(
|
|
|
|
locale.getpreferredencoding())
|
2006-09-26 04:41:47 +02:00
|
|
|
text = text % local_time
|
|
|
|
show += text
|
2007-06-03 12:04:20 +02:00
|
|
|
if self.account and \
|
|
|
|
gajim.gc_connected[self.account].has_key(prim_contact.jid):
|
|
|
|
if gajim.gc_connected[self.account][prim_contact.jid]:
|
|
|
|
show = _('Connected')
|
|
|
|
else:
|
|
|
|
show = _('Disconnected')
|
2006-09-28 00:56:50 +02:00
|
|
|
show = '<i>' + show + '</i>'
|
2006-09-26 16:40:13 +02:00
|
|
|
# we append show below
|
2006-09-26 04:41:47 +02:00
|
|
|
|
2007-03-29 21:04:14 +02:00
|
|
|
if contact.mood.has_key('mood'):
|
2007-12-13 21:26:13 +01:00
|
|
|
mood_string = _('Mood:') + ' <b>%s</b>' % contact.mood['mood'].strip()
|
2007-03-31 01:24:12 +02:00
|
|
|
if contact.mood.has_key('text') and contact.mood['text'] != '':
|
|
|
|
mood_string += ' (%s)' % contact.mood['text'].strip()
|
|
|
|
properties.append((mood_string, None))
|
2007-03-26 00:16:48 +02:00
|
|
|
|
2007-03-29 21:04:14 +02:00
|
|
|
if contact.activity.has_key('activity'):
|
|
|
|
activity = contact.activity['activity'].strip()
|
2007-12-13 21:26:13 +01:00
|
|
|
activity_string = _('Activity:') + ' <b>%s' % activity
|
2007-03-29 21:04:14 +02:00
|
|
|
if contact.activity.has_key('subactivity'):
|
|
|
|
activity_sub = contact.activity['subactivity'].strip()
|
|
|
|
activity_string += ' (%s)</b>' % activity_sub
|
|
|
|
else:
|
|
|
|
activity_string += '</b>'
|
|
|
|
if contact.activity.has_key('text'):
|
|
|
|
activity_text = contact.activity['text'].strip()
|
|
|
|
activity_string += ' (%s)' % activity_text
|
|
|
|
properties.append((activity_string, None))
|
2007-03-28 23:18:16 +02:00
|
|
|
|
2007-04-01 11:02:04 +02:00
|
|
|
if contact.tune.has_key('artist') or contact.tune.has_key('title'):
|
|
|
|
if contact.tune.has_key('artist'):
|
|
|
|
artist = contact.tune['artist'].strip()
|
|
|
|
else:
|
|
|
|
artist = _('Unknown Artist')
|
|
|
|
if contact.tune.has_key('title'):
|
|
|
|
title = contact.tune['title'].strip()
|
|
|
|
else:
|
|
|
|
title = _('Unknown Title')
|
|
|
|
if contact.tune.has_key('source'):
|
|
|
|
source = contact.tune['source'].strip()
|
|
|
|
else:
|
|
|
|
source = _('Unknown Source')
|
2007-12-13 21:26:13 +01:00
|
|
|
tune_string = _('Tune:') + ' ' + _('<b>"%(title)s"</b> by <i>%(artist)s</i>\nfrom <i>%(source)s</i>' %\
|
|
|
|
{'title': title, 'artist': artist, 'source': source})
|
2007-04-01 11:02:04 +02:00
|
|
|
properties.append((tune_string, None))
|
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
if contact.status:
|
|
|
|
status = contact.status.strip()
|
2006-03-21 21:22:16 +01:00
|
|
|
if status:
|
2005-09-04 03:40:17 +02:00
|
|
|
# reduce long status
|
2007-06-03 12:04:20 +02:00
|
|
|
# (no more than 300 chars on line and no more than 5 lines)
|
|
|
|
# status is wrapped
|
|
|
|
status = helpers.reduce_chars_newlines(status, 300, 5)
|
2005-08-25 17:10:53 +02:00
|
|
|
# escape markup entities.
|
2007-01-17 00:26:38 +01:00
|
|
|
status = gobject.markup_escape_text(status)
|
2006-09-28 00:56:50 +02:00
|
|
|
properties.append(('<i>%s</i>' % status, None))
|
2006-09-26 16:40:13 +02:00
|
|
|
properties.append((show, None))
|
2006-09-26 04:41:47 +02:00
|
|
|
|
|
|
|
properties.append((_('Jabber ID: '), prim_contact.jid ))
|
2006-09-28 00:06:53 +02:00
|
|
|
|
|
|
|
# contact has only one ressource
|
|
|
|
if num_resources == 1 and contact.resource:
|
|
|
|
properties.append((_('Resource: '),
|
2007-01-17 00:26:38 +01:00
|
|
|
gobject.markup_escape_text(contact.resource) +\
|
2006-09-28 00:56:50 +02:00
|
|
|
' (' + unicode(contact.priority) + ')'))
|
2006-09-28 00:06:53 +02:00
|
|
|
|
2007-06-03 12:04:20 +02:00
|
|
|
if self.account and prim_contact.sub and prim_contact.sub != 'both' and\
|
|
|
|
not gajim.gc_connected[self.account].has_key(prim_contact.jid):
|
2006-09-26 04:41:47 +02:00
|
|
|
# ('both' is the normal sub so we don't show it)
|
|
|
|
properties.append(( _('Subscription: '),
|
2007-01-17 00:26:38 +01:00
|
|
|
gobject.markup_escape_text(helpers.get_uf_sub(prim_contact.sub))))
|
2006-09-28 00:06:53 +02:00
|
|
|
|
2006-09-26 04:41:47 +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:
|
|
|
|
properties.append((_('OpenPGP: '),
|
2007-01-17 00:26:38 +01:00
|
|
|
gobject.markup_escape_text(keyID)))
|
2006-09-26 04:41:47 +02:00
|
|
|
|
2006-03-21 21:22:16 +01:00
|
|
|
while properties:
|
|
|
|
property = properties.pop(0)
|
|
|
|
vcard_current_row += 1
|
|
|
|
vertical_fill = gtk.FILL
|
|
|
|
if not properties and table_size == 4:
|
|
|
|
vertical_fill |= gtk.EXPAND
|
|
|
|
label = gtk.Label()
|
|
|
|
label.set_alignment(0, 0)
|
|
|
|
if property[1]:
|
2006-04-21 15:48:27 +02:00
|
|
|
label.set_markup(property[0])
|
2006-09-28 00:56:50 +02:00
|
|
|
vcard_table.attach(label, 1, 2, vcard_current_row,
|
2007-12-12 09:44:46 +01:00
|
|
|
vcard_current_row + 1, gtk.FILL, vertical_fill, 0, 0)
|
2006-03-21 16:44:36 +01:00
|
|
|
label = gtk.Label()
|
2006-10-12 10:28:16 +02:00
|
|
|
label.set_alignment(0, 0)
|
2006-03-21 21:22:16 +01:00
|
|
|
label.set_markup(property[1])
|
2006-03-21 21:25:53 +01:00
|
|
|
label.set_line_wrap(True)
|
2006-09-28 00:56:50 +02:00
|
|
|
vcard_table.attach(label, 2, 3, vcard_current_row,
|
|
|
|
vcard_current_row + 1, gtk.EXPAND | gtk.FILL,
|
|
|
|
vertical_fill, 0, 0)
|
2006-03-21 21:22:16 +01:00
|
|
|
else:
|
2006-09-28 01:17:54 +02:00
|
|
|
if isinstance(property[0], (unicode, str)): #FIXME: rm unicode?
|
2006-03-21 21:52:25 +01:00
|
|
|
label.set_markup(property[0])
|
2007-06-03 12:04:20 +02:00
|
|
|
label.set_line_wrap(True)
|
2006-03-21 21:52:25 +01:00
|
|
|
else:
|
|
|
|
label = property[0]
|
2006-09-28 00:56:50 +02:00
|
|
|
vcard_table.attach(label, 1, 3, vcard_current_row,
|
|
|
|
vcard_current_row + 1, gtk.FILL, vertical_fill, 0)
|
2006-03-21 21:22:16 +01:00
|
|
|
self.avatar_image.set_alignment(0, 0)
|
|
|
|
if table_size == 4:
|
2006-09-28 00:56:50 +02:00
|
|
|
vcard_table.attach(self.avatar_image, 3, 4, 2,
|
|
|
|
vcard_current_row + 1, gtk.FILL, gtk.FILL | gtk.EXPAND, 3, 3)
|
2006-03-21 22:33:56 +01:00
|
|
|
self.win.add(vcard_table)
|
2005-08-15 01:52:12 +02:00
|
|
|
|
|
|
|
class FileTransfersTooltip(BaseTooltip):
|
|
|
|
''' Tooltip that is shown in the notification area '''
|
|
|
|
def __init__(self):
|
|
|
|
BaseTooltip.__init__(self)
|
|
|
|
|
|
|
|
def populate(self, file_props):
|
2006-03-21 18:01:23 +01:00
|
|
|
ft_table = gtk.Table(2, 1)
|
|
|
|
ft_table.set_property('column-spacing', 2)
|
|
|
|
current_row = 1
|
2005-08-15 01:52:12 +02:00
|
|
|
self.create_window()
|
2006-03-21 18:01:23 +01:00
|
|
|
properties = []
|
2005-08-15 01:52:12 +02:00
|
|
|
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']
|
2006-03-21 18:01:23 +01:00
|
|
|
properties.append((_('Name: '),
|
2007-01-17 00:26:38 +01:00
|
|
|
gobject.markup_escape_text(file_name)))
|
2005-08-15 01:52:12 +02:00
|
|
|
if file_props['type'] == 'r':
|
2007-12-12 09:44:46 +01:00
|
|
|
type = _('Download')
|
2006-03-21 18:01:23 +01:00
|
|
|
actor = _('Sender: ')
|
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-03-21 18:01:23 +01:00
|
|
|
type = _('Upload')
|
|
|
|
actor = _('Recipient: ')
|
2005-08-15 01:52:12 +02:00
|
|
|
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]
|
2006-03-21 18:01:23 +01:00
|
|
|
properties.append((_('Type: '), type))
|
2007-01-17 00:26:38 +01:00
|
|
|
properties.append((actor, gobject.markup_escape_text(name)))
|
2006-03-21 18:01:23 +01:00
|
|
|
|
2005-08-15 01:52:12 +02:00
|
|
|
transfered_len = 0
|
|
|
|
if file_props.has_key('received-len'):
|
|
|
|
transfered_len = file_props['received-len']
|
2006-03-21 18:01:23 +01:00
|
|
|
properties.append((_('Transferred: '), helpers.convert_bytes(transfered_len)))
|
2005-08-15 01:52:12 +02:00
|
|
|
status = ''
|
|
|
|
if not file_props.has_key('started') or not file_props['started']:
|
2007-12-12 09:44:46 +01: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 \
|
2007-02-04 14:01:04 +01:00
|
|
|
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']:
|
2007-12-12 09:44:46 +01: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:
|
2007-12-12 09:44:46 +01:00
|
|
|
if file_props.has_key('paused') and \
|
2007-02-04 14:01:04 +01:00
|
|
|
file_props['paused'] == True:
|
|
|
|
status = _('?transfer status:Paused')
|
2005-08-15 01:52:12 +02:00
|
|
|
elif file_props.has_key('stalled') and \
|
2007-02-04 14:01:04 +01:00
|
|
|
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:
|
2007-12-12 09:44:46 +01:00
|
|
|
status = _('Not started')
|
2006-03-21 18:01:23 +01:00
|
|
|
properties.append((_('Status: '), status))
|
2007-12-12 09:44:46 +01:00
|
|
|
if 'desc' in file_props:
|
|
|
|
file_desc = file_props['desc']
|
|
|
|
properties.append((_('Description: '), gobject.markup_escape_text(
|
|
|
|
file_desc)))
|
2006-03-21 18:01:23 +01:00
|
|
|
while properties:
|
|
|
|
property = properties.pop(0)
|
|
|
|
current_row += 1
|
|
|
|
label = gtk.Label()
|
|
|
|
label.set_alignment(0, 0)
|
2006-04-21 15:48:27 +02:00
|
|
|
label.set_markup(property[0])
|
2006-03-21 18:01:23 +01:00
|
|
|
ft_table.attach(label, 1, 2, current_row, current_row + 1,
|
2007-12-12 09:44:46 +01:00
|
|
|
gtk.FILL, gtk.FILL, 0, 0)
|
2006-03-21 18:01:23 +01:00
|
|
|
label = gtk.Label()
|
|
|
|
label.set_alignment(0, 0)
|
|
|
|
label.set_line_wrap(True)
|
|
|
|
label.set_markup(property[1])
|
|
|
|
ft_table.attach(label, 2, 3, current_row, current_row + 1,
|
2007-01-31 12:31:07 +01:00
|
|
|
gtk.EXPAND | gtk.FILL, gtk.FILL, 0, 0)
|
2005-08-15 01:52:12 +02:00
|
|
|
|
2006-03-21 18:01:23 +01:00
|
|
|
self.win.add(ft_table)
|
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)
|