Reputation: 14046
I keep getting a 'uninitialize GLib::Object' error from my code.
Here's the code:
class MainWindow < Gtk::Window
def initialize
title = "I'm The Title Of An Application! Yay!"
border_width = 10
set_size_request(600, 300)
signal_connect("destroy") { Gtk.main_quit }
@vbox = Gtk::VBox.new(false, 10)
add(@vbox)
show_all
end
end
main_window = MainWindow.new
With this, I get the error
in `set_size_request': uninitialize GLib::Object
So I move that tidbit of code to outside the class like so:
main_window = MainWindow.new
main_window.set_size_request(600, 300)
Then I get:
in `signal_connect': uninitialize GLib::Object
So I change it so my class and move the 'signal_connect' method outside the class with 'set_resize_request', which looks like this:
main_window = MainWindow.new
main_window.set_size_request(600, 300)
main_window.signal_connect("destroy") { Gtk.main_quit }
And it gives me:
in `add': uninitialize GLib::Object
Gwar! I change it yet again...
main_window = MainWindow.new
main_window.set_size_request(600, 300)
main_window.signal_connect("destroy") { Gtk.main_quit }
main_window.add(@vbox)
Now this?!
in `show_all': uninitialize GLib::Object
So, yet again, I remove the method from the class and put it outside of the class
main_window = MainWindow.new
main_window.set_size_request(600, 300)
main_window.signal_connect("destroy") { Gtk.main_quit }
main_window.add(@vbox)
main_window.show_all
Maybe... just maybe it'll work this time, so I hope for the best and run the code again...
in `set_size_request': uninitialize GLib::Object
What?! What's going on here?
Upvotes: 0
Views: 347
Reputation: 370407
In addition to khell's answer you should also note that your first two lines of initialize:
title = "I'm The Title Of An Application! Yay!"
border_width = 10
Create two local variables that are never used. You probably want to prepend self.
there.
Upvotes: 3
Reputation: 24010
I think you have to call super
before anything else at the initialization phase:
def initialize
super
# Other code goes here
# ...
end
Also don't forget to add Gtk.main
:
main_window = MainWindow.new
# Don't forget this...
Gtk.main
Upvotes: 4