auto refresh file in textview
- From: Rudra Banerjee <bnrj rudra yahoo com>
 
- To: gtk devel <gtk-app-devel-list gnome org>
 
- Subject: auto refresh file in textview
 
- Date: Thu, 23 Aug 2012 13:45:39 +0100
 
Dear friends,
I am openning an existing file in textview from command line as:
    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:
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:
   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  post in gtkforums 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?
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]