forked from AuroraMiddleware/gtk
Merge branch 'kill-size-request'
This commit is contained in:
commit
2f3e51389e
@ -343,6 +343,182 @@ cairo_destroy (cr);
|
||||
have been either impossible or impractical.
|
||||
</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, &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, &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, &child_min, &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>
|
||||
<title>Replace GdkRegion by cairo_region_t</title>
|
||||
|
||||
|
@ -117,8 +117,12 @@ static void gtk_assistant_init (GtkAssistant *assistant);
|
||||
static void gtk_assistant_destroy (GtkWidget *widget);
|
||||
static void gtk_assistant_style_set (GtkWidget *widget,
|
||||
GtkStyle *old_style);
|
||||
static void gtk_assistant_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_assistant_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->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->map = gtk_assistant_map;
|
||||
widget_class->unmap = gtk_assistant_unmap;
|
||||
@ -1200,6 +1205,29 @@ gtk_assistant_size_request (GtkWidget *widget,
|
||||
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
|
||||
gtk_assistant_size_allocate (GtkWidget *widget,
|
||||
|
@ -81,8 +81,12 @@ static void gtk_button_box_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_button_box_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_button_box_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->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;
|
||||
|
||||
container_class->remove = gtk_button_box_remove;
|
||||
@ -612,6 +617,30 @@ gtk_button_box_size_request (GtkWidget *widget,
|
||||
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
|
||||
gtk_button_box_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
|
@ -341,8 +341,12 @@ static void gtk_calendar_get_property (GObject *object,
|
||||
|
||||
static void gtk_calendar_realize (GtkWidget *widget);
|
||||
static void gtk_calendar_unrealize (GtkWidget *widget);
|
||||
static void gtk_calendar_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_calendar_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->unrealize = gtk_calendar_unrealize;
|
||||
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->button_press_event = gtk_calendar_button_press;
|
||||
widget_class->button_release_event = gtk_calendar_button_release;
|
||||
@ -2029,6 +2034,30 @@ gtk_calendar_size_request (GtkWidget *widget,
|
||||
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
|
||||
gtk_calendar_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
|
@ -38,8 +38,12 @@
|
||||
#define INDICATOR_SPACING 2
|
||||
|
||||
|
||||
static void gtk_check_button_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_check_button_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
static gboolean gtk_check_button_draw (GtkWidget *widget,
|
||||
@ -57,10 +61,11 @@ static void
|
||||
gtk_check_button_class_init (GtkCheckButtonClass *class)
|
||||
{
|
||||
GtkWidgetClass *widget_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->draw = gtk_check_button_draw;
|
||||
|
||||
@ -195,11 +200,58 @@ _gtk_check_button_get_props (GtkCheckButton *check_button,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_check_button_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_check_button_get_preferred_width (GtkWidget *widget,
|
||||
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);
|
||||
|
||||
if (gtk_toggle_button_get_mode (toggle_button))
|
||||
{
|
||||
GtkWidget *child;
|
||||
@ -213,34 +265,33 @@ gtk_check_button_size_request (GtkWidget *widget,
|
||||
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);
|
||||
|
||||
requisition->width = border_width * 2;
|
||||
requisition->height = border_width * 2;
|
||||
"focus-line-width", &focus_width,
|
||||
"focus-padding", &focus_pad,
|
||||
NULL);
|
||||
|
||||
*minimum = border_width * 2;
|
||||
*natural = border_width * 2;
|
||||
|
||||
_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));
|
||||
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);
|
||||
|
||||
*minimum += child_min;
|
||||
*natural += child_nat;
|
||||
}
|
||||
|
||||
requisition->width += child_requisition.width + indicator_spacing;
|
||||
requisition->height += child_requisition.height;
|
||||
}
|
||||
|
||||
requisition->width += (indicator_size + indicator_spacing * 2 + 2 * (focus_width + focus_pad));
|
||||
|
||||
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
|
||||
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
|
||||
|
@ -1300,7 +1300,7 @@ gtk_drag_dest_set_proxy (GtkWidget *widget,
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
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->have_drag = FALSE;
|
||||
|
@ -258,8 +258,12 @@ static void gtk_entry_realize (GtkWidget *widget);
|
||||
static void gtk_entry_unrealize (GtkWidget *widget);
|
||||
static void gtk_entry_map (GtkWidget *widget);
|
||||
static void gtk_entry_unmap (GtkWidget *widget);
|
||||
static void gtk_entry_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_entry_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->realize = gtk_entry_realize;
|
||||
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->draw = gtk_entry_draw;
|
||||
widget_class->enter_notify_event = gtk_entry_enter_notify;
|
||||
@ -2853,8 +2858,9 @@ _gtk_entry_get_borders (GtkEntry *entry,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_entry_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_entry_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkEntry *entry = GTK_ENTRY (widget);
|
||||
GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
|
||||
@ -2862,33 +2868,29 @@ gtk_entry_size_request (GtkWidget *widget,
|
||||
gint xborder, yborder;
|
||||
GtkBorder inner_border;
|
||||
PangoContext *context;
|
||||
int icon_widths = 0;
|
||||
int icon_width, i;
|
||||
|
||||
gint icon_widths = 0;
|
||||
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_widget_get_style (widget)->font_desc,
|
||||
pango_context_get_language (context));
|
||||
|
||||
entry->ascent = pango_font_metrics_get_ascent (metrics);
|
||||
entry->descent = pango_font_metrics_get_descent (metrics);
|
||||
|
||||
_gtk_entry_get_borders (entry, &xborder, &yborder);
|
||||
_gtk_entry_effective_inner_border (entry, &inner_border);
|
||||
|
||||
if (entry->width_chars < 0)
|
||||
requisition->width = MIN_ENTRY_WIDTH + xborder * 2 + inner_border.left + inner_border.right;
|
||||
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;
|
||||
|
||||
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++)
|
||||
{
|
||||
@ -2897,10 +2899,45 @@ gtk_entry_size_request (GtkWidget *widget,
|
||||
icon_widths += icon_width + 2 * priv->icon_margin;
|
||||
}
|
||||
|
||||
if (icon_widths > requisition->width)
|
||||
requisition->width += icon_widths;
|
||||
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);
|
||||
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));
|
||||
|
||||
entry->ascent = pango_font_metrics_get_ascent (metrics);
|
||||
entry->descent = pango_font_metrics_get_descent (metrics);
|
||||
|
||||
_gtk_entry_get_borders (entry, &xborder, &yborder);
|
||||
_gtk_entry_effective_inner_border (entry, &inner_border);
|
||||
|
||||
height = PANGO_PIXELS (entry->ascent + entry->descent) + yborder * 2 + inner_border.top + inner_border.bottom;
|
||||
|
||||
pango_font_metrics_unref (metrics);
|
||||
|
||||
*minimum = height;
|
||||
*natural = height;
|
||||
}
|
||||
|
||||
static void
|
||||
|
308
gtk/gtkfixed.c
308
gtk/gtkfixed.c
@ -21,7 +21,7 @@
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@ -44,18 +44,22 @@ enum {
|
||||
};
|
||||
|
||||
static void gtk_fixed_realize (GtkWidget *widget);
|
||||
static void gtk_fixed_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_fixed_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
GtkAllocation *allocation);
|
||||
static void gtk_fixed_add (GtkContainer *container,
|
||||
GtkWidget *widget);
|
||||
GtkWidget *widget);
|
||||
static void gtk_fixed_remove (GtkContainer *container,
|
||||
GtkWidget *widget);
|
||||
GtkWidget *widget);
|
||||
static void gtk_fixed_forall (GtkContainer *container,
|
||||
gboolean include_internals,
|
||||
GtkCallback callback,
|
||||
gpointer callback_data);
|
||||
gboolean include_internals,
|
||||
GtkCallback callback,
|
||||
gpointer callback_data);
|
||||
static GType gtk_fixed_child_type (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;
|
||||
|
||||
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;
|
||||
|
||||
container_class->add = gtk_fixed_add;
|
||||
container_class->remove = gtk_fixed_remove;
|
||||
container_class->forall = gtk_fixed_forall;
|
||||
container_class->child_type = gtk_fixed_child_type;
|
||||
|
||||
container_class->set_child_property = gtk_fixed_set_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,
|
||||
CHILD_PROP_X,
|
||||
g_param_spec_int ("x",
|
||||
CHILD_PROP_X,
|
||||
g_param_spec_int ("x",
|
||||
P_("X position"),
|
||||
P_("X position of child widget"),
|
||||
G_MININT,
|
||||
G_MAXINT,
|
||||
0,
|
||||
G_MININT, G_MAXINT, 0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
gtk_container_class_install_child_property (container_class,
|
||||
CHILD_PROP_Y,
|
||||
g_param_spec_int ("y",
|
||||
CHILD_PROP_Y,
|
||||
g_param_spec_int ("y",
|
||||
P_("Y position"),
|
||||
P_("Y position of child widget"),
|
||||
G_MININT,
|
||||
G_MAXINT,
|
||||
0,
|
||||
G_MININT, G_MAXINT, 0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_type_class_add_private (class, sizeof (GtkFixedPrivate));
|
||||
}
|
||||
|
||||
static GType
|
||||
gtk_fixed_child_type (GtkContainer *container)
|
||||
gtk_fixed_child_type (GtkContainer *container)
|
||||
{
|
||||
return GTK_TYPE_WIDGET;
|
||||
}
|
||||
@ -124,16 +125,11 @@ gtk_fixed_child_type (GtkContainer *container)
|
||||
static void
|
||||
gtk_fixed_init (GtkFixed *fixed)
|
||||
{
|
||||
GtkFixedPrivate *priv;
|
||||
|
||||
fixed->priv = G_TYPE_INSTANCE_GET_PRIVATE (fixed,
|
||||
GTK_TYPE_FIXED,
|
||||
GtkFixedPrivate);
|
||||
priv = fixed->priv;
|
||||
fixed->priv = G_TYPE_INSTANCE_GET_PRIVATE (fixed, GTK_TYPE_FIXED, GtkFixedPrivate);
|
||||
|
||||
gtk_widget_set_has_window (GTK_WIDGET (fixed), FALSE);
|
||||
|
||||
priv->children = NULL;
|
||||
fixed->priv->children = NULL;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
@ -149,13 +145,11 @@ get_child (GtkFixed *fixed,
|
||||
GtkFixedPrivate *priv = fixed->priv;
|
||||
GList *children;
|
||||
|
||||
children = priv->children;
|
||||
while (children)
|
||||
for (children = priv->children; children; children = children->next)
|
||||
{
|
||||
GtkFixedChild *child;
|
||||
|
||||
|
||||
child = children->data;
|
||||
children = children->next;
|
||||
|
||||
if (child->widget == widget)
|
||||
return child;
|
||||
@ -165,10 +159,10 @@ get_child (GtkFixed *fixed,
|
||||
}
|
||||
|
||||
void
|
||||
gtk_fixed_put (GtkFixed *fixed,
|
||||
GtkWidget *widget,
|
||||
gint x,
|
||||
gint y)
|
||||
gtk_fixed_put (GtkFixed *fixed,
|
||||
GtkWidget *widget,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GtkFixedPrivate *priv = fixed->priv;
|
||||
GtkFixedChild *child_info;
|
||||
@ -187,73 +181,69 @@ gtk_fixed_put (GtkFixed *fixed,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_fixed_move_internal (GtkFixed *fixed,
|
||||
GtkWidget *widget,
|
||||
gboolean change_x,
|
||||
gint x,
|
||||
gboolean change_y,
|
||||
gint y)
|
||||
gtk_fixed_move_internal (GtkFixed *fixed,
|
||||
GtkFixedChild *child,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GtkFixedChild *child;
|
||||
|
||||
g_return_if_fail (GTK_IS_FIXED (fixed));
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (fixed));
|
||||
g_return_if_fail (gtk_widget_get_parent (child->widget) == GTK_WIDGET (fixed));
|
||||
|
||||
child = get_child (fixed, widget);
|
||||
gtk_widget_freeze_child_notify (child->widget);
|
||||
|
||||
g_assert (child);
|
||||
|
||||
gtk_widget_freeze_child_notify (widget);
|
||||
|
||||
if (change_x)
|
||||
if (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;
|
||||
gtk_widget_child_notify (widget, "y");
|
||||
gtk_widget_child_notify (child->widget, "y");
|
||||
}
|
||||
|
||||
gtk_widget_thaw_child_notify (widget);
|
||||
|
||||
if (gtk_widget_get_visible (widget) &&
|
||||
gtk_widget_thaw_child_notify (child->widget);
|
||||
|
||||
if (gtk_widget_get_visible (child->widget) &&
|
||||
gtk_widget_get_visible (GTK_WIDGET (fixed)))
|
||||
gtk_widget_queue_resize (GTK_WIDGET (fixed));
|
||||
}
|
||||
|
||||
void
|
||||
gtk_fixed_move (GtkFixed *fixed,
|
||||
GtkWidget *widget,
|
||||
gint x,
|
||||
gint y)
|
||||
gtk_fixed_move (GtkFixed *fixed,
|
||||
GtkWidget *widget,
|
||||
gint x,
|
||||
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
|
||||
gtk_fixed_set_child_property (GtkContainer *container,
|
||||
GtkWidget *child,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gtk_fixed_set_child_property (GtkContainer *container,
|
||||
GtkWidget *child,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFixed *fixed = GTK_FIXED (container);
|
||||
GtkFixedChild *fixed_child;
|
||||
|
||||
fixed_child = get_child (fixed, child);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case CHILD_PROP_X:
|
||||
gtk_fixed_move_internal (GTK_FIXED (container),
|
||||
child,
|
||||
TRUE, g_value_get_int (value),
|
||||
FALSE, 0);
|
||||
gtk_fixed_move_internal (fixed,
|
||||
fixed_child,
|
||||
g_value_get_int (value),
|
||||
fixed_child->y);
|
||||
break;
|
||||
case CHILD_PROP_Y:
|
||||
gtk_fixed_move_internal (GTK_FIXED (container),
|
||||
child,
|
||||
FALSE, 0,
|
||||
TRUE, g_value_get_int (value));
|
||||
gtk_fixed_move_internal (fixed,
|
||||
fixed_child,
|
||||
fixed_child->x,
|
||||
g_value_get_int (value));
|
||||
break;
|
||||
default:
|
||||
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
|
||||
@ -311,7 +301,7 @@ gtk_fixed_realize (GtkWidget *widget)
|
||||
attributes.visual = gtk_widget_get_visual (widget);
|
||||
attributes.event_mask = gtk_widget_get_events (widget);
|
||||
attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK;
|
||||
|
||||
|
||||
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
|
||||
|
||||
window = gdk_window_new (gtk_widget_get_parent_window (widget),
|
||||
@ -325,51 +315,64 @@ gtk_fixed_realize (GtkWidget *widget)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_fixed_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_fixed_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkFixedPrivate *priv;
|
||||
GtkFixed *fixed;
|
||||
GtkFixed *fixed = GTK_FIXED (widget);
|
||||
GtkFixedPrivate *priv = fixed->priv;
|
||||
GtkFixedChild *child;
|
||||
GList *children;
|
||||
GtkRequisition child_requisition;
|
||||
guint border_width;
|
||||
gint child_min, child_nat;
|
||||
|
||||
fixed = GTK_FIXED (widget);
|
||||
priv = fixed->priv;
|
||||
*minimum = 0;
|
||||
*natural = 0;
|
||||
|
||||
requisition->width = 0;
|
||||
requisition->height = 0;
|
||||
|
||||
children = priv->children;
|
||||
while (children)
|
||||
for (children = priv->children; children; children = children->next)
|
||||
{
|
||||
child = children->data;
|
||||
children = children->next;
|
||||
|
||||
if (gtk_widget_get_visible (child->widget))
|
||||
{
|
||||
gtk_widget_get_preferred_size (child->widget,
|
||||
&child_requisition,
|
||||
NULL);
|
||||
if (!gtk_widget_get_visible (child->widget))
|
||||
continue;
|
||||
|
||||
requisition->height = MAX (requisition->height,
|
||||
child->y +
|
||||
child_requisition.height);
|
||||
requisition->width = MAX (requisition->width,
|
||||
child->x +
|
||||
child_requisition.width);
|
||||
}
|
||||
gtk_widget_get_preferred_width (child->widget, &child_min, &child_nat);
|
||||
|
||||
*minimum = MAX (*minimum, child->x + child_min);
|
||||
*natural = MAX (*natural, child->x + child_nat);
|
||||
}
|
||||
}
|
||||
|
||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (fixed));
|
||||
requisition->height += border_width * 2;
|
||||
requisition->width += border_width * 2;
|
||||
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, &child_min, &child_nat);
|
||||
|
||||
*minimum = MAX (*minimum, child->y + child_min);
|
||||
*natural = MAX (*natural, child->y + child_nat);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_fixed_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
GtkFixed *fixed = GTK_FIXED (widget);
|
||||
GtkFixedPrivate *priv = fixed->priv;
|
||||
@ -377,58 +380,52 @@ gtk_fixed_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation child_allocation;
|
||||
GtkRequisition child_requisition;
|
||||
GList *children;
|
||||
guint border_width;
|
||||
|
||||
gtk_widget_set_allocation (widget, allocation);
|
||||
|
||||
if (gtk_widget_get_has_window (widget))
|
||||
{
|
||||
if (gtk_widget_get_realized (widget))
|
||||
gdk_window_move_resize (gtk_widget_get_window (widget),
|
||||
allocation->x,
|
||||
allocation->y,
|
||||
allocation->width,
|
||||
allocation->height);
|
||||
gdk_window_move_resize (gtk_widget_get_window (widget),
|
||||
allocation->x,
|
||||
allocation->y,
|
||||
allocation->width,
|
||||
allocation->height);
|
||||
}
|
||||
|
||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (fixed));
|
||||
|
||||
children = priv->children;
|
||||
while (children)
|
||||
for (children = priv->children; children; children = children->next)
|
||||
{
|
||||
child = children->data;
|
||||
children = children->next;
|
||||
|
||||
if (gtk_widget_get_visible (child->widget))
|
||||
{
|
||||
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))
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (!gtk_widget_get_visible (child->widget))
|
||||
continue;
|
||||
|
||||
gtk_widget_get_preferred_size (child->widget, &child_requisition, NULL);
|
||||
child_allocation.x = child->x;
|
||||
child_allocation.y = child->y;
|
||||
|
||||
if (!gtk_widget_get_has_window (widget))
|
||||
{
|
||||
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
|
||||
gtk_fixed_add (GtkContainer *container,
|
||||
GtkWidget *widget)
|
||||
GtkWidget *widget)
|
||||
{
|
||||
gtk_fixed_put (GTK_FIXED (container), widget, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_fixed_remove (GtkContainer *container,
|
||||
GtkWidget *widget)
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkFixed *fixed = GTK_FIXED (container);
|
||||
GtkFixedPrivate *priv = fixed->priv;
|
||||
@ -436,26 +433,25 @@ gtk_fixed_remove (GtkContainer *container,
|
||||
GtkWidget *widget_container = GTK_WIDGET (container);
|
||||
GList *children;
|
||||
|
||||
children = priv->children;
|
||||
while (children)
|
||||
for (children = priv->children; children; children = children->next)
|
||||
{
|
||||
child = children->data;
|
||||
|
||||
if (child->widget == widget)
|
||||
{
|
||||
gboolean was_visible = gtk_widget_get_visible (widget);
|
||||
|
||||
gtk_widget_unparent (widget);
|
||||
{
|
||||
gboolean was_visible = gtk_widget_get_visible (widget);
|
||||
|
||||
priv->children = g_list_remove_link (priv->children, children);
|
||||
g_list_free (children);
|
||||
g_free (child);
|
||||
gtk_widget_unparent (widget);
|
||||
|
||||
if (was_visible && gtk_widget_get_visible (widget_container))
|
||||
gtk_widget_queue_resize (widget_container);
|
||||
priv->children = g_list_remove_link (priv->children, children);
|
||||
g_list_free (children);
|
||||
g_free (child);
|
||||
|
||||
break;
|
||||
}
|
||||
if (was_visible && gtk_widget_get_visible (widget_container))
|
||||
gtk_widget_queue_resize (widget_container);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
children = children->next;
|
||||
}
|
||||
@ -463,20 +459,18 @@ gtk_fixed_remove (GtkContainer *container,
|
||||
|
||||
static void
|
||||
gtk_fixed_forall (GtkContainer *container,
|
||||
gboolean include_internals,
|
||||
GtkCallback callback,
|
||||
gpointer callback_data)
|
||||
gboolean include_internals,
|
||||
GtkCallback callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
GtkFixed *fixed = GTK_FIXED (container);
|
||||
GtkFixedPrivate *priv = fixed->priv;
|
||||
GtkFixedChild *child;
|
||||
GList *children;
|
||||
|
||||
children = priv->children;
|
||||
while (children)
|
||||
for (children = priv->children; children; children = children->next)
|
||||
{
|
||||
child = children->data;
|
||||
children = children->next;
|
||||
|
||||
(* callback) (child->widget, callback_data);
|
||||
}
|
||||
|
@ -140,6 +140,12 @@ static void gtk_handle_box_style_set (GtkWidget *widget,
|
||||
GtkStyle *previous_style);
|
||||
static void gtk_handle_box_size_request (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *real_allocation);
|
||||
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->unrealize = gtk_handle_box_unrealize;
|
||||
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->draw = gtk_handle_box_draw;
|
||||
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
|
||||
gtk_handle_box_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
|
775
gtk/gtkhsv.c
775
gtk/gtkhsv.c
File diff suppressed because it is too large
Load Diff
@ -272,8 +272,12 @@ static void gtk_icon_view_style_set (GtkWidget
|
||||
GtkStyle *previous_style);
|
||||
static void gtk_icon_view_state_changed (GtkWidget *widget,
|
||||
GtkStateType previous_state);
|
||||
static void gtk_icon_view_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_icon_view_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->style_set = gtk_icon_view_style_set;
|
||||
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->draw = gtk_icon_view_draw;
|
||||
widget_class->motion_notify_event = gtk_icon_view_motion;
|
||||
@ -1458,28 +1463,19 @@ gtk_icon_view_style_set (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_view_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_icon_view_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkIconView *icon_view = GTK_ICON_VIEW (widget);
|
||||
GList *tmp_list;
|
||||
*minimum = *natural = GTK_ICON_VIEW (widget)->priv->width;
|
||||
}
|
||||
|
||||
requisition->width = icon_view->priv->width;
|
||||
requisition->height = icon_view->priv->height;
|
||||
|
||||
tmp_list = icon_view->priv->children;
|
||||
|
||||
while (tmp_list)
|
||||
{
|
||||
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
|
||||
gtk_icon_view_get_preferred_height (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
*minimum = *natural = GTK_ICON_VIEW (widget)->priv->height;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -155,34 +155,39 @@ struct _GtkImagePrivate
|
||||
|
||||
|
||||
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_BUTTON
|
||||
static gint gtk_image_draw (GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
static void gtk_image_unmap (GtkWidget *widget);
|
||||
static void gtk_image_unrealize (GtkWidget *widget);
|
||||
static void gtk_image_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_image_style_set (GtkWidget *widget,
|
||||
GtkStyle *prev_style);
|
||||
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 gint gtk_image_draw (GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
static void gtk_image_unmap (GtkWidget *widget);
|
||||
static void gtk_image_unrealize (GtkWidget *widget);
|
||||
static void gtk_image_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural);
|
||||
static void gtk_image_get_preferred_height (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural);
|
||||
|
||||
static void gtk_image_update_size (GtkImage *image,
|
||||
gint image_width,
|
||||
gint image_height);
|
||||
static void gtk_image_style_set (GtkWidget *widget,
|
||||
GtkStyle *prev_style);
|
||||
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,
|
||||
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 gtk_image_update_size (GtkImage *image,
|
||||
gint image_width,
|
||||
gint image_height);
|
||||
|
||||
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
|
||||
{
|
||||
@ -215,7 +220,8 @@ gtk_image_class_init (GtkImageClass *class)
|
||||
widget_class = GTK_WIDGET_CLASS (class);
|
||||
widget_class->draw = gtk_image_draw;
|
||||
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->unrealize = gtk_image_unrealize;
|
||||
widget_class->style_set = gtk_image_style_set;
|
||||
@ -1928,19 +1934,35 @@ gtk_image_calc_size (GtkImage *image)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_image_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_image_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkImage *image;
|
||||
GtkImagePrivate *priv;
|
||||
|
||||
|
||||
image = GTK_IMAGE (widget);
|
||||
priv = image->priv;
|
||||
|
||||
gtk_image_calc_size (image);
|
||||
|
||||
requisition->width = priv->required_width;
|
||||
requisition->height = priv->required_height;
|
||||
*minimum = *natural = priv->required_width;
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -62,8 +62,16 @@ enum {
|
||||
static GtkActivatableIface *parent_activatable_iface;
|
||||
|
||||
static void gtk_image_menu_item_destroy (GtkWidget *widget);
|
||||
static void gtk_image_menu_item_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->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->map = gtk_image_menu_item_map;
|
||||
|
||||
@ -411,13 +421,13 @@ gtk_image_menu_item_get_label (GtkMenuItem *menu_item)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_image_menu_item_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
|
||||
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
|
||||
gint child_width = 0;
|
||||
gint child_height = 0;
|
||||
GtkPackDirection pack_dir;
|
||||
GtkWidget *parent;
|
||||
|
||||
@ -435,26 +445,92 @@ gtk_image_menu_item_size_request (GtkWidget *widget,
|
||||
gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
* toggle_size_request
|
||||
*/
|
||||
if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
|
||||
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
|
||||
*/
|
||||
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
|
||||
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
|
||||
gtk_image_menu_item_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
|
@ -80,7 +80,7 @@ struct _GtkLayoutChild {
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_HADJUSTMENT,
|
||||
PROP_VADJUSTMENT,
|
||||
PROP_VADJUSTMENT,
|
||||
PROP_HSCROLL_POLICY,
|
||||
PROP_VSCROLL_POLICY,
|
||||
PROP_WIDTH,
|
||||
@ -105,8 +105,12 @@ static void gtk_layout_finalize (GObject *object);
|
||||
static void gtk_layout_realize (GtkWidget *widget);
|
||||
static void gtk_layout_unrealize (GtkWidget *widget);
|
||||
static void gtk_layout_map (GtkWidget *widget);
|
||||
static void gtk_layout_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_layout_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->unrealize = gtk_layout_unrealize;
|
||||
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->draw = gtk_layout_draw;
|
||||
widget_class->style_set = gtk_layout_style_set;
|
||||
@ -932,15 +937,23 @@ gtk_layout_unrealize (GtkWidget *widget)
|
||||
GTK_WIDGET_CLASS (gtk_layout_parent_class)->unrealize (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_layout_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
static void
|
||||
gtk_layout_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
requisition->width = 0;
|
||||
requisition->height = 0;
|
||||
*minimum = *natural = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
gtk_layout_get_preferred_height (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
*minimum = *natural = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_layout_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
|
@ -68,6 +68,12 @@ static void gtk_menu_bar_get_property (GObject *object,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_menu_bar_size_request (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->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->draw = gtk_menu_bar_draw;
|
||||
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
|
||||
gtk_menu_bar_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
|
@ -333,6 +333,12 @@ static void gtk_notebook_realize (GtkWidget *widget);
|
||||
static void gtk_notebook_unrealize (GtkWidget *widget);
|
||||
static void gtk_notebook_size_request (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->realize = gtk_notebook_realize;
|
||||
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->draw = gtk_notebook_draw;
|
||||
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
|
||||
gtk_notebook_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
|
@ -51,38 +51,71 @@
|
||||
G_DEFINE_TYPE (GtkOffscreenWindow, gtk_offscreen_window, GTK_TYPE_WINDOW);
|
||||
|
||||
static void
|
||||
gtk_offscreen_window_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_offscreen_window_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN (widget);
|
||||
GtkWidget *child;
|
||||
gint border_width;
|
||||
gint default_width, default_height;
|
||||
gint default_width;
|
||||
|
||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
||||
|
||||
requisition->width = border_width * 2;
|
||||
requisition->height = border_width * 2;
|
||||
*minimum = border_width * 2;
|
||||
*natural = border_width * 2;
|
||||
|
||||
child = gtk_bin_get_child (bin);
|
||||
|
||||
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;
|
||||
requisition->height += child_req.height;
|
||||
*minimum += child_min;
|
||||
*natural += child_nat;
|
||||
}
|
||||
|
||||
gtk_window_get_default_size (GTK_WINDOW (widget),
|
||||
&default_width, &default_height);
|
||||
if (default_width > 0)
|
||||
requisition->width = default_width;
|
||||
&default_width, NULL);
|
||||
|
||||
if (default_height > 0)
|
||||
requisition->height = default_height;
|
||||
*minimum = MAX (*minimum, default_width);
|
||||
*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
|
||||
@ -238,7 +271,8 @@ gtk_offscreen_window_class_init (GtkOffscreenWindowClass *class)
|
||||
widget_class->realize = gtk_offscreen_window_realize;
|
||||
widget_class->show = gtk_offscreen_window_show;
|
||||
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;
|
||||
|
||||
container_class->check_resize = gtk_offscreen_window_check_resize;
|
||||
|
@ -119,8 +119,13 @@ static void gtk_paned_get_child_property (GtkContainer *container,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_paned_finalize (GObject *object);
|
||||
|
||||
static void gtk_paned_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_paned_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->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->realize = gtk_paned_realize;
|
||||
widget_class->unrealize = gtk_paned_unrealize;
|
||||
@ -792,41 +798,44 @@ gtk_paned_finalize (GObject *object)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_paned_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_paned_get_preferred_size (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkPaned *paned = GTK_PANED (widget);
|
||||
GtkPanedPrivate *priv = paned->priv;
|
||||
GtkRequisition child_requisition;
|
||||
gint child_min, child_nat;
|
||||
|
||||
requisition->width = 0;
|
||||
requisition->height = 0;
|
||||
*minimum = *natural = 0;
|
||||
|
||||
if (priv->child1 && gtk_widget_get_visible (priv->child1))
|
||||
{
|
||||
gtk_widget_get_preferred_size (priv->child1,
|
||||
&child_requisition, NULL);
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
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;
|
||||
requisition->width = child_requisition.width;
|
||||
*minimum = child_min;
|
||||
*natural = child_nat;
|
||||
}
|
||||
|
||||
if (priv->child2 && gtk_widget_get_visible (priv->child2))
|
||||
{
|
||||
gtk_widget_get_preferred_size (priv->child2,
|
||||
&child_requisition, NULL);
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
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,
|
||||
child_requisition.height);
|
||||
requisition->width += child_requisition.width;
|
||||
*minimum += child_min;
|
||||
*natural += child_nat;
|
||||
}
|
||||
else
|
||||
{
|
||||
requisition->width = MAX (requisition->width,
|
||||
child_requisition.width);
|
||||
requisition->height += child_requisition.height;
|
||||
*minimum = MAX (*minimum, child_min);
|
||||
*natural = MAX (*natural, child_nat);
|
||||
}
|
||||
}
|
||||
|
||||
@ -837,13 +846,30 @@ gtk_paned_size_request (GtkWidget *widget,
|
||||
|
||||
gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
|
||||
|
||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
requisition->width += handle_size;
|
||||
else
|
||||
requisition->height += handle_size;
|
||||
if (priv->orientation == orientation)
|
||||
{
|
||||
*minimum += 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
|
||||
flip_child (GtkWidget *widget,
|
||||
GtkAllocation *child_pos)
|
||||
|
110
gtk/gtkpathbar.c
110
gtk/gtkpathbar.c
@ -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_realize (GtkWidget *widget);
|
||||
static void gtk_path_bar_unrealize (GtkWidget *widget);
|
||||
static void gtk_path_bar_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_path_bar_get_preferred_width (GtkWidget *widget,
|
||||
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_unmap (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->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->unrealize = gtk_path_bar_unrealize;
|
||||
widget_class->map = gtk_path_bar_map;
|
||||
@ -315,46 +320,74 @@ gtk_path_bar_dispose (GObject *object)
|
||||
* available space.
|
||||
*/
|
||||
static void
|
||||
gtk_path_bar_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_path_bar_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
ButtonData *button_data;
|
||||
GtkPathBar *path_bar;
|
||||
GtkRequisition child_requisition;
|
||||
GList *list;
|
||||
gint child_height;
|
||||
gint height;
|
||||
gint child_min, child_nat;
|
||||
|
||||
path_bar = GTK_PATH_BAR (widget);
|
||||
|
||||
requisition->width = 0;
|
||||
requisition->height = 0;
|
||||
*minimum = *natural = 0;
|
||||
height = 0;
|
||||
|
||||
for (list = path_bar->button_list; list; list = list->next)
|
||||
{
|
||||
button_data = BUTTON_DATA (list->data);
|
||||
gtk_widget_get_preferred_size (button_data->button,
|
||||
&child_requisition, NULL);
|
||||
gtk_widget_get_preferred_width (button_data->button, &child_min, &child_nat);
|
||||
gtk_widget_get_preferred_height (button_data->button, &child_height, NULL);
|
||||
height = MAX (height, child_height);
|
||||
|
||||
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);
|
||||
else
|
||||
requisition->width = MAX (child_requisition.width, requisition->width);
|
||||
{
|
||||
/* Use 2*Height as button width because of ellipsized label. */
|
||||
child_min = MAX (child_min, child_height * 2);
|
||||
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 */
|
||||
/* Theoretically, the slider could be bigger than the other button. But we're
|
||||
* 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)
|
||||
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,
|
||||
&child_requisition, NULL);
|
||||
gtk_widget_get_preferred_size (path_bar->down_slider_button,
|
||||
&child_requisition, NULL);
|
||||
static void
|
||||
gtk_path_bar_get_preferred_height (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
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
|
||||
@ -1363,25 +1396,25 @@ get_dir_name (ButtonData *button_data)
|
||||
* or not the contents are bold
|
||||
*/
|
||||
static void
|
||||
label_size_request_cb (GtkWidget *widget,
|
||||
GtkRequisition *requisition,
|
||||
ButtonData *button_data)
|
||||
set_label_size_request (GtkWidget *alignment,
|
||||
ButtonData *button_data)
|
||||
{
|
||||
const gchar *dir_name = get_dir_name (button_data);
|
||||
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;
|
||||
|
||||
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);
|
||||
pango_layout_set_markup (layout, markup, -1);
|
||||
g_free (markup);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1509,18 +1542,19 @@ make_directory_button (GtkPathBar *path_bar,
|
||||
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->file = g_object_ref (file);
|
||||
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_widget_show_all (button_data->button);
|
||||
|
||||
|
@ -74,23 +74,28 @@ enum {
|
||||
PROP_ELLIPSIZE
|
||||
};
|
||||
|
||||
static void gtk_progress_bar_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_progress_bar_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_progress_bar_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_progress_bar_real_update (GtkProgressBar *progress);
|
||||
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);
|
||||
static void gtk_progress_bar_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_progress_bar_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_progress_bar_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural);
|
||||
static void gtk_progress_bar_get_preferred_height (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural);
|
||||
|
||||
static void gtk_progress_bar_real_update (GtkProgressBar *progress);
|
||||
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_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
|
||||
@ -109,11 +114,10 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
|
||||
gobject_class->finalize = gtk_progress_bar_finalize;
|
||||
|
||||
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,
|
||||
PROP_ORIENTATION,
|
||||
"orientation");
|
||||
g_object_class_override_property (gobject_class, PROP_ORIENTATION, "orientation");
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_INVERTED,
|
||||
@ -462,8 +466,9 @@ get_current_text (GtkProgressBar *pbar)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_progress_bar_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_progress_bar_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkProgressBar *pbar;
|
||||
GtkProgressBarPrivate *priv;
|
||||
@ -471,24 +476,21 @@ gtk_progress_bar_size_request (GtkWidget *widget,
|
||||
gchar *buf;
|
||||
PangoRectangle logical_rect;
|
||||
PangoLayout *layout;
|
||||
gint width, height;
|
||||
gint xspacing, yspacing;
|
||||
gint min_width, min_height;
|
||||
gint width;
|
||||
gint xspacing;
|
||||
gint min_width;
|
||||
|
||||
g_return_if_fail (GTK_IS_PROGRESS_BAR (widget));
|
||||
g_return_if_fail (requisition != NULL);
|
||||
|
||||
style = gtk_widget_get_style (widget);
|
||||
gtk_widget_style_get (widget,
|
||||
"xspacing", &xspacing,
|
||||
"yspacing", &yspacing,
|
||||
NULL);
|
||||
|
||||
pbar = GTK_PROGRESS_BAR (widget);
|
||||
priv = pbar->priv;
|
||||
|
||||
width = 2 * style->xthickness + xspacing;
|
||||
height = 2 * style->ythickness + yspacing;
|
||||
|
||||
if (priv->show_text)
|
||||
{
|
||||
@ -515,6 +517,56 @@ gtk_progress_bar_size_request (GtkWidget *widget,
|
||||
else
|
||||
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;
|
||||
|
||||
g_object_unref (layout);
|
||||
@ -523,17 +575,14 @@ gtk_progress_bar_size_request (GtkWidget *widget,
|
||||
|
||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
gtk_widget_style_get (widget,
|
||||
"min-horizontal-bar-width", &min_width,
|
||||
"min-horizontal-bar-height", &min_height,
|
||||
NULL);
|
||||
else
|
||||
gtk_widget_style_get (widget,
|
||||
"min-vertical-bar-width", &min_width,
|
||||
"min-vertical-bar-height", &min_height,
|
||||
NULL);
|
||||
|
||||
requisition->width = MAX (min_width, width);
|
||||
requisition->height = MAX (min_height, height);
|
||||
*minimum = *natural = MAX (min_height, height);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -182,8 +182,14 @@ static void gtk_range_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_range_destroy (GtkWidget *widget);
|
||||
static void gtk_range_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_range_get_preferred_width
|
||||
(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,
|
||||
GtkAllocation *allocation);
|
||||
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;
|
||||
|
||||
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->hierarchy_changed = gtk_range_hierarchy_changed;
|
||||
widget_class->realize = gtk_range_realize;
|
||||
@ -1550,16 +1557,17 @@ gtk_range_destroy (GtkWidget *widget)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_range_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_range_get_preferred_width (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,
|
||||
@ -1571,8 +1579,33 @@ gtk_range_size_request (GtkWidget *widget,
|
||||
focus_width, trough_border, stepper_spacing,
|
||||
&range_rect, &border, NULL, NULL, NULL, NULL);
|
||||
|
||||
requisition->width = range_rect.width + border.left + border.right;
|
||||
requisition->height = range_rect.height + border.top + border.bottom;
|
||||
*minimum = *natural = range_rect.width + border.left + border.right;
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -80,8 +80,14 @@ static void gtk_ruler_get_property (GObject *object,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_ruler_realize (GtkWidget *widget);
|
||||
static void gtk_ruler_unrealize (GtkWidget *widget);
|
||||
static void gtk_ruler_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_ruler_get_preferred_width
|
||||
(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,
|
||||
GtkAllocation *allocation);
|
||||
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->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->motion_notify_event = gtk_ruler_motion_notify;
|
||||
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_pos = gtk_ruler_real_draw_pos;
|
||||
|
||||
g_object_class_override_property (gobject_class,
|
||||
PROP_ORIENTATION,
|
||||
"orientation");
|
||||
g_object_class_override_property (gobject_class, PROP_ORIENTATION, "orientation");
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_LOWER,
|
||||
@ -532,25 +537,43 @@ gtk_ruler_unrealize (GtkWidget *widget)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_ruler_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_ruler_get_preferred_size (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkRuler *ruler = GTK_RULER (widget);
|
||||
GtkRulerPrivate *priv = ruler->priv;
|
||||
GtkStyle *style;
|
||||
gint thickness;
|
||||
|
||||
style = gtk_widget_get_style (widget);
|
||||
|
||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
requisition->width = style->xthickness * 2 + 1;
|
||||
requisition->height = style->ythickness * 2 + RULER_WIDTH;
|
||||
}
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
thickness = style->xthickness;
|
||||
else
|
||||
{
|
||||
requisition->width = style->xthickness * 2 + RULER_WIDTH;
|
||||
requisition->height = style->ythickness * 2 + 1;
|
||||
}
|
||||
thickness = style->ythickness;
|
||||
|
||||
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
|
||||
|
@ -116,8 +116,12 @@ static void gtk_scale_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_scale_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_scale_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkStyle *previous);
|
||||
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->screen_changed = gtk_scale_screen_changed;
|
||||
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->get_range_border = gtk_scale_get_range_border;
|
||||
@ -938,32 +943,54 @@ gtk_scale_screen_changed (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scale_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_scale_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkRange *range = GTK_RANGE (widget);
|
||||
gint n1, w1, h1, n2, w2, h2;
|
||||
gint slider_length;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_scale_parent_class)->size_request (widget, requisition);
|
||||
GTK_WIDGET_CLASS (gtk_scale_parent_class)->get_preferred_width (widget, minimum, natural);
|
||||
|
||||
gtk_widget_style_get (widget, "slider-length", &slider_length, NULL);
|
||||
|
||||
|
||||
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL)
|
||||
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == 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);
|
||||
|
||||
w1 = (n1 - 1) * w1 + MAX (w1, 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);
|
||||
h1 = (n1 - 1) * h1 + MAX (h1, 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,9 +61,14 @@ static void gtk_separator_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gtk_separator_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_separator_get_preferred_width
|
||||
(GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural);
|
||||
static void gtk_separator_get_preferred_height
|
||||
(GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural);
|
||||
static gboolean gtk_separator_draw (GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
|
||||
@ -82,12 +87,12 @@ gtk_separator_class_init (GtkSeparatorClass *class)
|
||||
object_class->set_property = gtk_separator_set_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;
|
||||
|
||||
g_object_class_override_property (object_class,
|
||||
PROP_ORIENTATION,
|
||||
"orientation");
|
||||
g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation");
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (GtkSeparatorPrivate));
|
||||
}
|
||||
@ -149,42 +154,55 @@ gtk_separator_get_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_separator_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_separator_get_preferred_size (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkSeparator *separator = GTK_SEPARATOR (widget);
|
||||
GtkSeparatorPrivate *private = separator->priv;
|
||||
GtkStyle *style;
|
||||
gboolean wide_separators;
|
||||
gint separator_width;
|
||||
gint separator_height;
|
||||
gboolean wide_sep;
|
||||
gint sep_width;
|
||||
gint sep_height;
|
||||
|
||||
style = gtk_widget_get_style (widget);
|
||||
gtk_widget_style_get (widget,
|
||||
"wide-separators", &wide_separators,
|
||||
"separator-width", &separator_width,
|
||||
"separator-height", &separator_height,
|
||||
"wide-separators", &wide_sep,
|
||||
"separator-width", &sep_width,
|
||||
"separator-height", &sep_height,
|
||||
NULL);
|
||||
|
||||
requisition->width = 1;
|
||||
requisition->height = 1;
|
||||
|
||||
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
if (orientation == private->orientation)
|
||||
{
|
||||
if (wide_separators)
|
||||
requisition->height = separator_height;
|
||||
else
|
||||
requisition->height = style->ythickness;
|
||||
*minimum = *natural = 1;
|
||||
}
|
||||
else if (orientation == GTK_ORIENTATION_VERTICAL)
|
||||
{
|
||||
*minimum = *natural = wide_sep ? sep_height : style->ythickness;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wide_separators)
|
||||
requisition->width = separator_width;
|
||||
else
|
||||
requisition->width = style->xthickness;
|
||||
*minimum = *natural = wide_sep ? sep_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
|
||||
gtk_separator_draw (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
|
@ -66,8 +66,12 @@ static void gtk_separator_tool_item_get_property (GObject
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_separator_tool_item_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_separator_tool_item_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->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->draw = gtk_separator_tool_item_draw;
|
||||
widget_class->realize = gtk_separator_tool_item_realize;
|
||||
@ -213,22 +218,37 @@ gtk_separator_tool_item_get_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_separator_tool_item_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_separator_tool_item_get_preferred_size (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkToolItem *item = GTK_TOOL_ITEM (widget);
|
||||
GtkOrientation orientation = gtk_tool_item_get_orientation (item);
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
requisition->width = get_space_size (item);
|
||||
requisition->height = 1;
|
||||
}
|
||||
if (gtk_tool_item_get_orientation (GTK_TOOL_ITEM (widget)) == orientation)
|
||||
*minimum = *natural = get_space_size (GTK_TOOL_ITEM (widget));
|
||||
else
|
||||
{
|
||||
requisition->height = get_space_size (item);
|
||||
requisition->width = 1;
|
||||
}
|
||||
*minimum = *natural = 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
|
||||
|
@ -118,8 +118,12 @@ static void gtk_socket_notify (GObject *object,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_socket_realize (GtkWidget *widget);
|
||||
static void gtk_socket_unrealize (GtkWidget *widget);
|
||||
static void gtk_socket_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_socket_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->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->hierarchy_changed = gtk_socket_hierarchy_changed;
|
||||
widget_class->grab_notify = gtk_socket_grab_notify;
|
||||
@ -452,30 +457,48 @@ gtk_socket_unrealize (GtkWidget *widget)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_socket_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_socket_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkSocket *socket = GTK_SOCKET (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
|
||||
{
|
||||
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)
|
||||
{
|
||||
requisition->width = MAX (socket->request_width, 1);
|
||||
requisition->height = MAX (socket->request_height, 1);
|
||||
}
|
||||
*minimum = *natural = MAX (socket->request_width, 1);
|
||||
else
|
||||
{
|
||||
requisition->width = 1;
|
||||
requisition->height = 1;
|
||||
}
|
||||
*minimum = *natural = 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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_realize (GtkWidget *widget);
|
||||
static void gtk_spin_button_unrealize (GtkWidget *widget);
|
||||
static void gtk_spin_button_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_spin_button_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural);
|
||||
|
||||
static void gtk_spin_button_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
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->realize = gtk_spin_button_realize;
|
||||
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->draw = gtk_spin_button_draw;
|
||||
widget_class->scroll_event = gtk_spin_button_scroll;
|
||||
@ -664,8 +666,9 @@ compute_double_length (double val, int digits)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_spin_button_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_spin_button_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
@ -694,23 +697,22 @@ gtk_spin_button_size_request (GtkWidget *widget,
|
||||
GtkBorder inner_border;
|
||||
|
||||
gtk_widget_style_get (widget,
|
||||
"interior-focus", &interior_focus,
|
||||
"focus-line-width", &focus_width,
|
||||
NULL);
|
||||
"interior-focus", &interior_focus,
|
||||
"focus-line-width", &focus_width,
|
||||
NULL);
|
||||
|
||||
context = gtk_widget_get_pango_context (widget);
|
||||
metrics = pango_context_get_metrics (context,
|
||||
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_SCALE *
|
||||
((digit_width + PANGO_SCALE - 1) / PANGO_SCALE);
|
||||
|
||||
pango_font_metrics_unref (metrics);
|
||||
|
||||
|
||||
/* Get max of MIN_SPIN_BUTTON_WIDTH, size of upper, size of lower */
|
||||
|
||||
width = MIN_SPIN_BUTTON_WIDTH;
|
||||
max_string_len = MAX (10, compute_double_length (1e9 * priv->adjustment->step_increment,
|
||||
priv->digits));
|
||||
@ -718,19 +720,22 @@ gtk_spin_button_size_request (GtkWidget *widget,
|
||||
string_len = compute_double_length (priv->adjustment->upper,
|
||||
priv->digits);
|
||||
w = PANGO_PIXELS (MIN (string_len, max_string_len) * digit_width);
|
||||
width = MAX (width, w);
|
||||
string_len = compute_double_length (priv->adjustment->lower,
|
||||
priv->digits);
|
||||
*minimum = MAX (*minimum, w);
|
||||
*natural = MAX (*natural, w);
|
||||
string_len = compute_double_length (priv->adjustment->lower, priv->digits);
|
||||
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_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
|
||||
|
@ -74,8 +74,12 @@ enum
|
||||
|
||||
|
||||
static void gtk_table_finalize (GObject *object);
|
||||
static void gtk_table_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_table_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->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->compute_expand = gtk_table_compute_expand;
|
||||
|
||||
@ -969,31 +974,52 @@ gtk_table_finalize (GObject *object)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_table_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_table_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkTable *table = GTK_TABLE (widget);
|
||||
GtkTablePrivate *priv = table->priv;
|
||||
gint row, col;
|
||||
|
||||
requisition->width = 0;
|
||||
requisition->height = 0;
|
||||
|
||||
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);
|
||||
|
||||
for (col = 0; col < priv->ncols; col++)
|
||||
requisition->width += priv->cols[col].requisition;
|
||||
for (col = 0; col + 1 < priv->ncols; col++)
|
||||
requisition->width += priv->cols[col].spacing;
|
||||
*minimum = 0;
|
||||
|
||||
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++)
|
||||
requisition->height += priv->rows[row].requisition;
|
||||
*minimum += priv->rows[row].requisition;
|
||||
for (row = 0; row + 1 < priv->nrows; row++)
|
||||
requisition->height += priv->rows[row].spacing;
|
||||
*minimum += priv->rows[row].spacing;
|
||||
|
||||
*natural = *minimum;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -39,13 +39,17 @@ struct _GtkTearoffMenuItemPrivate
|
||||
guint torn_off : 1;
|
||||
};
|
||||
|
||||
static void gtk_tearoff_menu_item_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
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);
|
||||
static void gtk_tearoff_menu_item_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural);
|
||||
static void gtk_tearoff_menu_item_get_preferred_height (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural);
|
||||
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)
|
||||
|
||||
@ -65,7 +69,8 @@ gtk_tearoff_menu_item_class_init (GtkTearoffMenuItemClass *klass)
|
||||
menu_item_class = (GtkMenuItemClass*) klass;
|
||||
|
||||
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;
|
||||
|
||||
menu_item_class->activate = gtk_tearoff_menu_item_activate;
|
||||
@ -87,8 +92,23 @@ gtk_tearoff_menu_item_init (GtkTearoffMenuItem *tearoff_menu_item)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tearoff_menu_item_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_tearoff_menu_item_get_preferred_width (GtkWidget *widget,
|
||||
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;
|
||||
GtkWidget *parent;
|
||||
@ -97,17 +117,18 @@ gtk_tearoff_menu_item_size_request (GtkWidget *widget,
|
||||
style = gtk_widget_get_style (widget);
|
||||
|
||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
||||
requisition->width = (border_width + style->xthickness + BORDER_SPACING) * 2;
|
||||
requisition->height = (border_width + style->ythickness) * 2;
|
||||
*minimum = *natural = (border_width + style->ythickness) * 2;
|
||||
|
||||
parent = gtk_widget_get_parent (widget);
|
||||
if (GTK_IS_MENU (parent) && GTK_MENU (parent)->torn_off)
|
||||
{
|
||||
requisition->height += ARROW_SIZE;
|
||||
*minimum += ARROW_SIZE;
|
||||
*natural += ARROW_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
requisition->height += style->ythickness + 4;
|
||||
*minimum += style->ythickness + 4;
|
||||
*natural += style->ythickness + 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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_size_request (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->grab_notify = gtk_text_view_grab_notify;
|
||||
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->event = gtk_text_view_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;
|
||||
}
|
||||
|
||||
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
|
||||
gtk_text_view_compute_child_allocation (GtkTextView *text_view,
|
||||
GtkTextViewChild *vc,
|
||||
@ -3889,7 +3921,7 @@ changed_handler (GtkTextLayout *layout,
|
||||
* to avoid the optimization which just returns widget->requisition
|
||||
* 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 ||
|
||||
old_req.height != new_req.height)
|
||||
|
@ -186,8 +186,13 @@ static gint gtk_toolbar_draw (GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
static void gtk_toolbar_realize (GtkWidget *widget);
|
||||
static void gtk_toolbar_unrealize (GtkWidget *widget);
|
||||
static void gtk_toolbar_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_toolbar_get_preferred_width (GtkWidget *widget,
|
||||
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,
|
||||
GtkAllocation *allocation);
|
||||
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->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->style_set = gtk_toolbar_style_set;
|
||||
widget_class->focus = gtk_toolbar_focus;
|
||||
@ -994,6 +1000,30 @@ gtk_toolbar_size_request (GtkWidget *widget,
|
||||
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
|
||||
position (GtkToolbar *toolbar,
|
||||
gint from,
|
||||
|
@ -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_map (GtkWidget *widget);
|
||||
static void gtk_tool_item_unmap (GtkWidget *widget);
|
||||
static void gtk_tool_item_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gtk_tool_item_get_preferred_width
|
||||
(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,
|
||||
GtkAllocation *allocation);
|
||||
|
||||
@ -163,7 +169,7 @@ gtk_tool_item_class_init (GtkToolItemClass *klass)
|
||||
|
||||
object_class = (GObjectClass *)klass;
|
||||
widget_class = (GtkWidgetClass *)klass;
|
||||
|
||||
|
||||
object_class->set_property = gtk_tool_item_set_property;
|
||||
object_class->get_property = gtk_tool_item_get_property;
|
||||
object_class->finalize = gtk_tool_item_finalize;
|
||||
@ -174,10 +180,13 @@ gtk_tool_item_class_init (GtkToolItemClass *klass)
|
||||
widget_class->unrealize = gtk_tool_item_unrealize;
|
||||
widget_class->map = gtk_tool_item_map;
|
||||
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->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;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
@ -403,20 +412,19 @@ create_drag_window (GtkToolItem *toolitem)
|
||||
GtkAllocation allocation;
|
||||
GtkWidget *widget;
|
||||
GdkWindowAttr attributes;
|
||||
gint attributes_mask, border_width;
|
||||
gint attributes_mask;
|
||||
|
||||
g_return_if_fail (toolitem->priv->use_drag_window == TRUE);
|
||||
|
||||
widget = GTK_WIDGET (toolitem);
|
||||
|
||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
|
||||
attributes.window_type = GDK_WINDOW_CHILD;
|
||||
attributes.x = allocation.x + border_width;
|
||||
attributes.y = allocation.y + border_width;
|
||||
attributes.width = allocation.width - border_width * 2;
|
||||
attributes.height = allocation.height - border_width * 2;
|
||||
attributes.x = allocation.x;
|
||||
attributes.y = allocation.y;
|
||||
attributes.width = allocation.width;
|
||||
attributes.height = allocation.height;
|
||||
attributes.wclass = GDK_INPUT_ONLY;
|
||||
attributes.event_mask = gtk_widget_get_events (widget);
|
||||
attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
|
||||
@ -493,26 +501,31 @@ gtk_tool_item_unmap (GtkWidget *widget)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tool_item_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
gtk_tool_item_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkWidget *child;
|
||||
guint border_width;
|
||||
|
||||
*minimum = *natural = 0;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||
if (child && gtk_widget_get_visible (child))
|
||||
{
|
||||
gtk_widget_get_preferred_size (child, requisition, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
requisition->height = 0;
|
||||
requisition->width = 0;
|
||||
}
|
||||
gtk_widget_get_preferred_width (child, minimum, natural);
|
||||
}
|
||||
|
||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
||||
requisition->width += border_width * 2;
|
||||
requisition->height += border_width * 2;
|
||||
static void
|
||||
gtk_tool_item_get_preferred_height (GtkWidget *widget,
|
||||
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
|
||||
@ -521,27 +534,24 @@ gtk_tool_item_size_allocate (GtkWidget *widget,
|
||||
{
|
||||
GtkToolItem *toolitem = GTK_TOOL_ITEM (widget);
|
||||
GtkAllocation child_allocation;
|
||||
gint border_width;
|
||||
GtkWidget *child;
|
||||
|
||||
gtk_widget_set_allocation (widget, allocation);
|
||||
|
||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
||||
|
||||
if (toolitem->priv->drag_window)
|
||||
gdk_window_move_resize (toolitem->priv->drag_window,
|
||||
allocation->x + border_width,
|
||||
allocation->y + border_width,
|
||||
allocation->width - border_width * 2,
|
||||
allocation->height - border_width * 2);
|
||||
allocation->x,
|
||||
allocation->y,
|
||||
allocation->width,
|
||||
allocation->height);
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||
if (child && gtk_widget_get_visible (child))
|
||||
{
|
||||
child_allocation.x = allocation->x + border_width;
|
||||
child_allocation.y = allocation->y + border_width;
|
||||
child_allocation.width = allocation->width - 2 * border_width;
|
||||
child_allocation.height = allocation->height - 2 * border_width;
|
||||
child_allocation.x = allocation->x;
|
||||
child_allocation.y = allocation->y;
|
||||
child_allocation.width = allocation->width;
|
||||
child_allocation.height = allocation->height;
|
||||
|
||||
gtk_widget_size_allocate (child, &child_allocation);
|
||||
}
|
||||
|
@ -307,15 +307,6 @@ gtk_tool_item_group_header_draw_cb (GtkWidget *widget,
|
||||
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
|
||||
gtk_tool_item_group_header_clicked_cb (GtkButton *button,
|
||||
gpointer data)
|
||||
@ -344,6 +335,8 @@ gtk_tool_item_group_header_adjust_style (GtkToolItemGroup *group)
|
||||
"header-spacing", &(priv->header_spacing),
|
||||
"expander-size", &(priv->expander_size),
|
||||
NULL);
|
||||
|
||||
gtk_widget_set_size_request (alignment, -1, priv->expander_size);
|
||||
|
||||
switch (gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group)))
|
||||
{
|
||||
@ -412,9 +405,6 @@ gtk_tool_item_group_init (GtkToolItemGroup *group)
|
||||
g_signal_connect_after (alignment, "draw",
|
||||
G_CALLBACK (gtk_tool_item_group_header_draw_cb),
|
||||
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_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;
|
||||
}
|
||||
|
||||
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
|
||||
gtk_tool_item_group_is_item_visible (GtkToolItemGroup *group,
|
||||
GtkToolItemGroupChild *child)
|
||||
@ -1552,12 +1567,13 @@ gtk_tool_item_group_class_init (GtkToolItemGroupClass *cls)
|
||||
oclass->finalize = gtk_tool_item_group_finalize;
|
||||
oclass->dispose = gtk_tool_item_group_dispose;
|
||||
|
||||
wclass->size_request = gtk_tool_item_group_size_request;
|
||||
wclass->size_allocate = gtk_tool_item_group_size_allocate;
|
||||
wclass->realize = gtk_tool_item_group_realize;
|
||||
wclass->unrealize = gtk_tool_item_group_unrealize;
|
||||
wclass->style_set = gtk_tool_item_group_style_set;
|
||||
wclass->screen_changed = gtk_tool_item_group_screen_changed;
|
||||
wclass->get_preferred_width = gtk_tool_item_group_get_preferred_width;
|
||||
wclass->get_preferred_height = gtk_tool_item_group_get_preferred_height;
|
||||
wclass->size_allocate = gtk_tool_item_group_size_allocate;
|
||||
wclass->realize = gtk_tool_item_group_realize;
|
||||
wclass->unrealize = gtk_tool_item_group_unrealize;
|
||||
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->remove = gtk_tool_item_group_remove;
|
||||
|
@ -435,6 +435,31 @@ gtk_tool_palette_size_request (GtkWidget *widget,
|
||||
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
|
||||
gtk_tool_palette_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
@ -961,7 +986,8 @@ gtk_tool_palette_class_init (GtkToolPaletteClass *cls)
|
||||
oclass->dispose = gtk_tool_palette_dispose;
|
||||
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->draw = gtk_tool_palette_draw;
|
||||
wclass->realize = gtk_tool_palette_realize;
|
||||
|
@ -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_unrealize (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,
|
||||
GtkRequisition *requisition);
|
||||
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->realize = gtk_tree_view_realize;
|
||||
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->button_press_event = gtk_tree_view_button_press;
|
||||
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);
|
||||
|
||||
tmp_list = tree_view->priv->children;
|
||||
}
|
||||
|
||||
while (tmp_list)
|
||||
{
|
||||
GtkTreeViewChild *child = tmp_list->data;
|
||||
GtkRequisition child_requisition;
|
||||
static void
|
||||
gtk_tree_view_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
GtkRequisition requisition;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
gtk_tree_view_size_request (widget, &requisition);
|
||||
|
||||
if (gtk_widget_get_visible (child->widget))
|
||||
gtk_widget_get_preferred_size (child->widget, &child_requisition, NULL);
|
||||
}
|
||||
*minimum = *natural = requisition.width;
|
||||
}
|
||||
|
||||
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
|
||||
@ -6332,12 +6352,23 @@ do_validate_rows (GtkTreeView *tree_view, gboolean queue_resize)
|
||||
if (validated_area)
|
||||
{
|
||||
GtkRequisition requisition;
|
||||
|
||||
/* 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
|
||||
* in an inconsistent state when we call top_row_to_dy. */
|
||||
|
||||
gtk_widget_get_preferred_size (GTK_WIDGET (tree_view),
|
||||
&requisition, NULL);
|
||||
/* FIXME: This is called from size_request, for some reason it is not infinitely
|
||||
* 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->vadjustment->upper = MAX (tree_view->priv->vadjustment->upper, (gfloat)requisition.height);
|
||||
gtk_adjustment_changed (tree_view->priv->hadjustment);
|
||||
|
@ -701,7 +701,7 @@ main (gint argc, gchar **argv)
|
||||
add_item_to_list (store, item, "Video");
|
||||
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");
|
||||
add_item_to_list (store, item, "Terminal");
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
|
||||
|
Loading…
Reference in New Issue
Block a user