Problem with GTK+ Application
Author |
Message |
apython1992
|
Posted: Sun Nov 28, 2010 5:43 pm Post subject: Problem with GTK+ Application |
|
|
Hello, I am writing a GTK+ application as part of a final project at school. To start, I wrote a toy application with simply a window that has one callback function, "on_window_destroy", just to work the kinks out before I add more widgets. However, when I try to run the program, I get the following error message:
(test.exe:1236): Gtk-CRITICAL **: gtk_widget_show: assertion `GTK_IS_WIDGET (widget)' failed
I am designing my application with Glade 3.6, which essentially builds an XML file that the C++ code parses, using GtkBuilder.
Here is the XML file created by Glade:
code: |
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="window">
<property name="title" translatable="yes">GTK+ Text Editor</property>
<signal name="destroy" handler="on_window_destroy"/>
<child>
<placeholder/>
</child>
</object>
</interface>
|
And my C++ code:
code: |
#include <stdlib.h>
#include <gtk/gtk.h>
void on_window_destroy(GtkObject *object, gpointer user_data)
{
gtk_main_quit();
}
int main(int argc, char *argv[])
{
GtkBuilder *builder;
GtkWidget *window;
gtk_init(&argc, &argv);
builder = gtk_builder_new();
gtk_builder_add_from_file(builder, "tutorial.xml", NULL);
window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
gtk_builder_connect_signals(builder, NULL);
g_object_unref(G_OBJECT(builder));
gtk_widget_show(window);
gtk_main();
return 0;
}
|
I write my C++ code with codeblocks, and use the GNU GCC compiler, if that's relevant. Thank you in advance. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
wtd
|
Posted: Mon Nov 29, 2010 2:19 am Post subject: RE:Problem with GTK+ Application |
|
|
Any particular reason you hate yourself enough to use C++ for this?
Something like Vala would seem a better choice. |
|
|
|
|
|
apython1992
|
Posted: Mon Nov 29, 2010 8:51 pm Post subject: Re: Problem with GTK+ Application |
|
|
Trust me, I have used GTK with Python before, and I agree, using it with C++ is a bit of a pain by comparison. However, as this is for a school project, I really have no choice but to use C++. |
|
|
|
|
|
apython1992
|
Posted: Tue Nov 30, 2010 8:17 pm Post subject: Re: Problem with GTK+ Application |
|
|
I found the problem, thanks. |
|
|
|
|
|
|
|