GNOME Bugzilla – Bug 356033
Oddness in GtkWindow vs GdkWindow
Last modified: 2006-09-15 15:37:23 UTC
I'm still a python and pygtk newbie, so there may be reasons against this, but I was wondering if it'd make sense to have set_user_time() automatically realize the window for the user if it hasn't been already? Trying to help debug bug 351797, I found out that pygtk allows GdkWindow functions to be called on GtkWindow objects. i.e. window.set_user_time(timestamp) makes sense even though window is a GtkDialog. However, this function will silently fail if window has not been realized, forcing users to instead type window.realize() window.set_user_time(timestamp) to get correct behavior. That seems error prone given that there's no hint from the code why set_user_time might silently fail. In C, this isn't really fixable but at least the problem is slightly more noticable. The calls there are actually GdkWindow *gdk_window = GTK_WIDGET (window)->window; gdk_x11_window_set_user_time(gdk_window, timestamp); Thus gdk_x11_window_set_user_time doesn't have a GtkWindow object and can't realize one in order to obtain a valid gdk_window. It instead has to just exit early without doing anything. But, at least with this code it's a little more clear that gdk_window might be invalid (in this case, due to the fact that the window isn't realized). This means that if they do correctly guess that their gdk_window is invalid (or they just look up the function definition and see it has an early-exit possibility) then they are more likely to be able to discover the correct C version: GdkWindow *gdk_window; gtk_window_realize (window); gdk_window = GTK_WIDGET (window)->window; gdk_x11_window_set_user_time(gdk_window, timestamp);
> pygtk allows GdkWindow functions to be called on GtkWindow objects Are you sure?! That's news to me :o At least _my_ pygtk doesn't seem to allow it, as expected... what kind of broken pygtk version do you have?
Oops, I misread the orca code. It was window.window.set_user_time not window.set_user_time. Sorry for the noise...