Hi there,

Sorry for the bump, but there's also another issue that's frustrating
me. If I compile the test application with the gtk_widget_set_hexpand
line uncommented I see more unexpected behaviour resizing the window
horizontally.

Widening the window works as expected - except for the vertical
padding as noted below - but when I make the window narrower again,
the viewport (and the GtkTextViews inside it) seems to stay the same
size, suddenly requiring you to scroll horizontally to see all the
text (I had hoped for the GtkTextView to automatically resize to the
new width of the window). This happens regardless of what policy I set
for the horizontal scrollbar.

I'm sure I must be doing something fundamentally wrong as it seems
this should all be so simple; unfortunately I can't figure it out and
it's been driving me crazy for a couple of weeks now! I hope I don't
have to roll back to Gtk+ 2 where everything used to work for me! So
if anyone can offer any help whatsoever, I'd really appreciate it!

Thanks in advance,
Paul


On Sat, Apr 21, 2012 at 10:01 AM, Paul wrote:
> 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

Reply via email to