diff --git a/src/groupchat_window.py b/src/groupchat_window.py index 9506dff72..7738dcccb 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -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() diff --git a/src/gtkgui.glade b/src/gtkgui.glade index 6334d9390..90af158c7 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -8865,6 +8865,8 @@ topic + + diff --git a/src/tooltips.py b/src/tooltips.py index c66b5ed77..e0c5239b4 100644 --- a/src/tooltips.py +++ b/src/tooltips.py @@ -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 = '' + contact.name + '' + info += '\n' + _('Role: ') + '' + \ + gtkgui_helpers.escape_for_pango_markup(contact.role) + + info += '\n' + _('Affiliation: ') + '' + \ + gtkgui_helpers.escape_for_pango_markup(contact.affiliation) + + info += '\n' + _('Status: ') + \ + '' + 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):