Auto scrolling GtkScrolledWindow with GtkTextView wrapped in GtkBox

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

 



Hello,

When I have GtkTextView in GtkScrolledWindow, it scrolls automatically when user appends new line at the bottom of the widget. When I put GtkTextView in GtkBox and then in GtkScrolledWindow autoscrolling doesn't work. I need to put box between GtkTextView and scrollbar and I can't do that without placing whole thing in another box. Is there any way to preserve autoscrolling behaviour when using GtkBox inside GtkScrolledWindow? There is code that ilustrates my problem:

#include <gtk/gtk.h>

int main(int argc, char *argv[]) {
    GtkWidget *window;
    gtk_init(&argc, &argv);
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(window),
        gdk_screen_width()*0.5, gdk_screen_height()*0.5); 

    GtkWidget *main = gtk_box_new(0, 0);
    gtk_container_add(GTK_CONTAINER(window), main);
    /*/////////////////////////////////////////////////*/

    /* IMPORTANT PART */

    /* FIRST CASE */
    GtkWidget *scrolled_window_first = gtk_scrolled_window_new(NULL, NULL);
    GtkWidget *text_view_first = gtk_text_view_new();

    gtk_container_add(GTK_CONTAINER(scrolled_window_first), text_view_first);
    gtk_box_pack_start(GTK_BOX(main), scrolled_window_first, 1, 1, 0);

    /* SECOND CASE */
    GtkWidget *scrolled_window_second = gtk_scrolled_window_new(NULL, NULL);
    GtkWidget *viewport = gtk_viewport_new(NULL, NULL);
    GtkWidget *text_view_second = gtk_text_view_new();
    GtkWidget *box_from_second_example = gtk_box_new(0, 0);


    gtk_box_pack_start(GTK_BOX(box_from_second_example), text_view_second, 1, 1, 0);
    gtk_container_add(GTK_CONTAINER(viewport), box_from_second_example);
    gtk_container_add(GTK_CONTAINER(scrolled_window_second), viewport);

    gtk_box_pack_start(GTK_BOX(main), scrolled_window_second, 1, 1, 0);

    /* END OF IMPORTANT PART */

    /*/////////////////////////////////////////////////*/
    g_signal_connect(GTK_WINDOW(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
    gtk_widget_show_all(window);
    gtk_main ();

    return 0;
}

Greetings,
solusipse
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list




[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux