cgtkgtktreeviewgtkscrolledwindow

How to make a Gtk+ widget inside a GtkScrolledWindow to expand when packed into a GtkPane?


I have a program which shows two GtkTreeViews packed inside a GtkPaned (sscce: here):

gtk_paned_add1(GTK_PANED(paned), tree_view1);
gtk_paned_add2(GTK_PANED(paned), tree_view2);

The result is the following:

Window presenting the two tree views

However, the tables can become bigger, so I added then to GtkScrolledWindows (sscce: here):

GtkWidget *scrolled_window1 = gtk_scrolled_window_new(NULL, NULL),
          *scrolled_window2 = gtk_scrolled_window_new(NULL, NULL);
gtk_container_add(GTK_CONTAINER(scrolled_window1), tree_view1);
gtk_container_add(GTK_CONTAINER(scrolled_window2), tree_view2);
gtk_paned_add1(GTK_PANED(paned), scrolled_window1);
gtk_paned_add2(GTK_PANED(paned), scrolled_window2);

However, now the window collapses itself to the point it is almost a thin trance, as in the screenshot below:

Insanely small window

If I maximize the window, the first column does not appear (although I can manually expand it):

The first table does not appear

So, what is the best method of getting the appearance of the first screenshot wen using GtkScrolledWindows in this scenario? Also, could I define the size of the pane columns in relation to one another (for example, 30% for the first one, 70% for the second one?


Solution

  • The solution I adopted was to actually set the size of the scrolled windows (sscce):

    gtk_widget_set_size_request(scrolled_window1, 200, 600);
    gtk_widget_set_size_request(scrolled_window2, 600, 600);
    

    The result was, as one would expect, a window with 800x600:

    A window with good dimentions

    I am not satisfied: this approach relies on arbitrary sizes and it seems too "manual". Nonetheless, I want to use my software so I will adopt it for now.