changeset c44805f8d96b in /home/hg/repos/gajim
author: lovetox <[email protected]>
branches:
details:http://hg.gajim.org/gajim?cmd=changeset;node=c44805f8d96b
description: Refactor GC Roster tooltip
diffstat:
data/gui/tooltip_gc_contact.ui | 145 +++++++++++++++++++++++++++
src/groupchat_control.py | 107 ++++++++-----------
src/tooltips.py | 220 ++++++++++++++++++----------------------
3 files changed, 290 insertions(+), 182 deletions(-)
diffs (truncated from 576 to 300 lines):
diff -r bf2bfc1be419 -r c44805f8d96b data/gui/tooltip_gc_contact.ui
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data/gui/tooltip_gc_contact.ui Sun Nov 13 21:06:37 2016 +0100
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <object class="GtkGrid" id="tooltip_grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="column_spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="nick">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="status">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="wrap">True</property>
+ <property name="max_width_chars">40</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="style" value="italic"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="jid_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="label" translatable="yes">Jabber ID:</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="avatar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-missing-image</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="height">7</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="resource_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="label" translatable="yes">Resource:</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="affiliation">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">5</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="user_show">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="fillelement">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="vexpand">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">6</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="resource">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="jid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff -r bf2bfc1be419 -r c44805f8d96b src/groupchat_control.py
--- a/src/groupchat_control.py Sat Nov 12 23:54:33 2016 +0000
+++ b/src/groupchat_control.py Sun Nov 13 21:06:37 2016 +0100
@@ -360,6 +360,12 @@
img = self.xml.get_object('history_image')
img.set_from_icon_name('document-open-recent', Gtk.IconSize.MENU)
widget = self.xml.get_object('list_treeview')
+ widget.set_has_tooltip(True)
+ widget.set_tooltip_window(tooltips.GCTooltip(self.parent_win.window))
+ self.current_tooltip = None
+ id_ = widget.connect('query-tooltip', self.query_tooltip)
+ self.handlers[id_] = widget
+
id_ = widget.connect('row_expanded',
self.on_list_treeview_row_expanded)
self.handlers[id_] = widget
@@ -379,14 +385,6 @@
self.on_list_treeview_key_press_event)
self.handlers[id_] = widget
- id_ = widget.connect('motion_notify_event',
- self.on_list_treeview_motion_notify_event)
- self.handlers[id_] = widget
-
- id_ = widget.connect('leave_notify_event',
- self.on_list_treeview_leave_notify_event)
- self.handlers[id_] = widget
-
self.room_jid = self.contact.jid
self.nick = contact.name
self.new_nick = ''
@@ -419,8 +417,6 @@
self.subject = ''
- self.tooltip = tooltips.GCTooltip()
-
# nickname coloring
self.gc_count_nicknames_colors = -1
self.gc_custom_colors = {}
@@ -530,6 +526,46 @@
# instance object
gajim.plugin_manager.gui_extension_point('groupchat_control', self)
+ def query_tooltip(self, widget, x_pos, y_pos, keyboard_mode, tooltip):
+ try:
+ row = self.list_treeview.get_path_at_pos(x_pos, y_pos)[0]
+ except TypeError:
+ return False
+ if not row:
+ return False
+
+ iter_ = None
+ try:
+ iter_ = self.model.get_iter(row)
+ except Exception:
+ return False
+
+ typ = self.model[iter_][C_TYPE]
+ nick = self.model[iter_][C_NICK]
+
+ if typ != 'contact':
+ return False
+
+ if self.current_tooltip != row:
+ # If the row changes we hide the current tooltip
+ self.current_tooltip = row
+ return False
+
+ tooltip = widget.get_tooltip_window()
+
+ if tooltip.row == row:
+ # We already populated the window with the row data
+ return True
+ tooltip.row = row
+
+ contact = gajim.contacts.get_gc_contact(
+ self.account, self.room_jid, nick)
+ if not contact:
+ return False
+
+ tooltip.populate(contact)
+ return True
+
def fill_column(self, col):
for rend in self.renderers_list:
col.pack_start(rend[1], rend[2])
@@ -2638,8 +2674,6 @@
"""
Popup user's group's or agent menu
"""
- # hide tooltip, no matter the button is pressed
- self.tooltip.hide_tooltip()
try:
pos = widget.get_path_at_pos(int(event.x), int(event.y))
path, x = pos[0], pos[2]
@@ -2697,55 +2731,6 @@
add = gc_refer_to_nick_char + ' '
message_buffer.insert_at_cursor(start + nick + add)
- def on_list_treeview_motion_notify_event(self, widget, event):
- props = widget.get_path_at_pos(int(event.x), int(event.y))
- if self.tooltip.timeout > 0 or self.tooltip.shown:
- if not props or self.tooltip.id != props[0]:
- self.tooltip.hide_tooltip()
- if props:
- [row, col, x, y] = props
- iter_ = None
- try:
- iter_ = self.model.get_iter(row)
- except Exception:
- self.tooltip.hide_tooltip()
- return
- typ = self.model[iter_][C_TYPE]
- if typ == 'contact':
- account = self.account
-
- if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
- self.tooltip.id = row
- nick = self.model[iter_][C_NICK]
- self.tooltip.timeout = GLib.timeout_add(500,
- self.show_tooltip, gajim.contacts.get_gc_contact(
- account, self.room_jid, nick))
-
- def on_list_treeview_leave_notify_event(self, widget, event):
- props = widget.get_path_at_pos(int(event.x), int(event.y))
- if self.tooltip.timeout > 0 or self.tooltip.shown:
- if not props or self.tooltip.id == props[0]:
- self.tooltip.hide_tooltip()
-
- def show_tooltip(self, contact):
- self.tooltip.timeout = 0
- if not self.list_treeview.get_window():
- # control has been destroyed since tooltip was requested
- return
- w = self.list_treeview.get_window()
- device = w.get_display().get_device_manager().get_client_pointer()
- pointer = w.get_device_position(device)
- props = self.list_treeview.get_path_at_pos(pointer[1], pointer[2])
- # check if the current pointer is at the same path
- # as it was before setting the timeout
- if props and self.tooltip.id == props[0]:
- rect = self.list_treeview.get_cell_area(props[0], props[1])
- position = w.get_origin()[1:]
- self.tooltip.show_tooltip(contact, rect.height,
- position[1] + rect.y)
- else:
- self.tooltip.hide_tooltip()
-
def grant_voice(self, widget, nick):
"""
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits