problem: text view appends



Hello friends,
I am trying to append text in a text view, don't know
how to do this (tried alot of things).


here is code snippet:

gint call_me(gpointer user_data)
{
        int bytes=0,temp;
//checks to see whether called for first time or not
        static int flag=1;
        GtkWidget *textview1;
        FILE *fp;
        gchar *buffer=NULL;
  GtkTextBuffer *buffer2=gtk_text_buffer_new(NULL);

        textview1=(GtkWidget *)user_data;
        fp=fopen("/var/log/messages","r");
        while(1)
        {
                temp=getline(&buffer,&bytes,fp);
                if(temp<=0)
                        break;                  
        }
        if(flag)
        {
                        gtk_text_buffer_set_text(buffer2,buffer,-1);
                        flag=0;
        }
        else
        {
//TODO: something that makes the previous text as it
is      // and the new text to appear below it. (don't
know 
// what to write).
        }

gtk_text_view_set_buffer(GTK_TEXT_VIEW(textview1),buffer2);
        fclose(fp);
        return 1;
}

and here is the timeout function call:

gint
i=g_timeout_add(1000,call_me,(gpointer)textview1);

what should i write in the commented area (else part)
so that the text previously displayed by the view
doesn't get's cleared up and the new text (line in
this case) gets appear below it.

Regards
Deependra Singh

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]