forked from AuroraMiddleware/gtk
Mass api change from GtkExtendedLayout --> GtkSizeRequest
This commit makes a few massive changes to the extended layout code: a.) gtkextendedlayout.c --> gtksizerequest.c b.) _is_height_for_width --> get_request_mode() c.) get_desired_size(), get_desired_width(), get_desired_height() --> get_size(), get_width(), get_height() This is the first partial commit and only effects portions of the tree that have already been merged in master (in order to easily cherry pick this commit). Conflicts: gtk/Makefile.am gtk/gtk.h gtk/gtk.symbols gtk/gtkextendedlayout.h
This commit is contained in:
parent
cf75457faa
commit
edd57602b8
@ -214,7 +214,6 @@ gtk_public_h_sources = \
|
||||
gtkenums.h \
|
||||
gtkeventbox.h \
|
||||
gtkexpander.h \
|
||||
gtkextendedlayout.h \
|
||||
gtkfilechooser.h \
|
||||
gtkfilechooserbutton.h \
|
||||
gtkfilechooserdialog.h \
|
||||
@ -299,6 +298,7 @@ gtk_public_h_sources = \
|
||||
gtkshow.h \
|
||||
gtksettings.h \
|
||||
gtksizegroup.h \
|
||||
gtksizerequest.h \
|
||||
gtksocket.h \
|
||||
gtkspinbutton.h \
|
||||
gtkspinner.h \
|
||||
@ -470,7 +470,6 @@ gtk_base_c_sources = \
|
||||
gtkentrycompletion.c \
|
||||
gtkeventbox.c \
|
||||
gtkexpander.c \
|
||||
gtkextendedlayout.c \
|
||||
gtkfilechooser.c \
|
||||
gtkfilechooserbutton.c \
|
||||
gtkfilechooserdefault.c \
|
||||
@ -570,6 +569,7 @@ gtk_base_c_sources = \
|
||||
gtkseparatortoolitem.c \
|
||||
gtksettings.c \
|
||||
gtksizegroup.c \
|
||||
gtksizerequest.c \
|
||||
gtkshow.c \
|
||||
gtksocket.c \
|
||||
gtkspinbutton.c \
|
||||
|
@ -84,7 +84,6 @@
|
||||
#include <gtk/gtkenums.h>
|
||||
#include <gtk/gtkeventbox.h>
|
||||
#include <gtk/gtkexpander.h>
|
||||
#include <gtk/gtkextendedlayout.h>
|
||||
#include <gtk/gtkfixed.h>
|
||||
#include <gtk/gtkfilechooser.h>
|
||||
#include <gtk/gtkfilechooserbutton.h>
|
||||
@ -167,6 +166,7 @@
|
||||
#include <gtk/gtksettings.h>
|
||||
#include <gtk/gtkshow.h>
|
||||
#include <gtk/gtksizegroup.h>
|
||||
#include <gtk/gtksizerequest.h>
|
||||
#include <gtk/gtksocket.h>
|
||||
#include <gtk/gtkspinbutton.h>
|
||||
#include <gtk/gtkspinner.h>
|
||||
|
@ -1218,18 +1218,6 @@ gtk_expander_set_use_underline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_EXTENDED_LAYOUT_H__)
|
||||
#if IN_FILE(__GTK_EXTENDED_LAYOUT_C__)
|
||||
gtk_extended_layout_get_type G_GNUC_CONST
|
||||
gtk_extended_layout_get_desired_height
|
||||
gtk_extended_layout_get_desired_size
|
||||
gtk_extended_layout_get_desired_width
|
||||
gtk_extended_layout_get_height_for_width
|
||||
gtk_extended_layout_get_width_for_height
|
||||
gtk_extended_layout_is_height_for_width
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_FILE_CHOOSER_H__)
|
||||
#if IN_FILE(__GTK_FILE_CHOOSER_C__)
|
||||
gtk_file_chooser_add_filter
|
||||
@ -3183,6 +3171,18 @@ gtk_size_group_set_mode
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_SIZE_REQUEST_H__)
|
||||
#if IN_FILE(__GTK_SIZE_REQUEST_C__)
|
||||
gtk_size_request_get_height
|
||||
gtk_size_request_get_height_for_width
|
||||
gtk_size_request_get_request_mode
|
||||
gtk_size_request_get_size
|
||||
gtk_size_request_get_type G_GNUC_CONST
|
||||
gtk_size_request_get_width
|
||||
gtk_size_request_get_width_for_height
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_SHOW_H__)
|
||||
#if IN_FILE(__GTK_SHOW_C__)
|
||||
gtk_show_uri
|
||||
|
@ -45,7 +45,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "gtkalignment.h"
|
||||
#include "gtkextendedlayout.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkalias.h"
|
||||
@ -85,17 +85,17 @@ static void gtk_alignment_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gtk_alignment_extended_layout_init (GtkExtendedLayoutIface *iface);
|
||||
static void gtk_alignment_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_alignment_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_alignment_size_request_init (GtkSizeRequestIface *iface);
|
||||
static void gtk_alignment_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_alignment_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkAlignment, gtk_alignment, GTK_TYPE_BIN,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
|
||||
gtk_alignment_extended_layout_init))
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
|
||||
gtk_alignment_size_request_init))
|
||||
|
||||
static void
|
||||
gtk_alignment_class_init (GtkAlignmentClass *class)
|
||||
@ -491,7 +491,7 @@ gtk_alignment_size_allocate (GtkWidget *widget,
|
||||
|
||||
if (bin->child && gtk_widget_get_visible (bin->child))
|
||||
{
|
||||
GtkExtendedLayout *layout = GTK_EXTENDED_LAYOUT (bin->child);
|
||||
GtkSizeRequest *child = GTK_SIZE_REQUEST (bin->child);
|
||||
gint child_nat_width;
|
||||
gint child_nat_height;
|
||||
gint child_width, child_height;
|
||||
@ -505,23 +505,23 @@ gtk_alignment_size_allocate (GtkWidget *widget,
|
||||
width = MAX (1, allocation->width - padding_horizontal - 2 * border_width);
|
||||
height = MAX (1, allocation->height - padding_vertical - 2 * border_width);
|
||||
|
||||
if (gtk_extended_layout_is_height_for_width (layout))
|
||||
if (gtk_size_request_get_request_mode (child) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
|
||||
{
|
||||
gtk_extended_layout_get_desired_width (layout, NULL, &child_nat_width);
|
||||
gtk_size_request_get_width (child, NULL, &child_nat_width);
|
||||
|
||||
child_width = MIN (width, child_nat_width);
|
||||
|
||||
gtk_extended_layout_get_height_for_width (layout, child_width, NULL, &child_nat_height);
|
||||
gtk_size_request_get_height_for_width (child, child_width, NULL, &child_nat_height);
|
||||
|
||||
child_height = MIN (height, child_nat_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_extended_layout_get_desired_height (layout, NULL, &child_nat_height);
|
||||
gtk_size_request_get_height (child, NULL, &child_nat_height);
|
||||
|
||||
child_height = MIN (height, child_nat_height);
|
||||
|
||||
gtk_extended_layout_get_width_for_height (layout, child_height, NULL, &child_nat_width);
|
||||
gtk_size_request_get_width_for_height (child, child_height, NULL, &child_nat_width);
|
||||
|
||||
child_width = MIN (width, child_nat_width);
|
||||
}
|
||||
@ -553,27 +553,27 @@ gtk_alignment_size_allocate (GtkWidget *widget,
|
||||
|
||||
|
||||
static void
|
||||
gtk_alignment_extended_layout_init (GtkExtendedLayoutIface *iface)
|
||||
gtk_alignment_size_request_init (GtkSizeRequestIface *iface)
|
||||
{
|
||||
iface->get_desired_width = gtk_alignment_get_desired_width;
|
||||
iface->get_desired_height = gtk_alignment_get_desired_height;
|
||||
iface->get_width = gtk_alignment_get_width;
|
||||
iface->get_height = gtk_alignment_get_height;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_alignment_get_desired_size (GtkExtendedLayout *layout,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_alignment_get_size (GtkSizeRequest *widget,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
GtkWidget *child;
|
||||
GtkAlignmentPrivate *priv;
|
||||
gint minimum, natural;
|
||||
|
||||
priv = GTK_ALIGNMENT_GET_PRIVATE (layout);
|
||||
priv = GTK_ALIGNMENT_GET_PRIVATE (widget);
|
||||
|
||||
natural = minimum = GTK_CONTAINER (layout)->border_width * 2;
|
||||
natural = minimum = GTK_CONTAINER (widget)->border_width * 2;
|
||||
|
||||
if ((child = gtk_bin_get_child (GTK_BIN (layout))) && gtk_widget_get_visible (child))
|
||||
if ((child = gtk_bin_get_child (GTK_BIN (widget))) && gtk_widget_get_visible (child))
|
||||
{
|
||||
gint child_min, child_nat;
|
||||
|
||||
@ -581,14 +581,14 @@ gtk_alignment_get_desired_size (GtkExtendedLayout *layout,
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
minimum += (priv->padding_left + priv->padding_right);
|
||||
gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child),
|
||||
&child_min, &child_nat);
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (child),
|
||||
&child_min, &child_nat);
|
||||
}
|
||||
else
|
||||
{
|
||||
minimum += (priv->padding_top + priv->padding_bottom);
|
||||
gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child),
|
||||
&child_min, &child_nat);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (child),
|
||||
&child_min, &child_nat);
|
||||
}
|
||||
|
||||
natural = minimum;
|
||||
@ -605,19 +605,19 @@ gtk_alignment_get_desired_size (GtkExtendedLayout *layout,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_alignment_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_alignment_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_alignment_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
gtk_alignment_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_alignment_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_alignment_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_alignment_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
gtk_alignment_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
/**
|
||||
|
82
gtk/gtkbin.c
82
gtk/gtkbin.c
@ -39,7 +39,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "gtkbin.h"
|
||||
#include "gtkextendedlayout.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
@ -54,22 +54,22 @@ static void gtk_bin_forall (GtkContainer *container,
|
||||
static GType gtk_bin_child_type (GtkContainer *container);
|
||||
|
||||
|
||||
static void gtk_bin_extended_layout_init (GtkExtendedLayoutIface *iface);
|
||||
static gboolean gtk_bin_is_height_for_width (GtkExtendedLayout *layout);
|
||||
static void gtk_bin_get_width_for_height (GtkExtendedLayout *layout,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
static void gtk_bin_get_height_for_width (GtkExtendedLayout *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
static void gtk_bin_size_request_init (GtkSizeRequestIface *iface);
|
||||
static GtkSizeRequestMode gtk_bin_get_request_mode (GtkSizeRequest *widget);
|
||||
static void gtk_bin_get_width_for_height (GtkSizeRequest *widget,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
static void gtk_bin_get_height_for_width (GtkSizeRequest *widget,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
|
||||
static GtkExtendedLayoutIface *parent_extended_layout_iface;
|
||||
static GtkSizeRequestIface *parent_size_request_iface;
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GtkBin, gtk_bin, GTK_TYPE_CONTAINER,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
|
||||
gtk_bin_extended_layout_init))
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
|
||||
gtk_bin_size_request_init))
|
||||
|
||||
static void
|
||||
gtk_bin_class_init (GtkBinClass *class)
|
||||
@ -159,7 +159,7 @@ gtk_bin_forall (GtkContainer *container,
|
||||
|
||||
|
||||
/* GtkBin widgets define the padding and borders independantly so
|
||||
* we cannot provide a generic get_desired_size() for the same reason
|
||||
* we cannot provide a generic get_size() for the same reason
|
||||
* we never implemented size_request() here.
|
||||
*
|
||||
* But for cases where the GtkBin class's padding is constant and
|
||||
@ -168,24 +168,24 @@ gtk_bin_forall (GtkContainer *container,
|
||||
* cases by using the delta of the base size requsts.
|
||||
*/
|
||||
static void
|
||||
gtk_bin_extended_layout_init (GtkExtendedLayoutIface *iface)
|
||||
gtk_bin_size_request_init (GtkSizeRequestIface *iface)
|
||||
{
|
||||
parent_extended_layout_iface = g_type_interface_peek_parent (iface);
|
||||
parent_size_request_iface = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->is_height_for_width = gtk_bin_is_height_for_width;
|
||||
iface->get_request_mode = gtk_bin_get_request_mode;
|
||||
iface->get_width_for_height = gtk_bin_get_width_for_height;
|
||||
iface->get_height_for_width = gtk_bin_get_height_for_width;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_bin_is_height_for_width (GtkExtendedLayout *layout)
|
||||
static GtkSizeRequestMode
|
||||
gtk_bin_get_request_mode (GtkSizeRequest *widget)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN (layout);
|
||||
GtkBin *bin = GTK_BIN (widget);
|
||||
|
||||
if (bin->child)
|
||||
return gtk_extended_layout_is_height_for_width (GTK_EXTENDED_LAYOUT (bin->child));
|
||||
return gtk_size_request_get_request_mode (GTK_SIZE_REQUEST (bin->child));
|
||||
|
||||
return TRUE;
|
||||
return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -195,30 +195,30 @@ get_child_padding_delta (GtkBin *bin,
|
||||
{
|
||||
gint hmin, vmin, child_hmin, child_vmin;
|
||||
|
||||
gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (bin), &hmin, NULL);
|
||||
gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (bin), &vmin, NULL);
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (bin), &hmin, NULL);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (bin), &vmin, NULL);
|
||||
|
||||
gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (bin->child), &child_hmin, NULL);
|
||||
gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (bin->child), &child_vmin, NULL);
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (bin->child), &child_hmin, NULL);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (bin->child), &child_vmin, NULL);
|
||||
|
||||
*delta_h = hmin - child_hmin;
|
||||
*delta_v = vmin - child_vmin;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_bin_get_width_for_height (GtkExtendedLayout *layout,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width)
|
||||
gtk_bin_get_width_for_height (GtkSizeRequest *widget,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN (layout);
|
||||
GtkBin *bin = GTK_BIN (widget);
|
||||
gint hdelta, vdelta, child_min, child_nat;
|
||||
|
||||
if (bin->child)
|
||||
{
|
||||
get_child_padding_delta (bin, &hdelta, &vdelta);
|
||||
|
||||
gtk_extended_layout_get_width_for_height (GTK_EXTENDED_LAYOUT (bin->child),
|
||||
gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (bin->child),
|
||||
height - vdelta,
|
||||
&child_min, &child_nat);
|
||||
|
||||
@ -229,23 +229,23 @@ gtk_bin_get_width_for_height (GtkExtendedLayout *layout,
|
||||
*natural_width = child_nat + hdelta;
|
||||
}
|
||||
else
|
||||
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_width (layout, minimum_width, natural_width);
|
||||
GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width (widget, minimum_width, natural_width);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_bin_get_height_for_width (GtkExtendedLayout *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height)
|
||||
gtk_bin_get_height_for_width (GtkSizeRequest *widget,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN (layout);
|
||||
GtkBin *bin = GTK_BIN (widget);
|
||||
gint hdelta, vdelta, child_min, child_nat;
|
||||
|
||||
if (bin->child)
|
||||
{
|
||||
get_child_padding_delta (bin, &hdelta, &vdelta);
|
||||
|
||||
gtk_extended_layout_get_height_for_width (GTK_EXTENDED_LAYOUT (bin->child),
|
||||
gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (bin->child),
|
||||
width - hdelta,
|
||||
&child_min, &child_nat);
|
||||
|
||||
@ -256,7 +256,7 @@ gtk_bin_get_height_for_width (GtkExtendedLayout *layout,
|
||||
*natural_height = child_nat + vdelta;
|
||||
}
|
||||
else
|
||||
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_height (layout, minimum_height, natural_height);
|
||||
GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height (widget, minimum_height, natural_height);
|
||||
}
|
||||
|
||||
|
||||
|
141
gtk/gtkbox.c
141
gtk/gtkbox.c
@ -77,7 +77,7 @@
|
||||
|
||||
#include "gtkbox.h"
|
||||
#include "gtkorientable.h"
|
||||
#include "gtkextendedlayout.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkalias.h"
|
||||
@ -158,30 +158,30 @@ static void gtk_box_get_child_property (GtkContainer *container,
|
||||
static GType gtk_box_child_type (GtkContainer *container);
|
||||
|
||||
|
||||
static void gtk_box_extended_layout_init (GtkExtendedLayoutIface *iface);
|
||||
static gboolean gtk_box_is_height_for_width (GtkExtendedLayout *layout);
|
||||
static void gtk_box_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_box_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_box_get_width_for_height (GtkExtendedLayout *layout,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
static void gtk_box_get_height_for_width (GtkExtendedLayout *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
static void gtk_box_size_request_init (GtkSizeRequestIface *iface);
|
||||
static GtkSizeRequestMode gtk_box_get_request_mode (GtkSizeRequest *widget);
|
||||
static void gtk_box_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_box_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_box_get_width_for_height (GtkSizeRequest *widget,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
static void gtk_box_get_height_for_width (GtkSizeRequest *widget,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
|
||||
static GtkExtendedLayoutIface *parent_extended_layout_iface;
|
||||
static GtkSizeRequestIface *parent_size_request_iface;
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkBox, gtk_box, GTK_TYPE_CONTAINER,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE,
|
||||
NULL)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
|
||||
gtk_box_extended_layout_init));
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
|
||||
gtk_box_size_request_init));
|
||||
|
||||
static void
|
||||
gtk_box_class_init (GtkBoxClass *class)
|
||||
@ -445,12 +445,12 @@ gtk_box_size_allocate (GtkWidget *widget,
|
||||
if (gtk_widget_get_visible (child->widget))
|
||||
{
|
||||
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
gtk_extended_layout_get_width_for_height (GTK_EXTENDED_LAYOUT (child->widget),
|
||||
gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget),
|
||||
allocation->height,
|
||||
&sizes[i].minimum_size,
|
||||
&sizes[i].natural_size);
|
||||
else
|
||||
gtk_extended_layout_get_height_for_width (GTK_EXTENDED_LAYOUT (child->widget),
|
||||
gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget),
|
||||
allocation->width,
|
||||
&sizes[i].minimum_size,
|
||||
&sizes[i].natural_size);
|
||||
@ -835,30 +835,31 @@ gtk_box_pack (GtkBox *box,
|
||||
|
||||
|
||||
static void
|
||||
gtk_box_extended_layout_init (GtkExtendedLayoutIface *iface)
|
||||
gtk_box_size_request_init (GtkSizeRequestIface *iface)
|
||||
{
|
||||
parent_extended_layout_iface = g_type_interface_peek_parent (iface);
|
||||
parent_size_request_iface = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->is_height_for_width = gtk_box_is_height_for_width;
|
||||
iface->get_desired_width = gtk_box_get_desired_width;
|
||||
iface->get_desired_height = gtk_box_get_desired_height;
|
||||
iface->get_request_mode = gtk_box_get_request_mode;
|
||||
iface->get_width = gtk_box_get_width;
|
||||
iface->get_height = gtk_box_get_height;
|
||||
iface->get_height_for_width = gtk_box_get_height_for_width;
|
||||
iface->get_width_for_height = gtk_box_get_width_for_height;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_box_is_height_for_width (GtkExtendedLayout *layout)
|
||||
static GtkSizeRequestMode
|
||||
gtk_box_get_request_mode (GtkSizeRequest *widget)
|
||||
{
|
||||
GtkBoxPrivate *private = GTK_BOX_GET_PRIVATE (layout);
|
||||
GtkBoxPrivate *private = GTK_BOX_GET_PRIVATE (widget);
|
||||
|
||||
return (private->orientation == GTK_ORIENTATION_VERTICAL);
|
||||
return (private->orientation == GTK_ORIENTATION_VERTICAL) ?
|
||||
GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH : GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_box_get_desired_size (GtkExtendedLayout *layout,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_box_get_size (GtkSizeRequest *widget,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
GtkBox *box;
|
||||
GtkBoxPrivate *private;
|
||||
@ -867,7 +868,7 @@ gtk_box_get_desired_size (GtkExtendedLayout *layout,
|
||||
gint border_width;
|
||||
gint minimum, natural;
|
||||
|
||||
box = GTK_BOX (layout);
|
||||
box = GTK_BOX (widget);
|
||||
private = GTK_BOX_GET_PRIVATE (box);
|
||||
border_width = GTK_CONTAINER (box)->border_width;
|
||||
|
||||
@ -884,11 +885,11 @@ gtk_box_get_desired_size (GtkExtendedLayout *layout,
|
||||
gint child_minimum, child_natural;
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child->widget),
|
||||
&child_minimum, &child_natural);
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget),
|
||||
&child_minimum, &child_natural);
|
||||
else
|
||||
gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child->widget),
|
||||
&child_minimum, &child_natural);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget),
|
||||
&child_minimum, &child_natural);
|
||||
|
||||
if (private->orientation == orientation)
|
||||
{
|
||||
@ -941,19 +942,19 @@ gtk_box_get_desired_size (GtkExtendedLayout *layout,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_box_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_box_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_box_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
gtk_box_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_box_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_box_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_box_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
gtk_box_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -991,13 +992,13 @@ gtk_box_compute_size_for_opposing_orientation (GtkBox *box,
|
||||
if (gtk_widget_get_visible (child->widget))
|
||||
{
|
||||
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child->widget),
|
||||
&sizes[i].minimum_size,
|
||||
&sizes[i].natural_size);
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget),
|
||||
&sizes[i].minimum_size,
|
||||
&sizes[i].natural_size);
|
||||
else
|
||||
gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child->widget),
|
||||
&sizes[i].minimum_size,
|
||||
&sizes[i].natural_size);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget),
|
||||
&sizes[i].minimum_size,
|
||||
&sizes[i].natural_size);
|
||||
|
||||
/* Assert the api is working properly */
|
||||
if (sizes[i].minimum_size < 0)
|
||||
@ -1135,10 +1136,10 @@ gtk_box_compute_size_for_opposing_orientation (GtkBox *box,
|
||||
|
||||
/* Assign the child's position. */
|
||||
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
gtk_extended_layout_get_height_for_width (GTK_EXTENDED_LAYOUT (child->widget),
|
||||
gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget),
|
||||
child_size, &child_minimum, &child_natural);
|
||||
else /* (private->orientation == GTK_ORIENTATION_VERTICAL) */
|
||||
gtk_extended_layout_get_width_for_height (GTK_EXTENDED_LAYOUT (child->widget),
|
||||
gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget),
|
||||
child_size, &child_minimum, &child_natural);
|
||||
|
||||
|
||||
@ -1183,10 +1184,10 @@ gtk_box_compute_size_for_orientation (GtkBox *box,
|
||||
{
|
||||
|
||||
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
gtk_extended_layout_get_width_for_height (GTK_EXTENDED_LAYOUT (child->widget),
|
||||
gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget),
|
||||
avail_size, &child_size, &child_natural);
|
||||
else
|
||||
gtk_extended_layout_get_height_for_width (GTK_EXTENDED_LAYOUT (child->widget),
|
||||
gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget),
|
||||
avail_size, &child_size, &child_natural);
|
||||
|
||||
|
||||
@ -1227,13 +1228,13 @@ gtk_box_compute_size_for_orientation (GtkBox *box,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_box_get_width_for_height (GtkExtendedLayout *layout,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width)
|
||||
gtk_box_get_width_for_height (GtkSizeRequest *widget,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width)
|
||||
{
|
||||
GtkBox *box = GTK_BOX (layout);
|
||||
GtkBoxPrivate *private = GTK_BOX_GET_PRIVATE (layout);
|
||||
GtkBox *box = GTK_BOX (widget);
|
||||
GtkBoxPrivate *private = GTK_BOX_GET_PRIVATE (widget);
|
||||
|
||||
if (private->orientation == GTK_ORIENTATION_VERTICAL)
|
||||
gtk_box_compute_size_for_opposing_orientation (box, height, minimum_width, natural_width);
|
||||
@ -1242,13 +1243,13 @@ gtk_box_get_width_for_height (GtkExtendedLayout *layout,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_box_get_height_for_width (GtkExtendedLayout *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height)
|
||||
gtk_box_get_height_for_width (GtkSizeRequest *widget,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height)
|
||||
{
|
||||
GtkBox *box = GTK_BOX (layout);
|
||||
GtkBoxPrivate *private = GTK_BOX_GET_PRIVATE (layout);
|
||||
GtkBox *box = GTK_BOX (widget);
|
||||
GtkBoxPrivate *private = GTK_BOX_GET_PRIVATE (widget);
|
||||
|
||||
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
gtk_box_compute_size_for_opposing_orientation (box, width, minimum_height, natural_height);
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "gtkstock.h"
|
||||
#include "gtkiconfactory.h"
|
||||
#include "gtkactivatable.h"
|
||||
#include "gtkextendedlayout.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkalias.h"
|
||||
@ -158,21 +158,21 @@ static void gtk_button_set_related_action (GtkButton *button,
|
||||
static void gtk_button_set_use_action_appearance (GtkButton *button,
|
||||
gboolean use_appearance);
|
||||
|
||||
static void gtk_button_extended_layout_init (GtkExtendedLayoutIface *iface);
|
||||
static void gtk_button_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_button_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_button_size_request_init (GtkSizeRequestIface *iface);
|
||||
static void gtk_button_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_button_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
|
||||
static guint button_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkButton, gtk_button, GTK_TYPE_BIN,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
|
||||
gtk_button_activatable_interface_init)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
|
||||
gtk_button_extended_layout_init))
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
|
||||
gtk_button_size_request_init))
|
||||
|
||||
static void
|
||||
gtk_button_class_init (GtkButtonClass *klass)
|
||||
@ -1776,19 +1776,19 @@ gtk_button_finish_activate (GtkButton *button,
|
||||
|
||||
|
||||
static void
|
||||
gtk_button_extended_layout_init (GtkExtendedLayoutIface *iface)
|
||||
gtk_button_size_request_init (GtkSizeRequestIface *iface)
|
||||
{
|
||||
iface->get_desired_width = gtk_button_get_desired_width;
|
||||
iface->get_desired_height = gtk_button_get_desired_height;
|
||||
iface->get_width = gtk_button_get_width;
|
||||
iface->get_height = gtk_button_get_height;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_button_get_desired_size (GtkExtendedLayout *layout,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_button_get_size (GtkSizeRequest *widget,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
GtkButton *button = GTK_BUTTON (layout);
|
||||
GtkButton *button = GTK_BUTTON (widget);
|
||||
GtkWidget *child;
|
||||
GtkBorder default_border;
|
||||
GtkBorder inner_border;
|
||||
@ -1797,27 +1797,27 @@ gtk_button_get_desired_size (GtkExtendedLayout *layout,
|
||||
gint minimum, natural;
|
||||
|
||||
gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL);
|
||||
gtk_widget_style_get (GTK_WIDGET (layout),
|
||||
gtk_widget_style_get (GTK_WIDGET (widget),
|
||||
"focus-line-width", &focus_width,
|
||||
"focus-padding", &focus_pad,
|
||||
NULL);
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
minimum = ((GTK_CONTAINER (layout)->border_width +
|
||||
GTK_WIDGET (layout)->style->xthickness) * 2 +
|
||||
minimum = ((GTK_CONTAINER (widget)->border_width +
|
||||
GTK_WIDGET (widget)->style->xthickness) * 2 +
|
||||
inner_border.left + inner_border.right);
|
||||
|
||||
if (gtk_widget_get_can_default (GTK_WIDGET (layout)))
|
||||
if (gtk_widget_get_can_default (GTK_WIDGET (widget)))
|
||||
minimum += default_border.left + default_border.right;
|
||||
}
|
||||
else
|
||||
{
|
||||
minimum = ((GTK_CONTAINER (layout)->border_width +
|
||||
GTK_WIDGET (layout)->style->ythickness) * 2 +
|
||||
minimum = ((GTK_CONTAINER (widget)->border_width +
|
||||
GTK_WIDGET (widget)->style->ythickness) * 2 +
|
||||
inner_border.top + inner_border.bottom);
|
||||
|
||||
if (gtk_widget_get_can_default (GTK_WIDGET (layout)))
|
||||
if (gtk_widget_get_can_default (GTK_WIDGET (widget)))
|
||||
minimum += default_border.top + default_border.bottom;
|
||||
}
|
||||
|
||||
@ -1830,11 +1830,11 @@ gtk_button_get_desired_size (GtkExtendedLayout *layout,
|
||||
gint child_min, child_nat;
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child),
|
||||
&child_min, &child_nat);
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (child),
|
||||
&child_min, &child_nat);
|
||||
else
|
||||
gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child),
|
||||
&child_min, &child_nat);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (child),
|
||||
&child_min, &child_nat);
|
||||
|
||||
minimum += child_min;
|
||||
natural += child_nat;
|
||||
@ -1848,19 +1848,19 @@ gtk_button_get_desired_size (GtkExtendedLayout *layout,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_button_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_button_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_button_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
gtk_button_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_button_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_button_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_button_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
gtk_button_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -546,6 +546,21 @@ typedef enum
|
||||
GTK_DRAG_RESULT_ERROR
|
||||
} GtkDragResult;
|
||||
|
||||
/**
|
||||
* GtkSizeRequestMode:
|
||||
* @GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH: Prefer height-for-width geometry management
|
||||
* @GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT: Prefer width-for-height geometry management
|
||||
*
|
||||
* Specifies a preference for height-for-width or
|
||||
* width-for-height geometry management.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH = 0,
|
||||
GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT,
|
||||
} GtkSizeRequestMode;
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_ENUMS_H__ */
|
||||
|
@ -1,89 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2007-2010 Openismus GmbH
|
||||
*
|
||||
* Authors:
|
||||
* Mathias Hasselmann <mathias@openismus.com>
|
||||
* Tristan Van Berkom <tristan.van.berkom@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_EXTENDED_LAYOUT_H__
|
||||
#define __GTK_EXTENDED_LAYOUT_H__
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_EXTENDED_LAYOUT (gtk_extended_layout_get_type ())
|
||||
#define GTK_EXTENDED_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_EXTENDED_LAYOUT, GtkExtendedLayout))
|
||||
#define GTK_EXTENDED_LAYOUT_CLASS(klass) ((GtkExtendedLayoutIface*)g_type_interface_peek ((klass), GTK_TYPE_EXTENDED_LAYOUT))
|
||||
#define GTK_IS_EXTENDED_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_EXTENDED_LAYOUT))
|
||||
#define GTK_EXTENDED_LAYOUT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_EXTENDED_LAYOUT, GtkExtendedLayoutIface))
|
||||
|
||||
typedef struct _GtkExtendedLayout GtkExtendedLayout;
|
||||
typedef struct _GtkExtendedLayoutIface GtkExtendedLayoutIface;
|
||||
|
||||
struct _GtkExtendedLayoutIface
|
||||
{
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* virtual table */
|
||||
gboolean (* is_height_for_width) (GtkExtendedLayout *layout);
|
||||
|
||||
void (* get_desired_width) (GtkExtendedLayout *layout,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
void (* get_desired_height) (GtkExtendedLayout *layout,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
void (* get_width_for_height) (GtkExtendedLayout *layout,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
void (* get_height_for_width) (GtkExtendedLayout *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
};
|
||||
|
||||
GType gtk_extended_layout_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gtk_extended_layout_is_height_for_width (GtkExtendedLayout *layout);
|
||||
void gtk_extended_layout_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
void gtk_extended_layout_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
void gtk_extended_layout_get_width_for_height (GtkExtendedLayout *layout,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
void gtk_extended_layout_get_height_for_width (GtkExtendedLayout *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
|
||||
void gtk_extended_layout_get_desired_size (GtkExtendedLayout *layout,
|
||||
gboolean request_natural,
|
||||
GtkRequisition *minimum_size,
|
||||
GtkRequisition *natural_size);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_EXTENDED_LAYOUT_H__ */
|
@ -31,7 +31,7 @@
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkextendedlayout.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
#define LABEL_PAD 1
|
||||
@ -80,19 +80,19 @@ static void gtk_frame_buildable_add_child (GtkBuildable *buildable,
|
||||
GObject *child,
|
||||
const gchar *type);
|
||||
|
||||
static void gtk_frame_extended_layout_init (GtkExtendedLayoutIface *iface);
|
||||
static void gtk_frame_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_frame_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_frame_size_request_init (GtkSizeRequestIface *iface);
|
||||
static void gtk_frame_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_frame_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkFrame, gtk_frame, GTK_TYPE_BIN,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
||||
gtk_frame_buildable_init)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
|
||||
gtk_frame_extended_layout_init))
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
|
||||
gtk_frame_size_request_init))
|
||||
|
||||
static void
|
||||
gtk_frame_class_init (GtkFrameClass *class)
|
||||
@ -705,12 +705,12 @@ gtk_frame_real_compute_child_allocation (GtkFrame *frame,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_frame_get_desired_size (GtkExtendedLayout *layout,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_frame_get_size (GtkSizeRequest *request,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (layout);
|
||||
GtkWidget *widget = GTK_WIDGET (request);
|
||||
GtkFrame *frame = GTK_FRAME (widget);
|
||||
GtkBin *bin = GTK_BIN (widget);
|
||||
gint child_min, child_nat;
|
||||
@ -720,15 +720,15 @@ gtk_frame_get_desired_size (GtkExtendedLayout *layout,
|
||||
{
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (frame->label_widget),
|
||||
&child_min, &child_nat);
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (frame->label_widget),
|
||||
&child_min, &child_nat);
|
||||
minimum = child_min + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
|
||||
natural = child_nat + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (frame->label_widget),
|
||||
&child_min, &child_nat);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (frame->label_widget),
|
||||
&child_min, &child_nat);
|
||||
minimum = MAX (0, child_min - widget->style->ythickness);
|
||||
natural = MAX (0, child_nat - widget->style->ythickness);
|
||||
}
|
||||
@ -743,15 +743,15 @@ gtk_frame_get_desired_size (GtkExtendedLayout *layout,
|
||||
{
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (bin->child),
|
||||
&child_min, &child_nat);
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (bin->child),
|
||||
&child_min, &child_nat);
|
||||
minimum = MAX (minimum, child_min);
|
||||
natural = MAX (natural, child_nat);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (bin->child),
|
||||
&child_min, &child_nat);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (bin->child),
|
||||
&child_min, &child_nat);
|
||||
minimum += child_min;
|
||||
natural += child_nat;
|
||||
}
|
||||
@ -780,26 +780,26 @@ gtk_frame_get_desired_size (GtkExtendedLayout *layout,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_frame_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_frame_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_frame_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
gtk_frame_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_frame_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_frame_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_frame_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
gtk_frame_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_frame_extended_layout_init (GtkExtendedLayoutIface *iface)
|
||||
gtk_frame_size_request_init (GtkSizeRequestIface *iface)
|
||||
{
|
||||
iface->get_desired_width = gtk_frame_get_desired_width;
|
||||
iface->get_desired_height = gtk_frame_get_desired_height;
|
||||
iface->get_width = gtk_frame_get_width;
|
||||
iface->get_height = gtk_frame_get_height;
|
||||
}
|
||||
|
||||
#define __GTK_FRAME_C__
|
||||
|
108
gtk/gtklabel.c
108
gtk/gtklabel.c
@ -48,7 +48,7 @@
|
||||
#include "gtkimage.h"
|
||||
#include "gtkshow.h"
|
||||
#include "gtktooltip.h"
|
||||
#include "gtkextendedlayout.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
@ -305,22 +305,22 @@ static void gtk_label_get_link_colors (GtkWidget *widget,
|
||||
static void emit_activate_link (GtkLabel *label,
|
||||
GtkLabelLink *link);
|
||||
|
||||
static void gtk_label_extended_layout_init (GtkExtendedLayoutIface *iface);
|
||||
static gboolean gtk_label_is_height_for_width (GtkExtendedLayout *layout);
|
||||
static void gtk_label_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_label_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_label_get_width_for_height (GtkExtendedLayout *layout,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
static void gtk_label_get_height_for_width (GtkExtendedLayout *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
static void gtk_label_size_request_init (GtkSizeRequestIface *iface);
|
||||
static GtkSizeRequestMode gtk_label_get_request_mode (GtkSizeRequest *widget);
|
||||
static void gtk_label_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_label_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_label_get_width_for_height (GtkSizeRequest *widget,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
static void gtk_label_get_height_for_width (GtkSizeRequest *widget,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
|
||||
static GQuark quark_angle = 0;
|
||||
|
||||
@ -329,8 +329,8 @@ static GtkBuildableIface *buildable_parent_iface = NULL;
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkLabel, gtk_label, GTK_TYPE_MISC,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
||||
gtk_label_buildable_interface_init)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
|
||||
gtk_label_extended_layout_init));
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
|
||||
gtk_label_size_request_init));
|
||||
|
||||
static void
|
||||
add_move_binding (GtkBindingSet *binding_set,
|
||||
@ -3271,25 +3271,25 @@ get_single_line_height (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_label_extended_layout_init (GtkExtendedLayoutIface *iface)
|
||||
gtk_label_size_request_init (GtkSizeRequestIface *iface)
|
||||
{
|
||||
iface->is_height_for_width = gtk_label_is_height_for_width;
|
||||
iface->get_desired_width = gtk_label_get_desired_width;
|
||||
iface->get_desired_height = gtk_label_get_desired_height;
|
||||
iface->get_request_mode = gtk_label_get_request_mode;
|
||||
iface->get_width = gtk_label_get_width;
|
||||
iface->get_height = gtk_label_get_height;
|
||||
iface->get_width_for_height = gtk_label_get_width_for_height;
|
||||
iface->get_height_for_width = gtk_label_get_height_for_width;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_label_is_height_for_width (GtkExtendedLayout *layout)
|
||||
static GtkSizeRequestMode
|
||||
gtk_label_get_request_mode (GtkSizeRequest *layout)
|
||||
{
|
||||
GtkLabel *label = GTK_LABEL (layout);
|
||||
gdouble angle = gtk_label_get_angle (label);
|
||||
|
||||
if (angle == 90 || angle == 270)
|
||||
return FALSE;
|
||||
return GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT;
|
||||
|
||||
return TRUE;
|
||||
return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3335,12 +3335,12 @@ get_size_for_allocation (GtkLabel *label,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_label_get_desired_size (GtkExtendedLayout *layout,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_label_get_size (GtkSizeRequest *widget,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
GtkLabel *label = GTK_LABEL (layout);
|
||||
GtkLabel *label = GTK_LABEL (widget);
|
||||
PangoRectangle required_rect;
|
||||
PangoRectangle natural_rect;
|
||||
gdouble angle;
|
||||
@ -3481,32 +3481,28 @@ gtk_label_get_desired_size (GtkExtendedLayout *layout,
|
||||
|
||||
|
||||
static void
|
||||
gtk_label_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_label_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_label_get_desired_size (layout,
|
||||
GTK_ORIENTATION_HORIZONTAL,
|
||||
minimum_size, natural_size);
|
||||
gtk_label_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_label_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_label_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_label_get_desired_size (layout,
|
||||
GTK_ORIENTATION_VERTICAL,
|
||||
minimum_size, natural_size);
|
||||
gtk_label_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_label_get_width_for_height (GtkExtendedLayout *layout,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width)
|
||||
gtk_label_get_width_for_height (GtkSizeRequest *widget,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width)
|
||||
{
|
||||
GtkLabel *label = GTK_LABEL (layout);
|
||||
GtkLabel *label = GTK_LABEL (widget);
|
||||
gdouble angle = gtk_label_get_angle (label);
|
||||
|
||||
if (label->wrap && (angle == 90 || angle == 270))
|
||||
@ -3525,16 +3521,16 @@ gtk_label_get_width_for_height (GtkExtendedLayout *layout,
|
||||
*natural_width += label->misc.xpad * 2;
|
||||
}
|
||||
else
|
||||
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_width (layout, minimum_width, natural_width);
|
||||
GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width (widget, minimum_width, natural_width);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_label_get_height_for_width (GtkExtendedLayout *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height)
|
||||
gtk_label_get_height_for_width (GtkSizeRequest *widget,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height)
|
||||
{
|
||||
GtkLabel *label = GTK_LABEL (layout);
|
||||
GtkLabel *label = GTK_LABEL (widget);
|
||||
gdouble angle = gtk_label_get_angle (label);
|
||||
|
||||
if (label->wrap && (angle == 0 || angle == 180 || angle == 360))
|
||||
@ -3553,7 +3549,7 @@ gtk_label_get_height_for_width (GtkExtendedLayout *layout,
|
||||
*natural_height += label->misc.ypad * 2;
|
||||
}
|
||||
else
|
||||
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_height (layout, minimum_height, natural_height);
|
||||
GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height (widget, minimum_height, natural_height);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <math.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkextendedlayout.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkscrolledwindow.h"
|
||||
#include "gtkwindow.h"
|
||||
@ -141,27 +141,27 @@ static void gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjus
|
||||
|
||||
static void gtk_scrolled_window_update_real_placement (GtkScrolledWindow *scrolled_window);
|
||||
|
||||
static void gtk_scrolled_window_extended_layout_init (GtkExtendedLayoutIface *iface);
|
||||
static void gtk_scrolled_window_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_scrolled_window_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_scrolled_window_get_height_for_width (GtkExtendedLayout *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
static void gtk_scrolled_window_get_width_for_height (GtkExtendedLayout *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
static void gtk_scrolled_window_size_request_init (GtkSizeRequestIface *iface);
|
||||
static void gtk_scrolled_window_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_scrolled_window_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_scrolled_window_get_height_for_width (GtkSizeRequest *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
static void gtk_scrolled_window_get_width_for_height (GtkSizeRequest *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
|
||||
static guint signals[LAST_SIGNAL] = {0};
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkScrolledWindow, gtk_scrolled_window, GTK_TYPE_BIN,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
|
||||
gtk_scrolled_window_extended_layout_init))
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
|
||||
gtk_scrolled_window_size_request_init))
|
||||
|
||||
|
||||
static void
|
||||
@ -1718,19 +1718,19 @@ _gtk_scrolled_window_get_scrollbar_spacing (GtkScrolledWindow *scrolled_window)
|
||||
|
||||
|
||||
static void
|
||||
gtk_scrolled_window_extended_layout_init (GtkExtendedLayoutIface *iface)
|
||||
gtk_scrolled_window_size_request_init (GtkSizeRequestIface *iface)
|
||||
{
|
||||
iface->get_desired_width = gtk_scrolled_window_get_desired_width;
|
||||
iface->get_desired_height = gtk_scrolled_window_get_desired_height;
|
||||
iface->get_width = gtk_scrolled_window_get_width;
|
||||
iface->get_height = gtk_scrolled_window_get_height;
|
||||
iface->get_height_for_width = gtk_scrolled_window_get_height_for_width;
|
||||
iface->get_width_for_height = gtk_scrolled_window_get_width_for_height;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scrolled_window_get_desired_size (GtkExtendedLayout *layout,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_scrolled_window_get_size (GtkSizeRequest *widget,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
GtkScrolledWindow *scrolled_window;
|
||||
GtkBin *bin;
|
||||
@ -1742,7 +1742,7 @@ gtk_scrolled_window_get_desired_size (GtkExtendedLayout *layout,
|
||||
GtkRequisition minimum_req, natural_req;
|
||||
gint min_child_size, nat_child_size;
|
||||
|
||||
scrolled_window = GTK_SCROLLED_WINDOW (layout);
|
||||
scrolled_window = GTK_SCROLLED_WINDOW (widget);
|
||||
bin = GTK_BIN (scrolled_window);
|
||||
|
||||
scrollbar_spacing = _gtk_scrolled_window_get_scrollbar_spacing (scrolled_window);
|
||||
@ -1763,9 +1763,9 @@ gtk_scrolled_window_get_desired_size (GtkExtendedLayout *layout,
|
||||
{
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (bin->child),
|
||||
&min_child_size,
|
||||
&nat_child_size);
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (bin->child),
|
||||
&min_child_size,
|
||||
&nat_child_size);
|
||||
|
||||
if (scrolled_window->hscrollbar_policy == GTK_POLICY_NEVER)
|
||||
{
|
||||
@ -1791,9 +1791,9 @@ gtk_scrolled_window_get_desired_size (GtkExtendedLayout *layout,
|
||||
}
|
||||
else /* GTK_ORIENTATION_VERTICAL */
|
||||
{
|
||||
gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (bin->child),
|
||||
&min_child_size,
|
||||
&nat_child_size);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (bin->child),
|
||||
&min_child_size,
|
||||
&nat_child_size);
|
||||
|
||||
if (scrolled_window->vscrollbar_policy == GTK_POLICY_NEVER)
|
||||
{
|
||||
@ -1837,17 +1837,17 @@ gtk_scrolled_window_get_desired_size (GtkExtendedLayout *layout,
|
||||
extra_width = scrollbar_spacing + vscrollbar_requisition.width;
|
||||
}
|
||||
|
||||
minimum_req.width += GTK_CONTAINER (layout)->border_width * 2 + MAX (0, extra_width);
|
||||
minimum_req.height += GTK_CONTAINER (layout)->border_width * 2 + MAX (0, extra_height);
|
||||
natural_req.width += GTK_CONTAINER (layout)->border_width * 2 + MAX (0, extra_width);
|
||||
natural_req.height += GTK_CONTAINER (layout)->border_width * 2 + MAX (0, extra_height);
|
||||
minimum_req.width += GTK_CONTAINER (widget)->border_width * 2 + MAX (0, extra_width);
|
||||
minimum_req.height += GTK_CONTAINER (widget)->border_width * 2 + MAX (0, extra_height);
|
||||
natural_req.width += GTK_CONTAINER (widget)->border_width * 2 + MAX (0, extra_width);
|
||||
natural_req.height += GTK_CONTAINER (widget)->border_width * 2 + MAX (0, extra_height);
|
||||
|
||||
if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
|
||||
{
|
||||
minimum_req.width += 2 * GTK_WIDGET (layout)->style->xthickness;
|
||||
minimum_req.height += 2 * GTK_WIDGET (layout)->style->ythickness;
|
||||
natural_req.width += 2 * GTK_WIDGET (layout)->style->xthickness;
|
||||
natural_req.height += 2 * GTK_WIDGET (layout)->style->ythickness;
|
||||
minimum_req.width += 2 * GTK_WIDGET (widget)->style->xthickness;
|
||||
minimum_req.height += 2 * GTK_WIDGET (widget)->style->ythickness;
|
||||
natural_req.width += 2 * GTK_WIDGET (widget)->style->xthickness;
|
||||
natural_req.height += 2 * GTK_WIDGET (widget)->style->ythickness;
|
||||
}
|
||||
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
@ -1867,41 +1867,41 @@ gtk_scrolled_window_get_desired_size (GtkExtendedLayout *layout,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scrolled_window_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_scrolled_window_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_scrolled_window_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
gtk_scrolled_window_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scrolled_window_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_scrolled_window_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_scrolled_window_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
gtk_scrolled_window_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scrolled_window_get_height_for_width (GtkExtendedLayout *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height)
|
||||
gtk_scrolled_window_get_height_for_width (GtkSizeRequest *widget,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET (layout));
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_height (layout, minimum_height, natural_height);
|
||||
GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height (widget, minimum_height, natural_height);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scrolled_window_get_width_for_height (GtkExtendedLayout *layout,
|
||||
gtk_scrolled_window_get_width_for_height (GtkSizeRequest *widget,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET (layout));
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_width (layout, minimum_width, natural_width);
|
||||
GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width (widget, minimum_width, natural_width);
|
||||
}
|
||||
|
||||
#define __GTK_SCROLLED_WINDOW_C__
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksizegroup.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkextendedlayout.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
enum {
|
||||
@ -630,7 +630,7 @@ get_base_dimension (GtkWidget *widget,
|
||||
/* XXX Possibly we should be using natural values and not minimums here. */
|
||||
gint width;
|
||||
|
||||
gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (widget), &width, NULL);
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (widget), &width, NULL);
|
||||
|
||||
return width;
|
||||
}
|
||||
@ -644,7 +644,7 @@ get_base_dimension (GtkWidget *widget,
|
||||
/* XXX Possibly we should be using natural values and not minimums here. */
|
||||
gint height;
|
||||
|
||||
gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (widget), &height, NULL);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (widget), &height, NULL);
|
||||
|
||||
return height;
|
||||
}
|
||||
@ -741,7 +741,7 @@ compute_dimension (GtkWidget *widget,
|
||||
* value in the dimension @mode.
|
||||
*
|
||||
* This function is used to update sizegroup minimum size information
|
||||
* in multiple passes from the new #GtkExtendedLayout manager.
|
||||
* in multiple passes from the new #GtkSizeRequest manager.
|
||||
*/
|
||||
gint
|
||||
_gtk_size_group_bump_requisition (GtkWidget *widget,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* gtkextendedlayout.c
|
||||
/* gtksizerequest.c
|
||||
* Copyright (C) 2007-2010 Openismus GmbH
|
||||
*
|
||||
* Authors:
|
||||
@ -23,11 +23,11 @@
|
||||
|
||||
|
||||
/**
|
||||
* SECTION:gtkextendedlayout
|
||||
* SECTION:gtksizerequest
|
||||
* @Short_Description: Height-for-width geometry management
|
||||
* @Title: GtkExtendedLayout
|
||||
* @Title: GtkSizeRequest
|
||||
*
|
||||
* The extended layout is GTK+'s height-for-width (and width-for-height)
|
||||
* The GtkSizeGroup interface is GTK+'s height-for-width (and width-for-height)
|
||||
* geometry management system. Height-for-width means that a widget can
|
||||
* change how much vertical space it needs, depending on the amount
|
||||
* of horizontal space that it is given (and similar for width-for-height).
|
||||
@ -36,16 +36,17 @@
|
||||
*
|
||||
* GTK+'s traditional two-pass <link linkend="size-allocation">size-allocation</link>
|
||||
* algorithm does not allow this flexibility. #GtkWidget provides a default
|
||||
* implementation of the #GtkExtendedLayout interface for existing widgets,
|
||||
* implementation of the #GtkSizeGroup interface for existing widgets,
|
||||
* which always requests the same height, regardless of the available width.
|
||||
*
|
||||
* <refsect2>
|
||||
* <title>Implementing GtkExtendedLayout</title>
|
||||
* <title>Implementing GtkSizeRequest</title>
|
||||
* <para>
|
||||
* Some important things to keep in mind when implementing
|
||||
* or using the extended layout.
|
||||
* the GtkSizeRequest interface and when using it in container
|
||||
* implementations.
|
||||
*
|
||||
* The Extended Layout system will query a logical hierarchy in
|
||||
* The geometry management system will query a logical hierarchy in
|
||||
* only one orientation at a time. When widgets are initially queried
|
||||
* for their minimum sizes it is generally done in a dual pass
|
||||
* in the direction chosen by the toplevel.
|
||||
@ -53,10 +54,10 @@
|
||||
* For instance when queried in the normal height-for-width mode:
|
||||
* First the default minimum and natural width for each widget
|
||||
* in the interface will computed and collectively returned to
|
||||
* the toplevel by way of gtk_extended_layout_get_desired_width().
|
||||
* the toplevel by way of gtk_size_request_get_desired_width().
|
||||
* Next, the toplevel will use the minimum width to query for the
|
||||
* minimum height contextual to that width using
|
||||
* gtk_extended_layout_get_height_for_width(), which will also be a
|
||||
* gtk_size_request_get_height_for_width(), which will also be a
|
||||
* highly recursive operation. This minimum-for-minimum size can be
|
||||
* used to set the minimum size constraint on the toplevel.
|
||||
*
|
||||
@ -66,13 +67,13 @@
|
||||
*
|
||||
* That means that the request operation at allocation time will
|
||||
* usually fire again in contexts of different allocated sizes than
|
||||
* the ones originally queried for. #GtkExtendedLayout caches a
|
||||
* the ones originally queried for. #GtkSizeRequest caches a
|
||||
* small number of results to avoid re-querying for the same
|
||||
* allocated size in one allocation cycle.
|
||||
*
|
||||
* A widget that does not actually do height-for-width
|
||||
* or width-for-height size negotiations only has to implement
|
||||
* get_desired_width() and get_desired_height().
|
||||
* get_width() and get_height().
|
||||
*
|
||||
* If a widget does move content around to smartly use up the
|
||||
* allocated size, then it must support the request properly in
|
||||
@ -80,7 +81,7 @@
|
||||
* one orientation.
|
||||
*
|
||||
* For instance, a GtkLabel that does height-for-width word wrapping
|
||||
* will not expect to have get_desired_height() called because that
|
||||
* will not expect to have get_height() called because that
|
||||
* call is specific to a width-for-height request, in this case the
|
||||
* label must return the heights contextual to its minimum possible
|
||||
* width. By following this rule any widget that handles height-for-width
|
||||
@ -92,13 +93,13 @@
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "gtkextendedlayout.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtksizegroup.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
/* With extended layout, a widget may be requested
|
||||
/* With GtkSizeRequest, a widget may be requested
|
||||
* its width for 2 or maximum 3 heights in one resize
|
||||
*/
|
||||
#define N_CACHED_SIZES 3
|
||||
@ -109,36 +110,36 @@ typedef struct
|
||||
gint for_size;
|
||||
gint minimum_size;
|
||||
gint natural_size;
|
||||
} DesiredSize;
|
||||
} SizeRequest;
|
||||
|
||||
typedef struct {
|
||||
DesiredSize desired_widths[N_CACHED_SIZES];
|
||||
DesiredSize desired_heights[N_CACHED_SIZES];
|
||||
SizeRequest widths[N_CACHED_SIZES];
|
||||
SizeRequest heights[N_CACHED_SIZES];
|
||||
guint8 cached_width_age;
|
||||
guint8 cached_height_age;
|
||||
} ExtendedLayoutCache;
|
||||
} SizeRequestCache;
|
||||
|
||||
static GQuark quark_cache = 0;
|
||||
|
||||
|
||||
GType
|
||||
gtk_extended_layout_get_type (void)
|
||||
gtk_size_request_get_type (void)
|
||||
{
|
||||
static GType extended_layout_type = 0;
|
||||
static GType size_request_type = 0;
|
||||
|
||||
if (G_UNLIKELY(!extended_layout_type))
|
||||
if (G_UNLIKELY(!size_request_type))
|
||||
{
|
||||
extended_layout_type =
|
||||
g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkExtendedLayout"),
|
||||
sizeof (GtkExtendedLayoutIface),
|
||||
size_request_type =
|
||||
g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkSizeRequest"),
|
||||
sizeof (GtkSizeRequestIface),
|
||||
NULL, 0, NULL, 0);
|
||||
|
||||
g_type_interface_add_prerequisite (extended_layout_type, GTK_TYPE_WIDGET);
|
||||
g_type_interface_add_prerequisite (size_request_type, GTK_TYPE_WIDGET);
|
||||
|
||||
quark_cache = g_quark_from_static_string ("gtk-extended-layout-cache");
|
||||
quark_cache = g_quark_from_static_string ("gtk-size-request-cache");
|
||||
}
|
||||
|
||||
return extended_layout_type;
|
||||
return size_request_type;
|
||||
}
|
||||
|
||||
/* looks for a cached size request for this for_size. If not
|
||||
@ -148,9 +149,9 @@ gtk_extended_layout_get_type (void)
|
||||
* the Clutter toolkit.
|
||||
*/
|
||||
static gboolean
|
||||
get_cached_desired_size (gint for_size,
|
||||
DesiredSize *cached_sizes,
|
||||
DesiredSize **result)
|
||||
get_cached_size (gint for_size,
|
||||
SizeRequest *cached_sizes,
|
||||
SizeRequest **result)
|
||||
{
|
||||
guint i;
|
||||
|
||||
@ -158,7 +159,7 @@ get_cached_desired_size (gint for_size,
|
||||
|
||||
for (i = 0; i < N_CACHED_SIZES; i++)
|
||||
{
|
||||
DesiredSize *cs;
|
||||
SizeRequest *cs;
|
||||
|
||||
cs = &cached_sizes[i];
|
||||
|
||||
@ -177,26 +178,26 @@ get_cached_desired_size (gint for_size,
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_cache (ExtendedLayoutCache *cache)
|
||||
destroy_cache (SizeRequestCache *cache)
|
||||
{
|
||||
g_slice_free (ExtendedLayoutCache, cache);
|
||||
g_slice_free (SizeRequestCache, cache);
|
||||
}
|
||||
|
||||
static ExtendedLayoutCache *
|
||||
get_cache (GtkExtendedLayout *layout,
|
||||
gboolean create)
|
||||
static SizeRequestCache *
|
||||
get_cache (GtkSizeRequest *widget,
|
||||
gboolean create)
|
||||
{
|
||||
ExtendedLayoutCache *cache;
|
||||
SizeRequestCache *cache;
|
||||
|
||||
cache = g_object_get_qdata (G_OBJECT (layout), quark_cache);
|
||||
cache = g_object_get_qdata (G_OBJECT (widget), quark_cache);
|
||||
if (!cache && create)
|
||||
{
|
||||
cache = g_slice_new0 (ExtendedLayoutCache);
|
||||
cache = g_slice_new0 (SizeRequestCache);
|
||||
|
||||
cache->cached_width_age = 1;
|
||||
cache->cached_height_age = 1;
|
||||
|
||||
g_object_set_qdata_full (G_OBJECT (layout), quark_cache, cache,
|
||||
g_object_set_qdata_full (G_OBJECT (widget), quark_cache, cache,
|
||||
(GDestroyNotify)destroy_cache);
|
||||
}
|
||||
|
||||
@ -218,44 +219,44 @@ do_size_request (GtkWidget *widget)
|
||||
}
|
||||
|
||||
static void
|
||||
compute_size_for_orientation (GtkExtendedLayout *layout,
|
||||
compute_size_for_orientation (GtkSizeRequest *request,
|
||||
GtkSizeGroupMode orientation,
|
||||
gint for_size,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
ExtendedLayoutCache *cache;
|
||||
DesiredSize *cached_size;
|
||||
GtkWidget *widget;
|
||||
gboolean found_in_cache = FALSE;
|
||||
SizeRequestCache *cache;
|
||||
SizeRequest *cached_size;
|
||||
GtkWidget *widget;
|
||||
gboolean found_in_cache = FALSE;
|
||||
|
||||
g_return_if_fail (GTK_IS_EXTENDED_LAYOUT (layout));
|
||||
g_return_if_fail (GTK_IS_SIZE_REQUEST (request));
|
||||
g_return_if_fail (minimum_size != NULL || natural_size != NULL);
|
||||
|
||||
widget = GTK_WIDGET (layout);
|
||||
cache = get_cache (layout, TRUE);
|
||||
widget = GTK_WIDGET (request);
|
||||
cache = get_cache (request, TRUE);
|
||||
|
||||
if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
|
||||
{
|
||||
cached_size = &cache->desired_widths[0];
|
||||
cached_size = &cache->widths[0];
|
||||
|
||||
if (!GTK_WIDGET_WIDTH_REQUEST_NEEDED (layout))
|
||||
found_in_cache = get_cached_desired_size (for_size, cache->desired_widths, &cached_size);
|
||||
if (!GTK_WIDGET_WIDTH_REQUEST_NEEDED (request))
|
||||
found_in_cache = get_cached_size (for_size, cache->widths, &cached_size);
|
||||
else
|
||||
{
|
||||
memset (cache->desired_widths, 0, N_CACHED_SIZES * sizeof (DesiredSize));
|
||||
memset (cache->widths, 0, N_CACHED_SIZES * sizeof (SizeRequest));
|
||||
cache->cached_width_age = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cached_size = &cache->desired_heights[0];
|
||||
cached_size = &cache->heights[0];
|
||||
|
||||
if (!GTK_WIDGET_HEIGHT_REQUEST_NEEDED (layout))
|
||||
found_in_cache = get_cached_desired_size (for_size, cache->desired_heights, &cached_size);
|
||||
if (!GTK_WIDGET_HEIGHT_REQUEST_NEEDED (request))
|
||||
found_in_cache = get_cached_size (for_size, cache->heights, &cached_size);
|
||||
else
|
||||
{
|
||||
memset (cache->desired_heights, 0, N_CACHED_SIZES * sizeof (DesiredSize));
|
||||
memset (cache->heights, 0, N_CACHED_SIZES * sizeof (SizeRequest));
|
||||
cache->cached_height_age = 1;
|
||||
}
|
||||
}
|
||||
@ -273,22 +274,24 @@ compute_size_for_orientation (GtkExtendedLayout *layout,
|
||||
requisition_size = widget->requisition.width;
|
||||
|
||||
if (for_size < 0)
|
||||
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_width (layout, &min_size, &nat_size);
|
||||
GTK_SIZE_REQUEST_GET_IFACE (request)->get_width (request, &min_size, &nat_size);
|
||||
else
|
||||
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_width_for_height (layout, for_size, &min_size, &nat_size);
|
||||
GTK_SIZE_REQUEST_GET_IFACE (request)->get_width_for_height (request, for_size,
|
||||
&min_size, &nat_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
requisition_size = widget->requisition.height;
|
||||
|
||||
if (for_size < 0)
|
||||
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_desired_height (layout, &min_size, &nat_size);
|
||||
GTK_SIZE_REQUEST_GET_IFACE (request)->get_height (request, &min_size, &nat_size);
|
||||
else
|
||||
GTK_EXTENDED_LAYOUT_GET_IFACE (layout)->get_height_for_width (layout, for_size, &min_size, &nat_size);
|
||||
GTK_SIZE_REQUEST_GET_IFACE (request)->get_height_for_width (request, for_size,
|
||||
&min_size, &nat_size);
|
||||
}
|
||||
|
||||
/* Support for dangling "size-request" signals and forward derived
|
||||
* classes that will not default to a ->get_desired_width() that
|
||||
* classes that will not default to a ->get_width() that
|
||||
* returns the values in the ->requisition cache.
|
||||
*/
|
||||
min_size = MAX (min_size, requisition_size);
|
||||
@ -303,14 +306,14 @@ compute_size_for_orientation (GtkExtendedLayout *layout,
|
||||
cached_size->age = cache->cached_width_age;
|
||||
cache->cached_width_age++;
|
||||
|
||||
GTK_PRIVATE_UNSET_FLAG (layout, GTK_WIDTH_REQUEST_NEEDED);
|
||||
GTK_PRIVATE_UNSET_FLAG (request, GTK_WIDTH_REQUEST_NEEDED);
|
||||
}
|
||||
else
|
||||
{
|
||||
cached_size->age = cache->cached_height_age;
|
||||
cache->cached_height_age++;
|
||||
|
||||
GTK_PRIVATE_UNSET_FLAG (layout, GTK_HEIGHT_REQUEST_NEEDED);
|
||||
GTK_PRIVATE_UNSET_FLAG (request, GTK_HEIGHT_REQUEST_NEEDED);
|
||||
}
|
||||
|
||||
/* Get size groups to compute the base requisition once one
|
||||
@ -321,7 +324,7 @@ compute_size_for_orientation (GtkExtendedLayout *layout,
|
||||
* are considered.
|
||||
*/
|
||||
group_size =
|
||||
_gtk_size_group_bump_requisition (GTK_WIDGET (layout),
|
||||
_gtk_size_group_bump_requisition (GTK_WIDGET (request),
|
||||
orientation, cached_size->minimum_size);
|
||||
|
||||
cached_size->minimum_size = MAX (cached_size->minimum_size, group_size);
|
||||
@ -336,9 +339,9 @@ compute_size_for_orientation (GtkExtendedLayout *layout,
|
||||
|
||||
g_assert (cached_size->minimum_size <= cached_size->natural_size);
|
||||
|
||||
GTK_NOTE (EXTENDED_LAYOUT,
|
||||
GTK_NOTE (SIZE_REQUEST,
|
||||
g_print ("[%p] %s\t%s: %d is minimum %d and natural: %d (hit cache: %s)\n",
|
||||
layout, G_OBJECT_TYPE_NAME (layout),
|
||||
request, G_OBJECT_TYPE_NAME (request),
|
||||
orientation == GTK_SIZE_GROUP_HORIZONTAL ?
|
||||
"width for height" : "height for width" ,
|
||||
for_size,
|
||||
@ -349,8 +352,8 @@ compute_size_for_orientation (GtkExtendedLayout *layout,
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_extended_layout_is_height_for_width:
|
||||
* @layout: a #GtkExtendedLayout instance
|
||||
* gtk_size_request_is_height_for_width:
|
||||
* @widget: a #GtkSizeRequest instance
|
||||
*
|
||||
* Gets whether the widget prefers a height-for-width layout
|
||||
* or a width-for-height layout.
|
||||
@ -365,24 +368,24 @@ compute_size_for_orientation (GtkExtendedLayout *layout,
|
||||
*
|
||||
* Since: 3.0
|
||||
*/
|
||||
gboolean
|
||||
gtk_extended_layout_is_height_for_width (GtkExtendedLayout *layout)
|
||||
GtkSizeRequestMode
|
||||
gtk_size_request_get_request_mode (GtkSizeRequest *widget)
|
||||
{
|
||||
GtkExtendedLayoutIface *iface;
|
||||
GtkSizeRequestIface *iface;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_EXTENDED_LAYOUT (layout), FALSE);
|
||||
g_return_val_if_fail (GTK_IS_SIZE_REQUEST (widget), GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH);
|
||||
|
||||
iface = GTK_EXTENDED_LAYOUT_GET_IFACE (layout);
|
||||
if (iface->is_height_for_width)
|
||||
return iface->is_height_for_width (layout);
|
||||
iface = GTK_SIZE_REQUEST_GET_IFACE (widget);
|
||||
if (iface->get_request_mode)
|
||||
return iface->get_request_mode (widget);
|
||||
|
||||
/* By default widgets are height-for-width. */
|
||||
return TRUE;
|
||||
return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_extended_layout_get_desired_width:
|
||||
* @layout: a #GtkExtendedLayout instance
|
||||
* gtk_size_request_get_width:
|
||||
* @widget: a #GtkSizeRequest instance
|
||||
* @minimum_width: (out) (allow-none): location to store the minimum width, or %NULL
|
||||
* @natural_width: (out) (allow-none): location to store the natural width, or %NULL
|
||||
*
|
||||
@ -394,18 +397,18 @@ gtk_extended_layout_is_height_for_width (GtkExtendedLayout *layout)
|
||||
* Since: 3.0
|
||||
*/
|
||||
void
|
||||
gtk_extended_layout_get_desired_width (GtkExtendedLayout *layout,
|
||||
gtk_size_request_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_width,
|
||||
gint *natural_width)
|
||||
{
|
||||
compute_size_for_orientation (layout, GTK_SIZE_GROUP_HORIZONTAL,
|
||||
compute_size_for_orientation (widget, GTK_SIZE_GROUP_HORIZONTAL,
|
||||
-1, minimum_width, natural_width);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_extended_layout_get_desired_height:
|
||||
* @layout: a #GtkExtendedLayout instance
|
||||
* gtk_size_request_get_height:
|
||||
* @widget: a #GtkSizeRequest instance
|
||||
* @minimum_height: (out) (allow-none): location to store the minimum height, or %NULL
|
||||
* @natural_height: (out) (allow-none): location to store the natural height, or %NULL
|
||||
*
|
||||
@ -416,19 +419,19 @@ gtk_extended_layout_get_desired_width (GtkExtendedLayout *layout,
|
||||
* Since: 3.0
|
||||
*/
|
||||
void
|
||||
gtk_extended_layout_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_height,
|
||||
gint *natural_height)
|
||||
gtk_size_request_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_height,
|
||||
gint *natural_height)
|
||||
{
|
||||
compute_size_for_orientation (layout, GTK_SIZE_GROUP_VERTICAL,
|
||||
compute_size_for_orientation (widget, GTK_SIZE_GROUP_VERTICAL,
|
||||
-1, minimum_height, natural_height);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* gtk_extended_layout_get_width_for_height:
|
||||
* @layout: a #GtkExtendedLayout instance
|
||||
* gtk_size_request_get_width_for_height:
|
||||
* @widget: a #GtkSizeRequest instance
|
||||
* @height: the height which is available for allocation
|
||||
* @minimum_width: (out) (allow-none): location for storing the minimum width, or %NULL
|
||||
* @natural_width: (out) (allow-none): location for storing the natural width, or %NULL
|
||||
@ -439,18 +442,18 @@ gtk_extended_layout_get_desired_height (GtkExtendedLayout *layout,
|
||||
* Since: 3.0
|
||||
*/
|
||||
void
|
||||
gtk_extended_layout_get_width_for_height (GtkExtendedLayout *layout,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width)
|
||||
gtk_size_request_get_width_for_height (GtkSizeRequest *widget,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width)
|
||||
{
|
||||
compute_size_for_orientation (layout, GTK_SIZE_GROUP_HORIZONTAL,
|
||||
compute_size_for_orientation (widget, GTK_SIZE_GROUP_HORIZONTAL,
|
||||
height, minimum_width, natural_width);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_extended_layout_get_height_for_width:
|
||||
* @layout: a #GtkExtendedLayout instance
|
||||
* gtk_size_request_get_height_for_width:
|
||||
* @widget: a #GtkSizeRequest instance
|
||||
* @width: the width which is available for allocation
|
||||
* @minimum_height: (out) (allow-none): location for storing the minimum height, or %NULL
|
||||
* @natural_height: (out) (allow-none): location for storing the natural height, or %NULL
|
||||
@ -461,74 +464,78 @@ gtk_extended_layout_get_width_for_height (GtkExtendedLayout *layout,
|
||||
* Since: 3.0
|
||||
*/
|
||||
void
|
||||
gtk_extended_layout_get_height_for_width (GtkExtendedLayout *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height)
|
||||
gtk_size_request_get_height_for_width (GtkSizeRequest *widget,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height)
|
||||
{
|
||||
compute_size_for_orientation (layout, GTK_SIZE_GROUP_VERTICAL,
|
||||
compute_size_for_orientation (widget, GTK_SIZE_GROUP_VERTICAL,
|
||||
width, minimum_height, natural_height);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_extended_layout_get_desired_size:
|
||||
* @layout: a #GtkExtendedLayout instance
|
||||
* @request_natural: Whether to base the contextual request off of the
|
||||
* base natural or the base minimum
|
||||
* gtk_size_request_get_size:
|
||||
* @widget: a #GtkSizeRequest instance
|
||||
* @minimum_size: (out) (allow-none): location for storing the minimum size, or %NULL
|
||||
* @natural_size: (out) (allow-none): location for storing the natural size, or %NULL
|
||||
*
|
||||
* Retrieves the minimum and natural size of a widget taking
|
||||
* into account the widget's preference for height-for-width management.
|
||||
*
|
||||
* If request_natural is specified, the non-contextual natural value will
|
||||
* be used to make the contextual request; otherwise the minimum will be used.
|
||||
*
|
||||
* This is used to retrieve a suitable size by container widgets which do
|
||||
* not impose any restrictions on the child placement.
|
||||
*
|
||||
* Since: 3.0
|
||||
*/
|
||||
void
|
||||
gtk_extended_layout_get_desired_size (GtkExtendedLayout *layout,
|
||||
gboolean request_natural,
|
||||
GtkRequisition *minimum_size,
|
||||
GtkRequisition *natural_size)
|
||||
gtk_size_request_get_size (GtkSizeRequest *widget,
|
||||
GtkRequisition *minimum_size,
|
||||
GtkRequisition *natural_size)
|
||||
{
|
||||
gint min_width, nat_width;
|
||||
gint min_height, nat_height;
|
||||
|
||||
g_return_if_fail (GTK_IS_EXTENDED_LAYOUT (layout));
|
||||
g_return_if_fail (GTK_IS_SIZE_REQUEST (widget));
|
||||
|
||||
if (gtk_extended_layout_is_height_for_width (layout))
|
||||
if (gtk_size_request_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
|
||||
{
|
||||
gtk_extended_layout_get_desired_width (layout, &min_width, &nat_width);
|
||||
gtk_extended_layout_get_height_for_width (layout,
|
||||
request_natural ? nat_width : min_width,
|
||||
&min_height, &nat_height);
|
||||
gtk_size_request_get_width (widget, &min_width, &nat_width);
|
||||
|
||||
if (minimum_size)
|
||||
{
|
||||
minimum_size->width = min_width;
|
||||
gtk_size_request_get_height_for_width (widget, min_width,
|
||||
&minimum_size->height, NULL);
|
||||
}
|
||||
|
||||
if (natural_size)
|
||||
{
|
||||
natural_size->width = nat_width;
|
||||
gtk_size_request_get_height_for_width (widget, nat_width,
|
||||
NULL, &natural_size->height);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_extended_layout_get_desired_height (layout, &min_height, &nat_height);
|
||||
gtk_extended_layout_get_width_for_height (layout,
|
||||
request_natural ? nat_height : min_height,
|
||||
&min_width, &nat_width);
|
||||
}
|
||||
gtk_size_request_get_height (widget, &min_height, &nat_height);
|
||||
|
||||
if (minimum_size)
|
||||
{
|
||||
minimum_size->width = min_width;
|
||||
minimum_size->height = min_height;
|
||||
}
|
||||
if (minimum_size)
|
||||
{
|
||||
minimum_size->height = min_height;
|
||||
gtk_size_request_get_width_for_height (widget, min_height,
|
||||
&minimum_size->width, NULL);
|
||||
}
|
||||
|
||||
if (natural_size)
|
||||
{
|
||||
natural_size->width = nat_width;
|
||||
natural_size->height = nat_height;
|
||||
if (natural_size)
|
||||
{
|
||||
natural_size->height = nat_height;
|
||||
gtk_size_request_get_width_for_height (widget, nat_height,
|
||||
NULL, &natural_size->width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define __GTK_EXTENDED_LAYOUT_C__
|
||||
#define __GTK_SIZE_REQUEST_C__
|
||||
#include "gtkaliasdef.c"
|
87
gtk/gtksizerequest.h
Normal file
87
gtk/gtksizerequest.h
Normal file
@ -0,0 +1,87 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2007-2010 Openismus GmbH
|
||||
*
|
||||
* Authors:
|
||||
* Mathias Hasselmann <mathias@openismus.com>
|
||||
* Tristan Van Berkom <tristan.van.berkom@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_SIZE_REQUEST_H__
|
||||
#define __GTK_SIZE_REQUEST_H__
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_SIZE_REQUEST (gtk_size_request_get_type ())
|
||||
#define GTK_SIZE_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SIZE_REQUEST, GtkSizeRequest))
|
||||
#define GTK_SIZE_REQUEST_CLASS(klass) ((GtkSizeRequestIface*)g_type_interface_peek ((klass), GTK_TYPE_SIZE_REQUEST))
|
||||
#define GTK_IS_SIZE_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SIZE_REQUEST))
|
||||
#define GTK_SIZE_REQUEST_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_SIZE_REQUEST, GtkSizeRequestIface))
|
||||
|
||||
typedef struct _GtkSizeRequest GtkSizeRequest;
|
||||
typedef struct _GtkSizeRequestIface GtkSizeRequestIface;
|
||||
|
||||
|
||||
struct _GtkSizeRequestIface
|
||||
{
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* virtual table */
|
||||
GtkSizeRequestMode (* get_request_mode) (GtkSizeRequest *layout);
|
||||
|
||||
void (* get_height) (GtkSizeRequest *layout,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
void (* get_width_for_height) (GtkSizeRequest *layout,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
void (* get_width) (GtkSizeRequest *layout,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
void (* get_height_for_width) (GtkSizeRequest *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
};
|
||||
|
||||
GType gtk_size_request_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkSizeRequestMode gtk_size_request_get_request_mode (GtkSizeRequest *layout);
|
||||
void gtk_size_request_get_width (GtkSizeRequest *layout,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
void gtk_size_request_get_height_for_width (GtkSizeRequest *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
void gtk_size_request_get_height (GtkSizeRequest *layout,
|
||||
gint *minimum_height,
|
||||
gint *natural_height);
|
||||
void gtk_size_request_get_width_for_height (GtkSizeRequest *layout,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width);
|
||||
void gtk_size_request_get_size (GtkSizeRequest *layout,
|
||||
GtkRequisition *minimum_size,
|
||||
GtkRequisition *natural_size);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_SIZE_REQUEST_H__ */
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "gtkviewport.h"
|
||||
#include "gtkextendedlayout.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkprivate.h"
|
||||
@ -87,18 +87,18 @@ static void gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment,
|
||||
static void gtk_viewport_style_set (GtkWidget *widget,
|
||||
GtkStyle *previous_style);
|
||||
|
||||
static void gtk_viewport_extended_layout_init (GtkExtendedLayoutIface *iface);
|
||||
static void gtk_viewport_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_viewport_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_viewport_size_request_init (GtkSizeRequestIface *iface);
|
||||
static void gtk_viewport_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_viewport_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkViewport, gtk_viewport, GTK_TYPE_BIN,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
|
||||
gtk_viewport_extended_layout_init))
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
|
||||
gtk_viewport_size_request_init))
|
||||
|
||||
static void
|
||||
gtk_viewport_class_init (GtkViewportClass *class)
|
||||
@ -447,7 +447,7 @@ viewport_set_vadjustment_values (GtkViewport *viewport,
|
||||
{
|
||||
gint natural_height;
|
||||
|
||||
gtk_extended_layout_get_height_for_width (GTK_EXTENDED_LAYOUT (bin->child),
|
||||
gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (bin->child),
|
||||
view_allocation.width,
|
||||
NULL,
|
||||
&natural_height);
|
||||
@ -875,35 +875,35 @@ gtk_viewport_style_set (GtkWidget *widget,
|
||||
|
||||
|
||||
static void
|
||||
gtk_viewport_extended_layout_init (GtkExtendedLayoutIface *iface)
|
||||
gtk_viewport_size_request_init (GtkSizeRequestIface *iface)
|
||||
{
|
||||
iface->get_desired_width = gtk_viewport_get_desired_width;
|
||||
iface->get_desired_height = gtk_viewport_get_desired_height;
|
||||
iface->get_width = gtk_viewport_get_width;
|
||||
iface->get_height = gtk_viewport_get_height;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_viewport_get_desired_size (GtkExtendedLayout *layout,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_viewport_get_size (GtkSizeRequest *widget,
|
||||
GtkOrientation orientation,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
GtkWidget *child;
|
||||
gint child_min, child_nat;
|
||||
gint minimum, natural;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (layout));
|
||||
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||
|
||||
/* XXX This should probably be (border_width * 2); but GTK+ has
|
||||
* been doing this with a single border for a while now...
|
||||
*/
|
||||
minimum = GTK_CONTAINER (layout)->border_width;
|
||||
minimum = GTK_CONTAINER (widget)->border_width;
|
||||
|
||||
if (GTK_VIEWPORT (layout)->shadow_type != GTK_SHADOW_NONE)
|
||||
if (GTK_VIEWPORT (widget)->shadow_type != GTK_SHADOW_NONE)
|
||||
{
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
minimum += 2 * GTK_WIDGET (layout)->style->xthickness;
|
||||
minimum += 2 * GTK_WIDGET (widget)->style->xthickness;
|
||||
else
|
||||
minimum += 2 * GTK_WIDGET (layout)->style->ythickness;
|
||||
minimum += 2 * GTK_WIDGET (widget)->style->ythickness;
|
||||
}
|
||||
|
||||
natural = minimum;
|
||||
@ -911,9 +911,9 @@ gtk_viewport_get_desired_size (GtkExtendedLayout *layout,
|
||||
if (child && gtk_widget_get_visible (child))
|
||||
{
|
||||
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
|
||||
else
|
||||
gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
|
||||
|
||||
minimum += child_min;
|
||||
natural += child_nat;
|
||||
@ -927,19 +927,19 @@ gtk_viewport_get_desired_size (GtkExtendedLayout *layout,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_viewport_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_viewport_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_viewport_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
gtk_viewport_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_viewport_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_viewport_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
gtk_viewport_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
gtk_viewport_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
|
||||
}
|
||||
|
||||
#define __GTK_VIEWPORT_C__
|
||||
|
@ -55,7 +55,7 @@
|
||||
#include "gtkinvisible.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbuilderprivate.h"
|
||||
#include "gtkextendedlayout.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
/**
|
||||
@ -347,11 +347,11 @@ static void gtk_widget_buildable_custom_finished (GtkBuildable
|
||||
static void gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
|
||||
GtkBuilder *builder);
|
||||
|
||||
static void gtk_widget_extended_layout_init (GtkExtendedLayoutIface *iface);
|
||||
static void gtk_widget_real_get_desired_width (GtkExtendedLayout *layout,
|
||||
static void gtk_widget_size_request_init (GtkSizeRequestIface *iface);
|
||||
static void gtk_widget_real_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_widget_real_get_desired_height (GtkExtendedLayout *layout,
|
||||
static void gtk_widget_real_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
|
||||
@ -433,7 +433,7 @@ gtk_widget_get_type (void)
|
||||
|
||||
const GInterfaceInfo layout_info =
|
||||
{
|
||||
(GInterfaceInitFunc) gtk_widget_extended_layout_init,
|
||||
(GInterfaceInitFunc) gtk_widget_size_request_init,
|
||||
(GInterfaceFinalizeFunc) NULL,
|
||||
NULL /* interface data */
|
||||
};
|
||||
@ -445,7 +445,7 @@ gtk_widget_get_type (void)
|
||||
&accessibility_info) ;
|
||||
g_type_add_interface_static (widget_type, GTK_TYPE_BUILDABLE,
|
||||
&buildable_info) ;
|
||||
g_type_add_interface_static (widget_type, GTK_TYPE_EXTENDED_LAYOUT,
|
||||
g_type_add_interface_static (widget_type, GTK_TYPE_SIZE_REQUEST,
|
||||
&layout_info) ;
|
||||
}
|
||||
|
||||
@ -3804,7 +3804,7 @@ gtk_widget_queue_resize_no_redraw (GtkWidget *widget)
|
||||
* Also remember that the size request is not necessarily the size
|
||||
* a widget will actually be allocated.
|
||||
*
|
||||
* Deprecated: 3.0: Use gtk_extended_layout_get_desired_size() instead.
|
||||
* Deprecated: 3.0: Use gtk_size_request_get_size() instead.
|
||||
**/
|
||||
void
|
||||
gtk_widget_size_request (GtkWidget *widget,
|
||||
@ -3818,7 +3818,7 @@ gtk_widget_size_request (GtkWidget *widget,
|
||||
"to widget->requisition. gtk_widget_set_usize() may not work properly.");
|
||||
#endif /* G_ENABLE_DEBUG */
|
||||
|
||||
gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (widget), FALSE, requisition, NULL);
|
||||
gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3846,13 +3846,13 @@ gtk_widget_size_request (GtkWidget *widget,
|
||||
* gtk_widget_size_request().
|
||||
*
|
||||
*
|
||||
* Deprecated: 3.0: Use gtk_extended_layout_get_desired_size() instead.
|
||||
* Deprecated: 3.0: Use gtk_size_request_get_size() instead.
|
||||
**/
|
||||
void
|
||||
gtk_widget_get_child_requisition (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
{
|
||||
gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (widget), FALSE, requisition, NULL);
|
||||
gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -10847,61 +10847,61 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
|
||||
}
|
||||
|
||||
/*
|
||||
* GtkExtendedLayout implementation
|
||||
* GtkSizeRequest implementation
|
||||
*/
|
||||
static void
|
||||
gtk_widget_real_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_widget_real_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
/* Set the initial values so that unimplemented classes will fall back
|
||||
* on the "size-request" collected values (see gtksizegroup.c:do_size_request()).
|
||||
*/
|
||||
if (minimum_size)
|
||||
*minimum_size = GTK_WIDGET (layout)->requisition.width;
|
||||
*minimum_size = GTK_WIDGET (widget)->requisition.width;
|
||||
|
||||
if (natural_size)
|
||||
*natural_size = GTK_WIDGET (layout)->requisition.width;
|
||||
*natural_size = GTK_WIDGET (widget)->requisition.width;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_real_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_widget_real_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
/* Set the initial values so that unimplemented classes will fall back
|
||||
* on the "size-request" collected values (see gtksizegroup.c:do_size_request()).
|
||||
*/
|
||||
if (minimum_size)
|
||||
*minimum_size = GTK_WIDGET (layout)->requisition.height;
|
||||
*minimum_size = GTK_WIDGET (widget)->requisition.height;
|
||||
|
||||
if (natural_size)
|
||||
*natural_size = GTK_WIDGET (layout)->requisition.height;
|
||||
*natural_size = GTK_WIDGET (widget)->requisition.height;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_real_get_height_for_width (GtkExtendedLayout *layout,
|
||||
gtk_widget_real_get_height_for_width (GtkSizeRequest *layout,
|
||||
gint width,
|
||||
gint *minimum_height,
|
||||
gint *natural_height)
|
||||
{
|
||||
gtk_extended_layout_get_desired_height (layout, minimum_height, natural_height);
|
||||
gtk_size_request_get_height (layout, minimum_height, natural_height);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_real_get_width_for_height (GtkExtendedLayout *layout,
|
||||
gtk_widget_real_get_width_for_height (GtkSizeRequest *layout,
|
||||
gint height,
|
||||
gint *minimum_width,
|
||||
gint *natural_width)
|
||||
{
|
||||
gtk_extended_layout_get_desired_width (layout, minimum_width, natural_width);
|
||||
gtk_size_request_get_width (layout, minimum_width, natural_width);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_extended_layout_init (GtkExtendedLayoutIface *iface)
|
||||
gtk_widget_size_request_init (GtkSizeRequestIface *iface)
|
||||
{
|
||||
iface->get_desired_width = gtk_widget_real_get_desired_width;
|
||||
iface->get_desired_height = gtk_widget_real_get_desired_height;
|
||||
iface->get_width = gtk_widget_real_get_width;
|
||||
iface->get_height = gtk_widget_real_get_height;
|
||||
iface->get_width_for_height = gtk_widget_real_get_width_for_height;
|
||||
iface->get_height_for_width = gtk_widget_real_get_height_for_width;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkplug.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkextendedlayout.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
@ -395,19 +395,19 @@ static void gtk_window_buildable_custom_finished (GtkBuildable *buildable,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
static void gtk_window_extended_layout_init (GtkExtendedLayoutIface *iface);
|
||||
static void gtk_window_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_window_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_window_size_request_init (GtkSizeRequestIface *iface);
|
||||
static void gtk_window_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
static void gtk_window_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkWindow, gtk_window, GTK_TYPE_BIN,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
||||
gtk_window_buildable_interface_init)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
|
||||
gtk_window_extended_layout_init))
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
|
||||
gtk_window_size_request_init))
|
||||
|
||||
static void
|
||||
add_tab_bindings (GtkBindingSet *binding_set,
|
||||
@ -5593,22 +5593,22 @@ gtk_window_real_set_focus (GtkWindow *window,
|
||||
|
||||
|
||||
static void
|
||||
gtk_window_extended_layout_init (GtkExtendedLayoutIface *iface)
|
||||
gtk_window_size_request_init (GtkSizeRequestIface *iface)
|
||||
{
|
||||
iface->get_desired_width = gtk_window_get_desired_width;
|
||||
iface->get_desired_height = gtk_window_get_desired_height;
|
||||
iface->get_width = gtk_window_get_width;
|
||||
iface->get_height = gtk_window_get_height;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_window_get_desired_width (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_window_get_width (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
GtkWindow *window;
|
||||
GtkWidget *child;
|
||||
|
||||
window = GTK_WINDOW (layout);
|
||||
window = GTK_WINDOW (widget);
|
||||
child = gtk_bin_get_child (GTK_BIN (window));
|
||||
|
||||
*minimum_size = GTK_CONTAINER (window)->border_width * 2;
|
||||
@ -5617,7 +5617,7 @@ gtk_window_get_desired_width (GtkExtendedLayout *layout,
|
||||
if (child && gtk_widget_get_visible (child))
|
||||
{
|
||||
gint child_min, child_nat;
|
||||
gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
|
||||
|
||||
*minimum_size += child_min;
|
||||
*natural_size += child_nat;
|
||||
@ -5625,14 +5625,14 @@ gtk_window_get_desired_width (GtkExtendedLayout *layout,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_window_get_desired_height (GtkExtendedLayout *layout,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
gtk_window_get_height (GtkSizeRequest *widget,
|
||||
gint *minimum_size,
|
||||
gint *natural_size)
|
||||
{
|
||||
GtkWindow *window;
|
||||
GtkWidget *child;
|
||||
|
||||
window = GTK_WINDOW (layout);
|
||||
window = GTK_WINDOW (widget);
|
||||
child = gtk_bin_get_child (GTK_BIN (window));
|
||||
|
||||
*minimum_size = GTK_CONTAINER (window)->border_width * 2;
|
||||
@ -5641,7 +5641,7 @@ gtk_window_get_desired_height (GtkExtendedLayout *layout,
|
||||
if (child && gtk_widget_get_visible (child))
|
||||
{
|
||||
gint child_min, child_nat;
|
||||
gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (child), &child_min, &child_nat);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
|
||||
|
||||
*minimum_size += child_min;
|
||||
*natural_size += child_nat;
|
||||
|
@ -30,7 +30,6 @@ noinst_PROGRAMS = $(TEST_PROGS) \
|
||||
simple \
|
||||
flicker \
|
||||
print-editor \
|
||||
extendedlayoutexample \
|
||||
testaccel \
|
||||
testassistant \
|
||||
testbbox \
|
||||
@ -49,6 +48,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
|
||||
testfilechooserbutton \
|
||||
testframe \
|
||||
testgtk \
|
||||
testheightforwidth \
|
||||
testiconview \
|
||||
testiconview-keynav \
|
||||
testicontheme \
|
||||
@ -117,7 +117,7 @@ endif
|
||||
flicker_DEPENDENCIES = $(TEST_DEPS)
|
||||
simple_DEPENDENCIES = $(TEST_DEPS)
|
||||
print_editor_DEPENDENCIES = $(TEST_DEPS)
|
||||
extendedlayoutexample_DEPENDENCIES = $(TEST_DEPS)
|
||||
testheightforwidth_DEPENDENCIES = $(TEST_DEPS)
|
||||
testicontheme_DEPENDENCIES = $(TEST_DEPS)
|
||||
testiconview_DEPENDENCIES = $(TEST_DEPS)
|
||||
testaccel_DEPENDENCIES = $(TEST_DEPS)
|
||||
@ -182,7 +182,6 @@ testwindows_DEPENDENCIES = $(TEST_DEPS)
|
||||
flicker_LDADD = $(LDADDS)
|
||||
simple_LDADD = $(LDADDS)
|
||||
print_editor_LDADD = $(LDADDS)
|
||||
extendedlayoutexample_LDADD = $(LDADDS)
|
||||
testaccel_LDADD = $(LDADDS)
|
||||
testapplication_LDADD = $(LDADDS)
|
||||
testassistant_LDADD = $(LDADDS)
|
||||
@ -202,6 +201,7 @@ testentryicons_LDADD = $(LDADDS)
|
||||
testfilechooser_LDADD = $(LDADDS)
|
||||
testfilechooserbutton_LDADD = $(LDADDS)
|
||||
testgtk_LDADD = $(LDADDS)
|
||||
testheightforwidth_LDADD = $(LDADDS)
|
||||
testicontheme_LDADD = $(LDADDS)
|
||||
testiconview_LDADD = $(LDADDS)
|
||||
testiconview_keynav_LDADD = $(LDADDS)
|
||||
|
@ -86,8 +86,8 @@ ebox_expose_event_cb (GtkWidget *widget,
|
||||
gtk_widget_translate_coordinates (label, widget, 0, 0, &x, &y);
|
||||
layout = gtk_widget_create_pango_layout (widget, "");
|
||||
|
||||
gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (label), FALSE,
|
||||
&minimum_size, &natural_size);
|
||||
gtk_size_request_get_size (GTK_SIZE_REQUEST (label),
|
||||
&minimum_size, &natural_size);
|
||||
|
||||
pango_layout_set_markup (layout,
|
||||
"<span color='#c33'>\342\227\217 requisition</span>\n"
|
||||
|
620
tests/testheightforwidth.c
Normal file
620
tests/testheightforwidth.c
Normal file
@ -0,0 +1,620 @@
|
||||
/* extendedlayoutexample.c
|
||||
* Copyright (C) 2010 Openismus GmbH
|
||||
*
|
||||
* Author:
|
||||
* Tristan Van Berkom <tristan.van.berkom@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef struct {
|
||||
const gchar *name;
|
||||
const gchar *tooltip;
|
||||
const gchar *interface;
|
||||
GtkWidget *window;
|
||||
} TestInterface;
|
||||
|
||||
|
||||
/* These strings were generated with:
|
||||
*
|
||||
* IFS=""; while read line; do echo -n \"; echo -n $line | sed -e 's|\"|\\"|g'; echo \"; done < file.glade
|
||||
*/
|
||||
TestInterface interfaces[] = {
|
||||
{
|
||||
"Ellipsizing Labels",
|
||||
"Demonstrates how labels will request a natural size in a horizontal space",
|
||||
"<interface>"
|
||||
" <requires lib=\"gtk+\" version=\"2.20\"/>"
|
||||
" <!-- interface-naming-policy project-wide -->"
|
||||
" <object class=\"GtkWindow\" id=\"window\">"
|
||||
" <property name=\"default_width\">450</property>"
|
||||
" <property name=\"default_height\">50</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkHBox\" id=\"hbox5\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label9\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">Some labels do ellipsize</property>"
|
||||
" <property name=\"ellipsize\">end</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"weight\" value=\"bold\"/>"
|
||||
" <attribute name=\"foreground\" value=\"#09610feefe03\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"position\">0</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label10\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">but some</property>"
|
||||
" <property name=\"ellipsize\">end</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"weight\" value=\"bold\"/>"
|
||||
" <attribute name=\"foreground\" value=\"#0000af6b0993\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"position\">1</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label11\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">do not at all</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"style\" value=\"normal\"/>"
|
||||
" <attribute name=\"weight\" value=\"bold\"/>"
|
||||
" <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"position\">2</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
"</interface>",
|
||||
NULL
|
||||
},
|
||||
|
||||
{
|
||||
"Wrapping Label",
|
||||
"Demonstrates how a wrapping label can require a height contextual to its allocated width",
|
||||
"<interface>"
|
||||
" <requires lib=\"gtk+\" version=\"2.18\"/>"
|
||||
" <!-- interface-naming-policy project-wide -->"
|
||||
" <object class=\"GtkWindow\" id=\"window\">"
|
||||
" <property name=\"border_width\">12</property>"
|
||||
" <property name=\"default_width\">300</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkHPaned\" id=\"hpaned1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"can_focus\">True</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkVBox\" id=\"vbox2\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label3\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">A short static label.</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"weight\" value=\"bold\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"position\">0</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkFrame\" id=\"frame1\">"
|
||||
" <property name=\"label\">Long label</property>"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">This is a really long label for the purpose of testing line wrapping is working correctly in conjunction with height-for-width support in GTK+</property>"
|
||||
" <property name=\"wrap\">True</property>"
|
||||
" <property name=\"max_width_chars\">30</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"foreground\" value=\"#18c52119f796\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"expand\">False</property>"
|
||||
" <property name=\"position\">1</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkButton\" id=\"button2\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"can_focus\">True</property>"
|
||||
" <property name=\"receives_default\">True</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label2\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">A really really long label inside a button to demonstrate height for width working inside buttons</property>"
|
||||
" <property name=\"wrap\">True</property>"
|
||||
" <property name=\"max_width_chars\">25</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"foreground\" value=\"#1e3687ab0a52\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"expand\">False</property>"
|
||||
" <property name=\"position\">2</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"resize\">False</property>"
|
||||
" <property name=\"shrink\">False</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label4\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">This static label\n"
|
||||
"can shrink.</property>"
|
||||
" <property name=\"justify\">center</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"style\" value=\"normal\"/>"
|
||||
" <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"resize\">True</property>"
|
||||
" <property name=\"shrink\">True</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
"</interface>",
|
||||
NULL
|
||||
},
|
||||
|
||||
{
|
||||
"Horizontal Box",
|
||||
"Demonstrates how a horizontal box can calculate the collective height for an allocated width",
|
||||
"<interface>"
|
||||
" <requires lib=\"gtk+\" version=\"2.20\"/>"
|
||||
" <!-- interface-naming-policy project-wide -->"
|
||||
" <object class=\"GtkWindow\" id=\"window\">"
|
||||
" <property name=\"default_height\">200</property>"
|
||||
" <property name=\"default_width\">600</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkHPaned\" id=\"hpaned1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"can_focus\">True</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkVBox\" id=\"vbox1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkHBox\" id=\"hbox1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkButton\" id=\"button1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"can_focus\">True</property>"
|
||||
" <property name=\"receives_default\">True</property>"
|
||||
" <property name=\"use_action_appearance\">False</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label2\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">A button that wraps.</property>"
|
||||
" <property name=\"wrap\">True</property>"
|
||||
" <property name=\"width_chars\">10</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"foreground\" value=\"#0000041dffff\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"expand\">False</property>"
|
||||
" <property name=\"position\">0</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">Lets try setting up some long text to wrap up in this hbox and see if the height-for-width is gonna work !</property>"
|
||||
" <property name=\"wrap\">True</property>"
|
||||
" <property name=\"width_chars\">30</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"foreground\" value=\"#07d0a9b20972\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"position\">1</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"expand\">False</property>"
|
||||
" <property name=\"position\">0</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkButton\" id=\"button2\">"
|
||||
" <property name=\"label\" translatable=\"yes\">A button that expands in the vbox</property>"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"can_focus\">True</property>"
|
||||
" <property name=\"receives_default\">True</property>"
|
||||
" <property name=\"use_action_appearance\">False</property>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"position\">1</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"resize\">False</property>"
|
||||
" <property name=\"shrink\">False</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label4\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">This label is\n"
|
||||
"set to shrink inside\n"
|
||||
"the paned window.</property>"
|
||||
" <property name=\"justify\">center</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"style\" value=\"normal\"/>"
|
||||
" <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"resize\">True</property>"
|
||||
" <property name=\"shrink\">True</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
"</interface>",
|
||||
NULL
|
||||
},
|
||||
|
||||
{
|
||||
"Vertical Labels",
|
||||
"Demonstrates how a horizontal box will consider width-for-height when allocating children "
|
||||
"even if the toplevel window is requested as height-for-width.",
|
||||
"<interface>"
|
||||
" <requires lib=\"gtk+\" version=\"2.20\"/>"
|
||||
" <!-- interface-naming-policy project-wide -->"
|
||||
" <object class=\"GtkWindow\" id=\"window\">"
|
||||
" <property name=\"default_width\">400</property>"
|
||||
" <property name=\"default_height\">300</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkVPaned\" id=\"vpaned1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"can_focus\">True</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkHBox\" id=\"hbox1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">Some long width-for-height text that wraps</property>"
|
||||
" <property name=\"justify\">center</property>"
|
||||
" <property name=\"wrap\">True</property>"
|
||||
" <property name=\"width_chars\">10</property>"
|
||||
" <property name=\"angle\">90</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"weight\" value=\"bold\"/>"
|
||||
" <attribute name=\"foreground\" value=\"#03e307ddfb5f\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"expand\">False</property>"
|
||||
" <property name=\"position\">0</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkFrame\" id=\"frame1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label_xalign\">0</property>"
|
||||
" <property name=\"shadow_type\">out</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label5\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">Neither of the panes are\n"
|
||||
"set to shrink.</property>"
|
||||
" <property name=\"justify\">center</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" </child>"
|
||||
" <child type=\"label_item\">"
|
||||
" <placeholder/>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"position\">1</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"resize\">False</property>"
|
||||
" <property name=\"shrink\">False</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkHBox\" id=\"hbox2\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkFrame\" id=\"frame2\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label_xalign\">0</property>"
|
||||
" <property name=\"shadow_type\">out</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label4\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">The interface is allocated as height\n"
|
||||
"for width, but the horizontal boxes\n"
|
||||
"allocate in width for height mode.</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"foreground\" value=\"#000097970808\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" </child>"
|
||||
" <child type=\"label_item\">"
|
||||
" <placeholder/>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"position\">0</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label3\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">Some long width-for-height text that wraps</property>"
|
||||
" <property name=\"justify\">center</property>"
|
||||
" <property name=\"wrap\">True</property>"
|
||||
" <property name=\"width_chars\">10</property>"
|
||||
" <property name=\"angle\">270</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"weight\" value=\"bold\"/>"
|
||||
" <attribute name=\"foreground\" value=\"#03e307ddfb5f\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"expand\">False</property>"
|
||||
" <property name=\"position\">1</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"resize\">False</property>"
|
||||
" <property name=\"shrink\">False</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
"</interface>",
|
||||
NULL
|
||||
},
|
||||
|
||||
{
|
||||
"Label Parameters",
|
||||
"This test demonstrates how \"width-chars\" and \"max-width-chars\" can be used "
|
||||
"to effect minimum and natural widths in wrapping labels.",
|
||||
"<interface>"
|
||||
" <requires lib=\"gtk+\" version=\"2.20\"/>"
|
||||
" <!-- interface-naming-policy project-wide -->"
|
||||
" <object class=\"GtkWindow\" id=\"window\">"
|
||||
" <property name=\"default_width\">900</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkHPaned\" id=\"hpaned1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"can_focus\">True</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkVBox\" id=\"vbox1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkHBox\" id=\"hbox1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"spacing\">6</property>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label1\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">The first 2 labels require 10 characters.</property>"
|
||||
" <property name=\"wrap\">True</property>"
|
||||
" <property name=\"width_chars\">10</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"weight\" value=\"bold\"/>"
|
||||
" <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"expand\">False</property>"
|
||||
" <property name=\"fill\">False</property>"
|
||||
" <property name=\"position\">0</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label2\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">This label has a maximum natural width of 20 characters. The second two labels expand.</property>"
|
||||
" <property name=\"wrap\">True</property>"
|
||||
" <property name=\"width_chars\">10</property>"
|
||||
" <property name=\"max_width_chars\">20</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"weight\" value=\"bold\"/>"
|
||||
" <attribute name=\"foreground\" value=\"#05c2a161134b\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"expand\">True</property>"
|
||||
" <property name=\"fill\">True</property>"
|
||||
" <property name=\"position\">1</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label3\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">This label requires a default minimum size.</property>"
|
||||
" <property name=\"wrap\">True</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"weight\" value=\"bold\"/>"
|
||||
" <attribute name=\"foreground\" value=\"#03e30758fb5f\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"position\">2</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"position\">0</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label4\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">This test demonstrates how the \"width-chars\" and \"max-width-chars\"\n"
|
||||
"properties can be used to specify the minimum requested wrap width\n"
|
||||
"and the maximum natural wrap width respectively.</property>"
|
||||
" <property name=\"ellipsize\">end</property>"
|
||||
" <property name=\"width_chars\">30</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"style\" value=\"normal\"/>"
|
||||
" <attribute name=\"foreground\" value=\"#05470000abaf\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"position\">1</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"resize\">False</property>"
|
||||
" <property name=\"shrink\">False</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" <child>"
|
||||
" <object class=\"GtkLabel\" id=\"label5\">"
|
||||
" <property name=\"visible\">True</property>"
|
||||
" <property name=\"label\" translatable=\"yes\">Some static\n"
|
||||
"text that shrinks.\n"
|
||||
"\n"
|
||||
"You will need to stretch\n"
|
||||
"this window quite wide\n"
|
||||
"to see the effects.</property>"
|
||||
" <property name=\"justify\">center</property>"
|
||||
" <attributes>"
|
||||
" <attribute name=\"foreground\" value=\"#ffff00000000\"/>"
|
||||
" </attributes>"
|
||||
" </object>"
|
||||
" <packing>"
|
||||
" <property name=\"resize\">True</property>"
|
||||
" <property name=\"shrink\">True</property>"
|
||||
" </packing>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
"</interface>",
|
||||
NULL
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
test_clicked (GtkWidget *button,
|
||||
TestInterface *interface)
|
||||
{
|
||||
if (!interface->window)
|
||||
{
|
||||
GtkBuilder *builder = gtk_builder_new ();
|
||||
|
||||
gtk_builder_add_from_string (builder, interface->interface, -1, NULL);
|
||||
interface->window = (GtkWidget *)gtk_builder_get_object (builder, "window");
|
||||
|
||||
g_signal_connect (interface->window, "delete_event",
|
||||
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
||||
}
|
||||
|
||||
gtk_widget_show (interface->window);
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
create_window (void)
|
||||
{
|
||||
GtkWidget *window, *vbox, *button;
|
||||
gint i;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
vbox = gtk_vbox_new (FALSE, 6);
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (interfaces); i++)
|
||||
{
|
||||
button = gtk_button_new_with_label (interfaces[i].name);
|
||||
|
||||
gtk_widget_set_tooltip_text (button, interfaces[i].tooltip);
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (test_clicked), &interfaces[i]);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
window = create_window ();
|
||||
|
||||
g_signal_connect (window, "delete-event",
|
||||
G_CALLBACK (gtk_main_quit), window);
|
||||
|
||||
gtk_widget_show (window);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user