aligned properties for FT tooltip
This commit is contained in:
parent
1ba8e37972
commit
e1ff481a84
|
@ -585,46 +585,42 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
class FileTransfersTooltip(BaseTooltip):
|
class FileTransfersTooltip(BaseTooltip):
|
||||||
''' Tooltip that is shown in the notification area '''
|
''' Tooltip that is shown in the notification area '''
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
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)
|
|
||||||
BaseTooltip.__init__(self)
|
BaseTooltip.__init__(self)
|
||||||
|
|
||||||
def populate(self, file_props):
|
def populate(self, file_props):
|
||||||
|
ft_table = gtk.Table(2, 1)
|
||||||
|
ft_table.set_property('column-spacing', 2)
|
||||||
|
current_row = 1
|
||||||
self.create_window()
|
self.create_window()
|
||||||
self.hbox = gtk.HBox()
|
properties = []
|
||||||
text = '<b>' + _('Name: ') + '</b>'
|
|
||||||
name = file_props['name']
|
name = file_props['name']
|
||||||
if file_props['type'] == 'r':
|
if file_props['type'] == 'r':
|
||||||
(file_path, file_name) = os.path.split(file_props['file-name'])
|
(file_path, file_name) = os.path.split(file_props['file-name'])
|
||||||
else:
|
else:
|
||||||
file_name = file_props['name']
|
file_name = file_props['name']
|
||||||
text += gtkgui_helpers.escape_for_pango_markup(file_name)
|
properties.append((_('Name: '),
|
||||||
text += '\n<b>' + _('Type: ') + '</b>'
|
gtkgui_helpers.escape_for_pango_markup(file_name)))
|
||||||
if file_props['type'] == 'r':
|
if file_props['type'] == 'r':
|
||||||
text += _('Download')
|
type = _('Download')
|
||||||
text += '\n<b>' + _('Sender: ') + '</b>'
|
actor = _('Sender: ')
|
||||||
sender = unicode(file_props['sender']).split('/')[0]
|
sender = unicode(file_props['sender']).split('/')[0]
|
||||||
name = gajim.contacts.get_first_contact_from_jid(
|
name = gajim.contacts.get_first_contact_from_jid(
|
||||||
file_props['tt_account'], sender).get_shown_name()
|
file_props['tt_account'], sender).get_shown_name()
|
||||||
else:
|
else:
|
||||||
text += _('Upload')
|
type = _('Upload')
|
||||||
text += '\n<b>' + _('Recipient: ') + '</b>'
|
actor = _('Recipient: ')
|
||||||
receiver = file_props['receiver']
|
receiver = file_props['receiver']
|
||||||
if hasattr(receiver, 'name'):
|
if hasattr(receiver, 'name'):
|
||||||
name = receiver.get_shown_name()
|
name = receiver.get_shown_name()
|
||||||
else:
|
else:
|
||||||
name = receiver.split('/')[0]
|
name = receiver.split('/')[0]
|
||||||
text += gtkgui_helpers.escape_for_pango_markup(name)
|
properties.append((_('Type: '), type))
|
||||||
text += '\n<b>' + _('Size: ') + '</b>'
|
properties.append((actor, gtkgui_helpers.escape_for_pango_markup(name)))
|
||||||
text += helpers.convert_bytes(file_props['size'])
|
|
||||||
text += '\n<b>' + _('Transferred: ') + '</b>'
|
|
||||||
transfered_len = 0
|
transfered_len = 0
|
||||||
if file_props.has_key('received-len'):
|
if file_props.has_key('received-len'):
|
||||||
transfered_len = file_props['received-len']
|
transfered_len = file_props['received-len']
|
||||||
text += helpers.convert_bytes(transfered_len)
|
properties.append((_('Transferred: '), helpers.convert_bytes(transfered_len)))
|
||||||
text += '\n<b>' + _('Status: ') + '</b>'
|
|
||||||
status = ''
|
status = ''
|
||||||
if not file_props.has_key('started') or not file_props['started']:
|
if not file_props.has_key('started') or not file_props['started']:
|
||||||
status = _('Not started')
|
status = _('Not started')
|
||||||
|
@ -649,11 +645,23 @@ class FileTransfersTooltip(BaseTooltip):
|
||||||
status = _('Transferring')
|
status = _('Transferring')
|
||||||
else:
|
else:
|
||||||
status = _('Not started')
|
status = _('Not started')
|
||||||
|
properties.append((_('Status: '), status))
|
||||||
|
while properties:
|
||||||
|
property = properties.pop(0)
|
||||||
|
current_row += 1
|
||||||
|
label = gtk.Label()
|
||||||
|
label.set_alignment(0, 0)
|
||||||
|
label.set_markup('<span weight="bold">%s</span>' % property[0])
|
||||||
|
ft_table.attach(label, 1, 2, current_row, current_row + 1,
|
||||||
|
gtk.FILL, gtk.FILL, 0, 0)
|
||||||
|
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,
|
||||||
|
gtk.EXPAND | gtk.FILL, gtk.FILL, 0, 0)
|
||||||
|
|
||||||
text += status
|
self.win.add(ft_table)
|
||||||
self.text_label.set_markup(text)
|
|
||||||
self.hbox.add(self.text_label)
|
|
||||||
self.win.add(self.hbox)
|
|
||||||
|
|
||||||
|
|
||||||
class ServiceDiscoveryTooltip(BaseTooltip):
|
class ServiceDiscoveryTooltip(BaseTooltip):
|
||||||
|
|
Loading…
Reference in New Issue