GtkTextBuffer and non UTF8 chars
- From: Magnus-swe <magnus-swe telia com>
- To: GTK Devel List <gtk-app-devel-list gnome org>
- Cc: magnus-swe telia com
- Subject: GtkTextBuffer and non UTF8 chars
- Date: 15 Jul 2002 18:35:21 +0200
The application crashes when i run this code more then 2 times
and wont set the text at all if there are swedish chars in it.
Im using GTK+ 2.0.5.
/* Read a textfile and put the contents in a textview. */
void
on_files_textview_map (GtkWidget *widget,
gpointer user_data)
{
FILE *fp;
long size_buffer;
char *file_buffer;
char *get_file_buffer;
GtkTextBuffer *file_text_buffer;
files_textview = lookup_widget (GTK_WIDGET (widget), "files_textview");
if( (fp = fopen("/var/log/xferlog", "r")) == NULL)
{
strcpy(info_buffer, "Cant find /var/log/xferlog.\n\n");
strcat(info_buffer, "If youre running GProFTPD as root\n");
strcat(info_buffer, "the xferlog has been added for you.\n");
error_window = create_error_window ();
gtk_widget_show (error_window);
system("touch /var/log/xferlog");
return;
}
fseek(fp, 0, SEEK_END);
size_buffer = ftell(fp);
rewind(fp);
file_buffer=(char *)malloc(size_buffer);
get_file_buffer=(char *)malloc(size_buffer);
while (fgets(file_buffer, size_buffer, fp)!=NULL)
{
strcat(get_file_buffer, file_buffer);
}
file_text_buffer =
gtk_text_view_get_buffer(GTK_TEXT_VIEW(files_textview));
gtk_text_buffer_set_text(file_text_buffer, get_file_buffer, -1);
fclose(fp);
free(file_buffer);
free(get_file_buffer);
}
I hope that someone can find the time to help me with this problem.
// Magnus-swe
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]