diff --git a/test/gtk/htmltextview.py b/test/gtk/htmltextview.py
index a49bc6897..6b296c779 100644
--- a/test/gtk/htmltextview.py
+++ b/test/gtk/htmltextview.py
@@ -1,17 +1,14 @@
-import sys
-import os
from unittest.mock import MagicMock
-sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
-
-from gi.repository import Gtk, Gdk
+import gi
+gi.require_version('Gtk', '3.0')
+from gi.repository import Gtk
from gajim.common import app
from gajim.common import configpaths
configpaths.init()
from gajim.common import caps_cache
-from gajim.gtk.util import get_cursor
from gajim.conversation_textview import ConversationTextview
from gajim.gui_interface import Interface
@@ -20,168 +17,192 @@ app.plugin_manager = MagicMock()
app.logger = MagicMock()
app.interface = Interface()
-change_cursor = None
-htmlview = ConversationTextview(None)
+XHTML = [
+ '''
+
+
Hello
+
\n
+
+
\n
+
World\n
+
+ \n
+ ''',
-def on_textview_motion_notify_event(widget, event):
- """
- Change the cursor to a hand when we are over a mail or an url
- """
- global change_cursor
- w = htmlview.tv.get_window(Gtk.TextWindowType.TEXT)
- device = w.get_display().get_device_manager().get_client_pointer()
- pointer = w.get_device_position(device)
- x = pointer[1]
- y = pointer[2]
- tags = htmlview.tv.get_iter_at_location(x, y)[1].get_tags()
- if change_cursor:
- w.set_cursor(get_cursor('XTERM'))
- change_cursor = None
- for tag in tags:
- try:
- if tag.is_anchor:
- w.set_cursor(get_cursor('HAND2'))
- change_cursor = tag
- except Exception:
- pass
+ '''
+
+ ''',
-htmlview.tv.connect('motion_notify_event', on_textview_motion_notify_event)
+ '''
+
+ a:b
+ Google
+
+
+
+ ''',
-def handler(texttag, widget, event, iter_, kind):
- if event.type == Gdk.EventType.BUTTON_PRESS:
- pass
+ '''
+
+
+ O
+ MG
+ , I'm greenwith
+ envy!
+
+
+ ''',
+ '''
+
+ ''',
-htmlview.print_real_text(None, xhtml=''
-'
Hello\n'
- '
\n'
-'
World\n'
- '
\n')
-htmlview.print_real_text(None, xhtml='
')
-htmlview.print_real_text(None, xhtml='''
-
- a:b
- Google
-
-
-''')
-htmlview.print_real_text(None, xhtml='''
-
-
- O
- MG,
- I'm green
- with envy!
-
-
- ''')
-htmlview.print_real_text(None, xhtml='
')
-htmlview.print_real_text(None, xhtml='''
-
+ '''
+
http://test.com/ testing links autolinkifying
-
- ''')
-htmlview.print_real_text(None, xhtml='
')
-htmlview.print_real_text(None, xhtml='''
-
- As Emerson said in his essay Self-Reliance:
-
- "A foolish consistency is the hobgoblin of little minds."
-
-
- ''')
-htmlview.print_real_text(None, xhtml='
')
-htmlview.print_real_text(None, xhtml='''
-
-
- Hey, are you licensed to Jabber?
-
-
-
-
-
- ''')
-htmlview.print_real_text(None, xhtml='
')
-htmlview.print_real_text(None, xhtml='''
-
-
def fac(n):
-def faciter(n,acc):
-if n==0: return acc
-return faciter(n-1, acc*n)
-if n<0: raise ValueError('Must be non-negative')
-return faciter(n,1)
-
- ''')
-htmlview.print_real_text(None, xhtml='
')
-htmlview.print_real_text(None, xhtml='''
-
-
- - One
- - Two is nested:
- - One
- - Two
- - Three
- - Four
-
- - Three
-
- ''')
-htmlview.print_real_text(None, xhtml='
')
-htmlview.print_real_text(None, xhtml='''
-
-
-
- xmpp link
- :
-
-
-
- examples@example.org wrote:
-
- this cite - bla bla bla, smile- :-) …
-
-
-
-
-#232/1
-
-''')
-htmlview.print_real_text(None, xhtml='
')
-htmlview.print_real_text(None, xhtml='''
-
-
-
-
-''')
-htmlview.tv.show()
-sw = Gtk.ScrolledWindow()
-sw.set_property('hscrollbar-policy', Gtk.PolicyType.AUTOMATIC)
-sw.set_property('vscrollbar-policy', Gtk.PolicyType.AUTOMATIC)
-sw.set_property('border-width', 0)
-sw.add(htmlview.tv)
-sw.show()
-frame = Gtk.Frame()
-frame.set_shadow_type(Gtk.ShadowType.IN)
-frame.show()
-frame.add(sw)
-win = Gtk.Window()
-win.add(frame)
-win.set_default_size(400, 300)
+
+ ''',
+
+ '''
+
+ ''',
+
+ '''
+
+ As Emerson said in his essay Self-Reliance:
+
+ "A foolish consistency is the hobgoblin of little minds."
+
+
+ ''',
+
+ '''
+
+ ''',
+
+ '''
+
+
+ Hey, are you licensed to Jabber?
+
+
+
+
+
+ ''',
+
+ '''
+
+ ''',
+
+ '''
+
+
+
+ def fac(n):
+ def faciter(n,acc):
+ if n==0: return acc
+ return faciter(n-1, acc*n)
+ if n<0: raise ValueError('Must be non-negative')
+ return faciter(n,1)
+
+ ''',
+
+ '''
+
+ ''',
+
+ '''
+
+
+ - One
+ -
+ Two is nested:
+
+ - One
+ - Two
+ - Three
+ - Four
+
+
+ - Three
+
+
+ ''',
+
+ '''
+
+ ''',
+
+ '''
+
+
+
+ xmpp link
+ :
+
+
+
+
+ examples@example.org wrote:
+
+ this cite - bla bla bla, smile- :-) …
+
+
+
+
+ #232/1
+
+ ''',
+
+ '''
+
+ ''',
+
+ '''
+
+
+
+
+ ''',
+
+]
+
+
+class TextviewWindow(Gtk.Window):
+ def __init__(self):
+ Gtk.Window.__init__(self, title="Textview Test")
+ self.set_default_size(600, 600)
+
+ self._textview = ConversationTextview(None)
+
+ scrolled = Gtk.ScrolledWindow()
+ scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ scrolled.add(self._textview.tv)
+ self.add(scrolled)
+ self.show()
+ self._print_xhtml()
+
+ def _print_xhtml(self):
+ for xhtml in XHTML:
+ self._textview.print_real_text(None, xhtml=xhtml)
+
+win = TextviewWindow()
+win.connect("destroy", Gtk.main_quit)
win.show_all()
-win.connect('destroy', lambda win: Gtk.main_quit())
Gtk.main()