quirky realize?



I have overridden the realize() function with my own for a widget that I
have written. I am attempting to set the event mask within this funtion as
follows.

<< code start >>

void
wm_root_realize(GtkWidget *widget)
{
        WmRoot *wm_root;

        printf("realize\n");

        g_return_if_fail(widget != NULL);
        g_return_if_fail(IS_WM_ROOT(widget));

        GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);

        wm_root = WM_ROOT(widget);

        widget->window = gdk_get_default_root_window();

        gtk_widget_set_events(widget, gtk_widget_get_events(widget) |
GDK_BUTTON_PRESS_MASK);

        g_object_ref(gdk_get_default_root_window());

        gdk_window_set_user_data(widget->window, widget);

        return;
}

<< code end >>

It fails with this message:

Gtk-CRITICAL **: file gtkwidget.c: line 4877 (gtk_widget_set_events):
assertion `!GTK_WIDGET_REALIZED (widget)' failed

GTK_WIDGET_REALIZED just seems to check the flags field, which I have set
to GTK_REALIZED already.

Why is this failing?

Thanks

-Ram




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