Merge branch 'kill-size-request'

This commit is contained in:
Tristan Van Berkom 2010-10-28 15:30:32 +09:00
commit 2f3e51389e
36 changed files with 2041 additions and 1026 deletions

View File

@ -343,6 +343,182 @@ cairo_destroy (cr);
have been either impossible or impractical. have been either impossible or impractical.
</para> </para>
<section>
<title>Replace size_request by get_preferred_width/height</title>
<para>
The request-phase of the traditional GTK+ geometry management
has been replaced by a more flexible height-for-width system,
which is described in detail in the API documentation
(see <xref linkend="geometry-management"/>). As a consequence,
the ::size-request signal and vfunc has been removed from
#GtkWidgetClass. The replacement for size_request() can
take several levels of sophistication:
<itemizedlist>
<listitem>As a minimal replacement to keep current functionality,
you can simply implement the get_preferred_width() and
get_preferred_height() vfuncs by calling your existing
size_request() function. So you go from
<informalexample><programlisting>
static void
my_widget_class_init (MyWidgetClass *class)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
/* ... */
widget_class->size_request = my_widget_size_request;
/* ... */
}
</programlisting></informalexample>
to something that looks more like this:
<informalexample><programlisting>
static void
my_widget_get_preferred_width (GtkWidget *widget,
gint *minimal_width,
gint *natural_width)
{
GtkRequisition requisition;
my_widget_size_request (widget, &amp;requisition);
*minimal_width = *natural_width = requisition.width;
}
static void
my_widget_get_preferred_height (GtkWidget *widget,
gint *minimal_height,
gint *natural_height)
{
GtkRequisition requisition;
my_widget_size_request (widget, &amp;requisition);
*minimal_height = *natural_height = requisition.height;
}
/* ... */
static void
my_widget_class_init (MyWidgetClass *class)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
/* ... */
widget_class->get_preferred_width = my_widget_get_preferred_width;
widget_class->get_preferred_height = my_widget_get_preferred_height;
/* ... */
}
</programlisting></informalexample>
Sometimes you can make things a little more streamlined
by replacing your existing size_request() implementation by
one that takes an orientation parameter:
<informalexample><programlisting>
static void
my_widget_get_preferred_size (GtkWidget *widget,
GtkOrientation orientation,
gint *minimal_size,
gint *natural_size)
{
/* do things that are common for both orientations ... */
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
/* do stuff that only applies to width... */
*minimal_size = *natural_size = ...
}
else
{
/* do stuff that only applies to height... */
*minimal_size = *natural_size = ...
}
}
static void
my_widget_get_preferred_width (GtkWidget *widget,
gint *minimal_width,
gint *natural_width)
{
my_widget_get_preferred_size (widget,
GTK_ORIENTATION_HORIZONTAL,
minimal_width,
natural_width);
}
static void
my_widget_get_preferred_height (GtkWidget *widget,
gint *minimal_height,
gint *natural_height)
{
my_widget_get_preferred_size (widget,
GTK_ORIENTATION_VERTICAL,
minimal_height,
natural_height);
}
/* ... */
</programlisting></informalexample>
</listitem>
<listitem>If your widget can cope with a small size,
but would appreciate getting some more space (a common
example would be that it contains ellipsizable labels),
you can do that by making your get_preferred_width()/height()
functions return a smaller value for @minimal than for @natural.
For @minimal, you probably want to return the same value
that your size_request() function returned before (since
size_request() was defined as returning the minimal size
a widget can work with). A simple way to obtain good
values for @natural, in the case of containers, is to use
gtk_widget_get_preferred_width() and
gtk_widget_get_preferred_height() on the children of the
container, as in the following example:
<informalexample><programlisting>
static void
gtk_fixed_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkFixed *fixed = GTK_FIXED (widget);
GtkFixedPrivate *priv = fixed->priv;
GtkFixedChild *child;
GList *children;
gint child_min, child_nat;
*minimum = 0;
*natural = 0;
for (children = priv->children; children; children = children->next)
{
child = children->data;
if (!gtk_widget_get_visible (child->widget))
continue;
gtk_widget_get_preferred_height (child->widget, &amp;child_min, &amp;child_nat);
*minimum = MAX (*minimum, child->y + child_min);
*natural = MAX (*natural, child->y + child_nat);
}
}
</programlisting></informalexample>
</listitem>
<listitem>To make full use of the new capabilities of the
height-for-width geometry management, you need to additionally
implement the get_preferred_height_for_width() and
get_preferred_width_for_height(). For details on these functions,
see <xref linkend="geometry-management"/>.
</listitem>
</itemizedlist>
</para>
</section>
<section> <section>
<title>Replace GdkRegion by cairo_region_t</title> <title>Replace GdkRegion by cairo_region_t</title>

View File

@ -117,8 +117,12 @@ static void gtk_assistant_init (GtkAssistant *assistant);
static void gtk_assistant_destroy (GtkWidget *widget); static void gtk_assistant_destroy (GtkWidget *widget);
static void gtk_assistant_style_set (GtkWidget *widget, static void gtk_assistant_style_set (GtkWidget *widget,
GtkStyle *old_style); GtkStyle *old_style);
static void gtk_assistant_size_request (GtkWidget *widget, static void gtk_assistant_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_assistant_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_assistant_size_allocate (GtkWidget *widget, static void gtk_assistant_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_assistant_map (GtkWidget *widget); static void gtk_assistant_map (GtkWidget *widget);
@ -209,7 +213,8 @@ gtk_assistant_class_init (GtkAssistantClass *class)
widget_class->destroy = gtk_assistant_destroy; widget_class->destroy = gtk_assistant_destroy;
widget_class->style_set = gtk_assistant_style_set; widget_class->style_set = gtk_assistant_style_set;
widget_class->size_request = gtk_assistant_size_request; widget_class->get_preferred_width = gtk_assistant_get_preferred_width;
widget_class->get_preferred_height = gtk_assistant_get_preferred_height;
widget_class->size_allocate = gtk_assistant_size_allocate; widget_class->size_allocate = gtk_assistant_size_allocate;
widget_class->map = gtk_assistant_map; widget_class->map = gtk_assistant_map;
widget_class->unmap = gtk_assistant_unmap; widget_class->unmap = gtk_assistant_unmap;
@ -1200,6 +1205,29 @@ gtk_assistant_size_request (GtkWidget *widget,
requisition->height = height; requisition->height = height;
} }
static void
gtk_assistant_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_assistant_size_request (widget, &requisition);
*minimum = *natural = requisition.width;
}
static void
gtk_assistant_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_assistant_size_request (widget, &requisition);
*minimum = *natural = requisition.height;
}
static void static void
gtk_assistant_size_allocate (GtkWidget *widget, gtk_assistant_size_allocate (GtkWidget *widget,

View File

@ -81,8 +81,12 @@ static void gtk_button_box_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_button_box_size_request (GtkWidget *widget, static void gtk_button_box_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_button_box_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_button_box_size_allocate (GtkWidget *widget, static void gtk_button_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_button_box_remove (GtkContainer *container, static void gtk_button_box_remove (GtkContainer *container,
@ -120,7 +124,8 @@ gtk_button_box_class_init (GtkButtonBoxClass *class)
gobject_class->set_property = gtk_button_box_set_property; gobject_class->set_property = gtk_button_box_set_property;
gobject_class->get_property = gtk_button_box_get_property; gobject_class->get_property = gtk_button_box_get_property;
widget_class->size_request = gtk_button_box_size_request; widget_class->get_preferred_width = gtk_button_box_get_preferred_width;
widget_class->get_preferred_height = gtk_button_box_get_preferred_height;
widget_class->size_allocate = gtk_button_box_size_allocate; widget_class->size_allocate = gtk_button_box_size_allocate;
container_class->remove = gtk_button_box_remove; container_class->remove = gtk_button_box_remove;
@ -612,6 +617,30 @@ gtk_button_box_size_request (GtkWidget *widget,
requisition->height += border_width * 2; requisition->height += border_width * 2;
} }
static void
gtk_button_box_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_button_box_size_request (widget, &requisition);
*minimum = *natural = requisition.width;
}
static void
gtk_button_box_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_button_box_size_request (widget, &requisition);
*minimum = *natural = requisition.height;
}
static void static void
gtk_button_box_size_allocate (GtkWidget *widget, gtk_button_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation) GtkAllocation *allocation)

View File

@ -341,8 +341,12 @@ static void gtk_calendar_get_property (GObject *object,
static void gtk_calendar_realize (GtkWidget *widget); static void gtk_calendar_realize (GtkWidget *widget);
static void gtk_calendar_unrealize (GtkWidget *widget); static void gtk_calendar_unrealize (GtkWidget *widget);
static void gtk_calendar_size_request (GtkWidget *widget, static void gtk_calendar_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_calendar_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_calendar_size_allocate (GtkWidget *widget, static void gtk_calendar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static gboolean gtk_calendar_draw (GtkWidget *widget, static gboolean gtk_calendar_draw (GtkWidget *widget,
@ -438,7 +442,8 @@ gtk_calendar_class_init (GtkCalendarClass *class)
widget_class->realize = gtk_calendar_realize; widget_class->realize = gtk_calendar_realize;
widget_class->unrealize = gtk_calendar_unrealize; widget_class->unrealize = gtk_calendar_unrealize;
widget_class->draw = gtk_calendar_draw; widget_class->draw = gtk_calendar_draw;
widget_class->size_request = gtk_calendar_size_request; widget_class->get_preferred_width = gtk_calendar_get_preferred_width;
widget_class->get_preferred_height = gtk_calendar_get_preferred_height;
widget_class->size_allocate = gtk_calendar_size_allocate; widget_class->size_allocate = gtk_calendar_size_allocate;
widget_class->button_press_event = gtk_calendar_button_press; widget_class->button_press_event = gtk_calendar_button_press;
widget_class->button_release_event = gtk_calendar_button_release; widget_class->button_release_event = gtk_calendar_button_release;
@ -2029,6 +2034,30 @@ gtk_calendar_size_request (GtkWidget *widget,
g_object_unref (layout); g_object_unref (layout);
} }
static void
gtk_calendar_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_calendar_size_request (widget, &requisition);
*minimum = *natural = requisition.width;
}
static void
gtk_calendar_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_calendar_size_request (widget, &requisition);
*minimum = *natural = requisition.height;
}
static void static void
gtk_calendar_size_allocate (GtkWidget *widget, gtk_calendar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation) GtkAllocation *allocation)

View File

@ -38,8 +38,12 @@
#define INDICATOR_SPACING 2 #define INDICATOR_SPACING 2
static void gtk_check_button_size_request (GtkWidget *widget, static void gtk_check_button_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_check_button_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_check_button_size_allocate (GtkWidget *widget, static void gtk_check_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static gboolean gtk_check_button_draw (GtkWidget *widget, static gboolean gtk_check_button_draw (GtkWidget *widget,
@ -60,7 +64,8 @@ gtk_check_button_class_init (GtkCheckButtonClass *class)
widget_class = (GtkWidgetClass*) class; widget_class = (GtkWidgetClass*) class;
widget_class->size_request = gtk_check_button_size_request; widget_class->get_preferred_width = gtk_check_button_get_preferred_width;
widget_class->get_preferred_height = gtk_check_button_get_preferred_height;
widget_class->size_allocate = gtk_check_button_size_allocate; widget_class->size_allocate = gtk_check_button_size_allocate;
widget_class->draw = gtk_check_button_draw; widget_class->draw = gtk_check_button_draw;
@ -195,8 +200,55 @@ _gtk_check_button_get_props (GtkCheckButton *check_button,
} }
static void static void
gtk_check_button_size_request (GtkWidget *widget, gtk_check_button_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (widget);
if (gtk_toggle_button_get_mode (toggle_button))
{
GtkWidget *child;
gint indicator_size;
gint indicator_spacing;
gint focus_width;
gint focus_pad;
guint border_width;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
gtk_widget_style_get (GTK_WIDGET (widget),
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
*minimum = 2 * border_width;
*natural = 2 * border_width;
_gtk_check_button_get_props (GTK_CHECK_BUTTON (widget),
&indicator_size, &indicator_spacing);
child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child))
{
gint child_min, child_nat;
gtk_widget_get_preferred_width (child, &child_min, &child_nat);
*minimum += child_min + indicator_spacing;
*natural += child_nat + indicator_spacing;
}
*minimum += (indicator_size + indicator_spacing * 2 + 2 * (focus_width + focus_pad));
*natural += (indicator_size + indicator_spacing * 2 + 2 * (focus_width + focus_pad));
}
else
GTK_WIDGET_CLASS (gtk_check_button_parent_class)->get_preferred_width (widget, minimum, natural);
}
static void
gtk_check_button_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{ {
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (widget); GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (widget);
@ -213,34 +265,33 @@ gtk_check_button_size_request (GtkWidget *widget,
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
gtk_widget_style_get (GTK_WIDGET (widget), gtk_widget_style_get (GTK_WIDGET (widget),
"focus-line-width", &focus_width, "focus-line-width", &focus_width,
"focus-padding", &focus_pad, "focus-padding", &focus_pad,
NULL); NULL);
requisition->width = border_width * 2; *minimum = border_width * 2;
requisition->height = border_width * 2; *natural = border_width * 2;
_gtk_check_button_get_props (GTK_CHECK_BUTTON (widget), _gtk_check_button_get_props (GTK_CHECK_BUTTON (widget),
&indicator_size, &indicator_spacing); &indicator_size, &indicator_spacing);
child = gtk_bin_get_child (GTK_BIN (widget)); child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child)) if (child && gtk_widget_get_visible (child))
{ {
GtkRequisition child_requisition; gint child_min, child_nat;
gtk_widget_get_preferred_size (child, &child_requisition, NULL); gtk_widget_get_preferred_height (child, &child_min, &child_nat);
requisition->width += child_requisition.width + indicator_spacing; *minimum += child_min;
requisition->height += child_requisition.height; *natural += child_nat;
} }
requisition->width += (indicator_size + indicator_spacing * 2 + 2 * (focus_width + focus_pad));
temp = indicator_size + indicator_spacing * 2; temp = indicator_size + indicator_spacing * 2;
requisition->height = MAX (requisition->height, temp) + 2 * (focus_width + focus_pad); *minimum = MAX (*minimum, temp) + 2 * (focus_width + focus_pad);
*natural = MAX (*natural, temp) + 2 * (focus_width + focus_pad);
} }
else else
GTK_WIDGET_CLASS (gtk_check_button_parent_class)->size_request (widget, requisition); GTK_WIDGET_CLASS (gtk_check_button_parent_class)->get_preferred_height (widget, minimum, natural);
} }
static void static void

View File

@ -1300,7 +1300,7 @@ gtk_drag_dest_set_proxy (GtkWidget *widget,
g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (!proxy_window || GDK_IS_WINDOW (proxy_window)); g_return_if_fail (!proxy_window || GDK_IS_WINDOW (proxy_window));
site = g_new (GtkDragDestSite, 1); site = g_slice_new (GtkDragDestSite);
site->flags = 0; site->flags = 0;
site->have_drag = FALSE; site->have_drag = FALSE;

View File

@ -258,8 +258,12 @@ static void gtk_entry_realize (GtkWidget *widget);
static void gtk_entry_unrealize (GtkWidget *widget); static void gtk_entry_unrealize (GtkWidget *widget);
static void gtk_entry_map (GtkWidget *widget); static void gtk_entry_map (GtkWidget *widget);
static void gtk_entry_unmap (GtkWidget *widget); static void gtk_entry_unmap (GtkWidget *widget);
static void gtk_entry_size_request (GtkWidget *widget, static void gtk_entry_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_entry_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_entry_size_allocate (GtkWidget *widget, static void gtk_entry_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_entry_draw_frame (GtkWidget *widget, static void gtk_entry_draw_frame (GtkWidget *widget,
@ -577,7 +581,8 @@ gtk_entry_class_init (GtkEntryClass *class)
widget_class->unmap = gtk_entry_unmap; widget_class->unmap = gtk_entry_unmap;
widget_class->realize = gtk_entry_realize; widget_class->realize = gtk_entry_realize;
widget_class->unrealize = gtk_entry_unrealize; widget_class->unrealize = gtk_entry_unrealize;
widget_class->size_request = gtk_entry_size_request; widget_class->get_preferred_width = gtk_entry_get_preferred_width;
widget_class->get_preferred_height = gtk_entry_get_preferred_height;
widget_class->size_allocate = gtk_entry_size_allocate; widget_class->size_allocate = gtk_entry_size_allocate;
widget_class->draw = gtk_entry_draw; widget_class->draw = gtk_entry_draw;
widget_class->enter_notify_event = gtk_entry_enter_notify; widget_class->enter_notify_event = gtk_entry_enter_notify;
@ -2853,8 +2858,9 @@ _gtk_entry_get_borders (GtkEntry *entry,
} }
static void static void
gtk_entry_size_request (GtkWidget *widget, gtk_entry_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkEntry *entry = GTK_ENTRY (widget); GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry); GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
@ -2862,8 +2868,57 @@ gtk_entry_size_request (GtkWidget *widget,
gint xborder, yborder; gint xborder, yborder;
GtkBorder inner_border; GtkBorder inner_border;
PangoContext *context; PangoContext *context;
int icon_widths = 0; gint icon_widths = 0;
int icon_width, i; gint icon_width, i;
gint width;
gtk_widget_ensure_style (widget);
context = gtk_widget_get_pango_context (widget);
metrics = pango_context_get_metrics (context,
gtk_widget_get_style (widget)->font_desc,
pango_context_get_language (context));
_gtk_entry_get_borders (entry, &xborder, &yborder);
_gtk_entry_effective_inner_border (entry, &inner_border);
if (entry->width_chars < 0)
width = MIN_ENTRY_WIDTH + xborder * 2 + inner_border.left + inner_border.right;
else
{
gint char_width = pango_font_metrics_get_approximate_char_width (metrics);
gint digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
gint char_pixels = (MAX (char_width, digit_width) + PANGO_SCALE - 1) / PANGO_SCALE;
width = char_pixels * entry->width_chars + xborder * 2 + inner_border.left + inner_border.right;
}
for (i = 0; i < MAX_ICONS; i++)
{
icon_width = get_icon_width (entry, i);
if (icon_width > 0)
icon_widths += icon_width + 2 * priv->icon_margin;
}
if (icon_widths > width)
width += icon_widths;
pango_font_metrics_unref (metrics);
*minimum = width;
*natural = width;
}
static void
gtk_entry_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkEntry *entry = GTK_ENTRY (widget);
PangoFontMetrics *metrics;
gint xborder, yborder;
GtkBorder inner_border;
PangoContext *context;
gint height;
gtk_widget_ensure_style (widget); gtk_widget_ensure_style (widget);
context = gtk_widget_get_pango_context (widget); context = gtk_widget_get_pango_context (widget);
@ -2877,30 +2932,12 @@ gtk_entry_size_request (GtkWidget *widget,
_gtk_entry_get_borders (entry, &xborder, &yborder); _gtk_entry_get_borders (entry, &xborder, &yborder);
_gtk_entry_effective_inner_border (entry, &inner_border); _gtk_entry_effective_inner_border (entry, &inner_border);
if (entry->width_chars < 0) height = PANGO_PIXELS (entry->ascent + entry->descent) + yborder * 2 + inner_border.top + inner_border.bottom;
requisition->width = MIN_ENTRY_WIDTH + xborder * 2 + inner_border.left + inner_border.right;
else
{
gint char_width = pango_font_metrics_get_approximate_char_width (metrics);
gint digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
gint char_pixels = (MAX (char_width, digit_width) + PANGO_SCALE - 1) / PANGO_SCALE;
requisition->width = char_pixels * entry->width_chars + xborder * 2 + inner_border.left + inner_border.right;
}
requisition->height = PANGO_PIXELS (entry->ascent + entry->descent) + yborder * 2 + inner_border.top + inner_border.bottom;
for (i = 0; i < MAX_ICONS; i++)
{
icon_width = get_icon_width (entry, i);
if (icon_width > 0)
icon_widths += icon_width + 2 * priv->icon_margin;
}
if (icon_widths > requisition->width)
requisition->width += icon_widths;
pango_font_metrics_unref (metrics); pango_font_metrics_unref (metrics);
*minimum = height;
*natural = height;
} }
static void static void

View File

@ -44,18 +44,22 @@ enum {
}; };
static void gtk_fixed_realize (GtkWidget *widget); static void gtk_fixed_realize (GtkWidget *widget);
static void gtk_fixed_size_request (GtkWidget *widget, static void gtk_fixed_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_fixed_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_fixed_size_allocate (GtkWidget *widget, static void gtk_fixed_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_fixed_add (GtkContainer *container, static void gtk_fixed_add (GtkContainer *container,
GtkWidget *widget); GtkWidget *widget);
static void gtk_fixed_remove (GtkContainer *container, static void gtk_fixed_remove (GtkContainer *container,
GtkWidget *widget); GtkWidget *widget);
static void gtk_fixed_forall (GtkContainer *container, static void gtk_fixed_forall (GtkContainer *container,
gboolean include_internals, gboolean include_internals,
GtkCallback callback, GtkCallback callback,
gpointer callback_data); gpointer callback_data);
static GType gtk_fixed_child_type (GtkContainer *container); static GType gtk_fixed_child_type (GtkContainer *container);
static void gtk_fixed_set_child_property (GtkContainer *container, static void gtk_fixed_set_child_property (GtkContainer *container,
@ -81,42 +85,39 @@ gtk_fixed_class_init (GtkFixedClass *class)
container_class = (GtkContainerClass*) class; container_class = (GtkContainerClass*) class;
widget_class->realize = gtk_fixed_realize; widget_class->realize = gtk_fixed_realize;
widget_class->size_request = gtk_fixed_size_request; widget_class->get_preferred_width = gtk_fixed_get_preferred_width;
widget_class->get_preferred_height = gtk_fixed_get_preferred_height;
widget_class->size_allocate = gtk_fixed_size_allocate; widget_class->size_allocate = gtk_fixed_size_allocate;
container_class->add = gtk_fixed_add; container_class->add = gtk_fixed_add;
container_class->remove = gtk_fixed_remove; container_class->remove = gtk_fixed_remove;
container_class->forall = gtk_fixed_forall; container_class->forall = gtk_fixed_forall;
container_class->child_type = gtk_fixed_child_type; container_class->child_type = gtk_fixed_child_type;
container_class->set_child_property = gtk_fixed_set_child_property; container_class->set_child_property = gtk_fixed_set_child_property;
container_class->get_child_property = gtk_fixed_get_child_property; container_class->get_child_property = gtk_fixed_get_child_property;
gtk_container_class_handle_border_width (container_class);
gtk_container_class_install_child_property (container_class, gtk_container_class_install_child_property (container_class,
CHILD_PROP_X, CHILD_PROP_X,
g_param_spec_int ("x", g_param_spec_int ("x",
P_("X position"), P_("X position"),
P_("X position of child widget"), P_("X position of child widget"),
G_MININT, G_MININT, G_MAXINT, 0,
G_MAXINT,
0,
GTK_PARAM_READWRITE)); GTK_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class, gtk_container_class_install_child_property (container_class,
CHILD_PROP_Y, CHILD_PROP_Y,
g_param_spec_int ("y", g_param_spec_int ("y",
P_("Y position"), P_("Y position"),
P_("Y position of child widget"), P_("Y position of child widget"),
G_MININT, G_MININT, G_MAXINT, 0,
G_MAXINT,
0,
GTK_PARAM_READWRITE)); GTK_PARAM_READWRITE));
g_type_class_add_private (class, sizeof (GtkFixedPrivate)); g_type_class_add_private (class, sizeof (GtkFixedPrivate));
} }
static GType static GType
gtk_fixed_child_type (GtkContainer *container) gtk_fixed_child_type (GtkContainer *container)
{ {
return GTK_TYPE_WIDGET; return GTK_TYPE_WIDGET;
} }
@ -124,16 +125,11 @@ gtk_fixed_child_type (GtkContainer *container)
static void static void
gtk_fixed_init (GtkFixed *fixed) gtk_fixed_init (GtkFixed *fixed)
{ {
GtkFixedPrivate *priv; fixed->priv = G_TYPE_INSTANCE_GET_PRIVATE (fixed, GTK_TYPE_FIXED, GtkFixedPrivate);
fixed->priv = G_TYPE_INSTANCE_GET_PRIVATE (fixed,
GTK_TYPE_FIXED,
GtkFixedPrivate);
priv = fixed->priv;
gtk_widget_set_has_window (GTK_WIDGET (fixed), FALSE); gtk_widget_set_has_window (GTK_WIDGET (fixed), FALSE);
priv->children = NULL; fixed->priv->children = NULL;
} }
GtkWidget* GtkWidget*
@ -149,13 +145,11 @@ get_child (GtkFixed *fixed,
GtkFixedPrivate *priv = fixed->priv; GtkFixedPrivate *priv = fixed->priv;
GList *children; GList *children;
children = priv->children; for (children = priv->children; children; children = children->next)
while (children)
{ {
GtkFixedChild *child; GtkFixedChild *child;
child = children->data; child = children->data;
children = children->next;
if (child->widget == widget) if (child->widget == widget)
return child; return child;
@ -165,10 +159,10 @@ get_child (GtkFixed *fixed,
} }
void void
gtk_fixed_put (GtkFixed *fixed, gtk_fixed_put (GtkFixed *fixed,
GtkWidget *widget, GtkWidget *widget,
gint x, gint x,
gint y) gint y)
{ {
GtkFixedPrivate *priv = fixed->priv; GtkFixedPrivate *priv = fixed->priv;
GtkFixedChild *child_info; GtkFixedChild *child_info;
@ -187,73 +181,69 @@ gtk_fixed_put (GtkFixed *fixed,
} }
static void static void
gtk_fixed_move_internal (GtkFixed *fixed, gtk_fixed_move_internal (GtkFixed *fixed,
GtkWidget *widget, GtkFixedChild *child,
gboolean change_x, gint x,
gint x, gint y)
gboolean change_y,
gint y)
{ {
GtkFixedChild *child;
g_return_if_fail (GTK_IS_FIXED (fixed)); g_return_if_fail (GTK_IS_FIXED (fixed));
g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (gtk_widget_get_parent (child->widget) == GTK_WIDGET (fixed));
g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (fixed));
child = get_child (fixed, widget); gtk_widget_freeze_child_notify (child->widget);
g_assert (child); if (child->x != x)
gtk_widget_freeze_child_notify (widget);
if (change_x)
{ {
child->x = x; child->x = x;
gtk_widget_child_notify (widget, "x"); gtk_widget_child_notify (child->widget, "x");
} }
if (change_y) if (child->y != y)
{ {
child->y = y; child->y = y;
gtk_widget_child_notify (widget, "y"); gtk_widget_child_notify (child->widget, "y");
} }
gtk_widget_thaw_child_notify (widget); gtk_widget_thaw_child_notify (child->widget);
if (gtk_widget_get_visible (widget) && if (gtk_widget_get_visible (child->widget) &&
gtk_widget_get_visible (GTK_WIDGET (fixed))) gtk_widget_get_visible (GTK_WIDGET (fixed)))
gtk_widget_queue_resize (GTK_WIDGET (fixed)); gtk_widget_queue_resize (GTK_WIDGET (fixed));
} }
void void
gtk_fixed_move (GtkFixed *fixed, gtk_fixed_move (GtkFixed *fixed,
GtkWidget *widget, GtkWidget *widget,
gint x, gint x,
gint y) gint y)
{ {
gtk_fixed_move_internal (fixed, widget, TRUE, x, TRUE, y); gtk_fixed_move_internal (fixed, get_child (fixed, widget), x, y);
} }
static void static void
gtk_fixed_set_child_property (GtkContainer *container, gtk_fixed_set_child_property (GtkContainer *container,
GtkWidget *child, GtkWidget *child,
guint property_id, guint property_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GtkFixed *fixed = GTK_FIXED (container);
GtkFixedChild *fixed_child;
fixed_child = get_child (fixed, child);
switch (property_id) switch (property_id)
{ {
case CHILD_PROP_X: case CHILD_PROP_X:
gtk_fixed_move_internal (GTK_FIXED (container), gtk_fixed_move_internal (fixed,
child, fixed_child,
TRUE, g_value_get_int (value), g_value_get_int (value),
FALSE, 0); fixed_child->y);
break; break;
case CHILD_PROP_Y: case CHILD_PROP_Y:
gtk_fixed_move_internal (GTK_FIXED (container), gtk_fixed_move_internal (fixed,
child, fixed_child,
FALSE, 0, fixed_child->x,
TRUE, g_value_get_int (value)); g_value_get_int (value));
break; break;
default: default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec); GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
@ -325,51 +315,64 @@ gtk_fixed_realize (GtkWidget *widget)
} }
static void static void
gtk_fixed_size_request (GtkWidget *widget, gtk_fixed_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkFixedPrivate *priv; GtkFixed *fixed = GTK_FIXED (widget);
GtkFixed *fixed; GtkFixedPrivate *priv = fixed->priv;
GtkFixedChild *child; GtkFixedChild *child;
GList *children; GList *children;
GtkRequisition child_requisition; gint child_min, child_nat;
guint border_width;
fixed = GTK_FIXED (widget); *minimum = 0;
priv = fixed->priv; *natural = 0;
requisition->width = 0; for (children = priv->children; children; children = children->next)
requisition->height = 0;
children = priv->children;
while (children)
{ {
child = children->data; child = children->data;
children = children->next;
if (gtk_widget_get_visible (child->widget)) if (!gtk_widget_get_visible (child->widget))
{ continue;
gtk_widget_get_preferred_size (child->widget,
&child_requisition,
NULL);
requisition->height = MAX (requisition->height, gtk_widget_get_preferred_width (child->widget, &child_min, &child_nat);
child->y +
child_requisition.height); *minimum = MAX (*minimum, child->x + child_min);
requisition->width = MAX (requisition->width, *natural = MAX (*natural, child->x + child_nat);
child->x +
child_requisition.width);
}
} }
}
border_width = gtk_container_get_border_width (GTK_CONTAINER (fixed)); static void
requisition->height += border_width * 2; gtk_fixed_get_preferred_height (GtkWidget *widget,
requisition->width += border_width * 2; gint *minimum,
gint *natural)
{
GtkFixed *fixed = GTK_FIXED (widget);
GtkFixedPrivate *priv = fixed->priv;
GtkFixedChild *child;
GList *children;
gint child_min, child_nat;
*minimum = 0;
*natural = 0;
for (children = priv->children; children; children = children->next)
{
child = children->data;
if (!gtk_widget_get_visible (child->widget))
continue;
gtk_widget_get_preferred_height (child->widget, &child_min, &child_nat);
*minimum = MAX (*minimum, child->y + child_min);
*natural = MAX (*natural, child->y + child_nat);
}
} }
static void static void
gtk_fixed_size_allocate (GtkWidget *widget, gtk_fixed_size_allocate (GtkWidget *widget,
GtkAllocation *allocation) GtkAllocation *allocation)
{ {
GtkFixed *fixed = GTK_FIXED (widget); GtkFixed *fixed = GTK_FIXED (widget);
GtkFixedPrivate *priv = fixed->priv; GtkFixedPrivate *priv = fixed->priv;
@ -377,58 +380,52 @@ gtk_fixed_size_allocate (GtkWidget *widget,
GtkAllocation child_allocation; GtkAllocation child_allocation;
GtkRequisition child_requisition; GtkRequisition child_requisition;
GList *children; GList *children;
guint border_width;
gtk_widget_set_allocation (widget, allocation); gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_has_window (widget)) if (gtk_widget_get_has_window (widget))
{ {
if (gtk_widget_get_realized (widget)) if (gtk_widget_get_realized (widget))
gdk_window_move_resize (gtk_widget_get_window (widget), gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->x,
allocation->y, allocation->y,
allocation->width, allocation->width,
allocation->height); allocation->height);
} }
border_width = gtk_container_get_border_width (GTK_CONTAINER (fixed)); for (children = priv->children; children; children = children->next)
children = priv->children;
while (children)
{ {
child = children->data; child = children->data;
children = children->next;
if (gtk_widget_get_visible (child->widget)) if (!gtk_widget_get_visible (child->widget))
{ continue;
gtk_widget_get_preferred_size (child->widget,
&child_requisition, NULL);
child_allocation.x = child->x + border_width;
child_allocation.y = child->y + border_width;
if (!gtk_widget_get_has_window (widget)) gtk_widget_get_preferred_size (child->widget, &child_requisition, NULL);
{ child_allocation.x = child->x;
child_allocation.x += allocation->x; child_allocation.y = child->y;
child_allocation.y += allocation->y;
}
child_allocation.width = child_requisition.width; if (!gtk_widget_get_has_window (widget))
child_allocation.height = child_requisition.height; {
gtk_widget_size_allocate (child->widget, &child_allocation); child_allocation.x += allocation->x;
} child_allocation.y += allocation->y;
}
child_allocation.width = child_requisition.width;
child_allocation.height = child_requisition.height;
gtk_widget_size_allocate (child->widget, &child_allocation);
} }
} }
static void static void
gtk_fixed_add (GtkContainer *container, gtk_fixed_add (GtkContainer *container,
GtkWidget *widget) GtkWidget *widget)
{ {
gtk_fixed_put (GTK_FIXED (container), widget, 0, 0); gtk_fixed_put (GTK_FIXED (container), widget, 0, 0);
} }
static void static void
gtk_fixed_remove (GtkContainer *container, gtk_fixed_remove (GtkContainer *container,
GtkWidget *widget) GtkWidget *widget)
{ {
GtkFixed *fixed = GTK_FIXED (container); GtkFixed *fixed = GTK_FIXED (container);
GtkFixedPrivate *priv = fixed->priv; GtkFixedPrivate *priv = fixed->priv;
@ -436,26 +433,25 @@ gtk_fixed_remove (GtkContainer *container,
GtkWidget *widget_container = GTK_WIDGET (container); GtkWidget *widget_container = GTK_WIDGET (container);
GList *children; GList *children;
children = priv->children; for (children = priv->children; children; children = children->next)
while (children)
{ {
child = children->data; child = children->data;
if (child->widget == widget) if (child->widget == widget)
{ {
gboolean was_visible = gtk_widget_get_visible (widget); gboolean was_visible = gtk_widget_get_visible (widget);
gtk_widget_unparent (widget); gtk_widget_unparent (widget);
priv->children = g_list_remove_link (priv->children, children); priv->children = g_list_remove_link (priv->children, children);
g_list_free (children); g_list_free (children);
g_free (child); g_free (child);
if (was_visible && gtk_widget_get_visible (widget_container)) if (was_visible && gtk_widget_get_visible (widget_container))
gtk_widget_queue_resize (widget_container); gtk_widget_queue_resize (widget_container);
break; break;
} }
children = children->next; children = children->next;
} }
@ -463,20 +459,18 @@ gtk_fixed_remove (GtkContainer *container,
static void static void
gtk_fixed_forall (GtkContainer *container, gtk_fixed_forall (GtkContainer *container,
gboolean include_internals, gboolean include_internals,
GtkCallback callback, GtkCallback callback,
gpointer callback_data) gpointer callback_data)
{ {
GtkFixed *fixed = GTK_FIXED (container); GtkFixed *fixed = GTK_FIXED (container);
GtkFixedPrivate *priv = fixed->priv; GtkFixedPrivate *priv = fixed->priv;
GtkFixedChild *child; GtkFixedChild *child;
GList *children; GList *children;
children = priv->children; for (children = priv->children; children; children = children->next)
while (children)
{ {
child = children->data; child = children->data;
children = children->next;
(* callback) (child->widget, callback_data); (* callback) (child->widget, callback_data);
} }

View File

@ -140,6 +140,12 @@ static void gtk_handle_box_style_set (GtkWidget *widget,
GtkStyle *previous_style); GtkStyle *previous_style);
static void gtk_handle_box_size_request (GtkWidget *widget, static void gtk_handle_box_size_request (GtkWidget *widget,
GtkRequisition *requisition); GtkRequisition *requisition);
static void gtk_handle_box_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_handle_box_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_handle_box_size_allocate (GtkWidget *widget, static void gtk_handle_box_size_allocate (GtkWidget *widget,
GtkAllocation *real_allocation); GtkAllocation *real_allocation);
static void gtk_handle_box_add (GtkContainer *container, static void gtk_handle_box_add (GtkContainer *container,
@ -224,7 +230,8 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class)
widget_class->realize = gtk_handle_box_realize; widget_class->realize = gtk_handle_box_realize;
widget_class->unrealize = gtk_handle_box_unrealize; widget_class->unrealize = gtk_handle_box_unrealize;
widget_class->style_set = gtk_handle_box_style_set; widget_class->style_set = gtk_handle_box_style_set;
widget_class->size_request = gtk_handle_box_size_request; widget_class->get_preferred_width = gtk_handle_box_get_preferred_width;
widget_class->get_preferred_height = gtk_handle_box_get_preferred_height;
widget_class->size_allocate = gtk_handle_box_size_allocate; widget_class->size_allocate = gtk_handle_box_size_allocate;
widget_class->draw = gtk_handle_box_draw; widget_class->draw = gtk_handle_box_draw;
widget_class->button_press_event = gtk_handle_box_button_press; widget_class->button_press_event = gtk_handle_box_button_press;
@ -623,6 +630,31 @@ gtk_handle_box_size_request (GtkWidget *widget,
} }
} }
static void
gtk_handle_box_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_handle_box_size_request (widget, &requisition);
*minimum = *natural = requisition.width;
}
static void
gtk_handle_box_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_handle_box_size_request (widget, &requisition);
*minimum = *natural = requisition.height;
}
static void static void
gtk_handle_box_size_allocate (GtkWidget *widget, gtk_handle_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation) GtkAllocation *allocation)

File diff suppressed because it is too large Load Diff

View File

@ -272,8 +272,12 @@ static void gtk_icon_view_style_set (GtkWidget
GtkStyle *previous_style); GtkStyle *previous_style);
static void gtk_icon_view_state_changed (GtkWidget *widget, static void gtk_icon_view_state_changed (GtkWidget *widget,
GtkStateType previous_state); GtkStateType previous_state);
static void gtk_icon_view_size_request (GtkWidget *widget, static void gtk_icon_view_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_icon_view_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_icon_view_size_allocate (GtkWidget *widget, static void gtk_icon_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static gboolean gtk_icon_view_draw (GtkWidget *widget, static gboolean gtk_icon_view_draw (GtkWidget *widget,
@ -531,7 +535,8 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
widget_class->unrealize = gtk_icon_view_unrealize; widget_class->unrealize = gtk_icon_view_unrealize;
widget_class->style_set = gtk_icon_view_style_set; widget_class->style_set = gtk_icon_view_style_set;
widget_class->get_accessible = gtk_icon_view_get_accessible; widget_class->get_accessible = gtk_icon_view_get_accessible;
widget_class->size_request = gtk_icon_view_size_request; widget_class->get_preferred_width = gtk_icon_view_get_preferred_width;
widget_class->get_preferred_height = gtk_icon_view_get_preferred_height;
widget_class->size_allocate = gtk_icon_view_size_allocate; widget_class->size_allocate = gtk_icon_view_size_allocate;
widget_class->draw = gtk_icon_view_draw; widget_class->draw = gtk_icon_view_draw;
widget_class->motion_notify_event = gtk_icon_view_motion; widget_class->motion_notify_event = gtk_icon_view_motion;
@ -1458,28 +1463,19 @@ gtk_icon_view_style_set (GtkWidget *widget,
} }
static void static void
gtk_icon_view_size_request (GtkWidget *widget, gtk_icon_view_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkIconView *icon_view = GTK_ICON_VIEW (widget); *minimum = *natural = GTK_ICON_VIEW (widget)->priv->width;
GList *tmp_list; }
requisition->width = icon_view->priv->width; static void
requisition->height = icon_view->priv->height; gtk_icon_view_get_preferred_height (GtkWidget *widget,
gint *minimum,
tmp_list = icon_view->priv->children; gint *natural)
{
while (tmp_list) *minimum = *natural = GTK_ICON_VIEW (widget)->priv->height;
{
GtkIconViewChild *child = tmp_list->data;
GtkRequisition child_requisition;
tmp_list = tmp_list->next;
if (gtk_widget_get_visible (child->widget))
gtk_widget_get_preferred_size (child->widget,
&child_requisition, NULL);
}
} }
static void static void

View File

@ -155,34 +155,39 @@ struct _GtkImagePrivate
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_BUTTON #define DEFAULT_ICON_SIZE GTK_ICON_SIZE_BUTTON
static gint gtk_image_draw (GtkWidget *widget, static gint gtk_image_draw (GtkWidget *widget,
cairo_t *cr); cairo_t *cr);
static void gtk_image_unmap (GtkWidget *widget); static void gtk_image_unmap (GtkWidget *widget);
static void gtk_image_unrealize (GtkWidget *widget); static void gtk_image_unrealize (GtkWidget *widget);
static void gtk_image_size_request (GtkWidget *widget, static void gtk_image_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
static void gtk_image_style_set (GtkWidget *widget, gint *natural);
GtkStyle *prev_style); static void gtk_image_get_preferred_height (GtkWidget *widget,
static void gtk_image_screen_changed (GtkWidget *widget, gint *minimum,
GdkScreen *prev_screen); gint *natural);
static void gtk_image_destroy (GtkWidget *widget);
static void gtk_image_reset (GtkImage *image);
static void gtk_image_calc_size (GtkImage *image);
static void gtk_image_update_size (GtkImage *image, static void gtk_image_style_set (GtkWidget *widget,
gint image_width, GtkStyle *prev_style);
gint image_height); static void gtk_image_screen_changed (GtkWidget *widget,
GdkScreen *prev_screen);
static void gtk_image_destroy (GtkWidget *widget);
static void gtk_image_reset (GtkImage *image);
static void gtk_image_calc_size (GtkImage *image);
static void gtk_image_set_property (GObject *object, static void gtk_image_update_size (GtkImage *image,
guint prop_id, gint image_width,
const GValue *value, gint image_height);
GParamSpec *pspec);
static void gtk_image_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void icon_theme_changed (GtkImage *image); static void gtk_image_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_image_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void icon_theme_changed (GtkImage *image);
enum enum
{ {
@ -215,7 +220,8 @@ gtk_image_class_init (GtkImageClass *class)
widget_class = GTK_WIDGET_CLASS (class); widget_class = GTK_WIDGET_CLASS (class);
widget_class->draw = gtk_image_draw; widget_class->draw = gtk_image_draw;
widget_class->destroy = gtk_image_destroy; widget_class->destroy = gtk_image_destroy;
widget_class->size_request = gtk_image_size_request; widget_class->get_preferred_width = gtk_image_get_preferred_width;
widget_class->get_preferred_height = gtk_image_get_preferred_height;
widget_class->unmap = gtk_image_unmap; widget_class->unmap = gtk_image_unmap;
widget_class->unrealize = gtk_image_unrealize; widget_class->unrealize = gtk_image_unrealize;
widget_class->style_set = gtk_image_style_set; widget_class->style_set = gtk_image_style_set;
@ -1928,8 +1934,9 @@ gtk_image_calc_size (GtkImage *image)
} }
static void static void
gtk_image_size_request (GtkWidget *widget, gtk_image_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkImage *image; GtkImage *image;
GtkImagePrivate *priv; GtkImagePrivate *priv;
@ -1939,8 +1946,23 @@ gtk_image_size_request (GtkWidget *widget,
gtk_image_calc_size (image); gtk_image_calc_size (image);
requisition->width = priv->required_width; *minimum = *natural = priv->required_width;
requisition->height = priv->required_height; }
static void
gtk_image_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkImage *image;
GtkImagePrivate *priv;
image = GTK_IMAGE (widget);
priv = image->priv;
gtk_image_calc_size (image);
*minimum = *natural = priv->required_height;
} }
static void static void

View File

@ -62,8 +62,16 @@ enum {
static GtkActivatableIface *parent_activatable_iface; static GtkActivatableIface *parent_activatable_iface;
static void gtk_image_menu_item_destroy (GtkWidget *widget); static void gtk_image_menu_item_destroy (GtkWidget *widget);
static void gtk_image_menu_item_size_request (GtkWidget *widget, static void gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_image_menu_item_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_image_menu_item_get_preferred_height_for_width (GtkWidget *widget,
gint width,
gint *minimum,
gint *natural);
static void gtk_image_menu_item_size_allocate (GtkWidget *widget, static void gtk_image_menu_item_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_image_menu_item_map (GtkWidget *widget); static void gtk_image_menu_item_map (GtkWidget *widget);
@ -117,7 +125,9 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
widget_class->destroy = gtk_image_menu_item_destroy; widget_class->destroy = gtk_image_menu_item_destroy;
widget_class->screen_changed = gtk_image_menu_item_screen_changed; widget_class->screen_changed = gtk_image_menu_item_screen_changed;
widget_class->size_request = gtk_image_menu_item_size_request; widget_class->get_preferred_width = gtk_image_menu_item_get_preferred_width;
widget_class->get_preferred_height = gtk_image_menu_item_get_preferred_height;
widget_class->get_preferred_height_for_width = gtk_image_menu_item_get_preferred_height_for_width;
widget_class->size_allocate = gtk_image_menu_item_size_allocate; widget_class->size_allocate = gtk_image_menu_item_size_allocate;
widget_class->map = gtk_image_menu_item_map; widget_class->map = gtk_image_menu_item_map;
@ -411,13 +421,13 @@ gtk_image_menu_item_get_label (GtkMenuItem *menu_item)
} }
static void static void
gtk_image_menu_item_size_request (GtkWidget *widget, gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget); GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
GtkImageMenuItemPrivate *priv = image_menu_item->priv; GtkImageMenuItemPrivate *priv = image_menu_item->priv;
gint child_width = 0; gint child_width = 0;
gint child_height = 0;
GtkPackDirection pack_dir; GtkPackDirection pack_dir;
GtkWidget *parent; GtkWidget *parent;
@ -435,26 +445,92 @@ gtk_image_menu_item_size_request (GtkWidget *widget,
gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL); gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
child_width = child_requisition.width; child_width = child_requisition.width;
}
GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->get_preferred_width (widget, minimum, natural);
if (pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT)
{
*minimum = MAX (*minimum, child_width);
*natural = MAX (*natural, child_width);
}
}
static void
gtk_image_menu_item_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
gint child_height = 0;
GtkPackDirection pack_dir;
GtkWidget *parent;
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU_BAR (parent))
pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
else
pack_dir = GTK_PACK_DIRECTION_LTR;
if (priv->image && gtk_widget_get_visible (priv->image))
{
GtkRequisition child_requisition;
gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
child_height = child_requisition.height; child_height = child_requisition.height;
} }
GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->size_request (widget, requisition); GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->get_preferred_height (widget, minimum, natural);
/* not done with height since that happens via the if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR)
* toggle_size_request {
*/ *minimum = MAX (*minimum, child_height);
if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) *natural = MAX (*natural, child_height);
requisition->height = MAX (requisition->height, child_height); }
else
requisition->width = MAX (requisition->width, child_width);
/* Note that GtkMenuShell always size requests before
* toggle_size_request, so toggle_size_request will be able to use
* priv->image->requisition
*/
} }
static void
gtk_image_menu_item_get_preferred_height_for_width (GtkWidget *widget,
gint width,
gint *minimum,
gint *natural)
{
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
gint child_height = 0;
GtkPackDirection pack_dir;
GtkWidget *parent;
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU_BAR (parent))
pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
else
pack_dir = GTK_PACK_DIRECTION_LTR;
if (priv->image && gtk_widget_get_visible (priv->image))
{
GtkRequisition child_requisition;
gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
child_height = child_requisition.height;
}
GTK_WIDGET_CLASS
(gtk_image_menu_item_parent_class)->get_preferred_height_for_width (widget, width, minimum, natural);
if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR)
{
*minimum = MAX (*minimum, child_height);
*natural = MAX (*natural, child_height);
}
}
static void static void
gtk_image_menu_item_size_allocate (GtkWidget *widget, gtk_image_menu_item_size_allocate (GtkWidget *widget,
GtkAllocation *allocation) GtkAllocation *allocation)

View File

@ -105,8 +105,12 @@ static void gtk_layout_finalize (GObject *object);
static void gtk_layout_realize (GtkWidget *widget); static void gtk_layout_realize (GtkWidget *widget);
static void gtk_layout_unrealize (GtkWidget *widget); static void gtk_layout_unrealize (GtkWidget *widget);
static void gtk_layout_map (GtkWidget *widget); static void gtk_layout_map (GtkWidget *widget);
static void gtk_layout_size_request (GtkWidget *widget, static void gtk_layout_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_layout_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_layout_size_allocate (GtkWidget *widget, static void gtk_layout_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static gint gtk_layout_draw (GtkWidget *widget, static gint gtk_layout_draw (GtkWidget *widget,
@ -651,7 +655,8 @@ gtk_layout_class_init (GtkLayoutClass *class)
widget_class->realize = gtk_layout_realize; widget_class->realize = gtk_layout_realize;
widget_class->unrealize = gtk_layout_unrealize; widget_class->unrealize = gtk_layout_unrealize;
widget_class->map = gtk_layout_map; widget_class->map = gtk_layout_map;
widget_class->size_request = gtk_layout_size_request; widget_class->get_preferred_width = gtk_layout_get_preferred_width;
widget_class->get_preferred_height = gtk_layout_get_preferred_height;
widget_class->size_allocate = gtk_layout_size_allocate; widget_class->size_allocate = gtk_layout_size_allocate;
widget_class->draw = gtk_layout_draw; widget_class->draw = gtk_layout_draw;
widget_class->style_set = gtk_layout_style_set; widget_class->style_set = gtk_layout_style_set;
@ -933,11 +938,19 @@ gtk_layout_unrealize (GtkWidget *widget)
} }
static void static void
gtk_layout_size_request (GtkWidget *widget, gtk_layout_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
requisition->width = 0; *minimum = *natural = 0;
requisition->height = 0; }
static void
gtk_layout_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
*minimum = *natural = 0;
} }
static void static void

View File

@ -68,6 +68,12 @@ static void gtk_menu_bar_get_property (GObject *object,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_menu_bar_size_request (GtkWidget *widget, static void gtk_menu_bar_size_request (GtkWidget *widget,
GtkRequisition *requisition); GtkRequisition *requisition);
static void gtk_menu_bar_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_menu_bar_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_menu_bar_size_allocate (GtkWidget *widget, static void gtk_menu_bar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static gint gtk_menu_bar_draw (GtkWidget *widget, static gint gtk_menu_bar_draw (GtkWidget *widget,
@ -98,7 +104,8 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
gobject_class->get_property = gtk_menu_bar_get_property; gobject_class->get_property = gtk_menu_bar_get_property;
gobject_class->set_property = gtk_menu_bar_set_property; gobject_class->set_property = gtk_menu_bar_set_property;
widget_class->size_request = gtk_menu_bar_size_request; widget_class->get_preferred_width = gtk_menu_bar_get_preferred_width;
widget_class->get_preferred_height = gtk_menu_bar_get_preferred_height;
widget_class->size_allocate = gtk_menu_bar_size_allocate; widget_class->size_allocate = gtk_menu_bar_size_allocate;
widget_class->draw = gtk_menu_bar_draw; widget_class->draw = gtk_menu_bar_draw;
widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed; widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
@ -347,6 +354,30 @@ gtk_menu_bar_size_request (GtkWidget *widget,
} }
} }
static void
gtk_menu_bar_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_menu_bar_size_request (widget, &requisition);
*minimum = *natural = requisition.width;
}
static void
gtk_menu_bar_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_menu_bar_size_request (widget, &requisition);
*minimum = *natural = requisition.height;
}
static void static void
gtk_menu_bar_size_allocate (GtkWidget *widget, gtk_menu_bar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation) GtkAllocation *allocation)

View File

@ -333,6 +333,12 @@ static void gtk_notebook_realize (GtkWidget *widget);
static void gtk_notebook_unrealize (GtkWidget *widget); static void gtk_notebook_unrealize (GtkWidget *widget);
static void gtk_notebook_size_request (GtkWidget *widget, static void gtk_notebook_size_request (GtkWidget *widget,
GtkRequisition *requisition); GtkRequisition *requisition);
static void gtk_notebook_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_notebook_get_preferred_height(GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_notebook_size_allocate (GtkWidget *widget, static void gtk_notebook_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static gint gtk_notebook_draw (GtkWidget *widget, static gint gtk_notebook_draw (GtkWidget *widget,
@ -635,7 +641,8 @@ gtk_notebook_class_init (GtkNotebookClass *class)
widget_class->unmap = gtk_notebook_unmap; widget_class->unmap = gtk_notebook_unmap;
widget_class->realize = gtk_notebook_realize; widget_class->realize = gtk_notebook_realize;
widget_class->unrealize = gtk_notebook_unrealize; widget_class->unrealize = gtk_notebook_unrealize;
widget_class->size_request = gtk_notebook_size_request; widget_class->get_preferred_width = gtk_notebook_get_preferred_width;
widget_class->get_preferred_height = gtk_notebook_get_preferred_height;
widget_class->size_allocate = gtk_notebook_size_allocate; widget_class->size_allocate = gtk_notebook_size_allocate;
widget_class->draw = gtk_notebook_draw; widget_class->draw = gtk_notebook_draw;
widget_class->button_press_event = gtk_notebook_button_press; widget_class->button_press_event = gtk_notebook_button_press;
@ -2209,6 +2216,31 @@ gtk_notebook_size_request (GtkWidget *widget,
} }
} }
static void
gtk_notebook_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_notebook_size_request (widget, &requisition);
*minimum = *natural = requisition.width;
}
static void
gtk_notebook_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_notebook_size_request (widget, &requisition);
*minimum = *natural = requisition.height;
}
static void static void
gtk_notebook_size_allocate (GtkWidget *widget, gtk_notebook_size_allocate (GtkWidget *widget,
GtkAllocation *allocation) GtkAllocation *allocation)

View File

@ -51,38 +51,71 @@
G_DEFINE_TYPE (GtkOffscreenWindow, gtk_offscreen_window, GTK_TYPE_WINDOW); G_DEFINE_TYPE (GtkOffscreenWindow, gtk_offscreen_window, GTK_TYPE_WINDOW);
static void static void
gtk_offscreen_window_size_request (GtkWidget *widget, gtk_offscreen_window_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkBin *bin = GTK_BIN (widget); GtkBin *bin = GTK_BIN (widget);
GtkWidget *child; GtkWidget *child;
gint border_width; gint border_width;
gint default_width, default_height; gint default_width;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
requisition->width = border_width * 2; *minimum = border_width * 2;
requisition->height = border_width * 2; *natural = border_width * 2;
child = gtk_bin_get_child (bin); child = gtk_bin_get_child (bin);
if (child != NULL && gtk_widget_get_visible (child)) if (child != NULL && gtk_widget_get_visible (child))
{ {
GtkRequisition child_req; gint child_min, child_nat;
gtk_widget_get_preferred_size (child, &child_req, NULL); gtk_widget_get_preferred_width (child, &child_min, &child_nat);
requisition->width += child_req.width; *minimum += child_min;
requisition->height += child_req.height; *natural += child_nat;
} }
gtk_window_get_default_size (GTK_WINDOW (widget), gtk_window_get_default_size (GTK_WINDOW (widget),
&default_width, &default_height); &default_width, NULL);
if (default_width > 0)
requisition->width = default_width;
if (default_height > 0) *minimum = MAX (*minimum, default_width);
requisition->height = default_height; *natural = MAX (*natural, default_width);
}
static void
gtk_offscreen_window_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkBin *bin = GTK_BIN (widget);
GtkWidget *child;
gint border_width;
gint default_height;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
*minimum = border_width * 2;
*natural = border_width * 2;
child = gtk_bin_get_child (bin);
if (child != NULL && gtk_widget_get_visible (child))
{
gint child_min, child_nat;
gtk_widget_get_preferred_height (child, &child_min, &child_nat);
*minimum += child_min;
*natural += child_nat;
}
gtk_window_get_default_size (GTK_WINDOW (widget),
NULL, &default_height);
*minimum = MAX (*minimum, default_height);
*natural = MAX (*natural, default_height);
} }
static void static void
@ -238,7 +271,8 @@ gtk_offscreen_window_class_init (GtkOffscreenWindowClass *class)
widget_class->realize = gtk_offscreen_window_realize; widget_class->realize = gtk_offscreen_window_realize;
widget_class->show = gtk_offscreen_window_show; widget_class->show = gtk_offscreen_window_show;
widget_class->hide = gtk_offscreen_window_hide; widget_class->hide = gtk_offscreen_window_hide;
widget_class->size_request = gtk_offscreen_window_size_request; widget_class->get_preferred_width = gtk_offscreen_window_get_preferred_width;
widget_class->get_preferred_height = gtk_offscreen_window_get_preferred_height;
widget_class->size_allocate = gtk_offscreen_window_size_allocate; widget_class->size_allocate = gtk_offscreen_window_size_allocate;
container_class->check_resize = gtk_offscreen_window_check_resize; container_class->check_resize = gtk_offscreen_window_check_resize;

View File

@ -119,8 +119,13 @@ static void gtk_paned_get_child_property (GtkContainer *container,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_paned_finalize (GObject *object); static void gtk_paned_finalize (GObject *object);
static void gtk_paned_size_request (GtkWidget *widget, static void gtk_paned_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_paned_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_paned_size_allocate (GtkWidget *widget, static void gtk_paned_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_paned_realize (GtkWidget *widget); static void gtk_paned_realize (GtkWidget *widget);
@ -228,7 +233,8 @@ gtk_paned_class_init (GtkPanedClass *class)
object_class->get_property = gtk_paned_get_property; object_class->get_property = gtk_paned_get_property;
object_class->finalize = gtk_paned_finalize; object_class->finalize = gtk_paned_finalize;
widget_class->size_request = gtk_paned_size_request; widget_class->get_preferred_width = gtk_paned_get_preferred_width;
widget_class->get_preferred_height = gtk_paned_get_preferred_height;
widget_class->size_allocate = gtk_paned_size_allocate; widget_class->size_allocate = gtk_paned_size_allocate;
widget_class->realize = gtk_paned_realize; widget_class->realize = gtk_paned_realize;
widget_class->unrealize = gtk_paned_unrealize; widget_class->unrealize = gtk_paned_unrealize;
@ -792,41 +798,44 @@ gtk_paned_finalize (GObject *object)
} }
static void static void
gtk_paned_size_request (GtkWidget *widget, gtk_paned_get_preferred_size (GtkWidget *widget,
GtkRequisition *requisition) GtkOrientation orientation,
gint *minimum,
gint *natural)
{ {
GtkPaned *paned = GTK_PANED (widget); GtkPaned *paned = GTK_PANED (widget);
GtkPanedPrivate *priv = paned->priv; GtkPanedPrivate *priv = paned->priv;
GtkRequisition child_requisition; gint child_min, child_nat;
requisition->width = 0; *minimum = *natural = 0;
requisition->height = 0;
if (priv->child1 && gtk_widget_get_visible (priv->child1)) if (priv->child1 && gtk_widget_get_visible (priv->child1))
{ {
gtk_widget_get_preferred_size (priv->child1, if (orientation == GTK_ORIENTATION_HORIZONTAL)
&child_requisition, NULL); gtk_widget_get_preferred_width (priv->child1, &child_min, &child_nat);
else
gtk_widget_get_preferred_height (priv->child1, &child_min, &child_nat);
requisition->height = child_requisition.height; *minimum = child_min;
requisition->width = child_requisition.width; *natural = child_nat;
} }
if (priv->child2 && gtk_widget_get_visible (priv->child2)) if (priv->child2 && gtk_widget_get_visible (priv->child2))
{ {
gtk_widget_get_preferred_size (priv->child2, if (orientation == GTK_ORIENTATION_HORIZONTAL)
&child_requisition, NULL); gtk_widget_get_preferred_width (priv->child2, &child_min, &child_nat);
else
gtk_widget_get_preferred_height (priv->child2, &child_min, &child_nat);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) if (priv->orientation == orientation)
{ {
requisition->height = MAX (requisition->height, *minimum += child_min;
child_requisition.height); *natural += child_nat;
requisition->width += child_requisition.width;
} }
else else
{ {
requisition->width = MAX (requisition->width, *minimum = MAX (*minimum, child_min);
child_requisition.width); *natural = MAX (*natural, child_nat);
requisition->height += child_requisition.height;
} }
} }
@ -837,13 +846,30 @@ gtk_paned_size_request (GtkWidget *widget,
gtk_widget_style_get (widget, "handle-size", &handle_size, NULL); gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) if (priv->orientation == orientation)
requisition->width += handle_size; {
else *minimum += handle_size;
requisition->height += handle_size; *natural += handle_size;
}
} }
} }
static void
gtk_paned_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
gtk_paned_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum, natural);
}
static void
gtk_paned_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
gtk_paned_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum, natural);
}
static void static void
flip_child (GtkWidget *widget, flip_child (GtkWidget *widget,
GtkAllocation *child_pos) GtkAllocation *child_pos)

View File

@ -85,8 +85,12 @@ static void gtk_path_bar_finalize (GObject *object);
static void gtk_path_bar_dispose (GObject *object); static void gtk_path_bar_dispose (GObject *object);
static void gtk_path_bar_realize (GtkWidget *widget); static void gtk_path_bar_realize (GtkWidget *widget);
static void gtk_path_bar_unrealize (GtkWidget *widget); static void gtk_path_bar_unrealize (GtkWidget *widget);
static void gtk_path_bar_size_request (GtkWidget *widget, static void gtk_path_bar_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_path_bar_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_path_bar_map (GtkWidget *widget); static void gtk_path_bar_map (GtkWidget *widget);
static void gtk_path_bar_unmap (GtkWidget *widget); static void gtk_path_bar_unmap (GtkWidget *widget);
static void gtk_path_bar_size_allocate (GtkWidget *widget, static void gtk_path_bar_size_allocate (GtkWidget *widget,
@ -216,7 +220,8 @@ gtk_path_bar_class_init (GtkPathBarClass *path_bar_class)
gobject_class->finalize = gtk_path_bar_finalize; gobject_class->finalize = gtk_path_bar_finalize;
gobject_class->dispose = gtk_path_bar_dispose; gobject_class->dispose = gtk_path_bar_dispose;
widget_class->size_request = gtk_path_bar_size_request; widget_class->get_preferred_width = gtk_path_bar_get_preferred_width;
widget_class->get_preferred_height = gtk_path_bar_get_preferred_height;
widget_class->realize = gtk_path_bar_realize; widget_class->realize = gtk_path_bar_realize;
widget_class->unrealize = gtk_path_bar_unrealize; widget_class->unrealize = gtk_path_bar_unrealize;
widget_class->map = gtk_path_bar_map; widget_class->map = gtk_path_bar_map;
@ -315,46 +320,74 @@ gtk_path_bar_dispose (GObject *object)
* available space. * available space.
*/ */
static void static void
gtk_path_bar_size_request (GtkWidget *widget, gtk_path_bar_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
ButtonData *button_data; ButtonData *button_data;
GtkPathBar *path_bar; GtkPathBar *path_bar;
GtkRequisition child_requisition;
GList *list; GList *list;
gint child_height;
gint height;
gint child_min, child_nat;
path_bar = GTK_PATH_BAR (widget); path_bar = GTK_PATH_BAR (widget);
requisition->width = 0; *minimum = *natural = 0;
requisition->height = 0; height = 0;
for (list = path_bar->button_list; list; list = list->next) for (list = path_bar->button_list; list; list = list->next)
{ {
button_data = BUTTON_DATA (list->data); button_data = BUTTON_DATA (list->data);
gtk_widget_get_preferred_size (button_data->button, gtk_widget_get_preferred_width (button_data->button, &child_min, &child_nat);
&child_requisition, NULL); gtk_widget_get_preferred_height (button_data->button, &child_height, NULL);
height = MAX (height, child_height);
if (button_data->type == NORMAL_BUTTON) if (button_data->type == NORMAL_BUTTON)
/* Use 2*Height as button width because of ellipsized label. */ {
requisition->width = MAX (child_requisition.height * 2, requisition->width); /* Use 2*Height as button width because of ellipsized label. */
else child_min = MAX (child_min, child_height * 2);
requisition->width = MAX (child_requisition.width, requisition->width); child_nat = MAX (child_min, child_height * 2);
}
requisition->height = MAX (child_requisition.height, requisition->height); *minimum = MAX (*minimum, child_min);
*natural = MAX (*natural, child_nat);
} }
/* Add space for slider, if we have more than one path */ /* Add space for slider, if we have more than one path */
/* Theoretically, the slider could be bigger than the other button. But we're /* Theoretically, the slider could be bigger than the other button. But we're
* not going to worry about that now. * not going to worry about that now.
*/ */
path_bar->slider_width = MIN(requisition->height * 2 / 3 + 5, requisition->height); path_bar->slider_width = MIN (height * 2 / 3 + 5, height);
if (path_bar->button_list && path_bar->button_list->next != NULL) if (path_bar->button_list && path_bar->button_list->next != NULL)
requisition->width += (path_bar->spacing + path_bar->slider_width) * 2; {
*minimum += (path_bar->spacing + path_bar->slider_width) * 2;
*natural += (path_bar->spacing + path_bar->slider_width) * 2;
}
}
gtk_widget_get_preferred_size (path_bar->up_slider_button, static void
&child_requisition, NULL); gtk_path_bar_get_preferred_height (GtkWidget *widget,
gtk_widget_get_preferred_size (path_bar->down_slider_button, gint *minimum,
&child_requisition, NULL); gint *natural)
{
ButtonData *button_data;
GtkPathBar *path_bar;
GList *list;
gint child_min, child_nat;
path_bar = GTK_PATH_BAR (widget);
*minimum = *natural = 0;
for (list = path_bar->button_list; list; list = list->next)
{
button_data = BUTTON_DATA (list->data);
gtk_widget_get_preferred_height (button_data->button, &child_min, &child_nat);
*minimum = MAX (*minimum, child_min);
*natural = MAX (*natural, child_nat);
}
} }
static void static void
@ -1363,25 +1396,25 @@ get_dir_name (ButtonData *button_data)
* or not the contents are bold * or not the contents are bold
*/ */
static void static void
label_size_request_cb (GtkWidget *widget, set_label_size_request (GtkWidget *alignment,
GtkRequisition *requisition, ButtonData *button_data)
ButtonData *button_data)
{ {
const gchar *dir_name = get_dir_name (button_data); const gchar *dir_name = get_dir_name (button_data);
PangoLayout *layout = gtk_widget_create_pango_layout (button_data->label, dir_name); PangoLayout *layout = gtk_widget_create_pango_layout (button_data->label, dir_name);
gint bold_width, bold_height; gint width, height, bold_width, bold_height;
gchar *markup; gchar *markup;
pango_layout_get_pixel_size (layout, &requisition->width, &requisition->height); pango_layout_get_pixel_size (layout, &width, &height);
markup = g_markup_printf_escaped ("<b>%s</b>", dir_name); markup = g_markup_printf_escaped ("<b>%s</b>", dir_name);
pango_layout_set_markup (layout, markup, -1); pango_layout_set_markup (layout, markup, -1);
g_free (markup); g_free (markup);
pango_layout_get_pixel_size (layout, &bold_width, &bold_height); pango_layout_get_pixel_size (layout, &bold_width, &bold_height);
requisition->width = MAX (requisition->width, bold_width);
requisition->height = MAX (requisition->height, bold_height);
gtk_widget_set_size_request (alignment,
MAX (width, bold_width),
MAX (height, bold_height));
g_object_unref (layout); g_object_unref (layout);
} }
@ -1509,18 +1542,19 @@ make_directory_button (GtkPathBar *path_bar,
button_data->image = NULL; button_data->image = NULL;
} }
/* label_alignment is created because we can't override size-request
* on label itself and still have the contents of the label centered
* properly in the label's requisition
*/
if (label_alignment)
g_signal_connect (label_alignment, "size-request",
G_CALLBACK (label_size_request_cb), button_data);
button_data->dir_name = g_strdup (dir_name); button_data->dir_name = g_strdup (dir_name);
button_data->file = g_object_ref (file); button_data->file = g_object_ref (file);
button_data->file_is_hidden = file_is_hidden; button_data->file_is_hidden = file_is_hidden;
/* FIXME: Maybe we dont need this alignment at all and we can
* use GtkMisc aligments or even GtkWidget:halign/valign center.
*
* The following function ensures that the alignment will always
* request the same size whether the button's text is bold or not.
*/
if (label_alignment)
set_label_size_request (label_alignment, button_data);
gtk_container_add (GTK_CONTAINER (button_data->button), child); gtk_container_add (GTK_CONTAINER (button_data->button), child);
gtk_widget_show_all (button_data->button); gtk_widget_show_all (button_data->button);

View File

@ -74,23 +74,28 @@ enum {
PROP_ELLIPSIZE PROP_ELLIPSIZE
}; };
static void gtk_progress_bar_set_property (GObject *object, static void gtk_progress_bar_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_progress_bar_get_property (GObject *object, static void gtk_progress_bar_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_progress_bar_size_request (GtkWidget *widget, static void gtk_progress_bar_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
static void gtk_progress_bar_real_update (GtkProgressBar *progress); gint *natural);
static gboolean gtk_progress_bar_draw (GtkWidget *widget, static void gtk_progress_bar_get_preferred_height (GtkWidget *widget,
cairo_t *cr); gint *minimum,
static void gtk_progress_bar_act_mode_enter (GtkProgressBar *progress); gint *natural);
static void gtk_progress_bar_finalize (GObject *object);
static void gtk_progress_bar_set_orientation (GtkProgressBar *progress, static void gtk_progress_bar_real_update (GtkProgressBar *progress);
GtkOrientation orientation); static gboolean gtk_progress_bar_draw (GtkWidget *widget,
cairo_t *cr);
static void gtk_progress_bar_act_mode_enter (GtkProgressBar *progress);
static void gtk_progress_bar_finalize (GObject *object);
static void gtk_progress_bar_set_orientation (GtkProgressBar *progress,
GtkOrientation orientation);
G_DEFINE_TYPE_WITH_CODE (GtkProgressBar, gtk_progress_bar, GTK_TYPE_WIDGET, G_DEFINE_TYPE_WITH_CODE (GtkProgressBar, gtk_progress_bar, GTK_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
@ -109,11 +114,10 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
gobject_class->finalize = gtk_progress_bar_finalize; gobject_class->finalize = gtk_progress_bar_finalize;
widget_class->draw = gtk_progress_bar_draw; widget_class->draw = gtk_progress_bar_draw;
widget_class->size_request = gtk_progress_bar_size_request; widget_class->get_preferred_width = gtk_progress_bar_get_preferred_width;
widget_class->get_preferred_height = gtk_progress_bar_get_preferred_height;
g_object_class_override_property (gobject_class, g_object_class_override_property (gobject_class, PROP_ORIENTATION, "orientation");
PROP_ORIENTATION,
"orientation");
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_INVERTED, PROP_INVERTED,
@ -462,8 +466,9 @@ get_current_text (GtkProgressBar *pbar)
} }
static void static void
gtk_progress_bar_size_request (GtkWidget *widget, gtk_progress_bar_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkProgressBar *pbar; GtkProgressBar *pbar;
GtkProgressBarPrivate *priv; GtkProgressBarPrivate *priv;
@ -471,24 +476,21 @@ gtk_progress_bar_size_request (GtkWidget *widget,
gchar *buf; gchar *buf;
PangoRectangle logical_rect; PangoRectangle logical_rect;
PangoLayout *layout; PangoLayout *layout;
gint width, height; gint width;
gint xspacing, yspacing; gint xspacing;
gint min_width, min_height; gint min_width;
g_return_if_fail (GTK_IS_PROGRESS_BAR (widget)); g_return_if_fail (GTK_IS_PROGRESS_BAR (widget));
g_return_if_fail (requisition != NULL);
style = gtk_widget_get_style (widget); style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget, gtk_widget_style_get (widget,
"xspacing", &xspacing, "xspacing", &xspacing,
"yspacing", &yspacing,
NULL); NULL);
pbar = GTK_PROGRESS_BAR (widget); pbar = GTK_PROGRESS_BAR (widget);
priv = pbar->priv; priv = pbar->priv;
width = 2 * style->xthickness + xspacing; width = 2 * style->xthickness + xspacing;
height = 2 * style->ythickness + yspacing;
if (priv->show_text) if (priv->show_text)
{ {
@ -515,6 +517,56 @@ gtk_progress_bar_size_request (GtkWidget *widget,
else else
width += logical_rect.width; width += logical_rect.width;
g_object_unref (layout);
g_free (buf);
}
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
gtk_widget_style_get (widget,
"min-horizontal-bar-width", &min_width,
NULL);
else
gtk_widget_style_get (widget,
"min-vertical-bar-width", &min_width,
NULL);
*minimum = *natural = MAX (min_width, width);
}
static void
gtk_progress_bar_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkProgressBar *pbar;
GtkProgressBarPrivate *priv;
GtkStyle *style;
gchar *buf;
PangoRectangle logical_rect;
PangoLayout *layout;
gint height;
gint yspacing;
gint min_height;
g_return_if_fail (GTK_IS_PROGRESS_BAR (widget));
style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget,
"yspacing", &yspacing,
NULL);
pbar = GTK_PROGRESS_BAR (widget);
priv = pbar->priv;
height = 2 * style->ythickness + yspacing;
if (priv->show_text)
{
buf = get_current_text (pbar);
layout = gtk_widget_create_pango_layout (widget, buf);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
height += logical_rect.height; height += logical_rect.height;
g_object_unref (layout); g_object_unref (layout);
@ -523,17 +575,14 @@ gtk_progress_bar_size_request (GtkWidget *widget,
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
gtk_widget_style_get (widget, gtk_widget_style_get (widget,
"min-horizontal-bar-width", &min_width,
"min-horizontal-bar-height", &min_height, "min-horizontal-bar-height", &min_height,
NULL); NULL);
else else
gtk_widget_style_get (widget, gtk_widget_style_get (widget,
"min-vertical-bar-width", &min_width,
"min-vertical-bar-height", &min_height, "min-vertical-bar-height", &min_height,
NULL); NULL);
requisition->width = MAX (min_width, width); *minimum = *natural = MAX (min_height, height);
requisition->height = MAX (min_height, height);
} }
static void static void

View File

@ -182,8 +182,14 @@ static void gtk_range_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_range_destroy (GtkWidget *widget); static void gtk_range_destroy (GtkWidget *widget);
static void gtk_range_size_request (GtkWidget *widget, static void gtk_range_get_preferred_width
GtkRequisition *requisition); (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_range_get_preferred_height
(GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_range_size_allocate (GtkWidget *widget, static void gtk_range_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_range_hierarchy_changed (GtkWidget *widget, static void gtk_range_hierarchy_changed (GtkWidget *widget,
@ -293,7 +299,8 @@ gtk_range_class_init (GtkRangeClass *class)
gobject_class->get_property = gtk_range_get_property; gobject_class->get_property = gtk_range_get_property;
widget_class->destroy = gtk_range_destroy; widget_class->destroy = gtk_range_destroy;
widget_class->size_request = gtk_range_size_request; widget_class->get_preferred_width = gtk_range_get_preferred_width;
widget_class->get_preferred_height = gtk_range_get_preferred_height;
widget_class->size_allocate = gtk_range_size_allocate; widget_class->size_allocate = gtk_range_size_allocate;
widget_class->hierarchy_changed = gtk_range_hierarchy_changed; widget_class->hierarchy_changed = gtk_range_hierarchy_changed;
widget_class->realize = gtk_range_realize; widget_class->realize = gtk_range_realize;
@ -1550,8 +1557,9 @@ gtk_range_destroy (GtkWidget *widget)
} }
static void static void
gtk_range_size_request (GtkWidget *widget, gtk_range_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkRange *range; GtkRange *range;
gint slider_width, stepper_size, focus_width, trough_border, stepper_spacing; gint slider_width, stepper_size, focus_width, trough_border, stepper_spacing;
@ -1571,8 +1579,33 @@ gtk_range_size_request (GtkWidget *widget,
focus_width, trough_border, stepper_spacing, focus_width, trough_border, stepper_spacing,
&range_rect, &border, NULL, NULL, NULL, NULL); &range_rect, &border, NULL, NULL, NULL, NULL);
requisition->width = range_rect.width + border.left + border.right; *minimum = *natural = range_rect.width + border.left + border.right;
requisition->height = range_rect.height + border.top + border.bottom; }
static void
gtk_range_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRange *range;
gint slider_width, stepper_size, focus_width, trough_border, stepper_spacing;
GdkRectangle range_rect;
GtkBorder border;
range = GTK_RANGE (widget);
gtk_range_get_props (range,
&slider_width, &stepper_size,
&focus_width, &trough_border,
&stepper_spacing, NULL,
NULL, NULL);
gtk_range_calc_request (range,
slider_width, stepper_size,
focus_width, trough_border, stepper_spacing,
&range_rect, &border, NULL, NULL, NULL, NULL);
*minimum = *natural = range_rect.height + border.top + border.bottom;
} }
static gboolean static gboolean

View File

@ -80,8 +80,14 @@ static void gtk_ruler_get_property (GObject *object,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_ruler_realize (GtkWidget *widget); static void gtk_ruler_realize (GtkWidget *widget);
static void gtk_ruler_unrealize (GtkWidget *widget); static void gtk_ruler_unrealize (GtkWidget *widget);
static void gtk_ruler_size_request (GtkWidget *widget, static void gtk_ruler_get_preferred_width
GtkRequisition *requisition); (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_ruler_get_preferred_height
(GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_ruler_size_allocate (GtkWidget *widget, static void gtk_ruler_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static gboolean gtk_ruler_motion_notify (GtkWidget *widget, static gboolean gtk_ruler_motion_notify (GtkWidget *widget,
@ -120,7 +126,8 @@ gtk_ruler_class_init (GtkRulerClass *class)
widget_class->realize = gtk_ruler_realize; widget_class->realize = gtk_ruler_realize;
widget_class->unrealize = gtk_ruler_unrealize; widget_class->unrealize = gtk_ruler_unrealize;
widget_class->size_request = gtk_ruler_size_request; widget_class->get_preferred_width = gtk_ruler_get_preferred_width;
widget_class->get_preferred_height = gtk_ruler_get_preferred_height;
widget_class->size_allocate = gtk_ruler_size_allocate; widget_class->size_allocate = gtk_ruler_size_allocate;
widget_class->motion_notify_event = gtk_ruler_motion_notify; widget_class->motion_notify_event = gtk_ruler_motion_notify;
widget_class->draw = gtk_ruler_draw; widget_class->draw = gtk_ruler_draw;
@ -128,9 +135,7 @@ gtk_ruler_class_init (GtkRulerClass *class)
class->draw_ticks = gtk_ruler_real_draw_ticks; class->draw_ticks = gtk_ruler_real_draw_ticks;
class->draw_pos = gtk_ruler_real_draw_pos; class->draw_pos = gtk_ruler_real_draw_pos;
g_object_class_override_property (gobject_class, g_object_class_override_property (gobject_class, PROP_ORIENTATION, "orientation");
PROP_ORIENTATION,
"orientation");
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_LOWER, PROP_LOWER,
@ -532,25 +537,43 @@ gtk_ruler_unrealize (GtkWidget *widget)
} }
static void static void
gtk_ruler_size_request (GtkWidget *widget, gtk_ruler_get_preferred_size (GtkWidget *widget,
GtkRequisition *requisition) GtkOrientation orientation,
gint *minimum,
gint *natural)
{ {
GtkRuler *ruler = GTK_RULER (widget); GtkRuler *ruler = GTK_RULER (widget);
GtkRulerPrivate *priv = ruler->priv; GtkRulerPrivate *priv = ruler->priv;
GtkStyle *style; GtkStyle *style;
gint thickness;
style = gtk_widget_get_style (widget); style = gtk_widget_get_style (widget);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) if (orientation == GTK_ORIENTATION_HORIZONTAL)
{ thickness = style->xthickness;
requisition->width = style->xthickness * 2 + 1;
requisition->height = style->ythickness * 2 + RULER_WIDTH;
}
else else
{ thickness = style->ythickness;
requisition->width = style->xthickness * 2 + RULER_WIDTH;
requisition->height = style->ythickness * 2 + 1; if (priv->orientation == orientation)
} *minimum = *natural = thickness * 2 + 1;
else
*minimum = *natural = thickness * 2 + RULER_WIDTH;
}
static void
gtk_ruler_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
gtk_ruler_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum, natural);
}
static void
gtk_ruler_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
gtk_ruler_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum, natural);
} }
static void static void

View File

@ -116,8 +116,12 @@ static void gtk_scale_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_scale_size_request (GtkWidget *widget, static void gtk_scale_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_scale_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_scale_style_set (GtkWidget *widget, static void gtk_scale_style_set (GtkWidget *widget,
GtkStyle *previous); GtkStyle *previous);
static void gtk_scale_get_range_border (GtkRange *range, static void gtk_scale_get_range_border (GtkRange *range,
@ -198,7 +202,8 @@ gtk_scale_class_init (GtkScaleClass *class)
widget_class->style_set = gtk_scale_style_set; widget_class->style_set = gtk_scale_style_set;
widget_class->screen_changed = gtk_scale_screen_changed; widget_class->screen_changed = gtk_scale_screen_changed;
widget_class->draw = gtk_scale_draw; widget_class->draw = gtk_scale_draw;
widget_class->size_request = gtk_scale_size_request; widget_class->get_preferred_width = gtk_scale_get_preferred_width;
widget_class->get_preferred_height = gtk_scale_get_preferred_height;
range_class->slider_detail = "Xscale"; range_class->slider_detail = "Xscale";
range_class->get_range_border = gtk_scale_get_range_border; range_class->get_range_border = gtk_scale_get_range_border;
@ -938,32 +943,54 @@ gtk_scale_screen_changed (GtkWidget *widget,
} }
static void static void
gtk_scale_size_request (GtkWidget *widget, gtk_scale_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkRange *range = GTK_RANGE (widget); GTK_WIDGET_CLASS (gtk_scale_parent_class)->get_preferred_width (widget, minimum, natural);
gint n1, w1, h1, n2, w2, h2;
gint slider_length;
GTK_WIDGET_CLASS (gtk_scale_parent_class)->size_request (widget, requisition); if (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == GTK_ORIENTATION_HORIZONTAL)
gtk_widget_style_get (widget, "slider-length", &slider_length, NULL);
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL)
{ {
gint n1, w1, h1, n2, w2, h2;
gint slider_length;
gint w;
gtk_widget_style_get (widget, "slider-length", &slider_length, NULL);
gtk_scale_get_mark_label_size (GTK_SCALE (widget), GTK_POS_TOP, &n1, &w1, &h1, &n2, &w2, &h2); gtk_scale_get_mark_label_size (GTK_SCALE (widget), GTK_POS_TOP, &n1, &w1, &h1, &n2, &w2, &h2);
w1 = (n1 - 1) * w1 + MAX (w1, slider_length); w1 = (n1 - 1) * w1 + MAX (w1, slider_length);
w2 = (n2 - 1) * w2 + MAX (w2, slider_length); w2 = (n2 - 1) * w2 + MAX (w2, slider_length);
requisition->width = MAX (requisition->width, MAX (w1, w2)); w = MAX (w1, w2);
*minimum = MAX (*minimum, w);
*natural = MAX (*natural, w);
} }
else }
static void
gtk_scale_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GTK_WIDGET_CLASS (gtk_scale_parent_class)->get_preferred_height (widget, minimum, natural);
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == GTK_ORIENTATION_VERTICAL)
{ {
gint n1, w1, h1, n2, w2, h2;
gint slider_length;
gint h;
gtk_widget_style_get (widget, "slider-length", &slider_length, NULL);
gtk_scale_get_mark_label_size (GTK_SCALE (widget), GTK_POS_LEFT, &n1, &w1, &h1, &n2, &w2, &h2); gtk_scale_get_mark_label_size (GTK_SCALE (widget), GTK_POS_LEFT, &n1, &w1, &h1, &n2, &w2, &h2);
h1 = (n1 - 1) * h1 + MAX (h1, slider_length); h1 = (n1 - 1) * h1 + MAX (h1, slider_length);
h2 = (n2 - 1) * h1 + MAX (h2, slider_length); h2 = (n2 - 1) * h1 + MAX (h2, slider_length);
requisition->height = MAX (requisition->height, MAX (h1, h2)); h = MAX (h1, h2);
*minimum = MAX (*minimum, h);
*natural = MAX (*natural, h);
} }
} }

View File

@ -61,9 +61,14 @@ static void gtk_separator_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_separator_get_preferred_width
static void gtk_separator_size_request (GtkWidget *widget, (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_separator_get_preferred_height
(GtkWidget *widget,
gint *minimum,
gint *natural);
static gboolean gtk_separator_draw (GtkWidget *widget, static gboolean gtk_separator_draw (GtkWidget *widget,
cairo_t *cr); cairo_t *cr);
@ -82,12 +87,12 @@ gtk_separator_class_init (GtkSeparatorClass *class)
object_class->set_property = gtk_separator_set_property; object_class->set_property = gtk_separator_set_property;
object_class->get_property = gtk_separator_get_property; object_class->get_property = gtk_separator_get_property;
widget_class->size_request = gtk_separator_size_request; widget_class->get_preferred_width = gtk_separator_get_preferred_width;
widget_class->get_preferred_height = gtk_separator_get_preferred_height;
widget_class->draw = gtk_separator_draw; widget_class->draw = gtk_separator_draw;
g_object_class_override_property (object_class, g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation");
PROP_ORIENTATION,
"orientation");
g_type_class_add_private (object_class, sizeof (GtkSeparatorPrivate)); g_type_class_add_private (object_class, sizeof (GtkSeparatorPrivate));
} }
@ -149,42 +154,55 @@ gtk_separator_get_property (GObject *object,
} }
static void static void
gtk_separator_size_request (GtkWidget *widget, gtk_separator_get_preferred_size (GtkWidget *widget,
GtkRequisition *requisition) GtkOrientation orientation,
gint *minimum,
gint *natural)
{ {
GtkSeparator *separator = GTK_SEPARATOR (widget); GtkSeparator *separator = GTK_SEPARATOR (widget);
GtkSeparatorPrivate *private = separator->priv; GtkSeparatorPrivate *private = separator->priv;
GtkStyle *style; GtkStyle *style;
gboolean wide_separators; gboolean wide_sep;
gint separator_width; gint sep_width;
gint separator_height; gint sep_height;
style = gtk_widget_get_style (widget); style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget, gtk_widget_style_get (widget,
"wide-separators", &wide_separators, "wide-separators", &wide_sep,
"separator-width", &separator_width, "separator-width", &sep_width,
"separator-height", &separator_height, "separator-height", &sep_height,
NULL); NULL);
requisition->width = 1; if (orientation == private->orientation)
requisition->height = 1;
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
{ {
if (wide_separators) *minimum = *natural = 1;
requisition->height = separator_height; }
else else if (orientation == GTK_ORIENTATION_VERTICAL)
requisition->height = style->ythickness; {
*minimum = *natural = wide_sep ? sep_height : style->ythickness;
} }
else else
{ {
if (wide_separators) *minimum = *natural = wide_sep ? sep_width : style->xthickness;
requisition->width = separator_width;
else
requisition->width = style->xthickness;
} }
} }
static void
gtk_separator_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
gtk_separator_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum, natural);
}
static void
gtk_separator_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
gtk_separator_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum, natural);
}
static gboolean static gboolean
gtk_separator_draw (GtkWidget *widget, gtk_separator_draw (GtkWidget *widget,
cairo_t *cr) cairo_t *cr)

View File

@ -66,8 +66,12 @@ static void gtk_separator_tool_item_get_property (GObject
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_separator_tool_item_size_request (GtkWidget *widget, static void gtk_separator_tool_item_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_separator_tool_item_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_separator_tool_item_size_allocate (GtkWidget *widget, static void gtk_separator_tool_item_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static gboolean gtk_separator_tool_item_draw (GtkWidget *widget, static gboolean gtk_separator_tool_item_draw (GtkWidget *widget,
@ -118,7 +122,8 @@ gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class)
object_class->set_property = gtk_separator_tool_item_set_property; object_class->set_property = gtk_separator_tool_item_set_property;
object_class->get_property = gtk_separator_tool_item_get_property; object_class->get_property = gtk_separator_tool_item_get_property;
widget_class->size_request = gtk_separator_tool_item_size_request; widget_class->get_preferred_width = gtk_separator_tool_item_get_preferred_width;
widget_class->get_preferred_height = gtk_separator_tool_item_get_preferred_height;
widget_class->size_allocate = gtk_separator_tool_item_size_allocate; widget_class->size_allocate = gtk_separator_tool_item_size_allocate;
widget_class->draw = gtk_separator_tool_item_draw; widget_class->draw = gtk_separator_tool_item_draw;
widget_class->realize = gtk_separator_tool_item_realize; widget_class->realize = gtk_separator_tool_item_realize;
@ -213,22 +218,37 @@ gtk_separator_tool_item_get_property (GObject *object,
} }
static void static void
gtk_separator_tool_item_size_request (GtkWidget *widget, gtk_separator_tool_item_get_preferred_size (GtkWidget *widget,
GtkRequisition *requisition) GtkOrientation orientation,
gint *minimum,
gint *natural)
{ {
GtkToolItem *item = GTK_TOOL_ITEM (widget); if (gtk_tool_item_get_orientation (GTK_TOOL_ITEM (widget)) == orientation)
GtkOrientation orientation = gtk_tool_item_get_orientation (item); *minimum = *natural = get_space_size (GTK_TOOL_ITEM (widget));
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
requisition->width = get_space_size (item);
requisition->height = 1;
}
else else
{ *minimum = *natural = 1;
requisition->height = get_space_size (item); }
requisition->width = 1;
} static void
gtk_separator_tool_item_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
gtk_separator_tool_item_get_preferred_size (widget,
GTK_ORIENTATION_HORIZONTAL,
minimum,
natural);
}
static void
gtk_separator_tool_item_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
gtk_separator_tool_item_get_preferred_size (widget,
GTK_ORIENTATION_VERTICAL,
minimum,
natural);
} }
static void static void

View File

@ -118,8 +118,12 @@ static void gtk_socket_notify (GObject *object,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_socket_realize (GtkWidget *widget); static void gtk_socket_realize (GtkWidget *widget);
static void gtk_socket_unrealize (GtkWidget *widget); static void gtk_socket_unrealize (GtkWidget *widget);
static void gtk_socket_size_request (GtkWidget *widget, static void gtk_socket_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_socket_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_socket_size_allocate (GtkWidget *widget, static void gtk_socket_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_socket_hierarchy_changed (GtkWidget *widget, static void gtk_socket_hierarchy_changed (GtkWidget *widget,
@ -197,7 +201,8 @@ gtk_socket_class_init (GtkSocketClass *class)
widget_class->realize = gtk_socket_realize; widget_class->realize = gtk_socket_realize;
widget_class->unrealize = gtk_socket_unrealize; widget_class->unrealize = gtk_socket_unrealize;
widget_class->size_request = gtk_socket_size_request; widget_class->get_preferred_width = gtk_socket_get_preferred_width;
widget_class->get_preferred_height = gtk_socket_get_preferred_height;
widget_class->size_allocate = gtk_socket_size_allocate; widget_class->size_allocate = gtk_socket_size_allocate;
widget_class->hierarchy_changed = gtk_socket_hierarchy_changed; widget_class->hierarchy_changed = gtk_socket_hierarchy_changed;
widget_class->grab_notify = gtk_socket_grab_notify; widget_class->grab_notify = gtk_socket_grab_notify;
@ -452,30 +457,48 @@ gtk_socket_unrealize (GtkWidget *widget)
} }
static void static void
gtk_socket_size_request (GtkWidget *widget, gtk_socket_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkSocket *socket = GTK_SOCKET (widget); GtkSocket *socket = GTK_SOCKET (widget);
if (socket->plug_widget) if (socket->plug_widget)
{ {
gtk_widget_get_preferred_size (socket->plug_widget, requisition, NULL); gtk_widget_get_preferred_width (socket->plug_widget, minimum, natural);
} }
else else
{ {
if (socket->is_mapped && !socket->have_size && socket->plug_window) if (socket->is_mapped && !socket->have_size && socket->plug_window)
_gtk_socket_windowing_size_request (socket); _gtk_socket_windowing_size_request (socket);
if (socket->is_mapped && socket->have_size) if (socket->is_mapped && socket->have_size)
{ *minimum = *natural = MAX (socket->request_width, 1);
requisition->width = MAX (socket->request_width, 1);
requisition->height = MAX (socket->request_height, 1);
}
else else
{ *minimum = *natural = 1;
requisition->width = 1; }
requisition->height = 1; }
}
static void
gtk_socket_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkSocket *socket = GTK_SOCKET (widget);
if (socket->plug_widget)
{
gtk_widget_get_preferred_height (socket->plug_widget, minimum, natural);
}
else
{
if (socket->is_mapped && !socket->have_size && socket->plug_window)
_gtk_socket_windowing_size_request (socket);
if (socket->is_mapped && socket->have_size)
*minimum = *natural = MAX (socket->request_height, 1);
else
*minimum = *natural = 1;
} }
} }

View File

@ -111,8 +111,10 @@ static void gtk_spin_button_map (GtkWidget *widget);
static void gtk_spin_button_unmap (GtkWidget *widget); static void gtk_spin_button_unmap (GtkWidget *widget);
static void gtk_spin_button_realize (GtkWidget *widget); static void gtk_spin_button_realize (GtkWidget *widget);
static void gtk_spin_button_unrealize (GtkWidget *widget); static void gtk_spin_button_unrealize (GtkWidget *widget);
static void gtk_spin_button_size_request (GtkWidget *widget, static void gtk_spin_button_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_spin_button_size_allocate (GtkWidget *widget, static void gtk_spin_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static gint gtk_spin_button_draw (GtkWidget *widget, static gint gtk_spin_button_draw (GtkWidget *widget,
@ -200,7 +202,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
widget_class->unmap = gtk_spin_button_unmap; widget_class->unmap = gtk_spin_button_unmap;
widget_class->realize = gtk_spin_button_realize; widget_class->realize = gtk_spin_button_realize;
widget_class->unrealize = gtk_spin_button_unrealize; widget_class->unrealize = gtk_spin_button_unrealize;
widget_class->size_request = gtk_spin_button_size_request; widget_class->get_preferred_width = gtk_spin_button_get_preferred_width;
widget_class->size_allocate = gtk_spin_button_size_allocate; widget_class->size_allocate = gtk_spin_button_size_allocate;
widget_class->draw = gtk_spin_button_draw; widget_class->draw = gtk_spin_button_draw;
widget_class->scroll_event = gtk_spin_button_scroll; widget_class->scroll_event = gtk_spin_button_scroll;
@ -664,8 +666,9 @@ compute_double_length (double val, int digits)
} }
static void static void
gtk_spin_button_size_request (GtkWidget *widget, gtk_spin_button_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget); GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin_button->priv; GtkSpinButtonPrivate *priv = spin_button->priv;
@ -677,7 +680,7 @@ gtk_spin_button_size_request (GtkWidget *widget,
arrow_size = spin_button_get_arrow_size (spin_button); arrow_size = spin_button_get_arrow_size (spin_button);
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->size_request (widget, requisition); GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->get_preferred_width (widget, minimum, natural);
if (gtk_entry_get_width_chars (entry) < 0) if (gtk_entry_get_width_chars (entry) < 0)
{ {
@ -694,14 +697,14 @@ gtk_spin_button_size_request (GtkWidget *widget,
GtkBorder inner_border; GtkBorder inner_border;
gtk_widget_style_get (widget, gtk_widget_style_get (widget,
"interior-focus", &interior_focus, "interior-focus", &interior_focus,
"focus-line-width", &focus_width, "focus-line-width", &focus_width,
NULL); NULL);
context = gtk_widget_get_pango_context (widget); context = gtk_widget_get_pango_context (widget);
metrics = pango_context_get_metrics (context, metrics = pango_context_get_metrics (context,
style->font_desc, style->font_desc,
pango_context_get_language (context)); pango_context_get_language (context));
digit_width = pango_font_metrics_get_approximate_digit_width (metrics); digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
digit_width = PANGO_SCALE * digit_width = PANGO_SCALE *
@ -710,7 +713,6 @@ gtk_spin_button_size_request (GtkWidget *widget,
pango_font_metrics_unref (metrics); pango_font_metrics_unref (metrics);
/* Get max of MIN_SPIN_BUTTON_WIDTH, size of upper, size of lower */ /* Get max of MIN_SPIN_BUTTON_WIDTH, size of upper, size of lower */
width = MIN_SPIN_BUTTON_WIDTH; width = MIN_SPIN_BUTTON_WIDTH;
max_string_len = MAX (10, compute_double_length (1e9 * priv->adjustment->step_increment, max_string_len = MAX (10, compute_double_length (1e9 * priv->adjustment->step_increment,
priv->digits)); priv->digits));
@ -718,19 +720,22 @@ gtk_spin_button_size_request (GtkWidget *widget,
string_len = compute_double_length (priv->adjustment->upper, string_len = compute_double_length (priv->adjustment->upper,
priv->digits); priv->digits);
w = PANGO_PIXELS (MIN (string_len, max_string_len) * digit_width); w = PANGO_PIXELS (MIN (string_len, max_string_len) * digit_width);
width = MAX (width, w); *minimum = MAX (*minimum, w);
string_len = compute_double_length (priv->adjustment->lower, *natural = MAX (*natural, w);
priv->digits); string_len = compute_double_length (priv->adjustment->lower, priv->digits);
w = PANGO_PIXELS (MIN (string_len, max_string_len) * digit_width); w = PANGO_PIXELS (MIN (string_len, max_string_len) * digit_width);
width = MAX (width, w); *minimum = MAX (*minimum, w);
*natural = MAX (*natural, w);
_gtk_entry_get_borders (entry, &xborder, &yborder); _gtk_entry_get_borders (entry, &xborder, &yborder);
_gtk_entry_effective_inner_border (entry, &inner_border); _gtk_entry_effective_inner_border (entry, &inner_border);
requisition->width = width + xborder * 2 + inner_border.left + inner_border.right; *minimum += xborder * 2 + inner_border.left + inner_border.right;
*natural += xborder * 2 + inner_border.left + inner_border.right;
} }
requisition->width += arrow_size + 2 * style->xthickness; *minimum += arrow_size + 2 * style->xthickness;
*natural += arrow_size + 2 * style->xthickness;
} }
static void static void

View File

@ -74,8 +74,12 @@ enum
static void gtk_table_finalize (GObject *object); static void gtk_table_finalize (GObject *object);
static void gtk_table_size_request (GtkWidget *widget, static void gtk_table_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_table_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_table_size_allocate (GtkWidget *widget, static void gtk_table_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_table_compute_expand (GtkWidget *widget, static void gtk_table_compute_expand (GtkWidget *widget,
@ -134,7 +138,8 @@ gtk_table_class_init (GtkTableClass *class)
gobject_class->get_property = gtk_table_get_property; gobject_class->get_property = gtk_table_get_property;
gobject_class->set_property = gtk_table_set_property; gobject_class->set_property = gtk_table_set_property;
widget_class->size_request = gtk_table_size_request; widget_class->get_preferred_width = gtk_table_get_preferred_width;
widget_class->get_preferred_height = gtk_table_get_preferred_height;
widget_class->size_allocate = gtk_table_size_allocate; widget_class->size_allocate = gtk_table_size_allocate;
widget_class->compute_expand = gtk_table_compute_expand; widget_class->compute_expand = gtk_table_compute_expand;
@ -969,31 +974,52 @@ gtk_table_finalize (GObject *object)
} }
static void static void
gtk_table_size_request (GtkWidget *widget, gtk_table_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkTable *table = GTK_TABLE (widget); GtkTable *table = GTK_TABLE (widget);
GtkTablePrivate *priv = table->priv; GtkTablePrivate *priv = table->priv;
gint row, col; gint row, col;
requisition->width = 0;
requisition->height = 0;
gtk_table_size_request_init (table); gtk_table_size_request_init (table);
gtk_table_size_request_pass1 (table); gtk_table_size_request_pass1 (table);
gtk_table_size_request_pass2 (table); gtk_table_size_request_pass2 (table);
gtk_table_size_request_pass3 (table); gtk_table_size_request_pass3 (table);
gtk_table_size_request_pass2 (table); gtk_table_size_request_pass2 (table);
for (col = 0; col < priv->ncols; col++) *minimum = 0;
requisition->width += priv->cols[col].requisition;
for (col = 0; col + 1 < priv->ncols; col++)
requisition->width += priv->cols[col].spacing;
for (col = 0; col < priv->ncols; col++)
*minimum += priv->cols[col].requisition;
for (col = 0; col + 1 < priv->ncols; col++)
*minimum += priv->cols[col].spacing;
*natural = *minimum;
}
static void
gtk_table_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkTable *table = GTK_TABLE (widget);
GtkTablePrivate *priv = table->priv;
gint row, col;
gtk_table_size_request_init (table);
gtk_table_size_request_pass1 (table);
gtk_table_size_request_pass2 (table);
gtk_table_size_request_pass3 (table);
gtk_table_size_request_pass2 (table);
*minimum = 0;
for (row = 0; row < priv->nrows; row++) for (row = 0; row < priv->nrows; row++)
requisition->height += priv->rows[row].requisition; *minimum += priv->rows[row].requisition;
for (row = 0; row + 1 < priv->nrows; row++) for (row = 0; row + 1 < priv->nrows; row++)
requisition->height += priv->rows[row].spacing; *minimum += priv->rows[row].spacing;
*natural = *minimum;
} }
static void static void

View File

@ -39,13 +39,17 @@ struct _GtkTearoffMenuItemPrivate
guint torn_off : 1; guint torn_off : 1;
}; };
static void gtk_tearoff_menu_item_size_request (GtkWidget *widget, static void gtk_tearoff_menu_item_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
static gboolean gtk_tearoff_menu_item_draw (GtkWidget *widget, gint *natural);
cairo_t *cr); static void gtk_tearoff_menu_item_get_preferred_height (GtkWidget *widget,
static void gtk_tearoff_menu_item_activate (GtkMenuItem *menu_item); gint *minimum,
static void gtk_tearoff_menu_item_parent_set (GtkWidget *widget, gint *natural);
GtkWidget *previous); static gboolean gtk_tearoff_menu_item_draw (GtkWidget *widget,
cairo_t *cr);
static void gtk_tearoff_menu_item_activate (GtkMenuItem *menu_item);
static void gtk_tearoff_menu_item_parent_set (GtkWidget *widget,
GtkWidget *previous);
G_DEFINE_TYPE (GtkTearoffMenuItem, gtk_tearoff_menu_item, GTK_TYPE_MENU_ITEM) G_DEFINE_TYPE (GtkTearoffMenuItem, gtk_tearoff_menu_item, GTK_TYPE_MENU_ITEM)
@ -65,7 +69,8 @@ gtk_tearoff_menu_item_class_init (GtkTearoffMenuItemClass *klass)
menu_item_class = (GtkMenuItemClass*) klass; menu_item_class = (GtkMenuItemClass*) klass;
widget_class->draw = gtk_tearoff_menu_item_draw; widget_class->draw = gtk_tearoff_menu_item_draw;
widget_class->size_request = gtk_tearoff_menu_item_size_request; widget_class->get_preferred_width = gtk_tearoff_menu_item_get_preferred_width;
widget_class->get_preferred_height = gtk_tearoff_menu_item_get_preferred_height;
widget_class->parent_set = gtk_tearoff_menu_item_parent_set; widget_class->parent_set = gtk_tearoff_menu_item_parent_set;
menu_item_class->activate = gtk_tearoff_menu_item_activate; menu_item_class->activate = gtk_tearoff_menu_item_activate;
@ -87,8 +92,23 @@ gtk_tearoff_menu_item_init (GtkTearoffMenuItem *tearoff_menu_item)
} }
static void static void
gtk_tearoff_menu_item_size_request (GtkWidget *widget, gtk_tearoff_menu_item_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{
GtkStyle *style;
guint border_width;
style = gtk_widget_get_style (widget);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
*minimum = *natural = (border_width + style->xthickness + BORDER_SPACING) * 2;
}
static void
gtk_tearoff_menu_item_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{ {
GtkStyle *style; GtkStyle *style;
GtkWidget *parent; GtkWidget *parent;
@ -97,17 +117,18 @@ gtk_tearoff_menu_item_size_request (GtkWidget *widget,
style = gtk_widget_get_style (widget); style = gtk_widget_get_style (widget);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
requisition->width = (border_width + style->xthickness + BORDER_SPACING) * 2; *minimum = *natural = (border_width + style->ythickness) * 2;
requisition->height = (border_width + style->ythickness) * 2;
parent = gtk_widget_get_parent (widget); parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU (parent) && GTK_MENU (parent)->torn_off) if (GTK_IS_MENU (parent) && GTK_MENU (parent)->torn_off)
{ {
requisition->height += ARROW_SIZE; *minimum += ARROW_SIZE;
*natural += ARROW_SIZE;
} }
else else
{ {
requisition->height += style->ythickness + 4; *minimum += style->ythickness + 4;
*natural += style->ythickness + 4;
} }
} }

View File

@ -282,6 +282,12 @@ static void gtk_text_view_get_property (GObject *object,
static void gtk_text_view_destroy (GtkWidget *widget); static void gtk_text_view_destroy (GtkWidget *widget);
static void gtk_text_view_size_request (GtkWidget *widget, static void gtk_text_view_size_request (GtkWidget *widget,
GtkRequisition *requisition); GtkRequisition *requisition);
static void gtk_text_view_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_text_view_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_text_view_size_allocate (GtkWidget *widget, static void gtk_text_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_text_view_realize (GtkWidget *widget); static void gtk_text_view_realize (GtkWidget *widget);
@ -589,7 +595,8 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
widget_class->direction_changed = gtk_text_view_direction_changed; widget_class->direction_changed = gtk_text_view_direction_changed;
widget_class->grab_notify = gtk_text_view_grab_notify; widget_class->grab_notify = gtk_text_view_grab_notify;
widget_class->state_changed = gtk_text_view_state_changed; widget_class->state_changed = gtk_text_view_state_changed;
widget_class->size_request = gtk_text_view_size_request; widget_class->get_preferred_width = gtk_text_view_get_preferred_width;
widget_class->get_preferred_height = gtk_text_view_get_preferred_height;
widget_class->size_allocate = gtk_text_view_size_allocate; widget_class->size_allocate = gtk_text_view_size_allocate;
widget_class->event = gtk_text_view_event; widget_class->event = gtk_text_view_event;
widget_class->key_press_event = gtk_text_view_key_press_event; widget_class->key_press_event = gtk_text_view_key_press_event;
@ -3305,6 +3312,31 @@ gtk_text_view_size_request (GtkWidget *widget,
priv->cached_size_request = *requisition; priv->cached_size_request = *requisition;
} }
static void
gtk_text_view_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_text_view_size_request (widget, &requisition);
*minimum = *natural = requisition.width;
}
static void
gtk_text_view_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_text_view_size_request (widget, &requisition);
*minimum = *natural = requisition.height;
}
static void static void
gtk_text_view_compute_child_allocation (GtkTextView *text_view, gtk_text_view_compute_child_allocation (GtkTextView *text_view,
GtkTextViewChild *vc, GtkTextViewChild *vc,
@ -3889,7 +3921,7 @@ changed_handler (GtkTextLayout *layout,
* to avoid the optimization which just returns widget->requisition * to avoid the optimization which just returns widget->requisition
* if a resize hasn't been queued. * if a resize hasn't been queued.
*/ */
GTK_WIDGET_GET_CLASS (widget)->size_request (widget, &new_req); gtk_text_view_size_request (widget, &new_req);
if (old_req.width != new_req.width || if (old_req.width != new_req.width ||
old_req.height != new_req.height) old_req.height != new_req.height)

View File

@ -186,8 +186,13 @@ static gint gtk_toolbar_draw (GtkWidget *widget,
cairo_t *cr); cairo_t *cr);
static void gtk_toolbar_realize (GtkWidget *widget); static void gtk_toolbar_realize (GtkWidget *widget);
static void gtk_toolbar_unrealize (GtkWidget *widget); static void gtk_toolbar_unrealize (GtkWidget *widget);
static void gtk_toolbar_size_request (GtkWidget *widget, static void gtk_toolbar_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_toolbar_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_toolbar_size_allocate (GtkWidget *widget, static void gtk_toolbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_toolbar_style_set (GtkWidget *widget, static void gtk_toolbar_style_set (GtkWidget *widget,
@ -363,7 +368,8 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
widget_class->button_press_event = gtk_toolbar_button_press; widget_class->button_press_event = gtk_toolbar_button_press;
widget_class->draw = gtk_toolbar_draw; widget_class->draw = gtk_toolbar_draw;
widget_class->size_request = gtk_toolbar_size_request; widget_class->get_preferred_width = gtk_toolbar_get_preferred_width;
widget_class->get_preferred_height = gtk_toolbar_get_preferred_height;
widget_class->size_allocate = gtk_toolbar_size_allocate; widget_class->size_allocate = gtk_toolbar_size_allocate;
widget_class->style_set = gtk_toolbar_style_set; widget_class->style_set = gtk_toolbar_style_set;
widget_class->focus = gtk_toolbar_focus; widget_class->focus = gtk_toolbar_focus;
@ -994,6 +1000,30 @@ gtk_toolbar_size_request (GtkWidget *widget,
priv->button_maxh = max_homogeneous_child_height; priv->button_maxh = max_homogeneous_child_height;
} }
static void
gtk_toolbar_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_toolbar_size_request (widget, &requisition);
*minimum = *natural = requisition.width;
}
static void
gtk_toolbar_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_toolbar_size_request (widget, &requisition);
*minimum = *natural = requisition.height;
}
static gint static gint
position (GtkToolbar *toolbar, position (GtkToolbar *toolbar,
gint from, gint from,

View File

@ -133,8 +133,14 @@ static void gtk_tool_item_realize (GtkWidget *widget);
static void gtk_tool_item_unrealize (GtkWidget *widget); static void gtk_tool_item_unrealize (GtkWidget *widget);
static void gtk_tool_item_map (GtkWidget *widget); static void gtk_tool_item_map (GtkWidget *widget);
static void gtk_tool_item_unmap (GtkWidget *widget); static void gtk_tool_item_unmap (GtkWidget *widget);
static void gtk_tool_item_size_request (GtkWidget *widget, static void gtk_tool_item_get_preferred_width
GtkRequisition *requisition); (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_tool_item_get_preferred_height
(GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_tool_item_size_allocate (GtkWidget *widget, static void gtk_tool_item_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
@ -174,10 +180,13 @@ gtk_tool_item_class_init (GtkToolItemClass *klass)
widget_class->unrealize = gtk_tool_item_unrealize; widget_class->unrealize = gtk_tool_item_unrealize;
widget_class->map = gtk_tool_item_map; widget_class->map = gtk_tool_item_map;
widget_class->unmap = gtk_tool_item_unmap; widget_class->unmap = gtk_tool_item_unmap;
widget_class->size_request = gtk_tool_item_size_request; widget_class->get_preferred_width = gtk_tool_item_get_preferred_width;
widget_class->get_preferred_height = gtk_tool_item_get_preferred_height;
widget_class->size_allocate = gtk_tool_item_size_allocate; widget_class->size_allocate = gtk_tool_item_size_allocate;
widget_class->parent_set = gtk_tool_item_parent_set; widget_class->parent_set = gtk_tool_item_parent_set;
gtk_container_class_handle_border_width (GTK_CONTAINER_CLASS (klass));
klass->create_menu_proxy = _gtk_tool_item_create_menu_proxy; klass->create_menu_proxy = _gtk_tool_item_create_menu_proxy;
g_object_class_install_property (object_class, g_object_class_install_property (object_class,
@ -403,20 +412,19 @@ create_drag_window (GtkToolItem *toolitem)
GtkAllocation allocation; GtkAllocation allocation;
GtkWidget *widget; GtkWidget *widget;
GdkWindowAttr attributes; GdkWindowAttr attributes;
gint attributes_mask, border_width; gint attributes_mask;
g_return_if_fail (toolitem->priv->use_drag_window == TRUE); g_return_if_fail (toolitem->priv->use_drag_window == TRUE);
widget = GTK_WIDGET (toolitem); widget = GTK_WIDGET (toolitem);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
gtk_widget_get_allocation (widget, &allocation); gtk_widget_get_allocation (widget, &allocation);
attributes.window_type = GDK_WINDOW_CHILD; attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = allocation.x + border_width; attributes.x = allocation.x;
attributes.y = allocation.y + border_width; attributes.y = allocation.y;
attributes.width = allocation.width - border_width * 2; attributes.width = allocation.width;
attributes.height = allocation.height - border_width * 2; attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_ONLY; attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
@ -493,26 +501,31 @@ gtk_tool_item_unmap (GtkWidget *widget)
} }
static void static void
gtk_tool_item_size_request (GtkWidget *widget, gtk_tool_item_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkWidget *child; GtkWidget *child;
guint border_width;
*minimum = *natural = 0;
child = gtk_bin_get_child (GTK_BIN (widget)); child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child)) if (child && gtk_widget_get_visible (child))
{ gtk_widget_get_preferred_width (child, minimum, natural);
gtk_widget_get_preferred_size (child, requisition, NULL); }
}
else
{
requisition->height = 0;
requisition->width = 0;
}
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); static void
requisition->width += border_width * 2; gtk_tool_item_get_preferred_height (GtkWidget *widget,
requisition->height += border_width * 2; gint *minimum,
gint *natural)
{
GtkWidget *child;
*minimum = *natural = 0;
child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child))
gtk_widget_get_preferred_height (child, minimum, natural);
} }
static void static void
@ -521,27 +534,24 @@ gtk_tool_item_size_allocate (GtkWidget *widget,
{ {
GtkToolItem *toolitem = GTK_TOOL_ITEM (widget); GtkToolItem *toolitem = GTK_TOOL_ITEM (widget);
GtkAllocation child_allocation; GtkAllocation child_allocation;
gint border_width;
GtkWidget *child; GtkWidget *child;
gtk_widget_set_allocation (widget, allocation); gtk_widget_set_allocation (widget, allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
if (toolitem->priv->drag_window) if (toolitem->priv->drag_window)
gdk_window_move_resize (toolitem->priv->drag_window, gdk_window_move_resize (toolitem->priv->drag_window,
allocation->x + border_width, allocation->x,
allocation->y + border_width, allocation->y,
allocation->width - border_width * 2, allocation->width,
allocation->height - border_width * 2); allocation->height);
child = gtk_bin_get_child (GTK_BIN (widget)); child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child)) if (child && gtk_widget_get_visible (child))
{ {
child_allocation.x = allocation->x + border_width; child_allocation.x = allocation->x;
child_allocation.y = allocation->y + border_width; child_allocation.y = allocation->y;
child_allocation.width = allocation->width - 2 * border_width; child_allocation.width = allocation->width;
child_allocation.height = allocation->height - 2 * border_width; child_allocation.height = allocation->height;
gtk_widget_size_allocate (child, &child_allocation); gtk_widget_size_allocate (child, &child_allocation);
} }

View File

@ -307,15 +307,6 @@ gtk_tool_item_group_header_draw_cb (GtkWidget *widget,
return FALSE; return FALSE;
} }
static void
gtk_tool_item_group_header_size_request_cb (GtkWidget *widget,
GtkRequisition *requisition,
gpointer data)
{
GtkToolItemGroup *group = GTK_TOOL_ITEM_GROUP (data);
requisition->height = MAX (requisition->height, group->priv->expander_size);
}
static void static void
gtk_tool_item_group_header_clicked_cb (GtkButton *button, gtk_tool_item_group_header_clicked_cb (GtkButton *button,
gpointer data) gpointer data)
@ -345,6 +336,8 @@ gtk_tool_item_group_header_adjust_style (GtkToolItemGroup *group)
"expander-size", &(priv->expander_size), "expander-size", &(priv->expander_size),
NULL); NULL);
gtk_widget_set_size_request (alignment, -1, priv->expander_size);
switch (gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group))) switch (gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group)))
{ {
case GTK_ORIENTATION_HORIZONTAL: case GTK_ORIENTATION_HORIZONTAL:
@ -412,9 +405,6 @@ gtk_tool_item_group_init (GtkToolItemGroup *group)
g_signal_connect_after (alignment, "draw", g_signal_connect_after (alignment, "draw",
G_CALLBACK (gtk_tool_item_group_header_draw_cb), G_CALLBACK (gtk_tool_item_group_header_draw_cb),
group); group);
g_signal_connect_after (alignment, "size-request",
G_CALLBACK (gtk_tool_item_group_header_size_request_cb),
group);
g_signal_connect (priv->header, "clicked", g_signal_connect (priv->header, "clicked",
G_CALLBACK (gtk_tool_item_group_header_clicked_cb), G_CALLBACK (gtk_tool_item_group_header_clicked_cb),
@ -578,6 +568,31 @@ gtk_tool_item_group_size_request (GtkWidget *widget,
requisition->height += border_width * 2; requisition->height += border_width * 2;
} }
static void
gtk_tool_item_group_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_tool_item_group_size_request (widget, &requisition);
*minimum = *natural = requisition.width;
}
static void
gtk_tool_item_group_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_tool_item_group_size_request (widget, &requisition);
*minimum = *natural = requisition.height;
}
static gboolean static gboolean
gtk_tool_item_group_is_item_visible (GtkToolItemGroup *group, gtk_tool_item_group_is_item_visible (GtkToolItemGroup *group,
GtkToolItemGroupChild *child) GtkToolItemGroupChild *child)
@ -1552,12 +1567,13 @@ gtk_tool_item_group_class_init (GtkToolItemGroupClass *cls)
oclass->finalize = gtk_tool_item_group_finalize; oclass->finalize = gtk_tool_item_group_finalize;
oclass->dispose = gtk_tool_item_group_dispose; oclass->dispose = gtk_tool_item_group_dispose;
wclass->size_request = gtk_tool_item_group_size_request; wclass->get_preferred_width = gtk_tool_item_group_get_preferred_width;
wclass->size_allocate = gtk_tool_item_group_size_allocate; wclass->get_preferred_height = gtk_tool_item_group_get_preferred_height;
wclass->realize = gtk_tool_item_group_realize; wclass->size_allocate = gtk_tool_item_group_size_allocate;
wclass->unrealize = gtk_tool_item_group_unrealize; wclass->realize = gtk_tool_item_group_realize;
wclass->style_set = gtk_tool_item_group_style_set; wclass->unrealize = gtk_tool_item_group_unrealize;
wclass->screen_changed = gtk_tool_item_group_screen_changed; wclass->style_set = gtk_tool_item_group_style_set;
wclass->screen_changed = gtk_tool_item_group_screen_changed;
cclass->add = gtk_tool_item_group_add; cclass->add = gtk_tool_item_group_add;
cclass->remove = gtk_tool_item_group_remove; cclass->remove = gtk_tool_item_group_remove;

View File

@ -435,6 +435,31 @@ gtk_tool_palette_size_request (GtkWidget *widget,
requisition->height += border_width * 2; requisition->height += border_width * 2;
} }
static void
gtk_tool_palette_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_tool_palette_size_request (widget, &requisition);
*minimum = *natural = requisition.width;
}
static void
gtk_tool_palette_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_tool_palette_size_request (widget, &requisition);
*minimum = *natural = requisition.height;
}
static void static void
gtk_tool_palette_size_allocate (GtkWidget *widget, gtk_tool_palette_size_allocate (GtkWidget *widget,
GtkAllocation *allocation) GtkAllocation *allocation)
@ -961,7 +986,8 @@ gtk_tool_palette_class_init (GtkToolPaletteClass *cls)
oclass->dispose = gtk_tool_palette_dispose; oclass->dispose = gtk_tool_palette_dispose;
oclass->finalize = gtk_tool_palette_finalize; oclass->finalize = gtk_tool_palette_finalize;
wclass->size_request = gtk_tool_palette_size_request; wclass->get_preferred_width = gtk_tool_palette_get_preferred_width;
wclass->get_preferred_height= gtk_tool_palette_get_preferred_height;
wclass->size_allocate = gtk_tool_palette_size_allocate; wclass->size_allocate = gtk_tool_palette_size_allocate;
wclass->draw = gtk_tool_palette_draw; wclass->draw = gtk_tool_palette_draw;
wclass->realize = gtk_tool_palette_realize; wclass->realize = gtk_tool_palette_realize;

View File

@ -167,6 +167,12 @@ static void gtk_tree_view_destroy (GtkWidget *widget);
static void gtk_tree_view_realize (GtkWidget *widget); static void gtk_tree_view_realize (GtkWidget *widget);
static void gtk_tree_view_unrealize (GtkWidget *widget); static void gtk_tree_view_unrealize (GtkWidget *widget);
static void gtk_tree_view_map (GtkWidget *widget); static void gtk_tree_view_map (GtkWidget *widget);
static void gtk_tree_view_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_tree_view_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_tree_view_size_request (GtkWidget *widget, static void gtk_tree_view_size_request (GtkWidget *widget,
GtkRequisition *requisition); GtkRequisition *requisition);
static void gtk_tree_view_size_allocate (GtkWidget *widget, static void gtk_tree_view_size_allocate (GtkWidget *widget,
@ -519,7 +525,8 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
widget_class->map = gtk_tree_view_map; widget_class->map = gtk_tree_view_map;
widget_class->realize = gtk_tree_view_realize; widget_class->realize = gtk_tree_view_realize;
widget_class->unrealize = gtk_tree_view_unrealize; widget_class->unrealize = gtk_tree_view_unrealize;
widget_class->size_request = gtk_tree_view_size_request; widget_class->get_preferred_width = gtk_tree_view_get_preferred_width;
widget_class->get_preferred_height = gtk_tree_view_get_preferred_height;
widget_class->size_allocate = gtk_tree_view_size_allocate; widget_class->size_allocate = gtk_tree_view_size_allocate;
widget_class->button_press_event = gtk_tree_view_button_press; widget_class->button_press_event = gtk_tree_view_button_press;
widget_class->button_release_event = gtk_tree_view_button_release; widget_class->button_release_event = gtk_tree_view_button_release;
@ -2034,17 +2041,30 @@ gtk_tree_view_size_request (GtkWidget *widget,
requisition->height = tree_view->priv->height + TREE_VIEW_HEADER_HEIGHT (tree_view); requisition->height = tree_view->priv->height + TREE_VIEW_HEADER_HEIGHT (tree_view);
tmp_list = tree_view->priv->children; tmp_list = tree_view->priv->children;
}
while (tmp_list) static void
{ gtk_tree_view_get_preferred_width (GtkWidget *widget,
GtkTreeViewChild *child = tmp_list->data; gint *minimum,
GtkRequisition child_requisition; gint *natural)
{
GtkRequisition requisition;
tmp_list = tmp_list->next; gtk_tree_view_size_request (widget, &requisition);
if (gtk_widget_get_visible (child->widget)) *minimum = *natural = requisition.width;
gtk_widget_get_preferred_size (child->widget, &child_requisition, NULL); }
}
static void
gtk_tree_view_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkRequisition requisition;
gtk_tree_view_size_request (widget, &requisition);
*minimum = *natural = requisition.height;
} }
static int static int
@ -6332,12 +6352,23 @@ do_validate_rows (GtkTreeView *tree_view, gboolean queue_resize)
if (validated_area) if (validated_area)
{ {
GtkRequisition requisition; GtkRequisition requisition;
/* We temporarily guess a size, under the assumption that it will be the /* We temporarily guess a size, under the assumption that it will be the
* same when we get our next size_allocate. If we don't do this, we'll be * same when we get our next size_allocate. If we don't do this, we'll be
* in an inconsistent state when we call top_row_to_dy. */ * in an inconsistent state when we call top_row_to_dy. */
gtk_widget_get_preferred_size (GTK_WIDGET (tree_view), /* FIXME: This is called from size_request, for some reason it is not infinitely
&requisition, NULL); * recursing, we cannot call gtk_widget_get_preferred_size() here because that's
* not allowed (from inside ->get_preferred_width/height() implementations, one
* should call the vfuncs directly). However what is desired here is the full
* size including any margins and limited by any alignment (i.e. after
* GtkWidget:adjust_size_request() is called).
*
* Currently bypassing this but the real solution is to not update the scroll adjustments
* untill we've recieved an allocation (never update scroll adjustments from size-requests).
*/
gtk_tree_view_size_request (GTK_WIDGET (tree_view), &requisition);
tree_view->priv->hadjustment->upper = MAX (tree_view->priv->hadjustment->upper, (gfloat)requisition.width); tree_view->priv->hadjustment->upper = MAX (tree_view->priv->hadjustment->upper, (gfloat)requisition.width);
tree_view->priv->vadjustment->upper = MAX (tree_view->priv->vadjustment->upper, (gfloat)requisition.height); tree_view->priv->vadjustment->upper = MAX (tree_view->priv->vadjustment->upper, (gfloat)requisition.height);
gtk_adjustment_changed (tree_view->priv->hadjustment); gtk_adjustment_changed (tree_view->priv->hadjustment);

View File

@ -701,7 +701,7 @@ main (gint argc, gchar **argv)
add_item_to_list (store, item, "Video"); add_item_to_list (store, item, "Video");
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
image = gtk_image_new_from_icon_name ("utility-terminal", GTK_ICON_SIZE_LARGE_TOOLBAR); image = gtk_image_new_from_icon_name ("utilities-terminal", GTK_ICON_SIZE_LARGE_TOOLBAR);
item = gtk_tool_button_new (image, "Terminal"); item = gtk_tool_button_new (image, "Terminal");
add_item_to_list (store, item, "Terminal"); add_item_to_list (store, item, "Terminal");
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);