commit almost there code for tooltip over ---- line. Dimitur plz read this commit and FIXME I have

This commit is contained in:
Nikos Kouremenos 2005-10-08 16:47:35 +00:00
parent 4d15c54010
commit c8602d63c4
3 changed files with 25 additions and 9 deletions

View file

@ -25,6 +25,7 @@ import time
import dialogs import dialogs
import history_window import history_window
import gtkgui_helpers import gtkgui_helpers
import tooltips
try: try:
import gtkspell import gtkspell
@ -844,8 +845,9 @@ class Chat:
def on_conversation_textview_motion_notify_event(self, widget, event): def on_conversation_textview_motion_notify_event(self, widget, event):
'''change the cursor to a hand when we are over a mail or an url''' '''change the cursor to a hand when we are over a mail or an url'''
jid = self.get_active_jid() jid = self.get_active_jid()
x, y, spam = widget.window.get_pointer() pointer_x, pointer_y, spam = widget.window.get_pointer()
x, y = widget.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, x, y) x, y = widget.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT, pointer_x,
pointer_y)
tags = widget.get_iter_at_location(x, y).get_tags() tags = widget.get_iter_at_location(x, y).get_tags()
if self.change_cursor: if self.change_cursor:
widget.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor( widget.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor(
@ -853,11 +855,24 @@ class Chat:
self.change_cursor = None self.change_cursor = None
tag_table = widget.get_buffer().get_tag_table() tag_table = widget.get_buffer().get_tag_table()
for tag in tags: for tag in tags:
if tag == tag_table.lookup('url') or tag == tag_table.lookup('mail'): if tag in (tag_table.lookup('url'), tag_table.lookup('mail')):
widget.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor( widget.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor(
gtk.gdk.Cursor(gtk.gdk.HAND2)) gtk.gdk.Cursor(gtk.gdk.HAND2))
self.change_cursor = tag self.change_cursor = tag
return False elif self.widget_name == 'groupchat_window' and \
tag == tag_table.lookup('focus-out-line'):
widget.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor(
gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
self.change_cursor = tag
tooltip = tooltips.BaseTooltip()
message = _('abcdoremi')
# FIXME: found out (dkirov can help) what those params are supposed to be
# FIXME: also fix tooltips.py docstrings and comments (imporve and add more)
# to explain it better as atm it's poor
#tooltip.show_tooltip(message, (pointer_x, pointer_y), (pointer_x, pointer_y))
if tooltip.timeout != 0:
tooltip.hide_tooltip()
def on_clear(self, widget, textview): def on_clear(self, widget, textview):
'''clear text in the given textview''' '''clear text in the given textview'''

View file

@ -32,10 +32,11 @@ _ = i18n._
APP = i18n.APP APP = i18n.APP
class BaseTooltip: class BaseTooltip:
''' Base Tooltip . Usage: ''' Base Tooltip; Usage:
tooltip = BaseTooltip() tooltip = BaseTooltip()
.... ....
tooltip.show_tooltip('', window_postions, widget_postions) tooltip.show_tooltip('', window_positions, widget_positions)
#FIXME: what is window, what is widget?
.... ....
if tooltip.timeout != 0: if tooltip.timeout != 0:
tooltip.hide_tooltip() tooltip.hide_tooltip()
@ -108,7 +109,7 @@ class BaseTooltip:
self.win.show_all() self.win.show_all()
def hide_tooltip(self): def hide_tooltip(self):
if(self.timeout > 0): if self.timeout > 0:
gobject.source_remove(self.timeout) gobject.source_remove(self.timeout)
self.timeout = 0 self.timeout = 0
if self.win: if self.win: