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 Aug 30, 2016 5:06 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 
GTK+ Guru

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

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);

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 previous post in this forum but cant manage much ( . I also tried the gtk manual on GFileMonitor and failed.
May I request your time for kind help?

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

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

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: Yahoo [Bot] and 1 guest

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