erratum [gtk-list] adding rows to CList from file
- From: Martin Kestel <mka mppmu mpg de>
- To: gtk-list redhat com
- Subject: erratum [gtk-list] adding rows to CList from file
- Date: Sat, 27 Nov 1999 02:22:39 +0100 (MET)
oops, sorry! switched in the lines... leave the gpointer casting out:
here is the corrected version
>>FILE *fp
>>char line[256];
>>if((fp = fopen("/tmp/output", "r")) == NULL)
>>{
>> perror("/tmp/output");
>> exit(1);
>>}
>>clist = gtk_clist_new_with_titles(1, titles);
>>gtk_signal_connect(GTK_OBJECT(clist), "select_row",
>> GTK_SIGNAL_FUNC(clist_selection_made_cb), NULL);
>>gtk_clist_set_shadow_type (GTK_CLIST(clist), GTK_SHADOW_OUT);
>>gtk_box_pack_start(GTK_BOX(vbox), clist, TRUE, TRUE, 0);
>>gtk_widget_show(clist);
>>while((fgets(line, sizeof line, fp)) != NULL)
>> gtk_clist_append(GTK_CLIST(clist), line);
>>...
>>
>>ok, the above code yields the gcc error:
>>passing arg 2 of 'gtk_clist_append' from incompatiple pointer type
>>
>>now I know that arg 2 needs to be a gchar *[], but even if I cast line
>>to gchar *, it still doesn't work.
>>
>>Any ideas?
>
What if you add some
char *pointer_to_entry;
and then say
pointer_to_entry = (gchar *)malloc((int)strlen(line));
pointer_to_entry = (gchar *)&line;
then appending should work:
gtk_clist_append(GTK_CLIST(clist), (gpointer) pointer_to_entry);
gtk_clist_append(GTK_CLIST(clist), &pointer_to_entry);
(adding simply the '&' does not help the gcc...)
This works for me like that, but the interesting question (to the
chefs) is why it does not go the easy way you had tried at first?
Martin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]