Hi,
I want to make a message window where I can get display running messages. I'm using the GtkTextView like this:
pwMessageText = gtk_text_view_new(); pbMessageBuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (pwMessageText)); gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( pwMessageText ), GTK_WRAP_WORD ); gtk_text_view_set_editable( GTK_TEXT_VIEW( pwMessageText ), FALSE ); gtk_text_view_set_cursor_visible( GTK_TEXT_VIEW( pwMessageText ), FALSE ); vscrollbar = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vscrollbar), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(pwvbox), vscrollbar, TRUE, TRUE, 0); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(vscrollbar), pwMessageText);
Then I'm sending messages the the buffer like this:
gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER( pbMessageBuffer ) , sz, -1);
First a problem:
When I'm adding text the latest text appear below the displayed viewport. I have to scroll down to see the added messages. Is there a simple way to get the message window to scroll to the bottom (where the message is added) when inserting a new message?
Then a question:
After a while the message buffer will be really big. Can I, in a simple
way, pop off the top of the buffer when it's unnecesarry big? (say 100 lines or something). Or do I have to make a message queue system, or something? (In case yes on the last question: Is there a glib datatype I can use for this?)
-Øystein _______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list