Re:Help replacing GtkDrawingArea with GtkLayout



I have constructed the following minimal example, it creates a GtkLayout
with one label inside it, sets the GDK_STRUCTURE_MASK on the GdkWindow
of the GtkLayout and connects the configure-event signal to a routine
that would just exit the main loop. Instead of exiting, the window is
created without the configure-event signal firing. The GdkWindow and its
mask are printed out and appear to be set as per the documentation.
Please can someone explain what is wrong!

#include <gtk/gtk.h>
static gboolean
configure_event ()
{
    fprintf (stderr, "configure-event\n");
    gtk_main_quit ();
    return FALSE;
}

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

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   
    layout = gtk_layout_new (NULL, NULL);
    gtk_container_add (GTK_CONTAINER (window), layout);
   

    label1 = gtk_label_new ("label 1");

    gtk_layout_put (GTK_LAYOUT (layout), label1, 10, 50);
  

    gtk_widget_show_all (window);

    GdkWindow *win = gtk_widget_get_window(layout); 
    g_print("win is %p initial mask 0x%x\n", win, gdk_window_get_events (win));
    gdk_window_set_events (win, gdk_window_get_events (win) | GDK_STRUCTURE_MASK);
    g_print("After adding GDK_STRUCTURE_MASK mask 0x%x\n", gdk_window_get_events (win));
    gtk_widget_add_events (layout, GDK_ALL_EVENTS_MASK);
    g_signal_connect (layout, "configure-event", G_CALLBACK (configure_event), NULL);

    gtk_main ();

    return 0;
}


Richard Shann

From: Richard Shann <richard rshann plus com>
To: gtk-app-devel-list gnome org
Subject: Help replacing GtkDrawingArea with GtkLayout
Message-ID: <1393771664 4221 117 camel DebianBox loc>
Content-Type: text/plain; charset="UTF-8"

I want to replace the existing GtkDrawingArea with a GtkLayout in a
large application (GNU Denemo).
When I do this just by substituting gtk_drawing_area_new() with
gtk_layout_new(NULL, NULL) I do not receive the configure_event and
scroll_event signals, although the code gtk_widget_add_events ..
GDK_EXPOSURE_MASK is still in place.

I suspect this is to do with the cryptic note that drawing has to be
done to the bin_window instead of window, but beyond that I am stumped.
The draw event is being handled fine, and mouse button clicks etc are
all working.

Any help in migrating from GtkDrawingArea to GtkLayout would be much
appreciated.

Richard Shann




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]