add tooltip for merged accounts row
This commit is contained in:
parent
0fd60e88aa
commit
7d827f0764
2 changed files with 55 additions and 36 deletions
|
@ -742,6 +742,10 @@ class RosterWindow:
|
||||||
# we're on an account entry in the roster
|
# we're on an account entry in the roster
|
||||||
account = model[iter][C_ACCOUNT].decode('utf-8')
|
account = model[iter][C_ACCOUNT].decode('utf-8')
|
||||||
if account == 'all':
|
if account == 'all':
|
||||||
|
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
|
||||||
|
self.tooltip.id = row
|
||||||
|
self.tooltip.timeout = gobject.timeout_add(500,
|
||||||
|
self.show_tooltip, [])
|
||||||
return
|
return
|
||||||
jid = gajim.get_jid_from_account(account)
|
jid = gajim.get_jid_from_account(account)
|
||||||
contacts = []
|
contacts = []
|
||||||
|
|
|
@ -124,6 +124,7 @@ class StatusTable:
|
||||||
self.current_row = 1
|
self.current_row = 1
|
||||||
self.table = None
|
self.table = None
|
||||||
self.text_lable = None
|
self.text_lable = None
|
||||||
|
self.spacer_label = ' '
|
||||||
|
|
||||||
def create_table(self):
|
def create_table(self):
|
||||||
self.table = gtk.Table(3, 1)
|
self.table = gtk.Table(3, 1)
|
||||||
|
@ -155,11 +156,11 @@ class StatusTable:
|
||||||
files.append(os.path.join(file_path, state_file + '.gif'))
|
files.append(os.path.join(file_path, state_file + '.gif'))
|
||||||
image = gtk.Image()
|
image = gtk.Image()
|
||||||
image.set_from_pixbuf(None)
|
image.set_from_pixbuf(None)
|
||||||
spacer = gtk.Label(' ')
|
|
||||||
for file in files:
|
for file in files:
|
||||||
if os.path.exists(file):
|
if os.path.exists(file):
|
||||||
image.set_from_file(file)
|
image.set_from_file(file)
|
||||||
break
|
break
|
||||||
|
spacer = gtk.Label(self.spacer_label)
|
||||||
image.set_alignment(0., 1.)
|
image.set_alignment(0., 1.)
|
||||||
self.table.attach(spacer, 1, 2, self.current_row,
|
self.table.attach(spacer, 1, 2, self.current_row,
|
||||||
self.current_row + 1, 0, 0, 0, 0)
|
self.current_row + 1, 0, 0, 0, 0)
|
||||||
|
@ -177,12 +178,8 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
|
||||||
BaseTooltip.__init__(self)
|
BaseTooltip.__init__(self)
|
||||||
StatusTable.__init__(self)
|
StatusTable.__init__(self)
|
||||||
|
|
||||||
def populate(self, data):
|
def get_accounts_info(self):
|
||||||
self.create_window()
|
accounts = []
|
||||||
self.create_table()
|
|
||||||
self.hbox = gtk.HBox()
|
|
||||||
self.table.set_property('column-spacing', 1)
|
|
||||||
text, single_line, accounts = '', '', []
|
|
||||||
if gajim.contacts:
|
if gajim.contacts:
|
||||||
for account in gajim.contacts.keys():
|
for account in gajim.contacts.keys():
|
||||||
status_idx = gajim.connections[account].connected
|
status_idx = gajim.connections[account].connected
|
||||||
|
@ -202,12 +199,43 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
|
||||||
message = helpers.get_uf_show(status)
|
message = helpers.get_uf_show(status)
|
||||||
accounts.append({'name': account, 'status_line': single_line,
|
accounts.append({'name': account, 'status_line': single_line,
|
||||||
'show': status, 'message': message})
|
'show': status, 'message': message})
|
||||||
|
return accounts
|
||||||
|
|
||||||
|
def fill_table_with_accounts(self, accounts):
|
||||||
|
iconset = gajim.config.get('iconset')
|
||||||
|
if not iconset:
|
||||||
|
iconset = 'sun'
|
||||||
|
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:
|
||||||
|
self.add_status_row(file_path, acct['show'], '<span weight="bold">' +
|
||||||
|
gtkgui_helpers.escape_for_pango_markup(acct['name']) + '</span>'
|
||||||
|
+ ' - ' + message)
|
||||||
|
else:
|
||||||
|
self.add_status_row(file_path, acct['show'], '<span weight="bold">' +
|
||||||
|
gtkgui_helpers.escape_for_pango_markup(acct['name']) + '</span>')
|
||||||
|
|
||||||
|
def populate(self, data):
|
||||||
|
self.create_window()
|
||||||
|
self.create_table()
|
||||||
|
self.hbox = gtk.HBox()
|
||||||
|
self.table.set_property('column-spacing', 1)
|
||||||
|
text, single_line = '', ''
|
||||||
|
|
||||||
unread_chat = gajim.interface.roster.nb_unread
|
unread_chat = gajim.interface.roster.nb_unread
|
||||||
unread_single_chat = 0
|
unread_single_chat = 0
|
||||||
unread_gc = 0
|
unread_gc = 0
|
||||||
unread_pm = 0
|
unread_pm = 0
|
||||||
|
|
||||||
|
accounts = self.get_accounts_info()
|
||||||
|
|
||||||
for acct in gajim.connections:
|
for acct in gajim.connections:
|
||||||
# we count unread chat/pm messages
|
# we count unread chat/pm messages
|
||||||
chat_wins = gajim.interface.windows[acct]['chats']
|
chat_wins = gajim.interface.windows[acct]['chats']
|
||||||
|
@ -257,29 +285,11 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
|
||||||
text = _('Gajim')
|
text = _('Gajim')
|
||||||
self.current_row = 1
|
self.current_row = 1
|
||||||
self.table.resize(2, 1)
|
self.table.resize(2, 1)
|
||||||
iconset = gajim.config.get('iconset')
|
self.fill_table_with_accounts(accounts)
|
||||||
if not iconset:
|
|
||||||
iconset = 'sun'
|
|
||||||
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:
|
|
||||||
self.add_status_row(file_path, acct['show'], '<span weight="bold">' +
|
|
||||||
gtkgui_helpers.escape_for_pango_markup(acct['name']) + '</span>'
|
|
||||||
+ ' - ' + message)
|
|
||||||
else:
|
|
||||||
self.add_status_row(file_path, acct['show'], '<span weight="bold">' +
|
|
||||||
gtkgui_helpers.escape_for_pango_markup(acct['name']) + '</span>')
|
|
||||||
|
|
||||||
elif len(accounts) == 1:
|
elif len(accounts) == 1:
|
||||||
message = gtkgui_helpers.reduce_chars_newlines(accounts[0]['status_line'],
|
message = accounts[0]['status_line']
|
||||||
50, 1)
|
message = gtkgui_helpers.reduce_chars_newlines(message, 50, 1)
|
||||||
message = gtkgui_helpers.escape_for_pango_markup(message)
|
message = gtkgui_helpers.escape_for_pango_markup(message)
|
||||||
text = _('Gajim - %s') % message
|
text = _('Gajim - %s') % message
|
||||||
else:
|
else:
|
||||||
|
@ -335,26 +345,31 @@ class GCTooltip(BaseTooltip, StatusTable):
|
||||||
hbox.add(self.text_lable)
|
hbox.add(self.text_lable)
|
||||||
self.win.add(hbox)
|
self.win.add(hbox)
|
||||||
|
|
||||||
class RosterTooltip(BaseTooltip, StatusTable):
|
class RosterTooltip(NotificationAreaTooltip):
|
||||||
''' Tooltip that is shown in the roster treeview '''
|
''' Tooltip that is shown in the roster treeview '''
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.account = None
|
self.account = None
|
||||||
|
|
||||||
self.image = gtk.Image()
|
self.image = gtk.Image()
|
||||||
self.image.set_alignment(0., 0.)
|
self.image.set_alignment(0., 0.)
|
||||||
# padding is independent of the total length and better than alignment
|
# padding is independent of the total length and better than alignment
|
||||||
self.image.set_padding(1, 2)
|
self.image.set_padding(1, 2)
|
||||||
BaseTooltip.__init__(self)
|
NotificationAreaTooltip.__init__(self)
|
||||||
StatusTable.__init__(self)
|
|
||||||
|
|
||||||
def populate(self, contacts):
|
def populate(self, contacts):
|
||||||
if not contacts or len(contacts) == 0:
|
|
||||||
return
|
|
||||||
self.create_window()
|
self.create_window()
|
||||||
self.hbox = gtk.HBox()
|
self.hbox = gtk.HBox()
|
||||||
self.hbox.set_homogeneous(False)
|
self.hbox.set_homogeneous(False)
|
||||||
self.hbox.set_spacing(0)
|
self.hbox.set_spacing(0)
|
||||||
self.create_table()
|
self.create_table()
|
||||||
|
if not contacts or len(contacts) == 0:
|
||||||
|
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
|
||||||
# primary contact
|
# primary contact
|
||||||
prim_contact = gajim.get_highest_prio_contact_from_contacts(contacts)
|
prim_contact = gajim.get_highest_prio_contact_from_contacts(contacts)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue