[Glade-devel] auto connect signals
- From: xyf.xiao at gmail.com (Xiao Yafeng)
- Subject: [Glade-devel] auto connect signals
- Date: Thu, 6 Aug 2009 11:37:51 +0800
I'm new to glade programming. below is my first gtk+ snippet with glade.
hello.c:
#include <gtk/gtk.h>
static int count;
void on_button_quit_clicked (GtkWidget *button, gpointer userdata){
//gtk_window_resize(window,(gint)100+count,(gint)100+count);
//count = count + 1;
gtk_main_quit();
}
int main (int argc, char **argv){
GtkBuilder *builder;
GtkWidget *window;
GtkWidget *button;
gtk_init (&argc, &argv);
builder = gtk_builder_new();
gtk_builder_add_from_file(builder, "hello.glade", NULL);
gtk_builder_connect_signals(builder,(GtkBuilde,NULL);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
hello.glade:
<?xml version="2.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="window1">
<child>
<object class="GtkVPaned" id="vpaned1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">label</property>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="button_quit">
<property name="label"
translatable="yes">quit</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_button_quit_clicked"
object="NULL"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button2">
<property name="label"
translatable="yes">button</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
error message:
(hello:8403): Gtk-WARNING **: Could not lookup object NULL on signal clicked
of object button_quit
(hello:8403): Gtk-CRITICAL **: gtk_main_quit: assertion `main_loops != NULL'
failed
Segmentation fault
It seems NULL is cause of failure, but who can post a correct code to prove
my guess?
TIA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-devel/attachments/20090806/8e8ec896/attachment.html
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]