[sef] tooltips in group chat roster

This commit is contained in:
Nikos Kouremenos 2005-08-24 12:58:03 +00:00
parent 2e26d5ee28
commit 1e2f27942b
3 changed files with 98 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import chat
import cell_renderer_image
import gtkgui_helpers
import history_window
import tooltips
from gajim import Contact
from common import gajim
@ -65,6 +66,7 @@ class GroupchatWindow(chat.Chat):
self.gc_refer_to_nick_char = gajim.config.get('gc_refer_to_nick_char')
self.new_room(room_jid, nick)
self.show_title()
self.tooltip = tooltips.GCTooltip(plugin)
# NOTE: if it not a window event, connect in new_room function
@ -1073,7 +1075,56 @@ class GroupchatWindow(chat.Chat):
self.got_disconnected(room_jid) #init some variables
conversation_textview.grab_focus()
self.childs[room_jid].show_all()
def on_list_treeview_motion_notify_event(self, widget, event):
model = widget.get_model()
props = widget.get_path_at_pos(int(event.x), int(event.y))
if self.tooltip.timeout > 0:
if not props or self.tooltip.id != props[0]:
self.tooltip.hide_tooltip()
if props:
[row, col, x, y] = props
iter = None
try:
iter = model.get_iter(row)
except:
self.tooltip.hide_tooltip()
return
room_jid = self.get_active_jid()
nick = model[iter][1]
if nick != 'moderator' and nick !='participant' :
account = self.account
img = model[iter][0]
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, gajim.gc_contacts[account][room_jid][nick])
pass
def on_list_treeview_leave_notify_event(self, widget, event):
model = widget.get_model()
props = widget.get_path_at_pos(int(event.x), int(event.y))
if self.tooltip.timeout > 0:
if not props or self.tooltip.id == props[0]:
self.tooltip.hide_tooltip()
pass
def show_tooltip(self, contact):
room_jid = self.get_active_jid()
pointer = self.list_treeview[room_jid].get_pointer()
props = self.list_treeview[room_jid].get_path_at_pos(pointer[0], pointer[1])
if props and self.tooltip.id == props[0]:
# check if the current pointer is at the same path
# as it was before setting the timeout
rect = self.list_treeview[room_jid].get_cell_area(props[0],props[1])
position = self.list_treeview[room_jid].window.get_origin()
pointer = self.window.get_pointer()
self.tooltip.show_tooltip(contact, (pointer[0], rect.height),
(position[0], position[1] + rect.y))
else:
self.tooltip.hide_tooltip()
def on_treeview_size_allocate(self, widget, allocation):
"""The MUC treeview has resized. Move the hpaneds in all tabs to match"""
thisroom_jid = self.get_active_jid()

View File

@ -8865,6 +8865,8 @@ topic</property>
<signal name="row_expanded" handler="on_list_treeview_row_expanded" last_modification_time="Sat, 05 Mar 2005 00:31:57 GMT"/>
<signal name="button_press_event" handler="on_list_treeview_button_press_event" last_modification_time="Sat, 05 Mar 2005 00:32:05 GMT"/>
<signal name="key_press_event" handler="on_list_treeview_key_press_event" last_modification_time="Sat, 26 Mar 2005 20:42:24 GMT"/>
<signal name="motion_notify_event" handler="on_list_treeview_motion_notify_event" last_modification_time="Thu, 18 Aug 2005 23:11:24 GMT"/>
<signal name="leave_notify_event" handler="on_list_treeview_leave_notify_event" last_modification_time="Thu, 18 Aug 2005 23:11:51 GMT"/>
</widget>
</child>
</widget>

View File

@ -243,7 +243,51 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
self.text_lable.set_markup(text)
self.hbox.add(self.table)
self.win.add(self.hbox)
class GCTooltip(BaseTooltip, StatusTable):
''' Tooltip that is shown in the GC treeview '''
def __init__(self, plugin):
self.account = None
self.plugin = plugin
self.image = gtk.Image()
self.image.set_alignment(0.5, 0.025)
BaseTooltip.__init__(self)
StatusTable.__init__(self)
def populate(self, contact):
if not contact :
return
self.create_window()
self.hbox = gtk.HBox()
self.hbox.set_homogeneous(False)
self.create_table()
info = '<span size="large" weight="bold">' + contact.name + '</span>'
info += '\n<span weight="bold">' + _('Role: ') + '</span>' + \
gtkgui_helpers.escape_for_pango_markup(contact.role)
info += '\n<span weight="bold">' + _('Affiliation: ') + '</span>' + \
gtkgui_helpers.escape_for_pango_markup(contact.affiliation)
info += '\n<span weight="bold">' + _('Status: ') + \
'</span>' + helpers.get_uf_show(contact.show)
if contact.status:
status = contact.status.strip()
if status != '':
# escape markup entities. Is it posible to have markup in status?
info += ' - ' + gtkgui_helpers.escape_for_pango_markup(status)
#single_line, resource_str, multiple_resource= '', '', False
self.text_lable.set_markup(info)
self.hbox.pack_start(self.image, False, False)
self.hbox.pack_start(self.table, True, True)
self.win.add(self.hbox)
class RosterTooltip(BaseTooltip, StatusTable):
''' Tooltip that is shown in the roster treeview '''
def __init__(self, plugin):