Re: Minimum height for minimum width



Agreed, GtkLabel needs to report min size = true min sane size and
natural size = either full width, or "a good width"
The full width is more correct imo, maybe we should figure out why
that doesn't work well.

A related patch attached, if you fix this you'll quickly want it.

Also, you said if doing minimum-height-for-natural-width the window
doesn't wrap the label and can't be made narrower. I don't understand
that... I would expect the min size of the window is the min height
for natural width as you propose, and the min width as returned by
get_preferred_width(). So the min width ought to be the true min
width?

Hmm. The "a good width to wrap to" thing seems like pretty much crack
to me. If people want their window to have some sort of pleasing
aspect ratio they should just pack the label to limit its width, or
set default size on the window, or whatever. Or maybe GtkWindow should
constrain the default size to "nice aspect ratio" somehow, solving
globally for the window instead of per-label.

Havoc
From 7ddeb49f1643799794bdc7d96a55fe9a885cd39f Mon Sep 17 00:00:00 2001
From: Havoc Pennington <hp pobox com>
Date: Mon, 6 Sep 2010 11:18:35 -0400
Subject: [PATCH] Make GtkWindow default to natural size not minimum size

Otherwise your ellipsized labels all start out ellipsized, unless
you manually gtk_window_set_default_size().

This probably makes it important to clamp the window's default
size to the size of the monitor's work area.
---
 gtk/gtkwindow.c |    4 ++--
 tests/testgtk.c |    1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 5f75dae..b50a9ab 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5725,9 +5725,9 @@ gtk_window_compute_configure_request_size (GtkWindow *window,
   
   if (window->need_default_size)
     {
-      gtk_widget_get_child_requisition (widget, &requisition);
+      gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), NULL, &requisition);
 
-      /* Default to requisition */
+      /* Default to natural requisition */
       *width = requisition.width;
       *height = requisition.height;
 
diff --git a/tests/testgtk.c b/tests/testgtk.c
index cddb7df..8ea1117 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -8431,6 +8431,7 @@ create_window_sizing (GtkWidget *widget)
 			     gtk_widget_get_screen (widget));
       label = gtk_label_new (NULL);
       gtk_label_set_markup (GTK_LABEL (label), "<span foreground=\"purple\"><big>Window being resized</big></span>\nBlah blah blah blah\nblah blah blah\nblah blah blah blah blah");
+      gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
       gtk_container_add (GTK_CONTAINER (target_window), label);
       gtk_widget_show (label);
       
-- 
1.7.0.4



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