GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 16, 2014 5:28 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: autorefresh textview
PostPosted: Thu Aug 23, 2012 12:36 pm 
Offline
GTK+ Guru

Joined: Sun Jul 08, 2012 3:14 pm
Posts: 107
Location: Coventry, UK
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?


Top
 Profile  
 
 Post subject: Re: autorefresh textview
PostPosted: Thu Sep 06, 2012 12:35 pm 
Offline
Familiar Face

Joined: Thu Sep 06, 2012 8:45 am
Posts: 6
You can use inotify libary if you are on a linux platform.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group