Hi there, I'm experiencing some issues trying to port an application of mine to Gtk+ 3. I have a vertical stack of GtkTextViews that I want to appear one after another without any vertical padding between them. I have issues using both GtkVBoxes (as originally used in my Gtk+ 2 version) and newer GtkGrids.
Having a quick look around I see the issues seem to be same as in bug 650267 [https://bugzilla.gnome.org/show_bug.cgi?id=650267] but there hasn't been any updates on that since it was raised about a year ago, so I thought I'd check for advice here. I've attached a simple test program below (which I hope is right -- I use gtkmm and haven't used the direct C API in a while). Like the original report mentioned, the GtkTextViews appear narrow and very tall by default. More difficult for me to understand is why there's extra vertical padding in the widgets without the focus, i.e., the top two of the three GtkTextViews in this example. Clicking on either of the top two GtkTextViews will suddenly resize it down to the correct size too! Setting hexpand TRUE on the GtkTextViews does help with the initial sizings: everything 'looks' OK until I resize the window, making it wider so the text renders in fewer lines in the GtkTextViews. I then get similar behaviour as before: the GtkTextViews without the focus don't automatically resize, only suddenly doing so when they receive focus. So, does anyone have any suggestions or fixes? If so they'd be greatly appreciated. Thanks, Paul --8<-- #include <gtk/gtk.h> #include <string.h> const char text[] = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod " "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim " "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea " "commodo consequat."; static GtkWidget *create_widget() { GtkWidget *widget = gtk_text_view_new(); gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)), text, strlen(text)); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(widget), GTK_WRAP_WORD); //gtk_widget_set_hexpand(widget, TRUE); /* helps with 'initial' sizings */ return widget; } int main(int argc, char **argv) { gtk_init(&argc, &argv); GtkWidget *grid = gtk_grid_new(); gtk_grid_attach(GTK_GRID(grid), create_widget(), 0, 0, 1, 1); gtk_grid_attach(GTK_GRID(grid), create_widget(), 0, 1, 1, 1); gtk_grid_attach(GTK_GRID(grid), create_widget(), 0, 2, 1, 1); GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), grid); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(window), 500, 300); gtk_container_add(GTK_CONTAINER(window), scrolled_window); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_widget_show_all(window); gtk_main(); return 0; } --8<-- _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list