why is class HelloWorld : public Gtk::Window ?
- From: Damon Register <damon w register lmco com>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: why is class HelloWorld : public Gtk::Window ?
- Date: Mon, 09 Feb 2009 16:27:40 -0500
In the gtkmm tutorial
http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-helloworld.html
and elsewhere I have seen this example method used for a gtkmm app.
There is the main() and a class that descends from Gtk::Window as in
class HelloWorld : public Gtk::Window
Why does HelloWorld descend from Gtk::Window?
I have seen examples for libglademm or gtk-builder which also have
a class such as HelloWorld that descends from Gtk::Window. So, I have
two questions:
1. Is it necessary to descend from Gtk::Window
when _not_ using libglademm or gtk-builder such as in the tutorial?
2. Is it necessary to descend from Gtk::Window
when using libglademm or gtk-builder?
Why do I care? In trying to find out why I get the
"assertion `G_IS_OBJECT (object)' failed" message, I am trying
different program configurations. In the process I have noticed
something interesting. In an example where
class HelloWorld : public Gtk::Window
I create an instance of the class in the main() with this
HelloWorld window;
and then in the class constructor I have
refXml = Gtk::Builder::create_from_file("../hello.xml");
refXml->get_widget("layout1", layout1);
layout1->reparent(*this);
When using libglademm I have something similar but in either case I
get the impression that I may have two Windows; one resulting from
refXml = Gtk::Builder::create_from_file("../hello.xml");
and another because the class descends from Gtk::Window. Is
that really happening as I suspect? I also noticed that the hello
class is destroyed after Gtk::Main::run finishes. Is that ok?
As an experiment I tried
connecting to Gtk::Main::signal_quit and in my signal handler
I call remove(). When I run the program and then exit, I don't
get the error message.
I tried a second experiment which proved interesting (for me
anyway). Instead of having the hello class descend from
Gtk::Window, I have it not descend from anything. In the
hello constructor I have
refXml = Gtk::Builder::create_from_file("../hello.xml");
refXml->get_widget("hello_main_window", pWindow);
and in the main() I have
kit.run(*(window.pWindow));
Am I on the right track so far? At this point I favor making
my class not descend from Gtk::Window as it seems to work but
I would like to know if this makes any sense before I go off
and change my applications.
Damon Register
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]