Cant get GtkTextBuffer from GtkTextView widget



Hi All!

I`ve got a problem with GtkTextView object. I want to append text to it
everytime when some event occurs.

Here is code snippet:

static void handler(GtkWidget *widget, GtkTextView *tview) {
        GtkTextBuffer *buffer;
        GtkTextIter *iterator;
        
        buffer = gtk_text_view_get_buffer(tview);
        g_assert(buffer == NULL);
        gtk_text_buffer_get_end_iter(buffer, iterator);
        gtk_text_buffer_insert(buffer, iterator, 
                "Info message", -1);
}

int main(int argc, char ** argv) {
        GtkWiget *tview;
        tview = gtk_text_view_new();

        g_signal_connect(G_OBJECT(button), "clicked",
                G_CALLBACK(handler), tview);

        return 0;
}


When I`m trying to get buffer object in habdler() it allways returned as
NULL and I`ve got segmentation fault. I can`t figure out where is my
fault :(

How can I append text to GtkTextView ?

Thanks

PS: Sorry for my english
-- 
If you think of MS-DOS as mono, and Windows as stereo,
 then Linux is Dolby Digital and all the music is free...



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