/*
 *  gcc b775631.c `pkg-config --cflags gtk+-3.0` `pkg-config --libs gtk+-3.0` -o b775631
 */


#include <stdio.h>
#include <gtk/gtk.h>


static void
primary_clipboard_owner_change_cb (GtkClipboard *clipboard,
                                   GdkEventOwnerChange *event)
{
    printf ("%s:%d - %p\n", __PRETTY_FUNCTION__, __LINE__, event);
}

int
main (int argc, char* argv[])
{
    GtkWidget *window;
    GtkWidget *entry;

    gtk_init(&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_show (window);

    entry = gtk_entry_new ();
    gtk_entry_set_text (GTK_ENTRY (entry), "Select part of me with shift and arrow..");
    gtk_container_add (GTK_CONTAINER (window), entry);
    gtk_widget_show (entry);

    g_signal_connect (
            gtk_clipboard_get (GDK_SELECTION_PRIMARY), "owner-change",
            G_CALLBACK (primary_clipboard_owner_change_cb), NULL);

    gtk_main();
    gtk_widget_destroy (window);

    return 0;
}
