Problem getting signal handler data
- From: Rai Singh <rais2k earthlink net>
- To: gtk-app-devel-list gnome org
- Subject: Problem getting signal handler data
- Date: Sat, 08 Mar 2003 17:53:50 -0500
Hello,
I am an absolute beginner in GTK programming and I'm having some trouble.
I'm having some difficulty in referencing data that is passed in via a
clist control's on_clist_realize event.
Here is the code. I borrowed this example from a previous post in this
list and made some modifications.
This is the output :
* The value passed in is 134694840
APPEND is : 0
DELETE is: 1
Did not append or delete anything.
*
I do not understand why I can't get the integer values of 0 or 1 from
gpointer user_data.
/*
* File : clisttest.c
*
* Description : Simple application to demonstrate the use of CList's and
* libglade.
*
* Dependencies : clisttest.glade
*
* Author : Andrae Muys
*
* Date : 6th Feburary 2001
*
* License : GPL.
*
*/
#include
#include
#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_clist_realize(GtkWidget *widget, gpointer user_data) {
gchar *row[4];
printf("The value passed in is %d\n",GPOINTER_TO_INT(user_data));
switch(GPOINTER_TO_INT(user_data)){
case APPEND:
row[0] = "Test 1";
row[1] = "Test 2";
row[2] = "Test 3";
row[3] = "Test 4";
gtk_clist_append(GTK_CLIST(widget), row);
break;
case DELETE:
gtk_clist_remove(GTK_CLIST(widget), 0);
break;
default:
printf ( "APPEND is : %d\n", APPEND );
printf ( "DELETE is : %d\n", DELETE );
printf("Did not append or delete anything.\n");
}
}
*This is part of the clisttest.glade XML file where the data is being passed in.*
GtkButton
button1
True
True
clicked
on_clist_realize
clist
GINT_TO_POINTER(0)
Tue, 06 Feb 2001 04:51:06 GMT
Append
GtkButton
button3
True
True
clicked
on_clist_realize
clist
GINT_TO_POINTER(1)
Tue, 06 Feb 2001 04:51:06 GMT
Delete
*This is the Makefile*
CC=gcc
DEBUG=-g
CFLAGS=$(DEBUG) -W -Wall -ansi-pedantic `gnome-config --cflags glib gtk libglade`
LDFLAGS=`gnome-config --libs glib gtk libglade`
all: clisttest
clisttest: clisttest.o
$(CC) $(LDFLAGS) -o $@ $^
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]