Dear friends,
I am openning an existing file in textview from command line as:
Code:
textview = gtk_text_view_new();
gtk_container_add(GTK_CONTAINER(scrolledwindow), textview);
textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
if (argc > 1 && argv[1] != NULL) {
char *flnm = argv[1];
read_view(flnm);
}
where the read_view is defined as:
Code:
static void read_view(char *inpfn) {
char *buffer;
stat(inpfn, &filestat);
textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
buffer = (char *) malloc(filestat.st_size * sizeof (char));
efile = fopen(inpfn, "r");
fread(buffer, filestat.st_size, 1, efile);
gtk_text_buffer_set_text(textbuffer, buffer, filestat.st_size);
free(buffer);
}
I am writing in the file that is opened as:
Code:
FILE *fop = fopen(filename, "a" );
g_fprintf( fop, "@%s{%s,\n", strcombo, strkey );
where the fileopen is difined globally.
whenever I am writing, it is saved, but to see the change, I have to reopen the file(obviously). I checked a previous post in this forum but cant manage much (
http://www.gtkforums.com/viewtopic.php?f=3&t=11443) . I also tried the gtk manual on GFileMonitor and failed.
May I request your time for kind help?