From: Daniel C. <dan...@gm...> - 2006-01-26 23:01:49
|
Daniel Chokola wrote: > While trying to write a custom widget for my application I noticed that > there is no way to set the Gdk::Window used in a Gtk::Widget. This > results in all sorts of assertions and Gtk::Widget#window obviously > returns nil. > > Relevant code: > signal_connect_after('realize') do > @window = Gdk::Window.new(parent_window, > Gdk::WindowAttr.new(@w, @h, Gdk::Window::Class::OUTPUT, > Gdk::Window::Type::CHILD), 0) > puts @window > set_flags(Gtk::Widget::REALIZED) > end > > Output: > #<Gdk::Window:0xb72cadfc> > test.rb: line 4 > Gdk-CRITICAL **:gdk_window_show: assertion `GDK_IS_WINDOW (window)' > failed > test.rb: line 4 > Gdk-CRITICAL **:gdk_window_hide: assertion `GDK_IS_WINDOW (window)' > failed > test.rb: line 4 > Gdk-CRITICAL **:gdk_window_set_user_data: assertion `window != NULL' > failed > test.rb: line 4 > Gdk-CRITICAL **:_gdk_window_destroy_hierarchy: assertion `window != > NULL' failed > test.rb: line 4 > GLib-GObject-CRITICAL **:g_object_unref: assertion `G_IS_OBJECT > (object)' failed > > -Dan Chokola > I've made a patch: --- a/gtk/src/rbgtkwidget.c 2006-01-26 17:52:22.000000000 -0500 +++ b/gtk/src/rbgtkwidget.c 2006-01-26 17:49:54.000000000 -0500 @@ -1039,6 +1039,14 @@ return window ? GOBJ2RVAL(window) : Qnil; } +static VALUE +widget_set_window(self, window) + VALUE self; +{ + _SELF(self)->window = RVAL2GOBJ(window); + return window ? window : Qnil; +} + #define DEFINE_IS_WIDGET(STATE) \ static VALUE \ widget_ ## STATE (self) \ @@ -1234,6 +1242,7 @@ rb_define_method(gWidget, "remove_mnemonic_label", widget_remove_mnemonic_label, 1); #endif rb_define_method(gWidget, "window", widget_window, 0); + rb_define_method(gWidget, "set_window", widget_set_window, 1); rb_define_method(gWidget, "allocation", widget_get_allocation, 0); rb_define_method(gWidget, "set_allocation", widget_set_allocation, 4); rb_define_method(gWidget, "requisition", widget_get_requisition, 0); |