#!/usr/bin/python

""""

This script shows a window with a selectable label as only child. With GTK+ 
<=3.12 right clicking on the label did not emit button-press-event on the 
parent and show a context menu. With GTK+ 3.13 it does both.

"""

import signal
from gi.repository import Gtk, GLib

def populate_popup_cb(*args):
    print("populate-popup", args)

def button_press_event_cb(*args):
    print("button-press-event", args)

window = Gtk.Window(default_width=200, default_height=200)
label = Gtk.Label(label="this is a label \0/", selectable=True)
label.connect("populate-popup", populate_popup_cb)
window.connect("button-press-event", button_press_event_cb)
window.add(label)
window.show_all()
window.connect("delete-event", Gtk.main_quit)

GLib.unix_signal_add(0, signal.SIGINT, Gtk.main_quit)
Gtk.main()
