[Glade-users] GtkClist Problem (Seg fault)
- From: guillaume at ruch.infini.fr (guillaume ruch infini fr)
- Subject: [Glade-users] GtkClist Problem (Seg fault)
- Date: Thu Jun 1 17:41:12 2006
Hello all,
I've Got a problem with creayion of a GtkClist.... I'm developping a small
mysql interface which only deals withs 3 tables. I've got 3 buttons which
may build each a dynamic clist to display the content of the selected
table in the same widget. When I compile it, it returns :
(project2:1390): Gtk-CRITICAL **: gtk_object_set_data_full: assertion
`GTK_IS_OBJECT (object)' failed
Erreur de segmentation
gtk_clist_new...OK
(project2:30722): Gtk-CRITICAL **: gtk_object_set: assertion
`GTK_IS_OBJECT (object)' failed
gtk_object_set_data_full...OK
(project2:30722): Gtk-CRITICAL **: gtk_object_set_data_full: assertion
`GTK_IS_OBJECT (object)' failed
Erreur de segmentation
The Widget is called dyn_clist and is called by an event on the button
"CLients" Here's the code :
GtkWidget *dyn_clist (gchar *nom_table)
{
GtkWidget *Stox_main;
GtkWidget *scrolledwindow1;
GtkWidget *clist1;
GtkWidget *label;
gint i;
gint cols = 3;
gchar *sql;
MYSQL_RES *res_str;
MYSQL_ROW db_row;
MYSQL_FIELD *field;
gchar *row[15] = {"", "", "", "", "",
"", "", "", "", "",
"", "", "", "", ""};
scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow1);
sql = g_strconcat("select * from ", nom_table, 0L);
g_print("sql is: %s\n", sql);
if (mysql_query (conn, sql) != 0)
{
g_print("Echec de la requete...\n");
return 0L;
}
res_str = mysql_store_result (conn);
g_print("mysql_store_result...OK\n");
cols = mysql_num_fields(res_str);
clist1 = gtk_clist_new (cols);
/*gtk_object_set_data_full(GTK_OBJECT(Stox_main),
"clist1", clist1,
0L); */
gtk_widget_show (clist1);
gtk_container_add (GTK_CONTAINER (scrolledwindow1), clist1);
gtk_clist_column_titles_show (GTK_CLIST (clist1));
for (i = 0; i < cols; i++)
{
mysql_field_seek(res_str, i);
field = mysql_fetch_field(res_str);
label = gtk_label_new (field->name);
gtk_widget_show (label);
gtk_clist_set_column_widget (GTK_CLIST (clist1),
i, label);
gtk_clist_set_column_width (GTK_CLIST (clist1),
i, 80);
}
while ((db_row = mysql_fetch_row (res_str)) != 0L)
{
for (i = 0; i < cols; i++)
{
row[i] = db_row[i];
}
gtk_clist_append(GTK_CLIST(clist1), row);
}
return scrolledwindow1;
}
/***********************Glade events*****************/
void
on_Clients_clicked (GtkButton *button,
gpointer user_data)
{
gchar *nom_table;
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
GTK_OBJECT (scwindow_table));
nom_table = "clients";
g_print("table name : %s...\n", nom_table);
scwindow_table = dyn_clist(nom_table);
gtk_widget_ref(scwindow_table);
g_print("widget_ref...OK\n");
/*gtk_object_set_data_full (GTK_OBJECT(StoX_main),
"scwindow_table", scwindow_table,
(GtkDestroyNotify) gtk_widget_unref);*/
gtk_container_add (GTK_CONTAINER(lookup_widget(StoX_main,
"vpaned_table_bottom")), scwindow_table);
gtk_widget_show(scwindow_table);
}
I'm newbie in devlopping applications, so I hope someone will know better
than me how to correct this error....
Friendly,
G.Ruch
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]