[Glade-users] problems with glade

hi all,

Now the program don't return errors, but, the text_view only show the
last line of the file, I think add:: sprintf(magatzem,"%s\n", magatzem);
but text_view only show the last line.

---------- 8< interface.c ----------

  FILE *correu;
  int a, i;
  char magatzem[1024];
  gchar *out;
  correu = fopen("/tmp/tenes777","r");
  textbox = gtk_text_view_new();
  buffer = gtk_text_buffer_new (NULL);
  while (!feof(correu)) {
  fgets(magatzem, 1000, correu);
  if (strstr(magatzem, "[Tenes777]") != NULL) {
  out = g_convert(magatzem, -1,"UTF-8","ISO8859-1",NULL,NULL,NULL);
  if (out == NULL) printf("\nerror g_convert\n");

    gtk_text_buffer_set_text (buffer, out, -1);
    gtk_text_view_set_buffer (GTK_TEXT_VIEW (textbox), buffer);
    gtk_widget_show (textbox);

[ ... ]
--------------------- 8< interface.c -------------

thanks for your time.


El vie, 07 de 11 de 2003 a las 01:34, Tomi Manninen escribi�:
On Fri, 2003-11-07 at 01:49, Albert wrote:

Thanks Damon, 
I try to convert the string to UTF-8 but the program return the same

  out = g_convert(magatzem, -1,"UTF-8","ISO8859-1",NULL,NULL,NULL);

    gtk_text_buffer_set_text (buffer, magatzem, -1);

You are still passing the unmodified string (magatzem) to
gtk_text_buffer_set_text(). It's `out' that has the converted string.
And remember to free it later. So something like this:

  out = g_convert(magatzem, -1,"UTF-8","ISO8859-1",NULL,NULL,NULL);

  if (out == NULL) {
    /* handle error */

  gtk_text_buffer_set_text (buffer, out, -1);


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