[Glade-users] problems referencing data parameter
- From: rais2k earthlink net (Rai Singh)
- Subject: [Glade-users] problems referencing data parameter
- Date: Sun, 09 Mar 2003 09:00:37 -0500
Hello,
I am having a problem referencing the gpointer data parameter within the
signal handlers on_button1_clicked and on_button3_clicked.
Instead of 0 and 1 respectively I get some arbitrary numbers 134694880
and 134694952.
The following is a fragment from the glade XML file that I'm using the
<data> element is set to GINT_TO_POINTER(0) and GINT_TO_POINTER(1)
respectively for both signal handlers. I just can't seem to initialize
the gpointer data parameter with these values. I really don't need to
reference that element, but I was just trying to see if it would work so
that I could use it later in some other applications:
<widget>
<class>GtkButton</class>
<name>button1</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_button1_clicked</handler>
<object>clist</object>
<data>GINT_TO_POINTER(0)</data>
<last_modification_time>Tue, 06 Feb 2001 04:51:06
GMT</last_modification_time>
</signal>
<label>Append</label>
</widget>
<widget>
<class>GtkButton</class>
<name>button3</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_button3_clicked</handler>
<object>clist</object>
<data>GINT_TO_POINTER(1)</data>
<last_modification_time>Tue, 06 Feb 2001 04:51:06
GMT</last_modification_time>
</signal>
<label>Delete</label>
</widget>
Here is the code that I'm using to reference the glade XML <data> elements.
#include <gtk/gtk.h>
#include <glade/glade.h>
#define FILENAME "clisttest.glade"
// #define MODES 2 // the number of modes that the column list
widget can be operating within.
// gchar *clist_mode[MODE] = { "append", "delete" };
typedef enum { APPEND, DELETE } mode; // the various mode type
possibilties
// mode mode_type; // keeps track of clist mode type
GladeXML *xml;
int main(int argc, char *argv[]) {
gtk_init(&argc, &argv);
glade_init();
xml = glade_xml_new(FILENAME, "mainWindow");
if(!xml) {
g_warning("Could not load interface.");
return 1;
}
glade_xml_signal_autoconnect(xml);
gtk_object_unref(GTK_OBJECT(xml));
gtk_main();
return 0;
}
//static gchar *row[4] = { "Test 1", "Test 2", "Test 3", "Test 4" };
void on_button1_clicked(GtkWidget *w, gpointer data) {
gchar *row[4];
GtkWidget *clist;
row[0] = "Test 1";
row[1] = "Test 2";
row[2] = "Test 3";
row[3] = "Test 4";
printf("The value at data is %d:\n",GPOINTER_TO_INT(data));
clist = GTK_WIDGET(w);
gtk_clist_append(GTK_CLIST(clist), row);
}
void on_button3_clicked(GtkWidget *w, gpointer data) {
gchar *row[4];
GtkObject *clist;
clist = GTK_WIDGET(w);
printf("The value at data is %d:\n",GPOINTER_TO_INT(data));
gtk_clist_remove(GTK_CLIST(clist), 0);
}
Please help.
Thanks,
Rai
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]