#!/usr/bin/python3

import gi

gi.require_version('Gdk', '3.0')
gi.require_version('Gtk', '3.0')

from gi.repository import Gdk, Gtk

Gtk.init()

textview = Gtk.TextView()

# The solution to this issue is the line below: connect to the button-press-event and
# button-release-event signals and make sure the event does not propagate the button
# events to the listbox
#textview.connect_after('button-press-event', lambda w,e: Gdk.EVENT_STOP)
#textview.connect_after('button-release-event', lambda w,e: Gdk.EVENT_STOP)

scrolled_window = Gtk.ScrolledWindow(hscrollbar_policy=Gtk.PolicyType.NEVER)
scrolled_window.set_min_content_height(200)
scrolled_window.add(textview)

listbox = Gtk.ListBox()
listbox.add(scrolled_window);

win = Gtk.Window(title='Listbox issue')
win.add(listbox)
win.connect('delete-event', Gtk.main_quit)
win.show_all()

Gtk.main()
