Re: [gtk-list] adding rows to CList from file



You just need to put an ampersand (&) in front of 'line' when you are passing
it to gtk_clist_append.

Later,
Chicane

Aaron Walker wrote:

> ok, this should be relatively simple...
> but it is not working as I thought it would.
>
> I would like to open a file, read in each line, and make a clist row for
> each line
> here is what I have:
>
> ...
> 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?
>
> Thanks,
> Aaron
>
> --
> Visit my web site at http://iconmedia.com/cgi-bin/index.pl
>
> Current uptime:
>   7:50pm  up 42 min,  1 user,  load average: 1.20, 1.36, 1.18
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]