Li... |
05-06-2005 07:17 PM |
GTK: how to write into a clist?
Hi there,
with glade-2 I've created an application which should show translated data into a clist. Therefore I use several buttons to control the clist. One of them is the start/stop button and a clear button. When the start/stop is pushed I want to write some text ("Hello World") into the clist. Currently I want to do this directly by the start-stop-function. In the future, the start-stop function reveices and translate the data to text.
I think that there's a problem using the g_signal_connect functions. I'm not sure.
The code produced by glade:
interface.c
-----------
Code:
GtkWidget* create_main_window (void)
{
GtkWidget *clist1;
GtkWidget *startstop;
GtkWidget *clr;
startstop = gtk_label_new_with_mnemonic (_("Start\nStop"));
gtk_widget_show (startstop);
gtk_box_pack_start (GTK_BOX (hbox21), startstop, FALSE, FALSE, 3);
gtk_widget_show (clr);
gtk_table_attach (....);
gtk_container_set_border_width (....);
clist1 = gtk_clist_new (9);
gtk_widget_show (clist1);
gtk_container_add (GTK_CONTAINER (scrolledwindow2), clist1);
...several clist options here...
g_signal_connect ((gpointer) startstop, "clicked",
G_CALLBACK (on_start_stop_clicked),
NULL);
g_signal_connect_swapped ((gpointer) clr, "clicked",
G_CALLBACK (on_clr_clicked),
GTK_OBJECT (clr_clicked_object));
GLADE_HOOKUP_OBJECT (main_window, clist1, "clist1"); // ?????
}
callbacks.c
-----------
Code:
void on_start_stop_clicked (GtkButton *button, gpointer user_data)
{
gtk_clist_set_text((GtkCList*)user_data, 1, 1, "Hello World");
}
void on_clr_clicked(GtkButton *button, gpointer user_data)
{
gtk_clist_clear((GtkCList*)user_data);
}
The messages I receive when the program is running in a terminal window are:
Quote:
(prog:22717): Gtk-CRITICAL **: file gtkclist.c: line 2243 (gtk_clist_set_text): assertion `GTK_IS_CLIST (clist)' failed
(prog:22717): Gtk-CRITICAL **: file gtkclist.c: line 2701 (gtk_clist_clear): assertion `GTK_IS_CLIST (clist)' failed
|
How can I solve this???????
Li
|