Re: GtkSizeGroup breakage (was Re: questions re: aux info, size request)



This is indeed quite a brain teaser.

I don't think your current approach of incrementally bumping the size
group requisition does even work correctly. How does the size group
requisition ever become smaller again ? The pre-hfw sizegroup code
always looped over all widgets to determine the size group
requisition, which seems to me the only way to make things work.

I'll attach a simple example that shows the problem with incremental
bumping. If you use the hpaned to make the long label unwrap
completely, the height request does not get reduced to a single line
height, as you can see by using the vpaned.

Matthias
#include <gtk/gtk.h>

int
main (int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *hbox;
  GtkWidget *vbox1;
  GtkWidget *vbox2;
  GtkWidget *c11, *c12, *c21, *c22;
  GtkSizeGroup *sg;
  GtkWidget *hpaned, *vpaned;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 600, 200);

  hpaned = gtk_hpaned_new ();
  vpaned = gtk_vpaned_new ();

  hbox = gtk_hbox_new (FALSE, 5);
  vbox1 = gtk_vbox_new (FALSE, 5);
  vbox2 = gtk_vbox_new (FALSE, 5);

  gtk_container_add (GTK_CONTAINER (window), hpaned);
  gtk_paned_add1 (GTK_PANED (hpaned), vpaned);
  gtk_paned_add2 (GTK_PANED (hpaned), gtk_label_new (""));
  gtk_paned_add1 (GTK_PANED (vpaned), hbox);
  gtk_paned_add2 (GTK_PANED (vpaned), gtk_label_new (""));
  gtk_container_add (GTK_CONTAINER (hbox), vbox1);
  gtk_container_add (GTK_CONTAINER (hbox), vbox2);

  c11 = gtk_label_new ("Some text that might wrap");
  c12 = gtk_label_new ("Ellipsizing text that doesn't wrap");
  c21 = gtk_label_new ("Short text");
  c22 = gtk_label_new ("Some longer text that might also wrap over several lines");

  gtk_label_set_line_wrap (GTK_LABEL (c11), TRUE);
  gtk_label_set_ellipsize (GTK_LABEL (c12), PANGO_ELLIPSIZE_END);
  gtk_label_set_ellipsize (GTK_LABEL (c21), PANGO_ELLIPSIZE_END);
  gtk_label_set_line_wrap (GTK_LABEL (c22), TRUE);

  gtk_container_add (GTK_CONTAINER (vbox1), c11);
  gtk_container_add (GTK_CONTAINER (vbox1), c12);
  gtk_container_add (GTK_CONTAINER (vbox2), c21);
  gtk_container_add (GTK_CONTAINER (vbox2), c22);

  sg = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
  gtk_size_group_add_widget (sg, c11);
  gtk_size_group_add_widget (sg, c22);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}



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