gtk_signal_connect_object () problem
- From: Tzunga Ma <freekathmandu yahoo com>
- To: gtk-app-devel-list gnome org
- Subject: gtk_signal_connect_object () problem
- Date: Wed, 13 Aug 2003 06:27:53 -0700 (PDT)
hello, i'm new to GTK programming.
i guess i have problem with gtk_signal_connect_object, according to GTK reference manual, the syntax for gtk_signal_connect_object is
gtk_signal_connect_object( GtkObject *object, const gchar *name, GtkSignalFunc func, gointer func_data);
how can i pass more than one value on func_data ?
i'm having a problem with passing values from some GtkEntry and GtkCList on func_data.
i can't append the data on the clist, but the mysql stuff works fine ( i checked this before ).
my guess is the func_data, as i pass value for the entry_name, not the clist value.
i need help regarding this.
Thanks!
here is my code (modified from original GtkCList sample code):
-------------------------------------------------------------------------------------------------------------
void button_search_clicked ( gpointer clist )
{
GtkWidget *entry_name;
char *name;
name = gtk_entry_get_text(GTK_ENTRY(entry_name));
int err = 0;
if(name == NULL)
{ printf("Please Enter A Name!"); }
else
{
MYSQL *dbase;
dbase = mysql_init(NULL);
if(!dbase) err = 1;
else
{
if(mysql_real_connect(dbase,"localhost","root","","db_book",0,NULL,0) == NULL) err = 1;
}
if(err)
{
printf("Error connecting to database\n");
exit(0);
}
sprintf(sqlbuff,"SELECT * FROM book_inv WHERE name LIKE '%%%s%%'", name);
if(mysql_real_query(dbase,sqlbuff,strlen(sqlbuff)))
{
printf("SQL error Or Field Doesn't Exist\n",sqlbuff);
exit(1);
}
int nrows;
MYSQL_RES *result;
result = mysql_store_result(dbase);
nrows = mysql_num_rows(result);
if(nrows == 0)
{ printf("Error!\tNo entries For Name: %s",name); }
else
{
int i;
MYSQL_ROW *row;
for (i=0;i<nrows;i++)
{
row = mysql_fetch_row(result);
gtk_clist_append( (GtkCList *) clist,
row[1]);
}
}
}
}
-------------------------------------------------------------------------------------------------------------
in the main function i put this:
gtk_signal_connect_object(GTK_OBJECT(button_search), "clicked",
GTK_SIGNAL_FUNC(button_search_clicked),
(gpointer) entry_name);
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]