#include "gtkrc.h"
#include "gtkselection.h"
#include "gtksettings.h"
-#include "gtksizegroup.h"
+#include "gtksizegroup-private.h"
#include "gtkwidget.h"
+#include "gtkwidgetprivate.h"
#include "gtkwindow.h"
#include "gtkbindings.h"
#include "gtkprivate.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
#include "gtksizerequest.h"
+#include "gtkdebug.h"
/**
* GtkWidget is the base class all widgets in GTK+ derive from. It manages the
* widget lifecycle, states and style.
*
+ * <refsect2 id="geometry-management">
+ * <title>Height-for-width Geometry Management</title>
+ * <para>
+ * GTK+ uses a 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). The most common
+ * example is a label that reflows to fill up the available width, wraps
+ * to fewer lines, and therefore needs less height.
+ *
+ * Height-for-width geometry management is implemented in GTK+ by way
+ * of five virtual methods:
+ * <variablelist>
+ * <varlistentry>
+ * <term>#GtkWidgetClass.get_request_mode()</term>
+ * <listitem>
+ * This allows a widget to tell it's parent container whether
+ * it preferrs to be allocated in %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH
+ * or %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT mode.
+ * %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH means the widget prefers to
+ * have #GtkWidgetClass.get_preferred_width() called and then
+ * #GtkWidgetClass.get_preferred_height_for_width() and is the
+ * default return for unimplemented cases.
+ * However it's important to note (as described below) that any
+ * widget which trades height-for-width must respond properly to
+ * both #GtkSizeRequestModes since it might be queried in either
+ * orientation by it's parent container.
+ * </listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>#GtkWidgetClass.get_preferred_width()</term>
+ * <listitem>
+ * This is called by containers to obtain the minimum and
+ * natural width of a widget. A widget will never be allocated
+ * a width less than it's minimum and will only ever be allocated
+ * a width greater than the natural width once all of the said
+ * widget's siblings have received their natural widths.
+ * Furthermore a widget will only ever be allocated a width greater
+ * than it's natural width if it was configured to receive extra
+ * expand space from it's parent container.
+ * </listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>#GtkWidgetClass.get_preferred_height()</term>
+ * <listitem>
+ * This is called by containers to obtain the minimum and
+ * natural height of a widget.
+ * A widget that does not actually trade any height for width
+ * or width for height only has to implement these two virtual
+ * methods (#GtkWidgetClass.get_preferred_width() and
+ * #GtkWidgetClass.get_preferred_height()).
+ * </listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>#GtkWidgetClass.get_preferred_height_for_width()</term>
+ * <listitem>
+ * This is similar to #GtkWidgetClass.get_preferred_height() except
+ * that it is passed a contextual width to request height for. By
+ * implementing this virtual method it is possible for a #GtkLabel
+ * to tell it's parent how much height would be required if the
+ * label were to be allocated a said width.
+ * </listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>#GtkWidgetClass.get_preferred_width_for_height()</term>
+ * <listitem>
+ * This is analogous to #GtkWidgetClass.get_preferred_height_for_width()
+ * except that it operates in the oposite orientation. It's rare that
+ * a widget actually does %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT requests
+ * but can happen when for example; a widget or container gets additional
+ * columns to compensate for a smaller allocated height.
+ * </listitem>
+ * </varlistentry>
+ * </variablelist>
+ *
+ * There are some important things to keep in mind when implementing
+ * height-for-width and when using it in container implementations.
+ *
+ * The geometry management system will query a widget hierarchy in
+ * only one orientation at a time. When widgets are initially queried
+ * for their minimum sizes it is generally done in two initial passes
+ * in the #GtkSizeRequestMode chosen by the toplevel.
+ *
+ * For example, when queried in the normal
+ * %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH mode:
+ * First, the default minimum and natural width for each widget
+ * in the interface will be computed using gtk_width_get_preferred_width().
+ * Because the preferred widths for each container depends on the preferred
+ * widths of thier children, this information propagates up the hierarchy,
+ * and finally a minimum and natural width is determined for the entire
+ * toplevel. Next, the toplevel will use the minimum width to query for the
+ * minimum height contextual to that width using
+ * gtk_widget_get_preferred_height_for_width(), which will also be a highly
+ * recursive operation. The minimum height for the minimum width is normally
+ * used to set the minimum size constraint on the toplevel
+ * (unless gtk_window_set_geometry_hints() is explicitly used instead).
+ *
+ * After the toplevel window has initially requested it's size in both
+ * dimensions it can go on to allocate itself a reasonable size (or a size
+ * previously specified with gtk_window_set_default_size()). During the
+ * recursive allocation process it's important to note that request cycles
+ * will be recursively executed while container widgets allocate their children.
+ * Each container widget, once allocated a size will go on to first share the
+ * space in one orientation among its children and then request each child's
+ * height for their target allocated width or width for allocated height
+ * depending. In this way a #GtkWidget will typically be requested its size
+ * a number of times before actually being allocated a size, the size a
+ * widget is finally allocated can of course differ from the size it
+ * requested. For this reason; #GtkWidget caches a small number of results
+ * to avoid re-querying for the same sizes in one allocation cycle.
+ *
+ * See <link linkend="container-geometry-management">GtkContainer's
+ * geometry management section</link>
+ * to learn more about how height-for-width allocations are performed
+ * by container widgets.
+ *
+ * If a widget does move content around to smartly use up the
+ * allocated size, then it must support the request in both
+ * #GtkSizeRequestModes even if the widget in question only
+ * trades sizes in a single orientation.
+ *
+ * For instance, a #GtkLabel that does height-for-width word wrapping
+ * will not expect to have #GtkWidgetClass.get_preferred_height() called
+ * because that call is specific to a width-for-height request. In this
+ * case the label must return the heights required for it's own minimum
+ * possible width. By following this rule any widget that handles
+ * height-for-width or width-for-height requests will always be allocated
+ * at least enough space to fit its own content.
+ *
+ * Here are some examples of how a %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH widget
+ * generally deals with width-for-height requests, for #GtkWidgetClass.get_preferred_height()
+ * it will do:
+ * <programlisting><![CDATA[
+ * static void
+ * foo_widget_get_preferred_height (GtkWidget *widget, gint *min_height, gint *nat_height)
+ * {
+ * if (i_am_in_height_for_width_mode)
+ * {
+ * gint min_width;
+ *
+ * GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, NULL);
+ * GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width (widget, min_width,
+ * min_height, nat_height);
+ * }
+ * else
+ * {
+ * ... some widgets do both, for instance if a GtkLabel is rotated to 90 degrees
+ * it will return the minimum and natural height for the rotated label here.
+ * }
+ * }
+ * ]]></programlisting>
+ *
+ * And in #GtkWidgetClass.get_preferred_width_for_height() it will simply return
+ * the minimum and natural width:
+ *
+ * <programlisting><![CDATA[
+ * static void
+ * foo_widget_get_preferred_width_for_height (GtkWidget *widget, gint for_height,
+ * gint *min_width, gint *nat_width)
+ * {
+ * if (i_am_in_height_for_width_mode)
+ * {
+ * GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, min_width, nat_width);
+ * }
+ * else
+ * {
+ * ... again if a widget is sometimes operating in width-for-height mode
+ * (like a rotated GtkLabel) it can go ahead and do it's real width for
+ * height calculation here.
+ * }
+ * }
+ * ]]></programlisting>
+ *
+ * Often a widget needs to get its own request during size request or
+ * allocation, for example when computing height it may need to also
+ * compute width, or when deciding how to use an allocation the widget
+ * may need to know its natural size. In these cases, the widget should
+ * be careful to call its virtual methods directly, like this:
+ * <example>
+ * <title>Widget calling its own size request method.</title>
+ * <programlisting>
+ * GTK_WIDGET_GET_CLASS(widget)->get_preferred_width (widget),
+ * &min, &natural);
+ * </programlisting>
+ * </example>
+ *
+ * It will not work to use the wrapper functions, such as
+ * gtk_widget_get_preferred_width(), inside your own size request
+ * implementation. These return a request adjusted by #GtkSizeGroup
+ * and by the #GtkWidgetClass.adjust_size_request() virtual method. If a
+ * widget used the wrappers inside its virtual method implementations,
+ * then the adjustments (such as widget margins) would be applied
+ * twice. GTK+ therefore does not allow this and will warn if you try
+ * to do it.
+ *
+ * Of course if you are getting the size request for
+ * <emphasis>another</emphasis> widget, such as a child of a
+ * container, you <emphasis>must</emphasis> use the wrapper APIs;
+ * otherwise, you would not properly consider widget margins,
+ * #GtkSizeGroup, and so forth.
+ * </para>
+ * </refsect2>
* <refsect2 id="style-properties">
+ * <title>Style Properties</title>
* <para>
* <structname>GtkWidget</structname> introduces <firstterm>style
* properties</firstterm> - these are basically object properties that are stored
*/
guint saved_state : 3;
- /* unused bits in our 32-bit block */
- guint reserved : 10;
+ guint direction : 2;
+
+ guint in_destruction : 1;
+ guint toplevel : 1;
+ guint anchored : 1;
+ guint composite_child : 1;
+ guint no_window : 1;
+ guint realized : 1;
+ guint mapped : 1;
+ guint visible : 1;
+ guint sensitive : 1;
+ guint parent_sensitive : 1;
+ guint can_focus : 1;
+ guint has_focus : 1;
+ guint can_default : 1;
+ guint has_default : 1;
+ guint receives_default : 1;
+ guint has_grab : 1;
+ guint shadowed : 1;
+ guint rc_style : 1;
+ guint user_style : 1;
+ guint app_paintable : 1;
+ guint double_buffered : 1;
+ guint redraw_on_alloc : 1;
+ guint no_show_all : 1;
+ guint child_visible : 1;
+ guint multidevice : 1;
+ guint has_shape_mask : 1;
+ guint in_reparent : 1;
+ guint resize_pending : 1;
+ guint alloc_needed : 1;
+ guint width_request_needed : 1;
+ guint height_request_needed : 1;
+
+ /* Expand-related flags */
+ guint need_compute_expand : 1; /* Need to recompute computed_[hv]_expand */
+ guint computed_hexpand : 1; /* computed results (composite of child flags) */
+ guint computed_vexpand : 1;
+ guint hexpand : 1; /* application-forced expand */
+ guint vexpand : 1;
+ guint hexpand_set : 1; /* whether to use application-forced */
+ guint vexpand_set : 1; /* instead of computing from children */
/* The widget's name. If the widget does not have a name
* (the name is NULL), then its name (as returned by
};
enum {
+ DESTROY,
SHOW,
HIDE,
MAP,
GRAB_FOCUS,
FOCUS,
MOVE_FOCUS,
+ KEYNAV_FAILED,
EVENT,
EVENT_AFTER,
BUTTON_PRESS_EVENT,
SELECTION_RECEIVED,
PROXIMITY_IN_EVENT,
PROXIMITY_OUT_EVENT,
+ CLIENT_EVENT,
+ NO_EXPOSE_EVENT,
+ VISIBILITY_NOTIFY_EVENT,
+ WINDOW_STATE_EVENT,
+ DAMAGE_EVENT,
+ GRAB_BROKEN_EVENT,
DRAG_BEGIN,
DRAG_END,
DRAG_DATA_DELETE,
DRAG_DROP,
DRAG_DATA_GET,
DRAG_DATA_RECEIVED,
- CLIENT_EVENT,
- NO_EXPOSE_EVENT,
- VISIBILITY_NOTIFY_EVENT,
- WINDOW_STATE_EVENT,
POPUP_MENU,
SHOW_HELP,
ACCEL_CLOSURES_CHANGED,
SCREEN_CHANGED,
CAN_ACTIVATE_ACCEL,
- GRAB_BROKEN,
COMPOSITED_CHANGED,
QUERY_TOOLTIP,
- KEYNAV_FAILED,
DRAG_FAILED,
- DAMAGE_EVENT,
LAST_SIGNAL
};
PROP_MARGIN_RIGHT,
PROP_MARGIN_TOP,
PROP_MARGIN_BOTTOM,
- PROP_MARGIN
+ PROP_MARGIN,
+ PROP_HEXPAND,
+ PROP_VEXPAND,
+ PROP_HEXPAND_SET,
+ PROP_VEXPAND_SET,
+ PROP_EXPAND
};
typedef struct _GtkStateData GtkStateData;
GValue *value,
GParamSpec *pspec);
static void gtk_widget_dispose (GObject *object);
-static void gtk_widget_real_destroy (GtkObject *object);
+static void gtk_widget_real_destroy (GtkWidget *object);
static void gtk_widget_finalize (GObject *object);
static void gtk_widget_real_show (GtkWidget *widget);
static void gtk_widget_real_hide (GtkWidget *widget);
static void gtk_widget_dispatch_child_properties_changed (GtkWidget *object,
guint n_pspecs,
GParamSpec **pspecs);
-static gboolean gtk_widget_real_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
static gboolean gtk_widget_real_key_press_event (GtkWidget *widget,
GdkEventKey *event);
static gboolean gtk_widget_real_key_release_event (GtkWidget *widget,
GdkEvent *event);
static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling);
+static void gtk_widget_real_get_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_widget_real_get_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_widget_real_get_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
+static void gtk_widget_real_get_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width);
static const GtkWidgetAuxInfo* _gtk_widget_get_aux_info_or_defaults (GtkWidget *widget);
static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info);
static AtkObject* gtk_widget_real_get_accessible (GtkWidget *widget);
static void gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
GtkBuilder *builder);
-static void gtk_widget_size_request_init (GtkSizeRequestIface *iface);
-static void gtk_widget_real_get_width (GtkSizeRequest *widget,
+static void gtk_widget_real_get_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_widget_real_get_height (GtkSizeRequest *widget,
+static void gtk_widget_real_get_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
static void gtk_widget_real_adjust_size_request (GtkWidget *widget,
GtkOrientation orientation,
- gint for_size,
gint *minimum_size,
gint *natural_size);
static void gtk_widget_real_adjust_size_allocation (GtkWidget *widget,
- GtkAllocation *allocation);
+ GtkOrientation orientation,
+ gint *natural_size,
+ gint *allocated_pos,
+ gint *allocated_size);
-static void gtk_widget_set_usize_internal (GtkWidget *widget,
- gint width,
- gint height);
+static void gtk_widget_set_usize_internal (GtkWidget *widget,
+ gint width,
+ gint height,
+ GtkQueueResizeFlags flags);
static void gtk_widget_add_events_internal (GtkWidget *widget,
GdkDevice *device,
static GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR;
static GParamSpecPool *style_property_spec_pool = NULL;
+/* XXX Temporarily here to fire warnings from gtksizerequest.c */
+guint size_request_signal_id = 0;
+
static GQuark quark_property_parser = 0;
static GQuark quark_aux_info = 0;
static GQuark quark_accel_path = 0;
static GQuark quark_tooltip_markup = 0;
static GQuark quark_has_tooltip = 0;
static GQuark quark_tooltip_window = 0;
+static GQuark quark_visual = 0;
GParamSpecPool *_gtk_widget_child_property_pool = NULL;
GObjectNotifyContext *_gtk_widget_child_property_notify_context = NULL;
NULL /* interface data */
};
- const GInterfaceInfo layout_info =
- {
- (GInterfaceInitFunc) gtk_widget_size_request_init,
- (GInterfaceFinalizeFunc) NULL,
- NULL /* interface data */
- };
-
- widget_type = g_type_register_static (GTK_TYPE_OBJECT, "GtkWidget",
- &widget_info, G_TYPE_FLAG_ABSTRACT);
+ widget_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "GtkWidget",
+ &widget_info, G_TYPE_FLAG_ABSTRACT);
g_type_add_interface_static (widget_type, ATK_TYPE_IMPLEMENTOR,
&accessibility_info) ;
g_type_add_interface_static (widget_type, GTK_TYPE_BUILDABLE,
&buildable_info) ;
- g_type_add_interface_static (widget_type, GTK_TYPE_SIZE_REQUEST,
- &layout_info) ;
}
return widget_type;
{
static GObjectNotifyContext cpn_context = { 0, NULL, NULL };
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkBindingSet *binding_set;
gtk_widget_parent_class = g_type_class_peek_parent (klass);
quark_tooltip_markup = g_quark_from_static_string ("gtk-tooltip-markup");
quark_has_tooltip = g_quark_from_static_string ("gtk-has-tooltip");
quark_tooltip_window = g_quark_from_static_string ("gtk-tooltip-window");
+ quark_visual = g_quark_from_static_string ("gtk-widget-visual");
style_property_spec_pool = g_param_spec_pool_new (FALSE);
_gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE);
gobject_class->set_property = gtk_widget_set_property;
gobject_class->get_property = gtk_widget_get_property;
- object_class->destroy = gtk_widget_real_destroy;
-
+ klass->destroy = gtk_widget_real_destroy;
+
klass->activate_signal = 0;
- klass->set_scroll_adjustments_signal = 0;
klass->dispatch_child_properties_changed = gtk_widget_dispatch_child_properties_changed;
klass->show = gtk_widget_real_show;
klass->show_all = gtk_widget_show;
klass->hide = gtk_widget_real_hide;
- klass->hide_all = gtk_widget_hide;
klass->map = gtk_widget_real_map;
klass->unmap = gtk_widget_real_unmap;
klass->realize = gtk_widget_real_realize;
klass->unrealize = gtk_widget_real_unrealize;
klass->size_request = gtk_widget_real_size_request;
klass->size_allocate = gtk_widget_real_size_allocate;
+ klass->get_preferred_width = gtk_widget_real_get_width;
+ klass->get_preferred_height = gtk_widget_real_get_height;
+ klass->get_preferred_width_for_height = gtk_widget_real_get_width_for_height;
+ klass->get_preferred_height_for_width = gtk_widget_real_get_height_for_width;
klass->state_changed = NULL;
klass->parent_set = NULL;
klass->hierarchy_changed = NULL;
klass->mnemonic_activate = gtk_widget_real_mnemonic_activate;
klass->grab_focus = gtk_widget_real_grab_focus;
klass->focus = gtk_widget_real_focus;
+ klass->move_focus = gtk_widget_real_move_focus;
+ klass->keynav_failed = gtk_widget_real_keynav_failed;
klass->event = NULL;
klass->button_press_event = NULL;
klass->button_release_event = NULL;
klass->motion_notify_event = NULL;
klass->delete_event = NULL;
klass->destroy_event = NULL;
- klass->expose_event = gtk_widget_real_expose_event;
klass->key_press_event = gtk_widget_real_key_press_event;
klass->key_release_event = gtk_widget_real_key_release_event;
klass->enter_notify_event = NULL;
0,
GTK_PARAM_READWRITE));
+ /**
+ * GtkWidget::destroy:
+ * @object: the object which received the signal
+ *
+ * Signals that all holders of a reference to the widget should release
+ * the reference that they hold. May result in finalization of the widget
+ * if all references are released.
+ */
+ widget_signals[DESTROY] =
+ g_signal_new (I_("destroy"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+ G_STRUCT_OFFSET (GtkWidgetClass, destroy),
+ NULL, NULL,
+ _gtk_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
+ * GtkWidget:hexpand
+ *
+ * Whether to expand horizontally. See gtk_widget_set_hexpand().
+ *
+ * Since: 3.0
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_HEXPAND,
+ g_param_spec_boolean ("hexpand",
+ P_("Horizontal Expand"),
+ P_("Whether widget wants more horizontal space"),
+ FALSE,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkWidget:hexpand-set
+ *
+ * Whether to use the GtkWidget:hexpand property. See gtk_widget_get_hexpand_set().
+ *
+ * Since: 3.0
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_HEXPAND_SET,
+ g_param_spec_boolean ("hexpand-set",
+ P_("Horizontal Expand Set"),
+ P_("Whether to use the hexpand property"),
+ FALSE,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkWidget:vexpand
+ *
+ * Whether to expand vertically. See gtk_widget_set_vexpand().
+ *
+ * Since: 3.0
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_VEXPAND,
+ g_param_spec_boolean ("vexpand",
+ P_("Vertical Expand"),
+ P_("Whether widget wants more vertical space"),
+ FALSE,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkWidget:vexpand-set
+ *
+ * Whether to use the GtkWidget:vexpand property. See gtk_widget_get_vexpand_set().
+ *
+ * Since: 3.0
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_VEXPAND_SET,
+ g_param_spec_boolean ("vexpand-set",
+ P_("Vertical Expand Set"),
+ P_("Whether to use the vexpand property"),
+ FALSE,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkWidget:expand
+ *
+ * Whether to expand in both directions. Setting this sets both GtkWidget:hexpand and GtkWidget:vexpand
+ *
+ * Since: 3.0
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_EXPAND,
+ g_param_spec_boolean ("expand",
+ P_("Expand Both"),
+ P_("Whether widget wants to expand in both directions"),
+ FALSE,
+ GTK_PARAM_READWRITE));
+
/**
* GtkWidget::show:
* @widget: the object which received the signal.
* @widget: the object which received the signal.
* @requisition:
*/
- widget_signals[SIZE_REQUEST] =
+ size_request_signal_id = widget_signals[SIZE_REQUEST] =
g_signal_new (I_("size-request"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
_gtk_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GTK_TYPE_STYLE);
-/**
- * GtkWidget::direction-changed:
- * @widget: the object on which the signal is emitted
- * @previous_direction: the previous text direction of @widget
- *
- * The ::direction-changed signal is emitted when the text direction
- * of a widget changes.
- */
+
+ /**
+ * GtkWidget::direction-changed:
+ * @widget: the object on which the signal is emitted
+ * @previous_direction: the previous text direction of @widget
+ *
+ * The ::direction-changed signal is emitted when the text direction
+ * of a widget changes.
+ */
widget_signals[DIRECTION_CHANGED] =
g_signal_new (I_("direction-changed"),
G_TYPE_FROM_CLASS (gobject_class),
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
-/**
- * GtkWidget::child-notify:
- * @widget: the object which received the signal
- * @pspec: the #GParamSpec of the changed child property
- *
- * The ::child-notify signal is emitted for each
- * <link linkend="child-properties">child property</link> that has
- * changed on an object. The signal's detail holds the property name.
- */
+ /**
+ * GtkWidget::child-notify:
+ * @widget: the object which received the signal
+ * @pspec: the #GParamSpec of the changed child property
+ *
+ * The ::child-notify signal is emitted for each
+ * <link linkend="child-properties">child property</link> that has
+ * changed on an object. The signal's detail holds the property name.
+ */
widget_signals[CHILD_NOTIFY] =
g_signal_new (I_("child-notify"),
G_TYPE_FROM_CLASS (gobject_class),
* GtkWidget::draw:
* @widget: the object which received the signal
* @cr: the cairo context to draw to
- * @width: width of the widget
- * @height: height of the widget
*
* This signal is emitted when a widget is supposed to render itself.
* The @widget's top left corner must be painted at the origin of
- * the passed in context and be sized in the given @width and @height.
+ * the passed in context and be sized to the values returned by
+ * gtk_widget_get_allocated_width() and
+ * gtk_widget_get_allocated_height().
*
* Signal handlers connected to this signal can modify the cairo
* context passed as @cr in any way they like and don't need to
*/
widget_signals[FOCUS] =
g_signal_new (I_("focus"),
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, focus),
_gtk_boolean_handled_accumulator, NULL,
* @direction:
*/
widget_signals[MOVE_FOCUS] =
- g_signal_new_class_handler (I_("move-focus"),
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_CALLBACK (gtk_widget_real_move_focus),
- NULL, NULL,
- _gtk_marshal_VOID__ENUM,
- G_TYPE_NONE,
- 1,
- GTK_TYPE_DIRECTION_TYPE);
+ g_signal_new (I_("move-focus"),
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtkWidgetClass, move_focus),
+ NULL, NULL,
+ _gtk_marshal_VOID__ENUM,
+ G_TYPE_NONE,
+ 1,
+ GTK_TYPE_DIRECTION_TYPE);
+
+ /**
+ * GtkWidget::keynav-failed:
+ * @widget: the object which received the signal
+ * @direction: the direction of movement
+ *
+ * Gets emitted if keyboard navigation fails.
+ * See gtk_widget_keynav_failed() for details.
+ *
+ * Returns: %TRUE if stopping keyboard navigation is fine, %FALSE
+ * if the emitting widget should try to handle the keyboard
+ * navigation attempt in its parent container(s).
+ *
+ * Since: 2.12
+ **/
+ widget_signals[KEYNAV_FAILED] =
+ g_signal_new (I_("keynav-failed"),
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkWidgetClass, keynav_failed),
+ _gtk_boolean_handled_accumulator, NULL,
+ _gtk_marshal_BOOLEAN__ENUM,
+ G_TYPE_BOOLEAN, 1,
+ GTK_TYPE_DIRECTION_TYPE);
+
/**
* GtkWidget::event:
* @widget: the object which received the signal.
*/
widget_signals[EVENT] =
g_signal_new (I_("event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[EVENT_AFTER] =
g_signal_new (I_("event-after"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
0,
0,
NULL, NULL,
*/
widget_signals[BUTTON_PRESS_EVENT] =
g_signal_new (I_("button-press-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, button_press_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[BUTTON_RELEASE_EVENT] =
g_signal_new (I_("button-release-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, button_release_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[SCROLL_EVENT] =
g_signal_new (I_("scroll-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, scroll_event),
_gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__BOXED,
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
/**
* GtkWidget::motion-notify-event:
* @widget: the object which received the signal.
*/
widget_signals[MOTION_NOTIFY_EVENT] =
g_signal_new (I_("motion-notify-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, motion_notify_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[COMPOSITED_CHANGED] =
g_signal_new (I_("composited-changed"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkWidgetClass, composited_changed),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- /**
- * GtkWidget::keynav-failed:
- * @widget: the object which received the signal
- * @direction: the direction of movement
- *
- * Gets emitted if keyboard navigation fails.
- * See gtk_widget_keynav_failed() for details.
- *
- * Returns: %TRUE if stopping keyboard navigation is fine, %FALSE
- * if the emitting widget should try to handle the keyboard
- * navigation attempt in its parent container(s).
- *
- * Since: 2.12
- **/
- widget_signals[KEYNAV_FAILED] =
- g_signal_new_class_handler (I_("keynav-failed"),
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_CALLBACK (gtk_widget_real_keynav_failed),
- _gtk_boolean_handled_accumulator, NULL,
- _gtk_marshal_BOOLEAN__ENUM,
- G_TYPE_BOOLEAN, 1,
- GTK_TYPE_DIRECTION_TYPE);
-
/**
* GtkWidget::delete-event:
* @widget: the object which received the signal
*/
widget_signals[DELETE_EVENT] =
g_signal_new (I_("delete-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, delete_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[DESTROY_EVENT] =
g_signal_new (I_("destroy-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, destroy_event),
_gtk_boolean_handled_accumulator, NULL,
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
- /**
- * GtkWidget::expose-event:
- * @widget: the object which received the signal.
- * @event: (type Gdk.EventExpose): the #GdkEventExpose which triggered
- * this signal.
- *
- * The ::expose-event signal is emitted when an area of a previously
- * obscured #GdkWindow is made visible and needs to be redrawn.
- * #GTK_NO_WINDOW widgets will get a synthesized event from their parent
- * widget.
- *
- * To receive this signal, the #GdkWindow associated to the widget needs
- * to enable the #GDK_EXPOSURE_MASK mask.
- *
- * Returns: %TRUE to stop other handlers from being invoked for the event.
- * %FALSE to propagate the event further.
- */
- widget_signals[EXPOSE_EVENT] =
- g_signal_new (I_("expose-event"),
- G_TYPE_FROM_CLASS (gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GtkWidgetClass, expose_event),
- _gtk_boolean_handled_accumulator, NULL,
- _gtk_marshal_BOOLEAN__BOXED,
- G_TYPE_BOOLEAN, 1,
- GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
-
/**
* GtkWidget::key-press-event:
* @widget: the object which received the signal
*/
widget_signals[KEY_PRESS_EVENT] =
g_signal_new (I_("key-press-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, key_press_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[KEY_RELEASE_EVENT] =
g_signal_new (I_("key-release-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, key_release_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[ENTER_NOTIFY_EVENT] =
g_signal_new (I_("enter-notify-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, enter_notify_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[LEAVE_NOTIFY_EVENT] =
g_signal_new (I_("leave-notify-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, leave_notify_event),
_gtk_boolean_handled_accumulator, NULL,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
- * GtkWidget::configure-event
+ * GtkWidget::configure-event:
* @widget: the object which received the signal
* @event: (type Gdk.EventConfigure): the #GdkEventConfigure which triggered
* this signal.
*/
widget_signals[CONFIGURE_EVENT] =
g_signal_new (I_("configure-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, configure_event),
_gtk_boolean_handled_accumulator, NULL,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
- * GtkWidget::focus-in-event
+ * GtkWidget::focus-in-event:
* @widget: the object which received the signal
* @event: (type Gdk.EventFocus): the #GdkEventFocus which triggered
* this signal.
*/
widget_signals[FOCUS_IN_EVENT] =
g_signal_new (I_("focus-in-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, focus_in_event),
_gtk_boolean_handled_accumulator, NULL,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
- * GtkWidget::focus-out-event
+ * GtkWidget::focus-out-event:
* @widget: the object which received the signal
* @event: (type Gdk.EventFocus): the #GdkEventFocus which triggered this
* signal.
*/
widget_signals[FOCUS_OUT_EVENT] =
g_signal_new (I_("focus-out-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, focus_out_event),
_gtk_boolean_handled_accumulator, NULL,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
- * GtkWidget::map-event
+ * GtkWidget::map-event:
* @widget: the object which received the signal
* @event: (type Gdk.EventAny): the #GdkEventAny which triggered this signal.
*
*/
widget_signals[MAP_EVENT] =
g_signal_new (I_("map-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, map_event),
_gtk_boolean_handled_accumulator, NULL,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
- * GtkWidget::unmap-event
+ * GtkWidget::unmap-event:
* @widget: the object which received the signal
* @event: (type Gdk.EventAny): the #GdkEventAny which triggered this signal
*
*/
widget_signals[UNMAP_EVENT] =
g_signal_new (I_("unmap-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, unmap_event),
_gtk_boolean_handled_accumulator, NULL,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
- * GtkWidget::property-notify-event
+ * GtkWidget::property-notify-event:
* @widget: the object which received the signal
* @event: (type Gdk.EventProperty): the #GdkEventProperty which triggered
* this signal.
*/
widget_signals[PROPERTY_NOTIFY_EVENT] =
g_signal_new (I_("property-notify-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, property_notify_event),
_gtk_boolean_handled_accumulator, NULL,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
- * GtkWidget::selection-clear-event
+ * GtkWidget::selection-clear-event:
* @widget: the object which received the signal
* @event: (type Gdk.EventSelection): the #GdkEventSelection which triggered
* this signal.
*/
widget_signals[SELECTION_CLEAR_EVENT] =
g_signal_new (I_("selection-clear-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, selection_clear_event),
_gtk_boolean_handled_accumulator, NULL,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
- * GtkWidget::selection-request-event
+ * GtkWidget::selection-request-event:
* @widget: the object which received the signal
* @event: (type Gdk.EventSelection): the #GdkEventSelection which triggered
* this signal.
*/
widget_signals[SELECTION_REQUEST_EVENT] =
g_signal_new (I_("selection-request-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, selection_request_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[SELECTION_NOTIFY_EVENT] =
g_signal_new (I_("selection-notify-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, selection_notify_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[SELECTION_RECEIVED] =
g_signal_new (I_("selection-received"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, selection_received),
NULL, NULL,
*/
widget_signals[SELECTION_GET] =
g_signal_new (I_("selection-get"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, selection_get),
NULL, NULL,
G_TYPE_UINT);
/**
- * GtkWidget::proximity-in-event
+ * GtkWidget::proximity-in-event:
* @widget: the object which received the signal
* @event: (type Gdk.EventProximity): the #GdkEventProximity which triggered
* this signal.
*/
widget_signals[PROXIMITY_IN_EVENT] =
g_signal_new (I_("proximity-in-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, proximity_in_event),
_gtk_boolean_handled_accumulator, NULL,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
- * GtkWidget::proximity-out-event
+ * GtkWidget::proximity-out-event:
* @widget: the object which received the signal
* @event: (type Gdk.EventProximity): the #GdkEventProximity which triggered
* this signal.
*/
widget_signals[PROXIMITY_OUT_EVENT] =
g_signal_new (I_("proximity-out-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, proximity_out_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[DRAG_LEAVE] =
g_signal_new (I_("drag-leave"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_leave),
NULL, NULL,
*/
widget_signals[DRAG_BEGIN] =
g_signal_new (I_("drag-begin"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_begin),
NULL, NULL,
*/
widget_signals[DRAG_END] =
g_signal_new (I_("drag-end"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_end),
NULL, NULL,
*/
widget_signals[DRAG_DATA_DELETE] =
g_signal_new (I_("drag-data-delete"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_data_delete),
NULL, NULL,
*/
widget_signals[DRAG_FAILED] =
g_signal_new (I_("drag-failed"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, _gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__OBJECT_ENUM,
*/
widget_signals[DRAG_MOTION] =
g_signal_new (I_("drag-motion"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_motion),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[DRAG_DROP] =
g_signal_new (I_("drag-drop"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_drop),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[DRAG_DATA_GET] =
g_signal_new (I_("drag-data-get"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_data_get),
NULL, NULL,
*/
widget_signals[DRAG_DATA_RECEIVED] =
g_signal_new (I_("drag-data-received"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_data_received),
NULL, NULL,
*/
widget_signals[VISIBILITY_NOTIFY_EVENT] =
g_signal_new (I_("visibility-notify-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, visibility_notify_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[CLIENT_EVENT] =
g_signal_new (I_("client-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, client_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[NO_EXPOSE_EVENT] =
g_signal_new (I_("no-expose-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, no_expose_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[WINDOW_STATE_EVENT] =
g_signal_new (I_("window-state-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, window_state_event),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[DAMAGE_EVENT] =
g_signal_new (I_("damage-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
- 0,
+ G_STRUCT_OFFSET (GtkWidgetClass, damage_event),
_gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__BOXED,
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
/**
* GtkWidget::grab-broken-event:
* @widget: the object which received the signal
*
* Since: 2.8
*/
- widget_signals[GRAB_BROKEN] =
+ widget_signals[GRAB_BROKEN_EVENT] =
g_signal_new (I_("grab-broken-event"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, grab_broken_event),
_gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__BOXED,
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
/**
* GtkWidget::query-tooltip:
* @widget: the object which received the signal
*/
widget_signals[QUERY_TOOLTIP] =
g_signal_new (I_("query-tooltip"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, query_tooltip),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[POPUP_MENU] =
g_signal_new (I_("popup-menu"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkWidgetClass, popup_menu),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[SHOW_HELP] =
g_signal_new (I_("show-help"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkWidgetClass, show_help),
_gtk_boolean_handled_accumulator, NULL,
*/
widget_signals[ACCEL_CLOSURES_CHANGED] =
g_signal_new (I_("accel-closures-changed"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
0,
0,
NULL, NULL,
*/
widget_signals[SCREEN_CHANGED] =
g_signal_new (I_("screen-changed"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, screen_changed),
NULL, NULL,
*/
widget_signals[CAN_ACTIVATE_ACCEL] =
g_signal_new (I_("can-activate-accel"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, can_activate_accel),
_gtk_boolean_handled_accumulator, NULL,
gtk_container_add (GTK_CONTAINER (g_value_get_object (value)), widget);
break;
case PROP_WIDTH_REQUEST:
- gtk_widget_set_usize_internal (widget, g_value_get_int (value), -2);
+ gtk_widget_set_usize_internal (widget, g_value_get_int (value), -2, 0);
break;
case PROP_HEIGHT_REQUEST:
- gtk_widget_set_usize_internal (widget, -2, g_value_get_int (value));
+ gtk_widget_set_usize_internal (widget, -2, g_value_get_int (value), 0);
break;
case PROP_VISIBLE:
gtk_widget_set_visible (widget, g_value_get_boolean (value));
gtk_widget_set_margin_bottom (widget, g_value_get_int (value));
g_object_thaw_notify (G_OBJECT (widget));
break;
+ case PROP_HEXPAND:
+ gtk_widget_set_hexpand (widget, g_value_get_boolean (value));
+ break;
+ case PROP_HEXPAND_SET:
+ gtk_widget_set_hexpand_set (widget, g_value_get_boolean (value));
+ break;
+ case PROP_VEXPAND:
+ gtk_widget_set_vexpand (widget, g_value_get_boolean (value));
+ break;
+ case PROP_VEXPAND_SET:
+ gtk_widget_set_vexpand_set (widget, g_value_get_boolean (value));
+ break;
+ case PROP_EXPAND:
+ g_object_freeze_notify (G_OBJECT (widget));
+ gtk_widget_set_hexpand (widget, g_value_get_boolean (value));
+ gtk_widget_set_vexpand (widget, g_value_get_boolean (value));
+ g_object_thaw_notify (G_OBJECT (widget));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
g_value_set_boolean (value, (gtk_widget_get_receives_default (widget) != FALSE));
break;
case PROP_COMPOSITE_CHILD:
- g_value_set_boolean (value, (GTK_OBJECT_FLAGS (widget) & GTK_COMPOSITE_CHILD) != 0 );
+ g_value_set_boolean (value, widget->priv->composite_child);
break;
case PROP_STYLE:
g_value_set_object (value, gtk_widget_get_style (widget));
}
}
break;
+ case PROP_HEXPAND:
+ g_value_set_boolean (value, gtk_widget_get_hexpand (widget));
+ break;
+ case PROP_HEXPAND_SET:
+ g_value_set_boolean (value, gtk_widget_get_hexpand_set (widget));
+ break;
+ case PROP_VEXPAND:
+ g_value_set_boolean (value, gtk_widget_get_vexpand (widget));
+ break;
+ case PROP_VEXPAND_SET:
+ g_value_set_boolean (value, gtk_widget_get_vexpand_set (widget));
+ break;
+ case PROP_EXPAND:
+ g_value_set_boolean (value,
+ gtk_widget_get_hexpand (widget) &&
+ gtk_widget_get_vexpand (widget));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
GtkWidgetPrivate);
priv = widget->priv;
- GTK_PRIVATE_FLAGS (widget) = PRIVATE_GTK_CHILD_VISIBLE;
+ priv->child_visible = TRUE;
priv->state = GTK_STATE_NORMAL;
priv->saved_state = GTK_STATE_NORMAL;
priv->name = NULL;
priv->window = NULL;
priv->parent = NULL;
- GTK_OBJECT_FLAGS (widget) |= GTK_SENSITIVE;
- GTK_OBJECT_FLAGS (widget) |= GTK_PARENT_SENSITIVE;
- GTK_OBJECT_FLAGS (widget) |= composite_child_stack ? GTK_COMPOSITE_CHILD : 0;
- gtk_widget_set_double_buffered (widget, TRUE);
-
- GTK_PRIVATE_SET_FLAG (widget, GTK_REDRAW_ON_ALLOC);
- GTK_PRIVATE_SET_FLAG (widget, GTK_WIDTH_REQUEST_NEEDED);
- GTK_PRIVATE_SET_FLAG (widget, GTK_HEIGHT_REQUEST_NEEDED);
- GTK_PRIVATE_SET_FLAG (widget, GTK_ALLOC_NEEDED);
+ priv->sensitive = TRUE;
+ priv->parent_sensitive = TRUE;
+ priv->composite_child = composite_child_stack != 0;
+ priv->double_buffered = TRUE;
+ priv->redraw_on_alloc = TRUE;
+ priv->width_request_needed = TRUE;
+ priv->height_request_needed = TRUE;
+ priv->alloc_needed = TRUE;
+
+ /* this will be set to TRUE if the widget gets a child or if the
+ * expand flag is set on the widget, but until one of those happen
+ * we know the expand is already properly FALSE.
+ *
+ * We really want to default FALSE here to avoid computing expand
+ * all over the place while initially building a widget tree.
+ */
+ priv->need_compute_expand = FALSE;
priv->style = gtk_widget_get_default_style ();
g_object_ref (priv->style);
/* If we are unanchoring the child, we save around the toplevel
* to emit hierarchy changed
*/
- if (GTK_WIDGET_ANCHORED (priv->parent))
+ if (priv->parent->priv->anchored)
g_object_ref (toplevel);
else
toplevel = NULL;
if (gtk_widget_get_realized (widget))
{
- if (GTK_WIDGET_IN_REPARENT (widget))
+ if (priv->in_reparent)
gtk_widget_unmap (widget);
else
gtk_widget_unrealize (widget);
* flag to the default state, so it doesn't affect the child
* in the next parent.
*/
- GTK_PRIVATE_SET_FLAG (widget, GTK_CHILD_VISIBLE);
+ priv->child_visible = TRUE;
old_parent = priv->parent;
priv->parent = NULL;
gtk_widget_set_parent_window (widget, NULL);
+
+ /* parent may no longer expand if the removed
+ * child was expand=TRUE and could therefore
+ * be forcing it to.
+ */
+ if (gtk_widget_get_visible (widget) &&
+ (priv->need_compute_expand ||
+ priv->computed_hexpand ||
+ priv->computed_vexpand))
+ {
+ gtk_widget_queue_compute_expand (old_parent);
+ }
+
g_signal_emit (widget, widget_signals[PARENT_SET], 0, old_parent);
if (toplevel)
{
_gtk_widget_propagate_hierarchy_changed (widget, toplevel);
g_object_unref (toplevel);
}
-
+
g_object_notify (G_OBJECT (widget), "parent");
g_object_thaw_notify (G_OBJECT (widget));
if (!priv->parent)
* gtk_widget_destroy:
* @widget: a #GtkWidget
*
- * Destroys a widget. Equivalent to gtk_object_destroy(), except that
- * you don't have to cast the widget to #GtkObject. When a widget is
+ * Destroys a widget.
+ *
+ * When a widget is
* destroyed, it will break any references it holds to other objects.
* If the widget is inside a container, the widget will be removed
* from the container. If the widget is a toplevel (derived from
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- gtk_object_destroy ((GtkObject*) widget);
+ if (!widget->priv->in_destruction)
+ g_object_run_dispose (G_OBJECT (widget));
}
/**
g_object_ref (widget);
if (!gtk_widget_is_toplevel (widget))
gtk_widget_queue_resize (widget);
+
+ /* see comment in set_parent() for why this should and can be
+ * conditional
+ */
+ if (widget->priv->need_compute_expand ||
+ widget->priv->computed_hexpand ||
+ widget->priv->computed_vexpand)
+ {
+ if (widget->priv->parent != NULL)
+ gtk_widget_queue_compute_expand (widget->priv->parent);
+ }
+
g_signal_emit (widget, widget_signals[SHOW], 0);
g_object_notify (G_OBJECT (widget), "visible");
g_object_unref (widget);
if (!gtk_widget_get_visible (widget))
{
- GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
+ priv->visible = TRUE;
if (priv->parent &&
gtk_widget_get_mapped (priv->parent) &&
- GTK_WIDGET_CHILD_VISIBLE (widget) &&
+ gtk_widget_get_child_visible (widget) &&
!gtk_widget_get_mapped (widget))
gtk_widget_map (widget);
}
if (toplevel != widget && gtk_widget_is_toplevel (toplevel))
_gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
+ /* a parent may now be expand=FALSE since we're hidden. */
+ if (widget->priv->need_compute_expand ||
+ widget->priv->computed_hexpand ||
+ widget->priv->computed_vexpand)
+ {
+ gtk_widget_queue_compute_expand (widget);
+ }
+
g_signal_emit (widget, widget_signals[HIDE], 0);
if (!gtk_widget_is_toplevel (widget))
gtk_widget_queue_resize (widget);
{
if (gtk_widget_get_visible (widget))
{
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
+ widget->priv->visible = FALSE;
if (gtk_widget_get_mapped (widget))
gtk_widget_unmap (widget);
class->show_all (widget);
}
-/**
- * gtk_widget_hide_all:
- * @widget: a #GtkWidget
- *
- * Recursively hides a widget and any child widgets.
- **/
-void
-gtk_widget_hide_all (GtkWidget *widget)
-{
- GtkWidgetClass *class;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- if (gtk_widget_get_no_show_all (widget))
- return;
-
- class = GTK_WIDGET_GET_CLASS (widget);
-
- if (class->hide_all)
- class->hide_all (widget);
-}
-
/**
* gtk_widget_map:
* @widget: a #GtkWidget
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (gtk_widget_get_visible (widget));
- g_return_if_fail (GTK_WIDGET_CHILD_VISIBLE (widget));
+ g_return_if_fail (gtk_widget_get_child_visible (widget));
priv = widget->priv;
cairo_region_t *region;
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (GTK_WIDGET_ANCHORED (widget) ||
+ g_return_if_fail (widget->priv->anchored ||
GTK_IS_INVISIBLE (widget));
priv = widget->priv;
GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (widget), quark_has_tooltip)),
TRUE);
- if (GTK_WIDGET_HAS_SHAPE_MASK (widget))
+ if (priv->has_shape_mask)
{
region = g_object_get_qdata (G_OBJECT (widget), quark_shape_info);
gdk_window_shape_combine_region (priv->window, region, 0, 0);
if (mode != GDK_EXTENSION_EVENTS_NONE)
gtk_widget_set_extension_events_internal (widget, mode, NULL);
- if ((GTK_WIDGET_FLAGS (widget) & GTK_MULTIDEVICE) != 0)
+ if (priv->multidevice)
gdk_window_set_support_multidevice (priv->window, TRUE);
_gtk_widget_enable_device_events (widget);
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (GTK_WIDGET_HAS_SHAPE_MASK (widget))
+ if (widget->priv->has_shape_mask)
gtk_widget_shape_combine_region (widget, NULL);
if (g_object_get_qdata (G_OBJECT (widget), quark_input_shape_info))
*****************************************/
/**
- * gtk_widget_queue_draw_area:
+ * gtk_widget_queue_draw_region:
* @widget: a #GtkWidget
- * @x: x coordinate of upper-left corner of rectangle to redraw
- * @y: y coordinate of upper-left corner of rectangle to redraw
- * @width: width of region to draw
- * @height: height of region to draw
+ * @region: region to draw
*
- * Invalidates the rectangular area of @widget defined by @x, @y,
- * @width and @height by calling gdk_window_invalidate_rect() on the
- * widget's window and all its child windows. Once the main loop
- * becomes idle (after the current batch of events has been processed,
- * roughly), the window will receive expose events for the union of
- * all regions that have been invalidated.
+ * Invalidates the rectangular area of @widget defined by @region by
+ * calling gdk_window_invalidate_region() on the widget's window and
+ * all its child windows. Once the main loop becomes idle (after the
+ * current batch of events has been processed, roughly), the window
+ * will receive expose events for the union of all regions that have
+ * been invalidated.
*
* Normally you would only use this function in widget
- * implementations. You might also use it, or
- * gdk_window_invalidate_rect() directly, to schedule a redraw of a
+ * implementations. You might also use it to schedule a redraw of a
* #GtkDrawingArea or some portion thereof.
- *
- * Frequently you can just call gdk_window_invalidate_rect() or
- * gdk_window_invalidate_region() instead of this function. Those
- * functions will invalidate only a single window, instead of the
- * widget and all its children.
- *
- * The advantage of adding to the invalidated region compared to
- * simply drawing immediately is efficiency; using an invalid region
- * ensures that you only have to redraw one time.
**/
void
-gtk_widget_queue_draw_area (GtkWidget *widget,
- gint x,
- gint y,
- gint width,
- gint height)
+gtk_widget_queue_draw_region (GtkWidget *widget,
+ cairo_region_t *region)
{
GtkWidgetPrivate *priv;
- GdkRectangle invalid_rect;
GtkWidget *w;
g_return_if_fail (GTK_IS_WIDGET (widget));
if (!gtk_widget_get_mapped (w))
return;
- /* Find the correct widget */
+ gdk_window_invalidate_region (priv->window, region, TRUE);
+}
- if (gtk_widget_get_has_window (widget))
- {
- if (priv->parent)
- {
- /* Translate widget relative to window-relative */
-
- gint wx, wy, wwidth, wheight;
-
- gdk_window_get_position (priv->window, &wx, &wy);
- x -= wx - priv->allocation.x;
- y -= wy - priv->allocation.y;
+/**
+ * gtk_widget_queue_draw_area:
+ * @widget: a #GtkWidget
+ * @x: x coordinate of upper-left corner of rectangle to redraw
+ * @y: y coordinate of upper-left corner of rectangle to redraw
+ * @width: width of region to draw
+ * @height: height of region to draw
+ *
+ * Convenience function that calls gtk_widget_queue_draw_region() on
+ * the region created from the given coordinates.
+ **/
+void
+gtk_widget_queue_draw_area (GtkWidget *widget,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
+{
+ GdkRectangle rect;
+ cairo_region_t *region;
- gdk_drawable_get_size (priv->window, &wwidth, &wheight);
+ g_return_if_fail (GTK_IS_WIDGET (widget));
- if (x + width <= 0 || y + height <= 0 ||
- x >= wwidth || y >= wheight)
- return;
-
- if (x < 0)
- {
- width += x; x = 0;
- }
- if (y < 0)
- {
- height += y; y = 0;
- }
- if (x + width > wwidth)
- width = wwidth - x;
- if (y + height > wheight)
- height = wheight - y;
- }
- }
+ rect.x = x;
+ rect.y = y;
+ rect.width = width;
+ rect.height = height;
- invalid_rect.x = x;
- invalid_rect.y = y;
- invalid_rect.width = width;
- invalid_rect.height = height;
-
- gdk_window_invalidate_rect (priv->window, &invalid_rect, TRUE);
+ region = cairo_region_create_rectangle (&rect);
+ gtk_widget_queue_draw_region (widget, region);
+ cairo_region_destroy (region);
}
/**
if (gtk_widget_get_realized (widget))
gtk_widget_queue_shallow_draw (widget);
- _gtk_size_group_queue_resize (widget);
+ _gtk_size_group_queue_resize (widget, 0);
}
/**
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- _gtk_size_group_queue_resize (widget);
+ _gtk_size_group_queue_resize (widget, 0);
}
/**
* Also remember that the size request is not necessarily the size
* a widget will actually be allocated.
*
- * Deprecated: 3.0: Use gtk_size_request_get_size() instead.
+ * Deprecated: 3.0: Use gtk_widget_get_preferred_size() instead.
**/
void
gtk_widget_size_request (GtkWidget *widget,
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
+ gtk_widget_get_preferred_size (widget, requisition, NULL);
}
/**
* gtk_widget_size_request().
*
*
- * Deprecated: 3.0: Use gtk_size_request_get_size() instead.
+ * Deprecated: 3.0: Use gtk_widget_get_preferred_size() instead.
**/
void
gtk_widget_get_child_requisition (GtkWidget *widget,
GtkRequisition *requisition)
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
+ gtk_widget_get_preferred_size (widget, requisition, NULL);
}
static gboolean
gboolean alloc_needed;
gboolean size_changed;
gboolean position_changed;
+ gint natural_width, natural_height;
+ gint min_width, min_height;
priv = widget->priv;
}
#endif /* G_ENABLE_DEBUG */
- alloc_needed = GTK_WIDGET_ALLOC_NEEDED (widget);
- if (!GTK_WIDGET_WIDTH_REQUEST_NEEDED (widget) &&
- !GTK_WIDGET_HEIGHT_REQUEST_NEEDED (widget)) /* Preserve request/allocate ordering */
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_ALLOC_NEEDED);
+ alloc_needed = priv->alloc_needed;
+ if (!priv->width_request_needed && !priv->height_request_needed)
+ /* Preserve request/allocate ordering */
+ priv->alloc_needed = FALSE;
old_allocation = priv->allocation;
real_allocation = *allocation;
adjusted_allocation = real_allocation;
- GTK_WIDGET_GET_CLASS (widget)->adjust_size_allocation (widget, &adjusted_allocation);
+ if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
+ {
+ /* Go ahead and request the height for allocated width, note that the internals
+ * of get_height_for_width will internally limit the for_size to natural size
+ * when aligning implicitly.
+ */
+ gtk_widget_get_preferred_width (widget, &min_width, &natural_width);
+ gtk_widget_get_preferred_height_for_width (widget, real_allocation.width, NULL, &natural_height);
+ }
+ else
+ {
+ /* Go ahead and request the width for allocated height, note that the internals
+ * of get_width_for_height will internally limit the for_size to natural size
+ * when aligning implicitly.
+ */
+ gtk_widget_get_preferred_height (widget, &min_height, &natural_height);
+ gtk_widget_get_preferred_width_for_height (widget, real_allocation.height, NULL, &natural_width);
+ }
+
+ /* Now that we have the right natural height and width, go ahead and remove any margins from the
+ * allocated sizes and possibly limit them to the natural sizes */
+ GTK_WIDGET_GET_CLASS (widget)->adjust_size_allocation (widget,
+ GTK_ORIENTATION_HORIZONTAL,
+ &natural_width,
+ &adjusted_allocation.x,
+ &adjusted_allocation.width);
+ GTK_WIDGET_GET_CLASS (widget)->adjust_size_allocation (widget,
+ GTK_ORIENTATION_VERTICAL,
+ &natural_height,
+ &adjusted_allocation.y,
+ &adjusted_allocation.height);
if (adjusted_allocation.x < real_allocation.x ||
adjusted_allocation.y < real_allocation.y ||
if (gtk_widget_get_mapped (widget))
{
- if (!gtk_widget_get_has_window (widget) && GTK_WIDGET_REDRAW_ON_ALLOC (widget) && position_changed)
+ if (!gtk_widget_get_has_window (widget) && priv->redraw_on_alloc && position_changed)
{
/* Invalidate union(old_allaction,priv->allocation) in priv->window
*/
if (size_changed)
{
- if (GTK_WIDGET_REDRAW_ON_ALLOC (widget))
+ if (priv->redraw_on_alloc)
{
/* Invalidate union(old_allaction,priv->allocation) in priv->window and descendents owned by widget
*/
}
static void
-get_span_inside_border (GtkWidget *widget,
- GtkAlign align,
- int start_pad,
- int end_pad,
- int allocated_outside_size,
- int natural_inside_size,
- int *coord_inside_p,
- int *size_inside_p)
+adjust_for_align(GtkAlign align,
+ gint *natural_size,
+ gint *allocated_pos,
+ gint *allocated_size)
{
- int inside_allocated;
- int content_size;
- int coord, size;
-
- inside_allocated = allocated_outside_size - start_pad - end_pad;
-
- content_size = natural_inside_size;
- if (content_size > inside_allocated)
- {
- /* didn't get full natural size */
- content_size = inside_allocated;
- }
-
- coord = size = 0; /* silence compiler */
switch (align)
{
case GTK_ALIGN_FILL:
- coord = start_pad;
- size = inside_allocated;
+ /* change nothing */
break;
case GTK_ALIGN_START:
- coord = start_pad;
- size = content_size;
+ /* keep *allocated_pos where it is */
+ *allocated_size = MIN (*allocated_size, *natural_size);
break;
case GTK_ALIGN_END:
- coord = allocated_outside_size - end_pad - content_size;
- size = content_size;
+ if (*allocated_size > *natural_size)
+ {
+ *allocated_pos += (*allocated_size - *natural_size);
+ *allocated_size = *natural_size;
+ }
break;
case GTK_ALIGN_CENTER:
- coord = start_pad + (inside_allocated - content_size) / 2;
- size = content_size;
+ if (*allocated_size > *natural_size)
+ {
+ *allocated_pos += (*allocated_size - *natural_size) / 2;
+ *allocated_size = MIN (*allocated_size, *natural_size);
+ }
break;
}
-
- if (coord_inside_p)
- *coord_inside_p = coord;
-
- if (size_inside_p)
- *size_inside_p = size;
}
static void
-get_span_inside_border_horizontal (GtkWidget *widget,
- const GtkWidgetAuxInfo *aux_info,
- int allocated_outside_width,
- int natural_inside_width,
- int *x_inside_p,
- int *width_inside_p)
-{
- get_span_inside_border (widget,
- aux_info->halign,
- aux_info->margin.left,
- aux_info->margin.right,
- allocated_outside_width,
- natural_inside_width,
- x_inside_p,
- width_inside_p);
-}
-
-static void
-get_span_inside_border_vertical (GtkWidget *widget,
- const GtkWidgetAuxInfo *aux_info,
- int allocated_outside_height,
- int natural_inside_height,
- int *y_inside_p,
- int *height_inside_p)
-{
- get_span_inside_border (widget,
- aux_info->valign,
- aux_info->margin.top,
- aux_info->margin.bottom,
- allocated_outside_height,
- natural_inside_height,
- y_inside_p,
- height_inside_p);
+adjust_for_margin(gint start_margin,
+ gint end_margin,
+ gint *natural_size,
+ gint *allocated_pos,
+ gint *allocated_size)
+{
+ *natural_size -= (start_margin + end_margin);
+ *allocated_pos += start_margin;
+ *allocated_size -= (start_margin + end_margin);
}
static void
gtk_widget_real_adjust_size_allocation (GtkWidget *widget,
- GtkAllocation *allocation)
+ GtkOrientation orientation,
+ gint *natural_size,
+ gint *allocated_pos,
+ gint *allocated_size)
{
const GtkWidgetAuxInfo *aux_info;
- GtkRequisition min, natural;
- int x, y, w, h;
aux_info = _gtk_widget_get_aux_info_or_defaults (widget);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &min, &natural);
-
- get_span_inside_border_horizontal (widget,
- aux_info,
- allocation->width,
- natural.width,
- &x, &w);
- get_span_inside_border_vertical (widget,
- aux_info,
- allocation->height,
- natural.height,
- &y, &h);
-
- allocation->x += x;
- allocation->y += y;
- allocation->width = w;
- allocation->height = h;
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ adjust_for_margin (aux_info->margin.left,
+ aux_info->margin.right,
+ natural_size, allocated_pos, allocated_size);
+ adjust_for_align (aux_info->halign,
+ natural_size, allocated_pos, allocated_size);
+ }
+ else
+ {
+ adjust_for_margin (aux_info->margin.top,
+ aux_info->margin.bottom,
+ natural_size, allocated_pos, allocated_size);
+ adjust_for_align (aux_info->valign,
+ natural_size, allocated_pos, allocated_size);
+ }
}
static gboolean
event->window == window;
}
-static gboolean
-gtk_widget_real_expose_event (GtkWidget *widget,
- GdkEventExpose *expose)
+/* code shared by gtk_container_propagate_draw() and
+ * gtk_widget_draw()
+ */
+void
+_gtk_widget_draw_internal (GtkWidget *widget,
+ cairo_t *cr,
+ gboolean clip_to_size)
{
- GdkWindow *window;
- gboolean result = FALSE;
- cairo_t *cr;
-
if (!gtk_widget_is_drawable (widget))
- return FALSE;
-
- cr = gdk_cairo_create (expose->window);
- gtk_cairo_set_event (cr, expose);
-
- gdk_cairo_region (cr, expose->region);
- cairo_clip (cr);
+ return;
- /* translate cairo context properly */
- window = gtk_widget_get_window (widget);
- if (window != expose->window)
+ if (clip_to_size)
{
- int x, y;
-
- if (gdk_window_get_parent (expose->window) == window)
- {
- gdk_window_get_position (expose->window, &x, &y);
- }
- else
- {
- int ex, ey;
- gdk_window_get_origin (expose->window, &ex, &ey);
- gdk_window_get_origin (window, &x, &y);
- x = ex - x;
- y = ey - y;
- }
-
- cairo_translate (cr, -x, -y);
+ cairo_rectangle (cr,
+ 0, 0,
+ widget->priv->allocation.width,
+ widget->priv->allocation.height);
+ cairo_clip (cr);
}
-
- if (!gtk_widget_get_has_window (widget))
+ if (gdk_cairo_get_clip_rectangle (cr, NULL))
{
- cairo_translate (cr,
- widget->priv->allocation.x,
- widget->priv->allocation.y);
+ gboolean result;
+
+ g_signal_emit (widget, widget_signals[DRAW],
+ 0, cr,
+ &result);
}
+}
+
+/**
+ * gtk_widget_draw:
+ * @widget: the widget to draw. It must be drawable (see
+ * gtk_widget_is_drawable()) and a size must have been allocated.
+ * @cr: a cairo context to draw to
+ *
+ * Draws @widget to @cr. The top left corner of the widget will be
+ * drawn to the currently set origin point of @cr.
+ *
+ * You should pass a cairo context as @cr argument that is in an
+ * original state. Otherwise the resulting drawing is undefined. For
+ * example changing the operator using cairo_set_operator() or the
+ * line width using cairo_set_line_width() might have unwanted side
+ * effects.
+ * You may however change the context's transform matrix - like with
+ * cairo_scale(), cairo_translate() or cairo_set_matrix() and clip
+ * region with cairo_clip() prior to calling this function. Also, it
+ * is fine to modify the context with cairo_save() and
+ * cairo_push_group() prior to calling this function.
+ *
+ * <note><para>Special purpose widgets may contain special code for
+ * rendering to the screen and might appear differently on screen
+ * and when rendered using gtk_widget_draw().</para></note>
+ **/
+void
+gtk_widget_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GdkEventExpose *tmp_event;
- g_signal_emit (widget, widget_signals[DRAW],
- 0, cr,
- &result);
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (!widget->priv->alloc_needed);
+ g_return_if_fail (cr != NULL);
- /* unset here, so if someone keeps a reference to cr we
- * don't leak the window. */
+ cairo_save (cr);
+ /* We have to reset the event here so that draw functions can call
+ * gtk_widget_draw() on random other widgets and get the desired
+ * effect: Drawing all contents, not just the current window.
+ */
+ tmp_event = _gtk_cairo_get_event (cr);
gtk_cairo_set_event (cr, NULL);
- cairo_destroy (cr);
- return result;
+ _gtk_widget_draw_internal (widget, cr, TRUE);
+
+ gtk_cairo_set_event (cr, tmp_event);
+ cairo_restore (cr);
}
static gboolean
gtk_widget_real_key_press_event (GtkWidget *widget,
GdkEventKey *event)
{
- return gtk_bindings_activate_event (GTK_OBJECT (widget), event);
+ return gtk_bindings_activate_event (G_OBJECT (widget), event);
}
static gboolean
gtk_widget_real_key_release_event (GtkWidget *widget,
GdkEventKey *event)
{
- return gtk_bindings_activate_event (GTK_OBJECT (widget), event);
+ return gtk_bindings_activate_event (G_OBJECT (widget), event);
}
static gboolean
return gtk_widget_event_internal (widget, event);
}
+/* Returns TRUE if a translation should be done */
+static gboolean
+gtk_widget_get_translation_to_window (GtkWidget *widget,
+ GdkWindow *window,
+ int *x,
+ int *y)
+{
+ GdkWindow *w, *widget_window;
+
+ if (!gtk_widget_get_has_window (widget))
+ {
+ *x = -widget->priv->allocation.x;
+ *y = -widget->priv->allocation.y;
+ }
+ else
+ {
+ *x = 0;
+ *y = 0;
+ }
+
+ widget_window = gtk_widget_get_window (widget);
+
+ for (w = window; w && w != widget_window; w = gdk_window_get_parent (w))
+ {
+ int wx, wy;
+ gdk_window_get_position (w, &wx, &wy);
+ *x += wx;
+ *y += wy;
+ }
+
+ if (w == NULL)
+ {
+ *x = 0;
+ *y = 0;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * gtk_cairo_transform_to_window:
+ * @cr: the cairo context to transform
+ * @widget: the widget the context is currently centered for
+ * @window: the window to transform the context to
+ *
+ * Transforms the given cairo context @cr that from @widget-relative
+ * coordinates to @window-relative coordinates.
+ * If the @widget's window is not an ancestor of @window, no
+ * modification will be applied.
+ *
+ * This is the inverse to the transformation GTK applies when
+ * preparing an expose event to be emitted with the GtkWidget::draw
+ * signal. It is intended to help porting multiwindow widgets from
+ * GTK 2 to the rendering architecture of GTK 3.
+ **/
+void
+gtk_cairo_transform_to_window (cairo_t *cr,
+ GtkWidget *widget,
+ GdkWindow *window)
+{
+ int x, y;
+
+ g_return_if_fail (cr != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (gtk_widget_get_translation_to_window (widget, window, &x, &y))
+ cairo_translate (cr, x, y);
+}
/**
* gtk_widget_send_expose:
* @event: a expose #GdkEvent
*
* Very rarely-used function. This function is used to emit
- * an expose event signals on a widget. This function is not
- * normally used directly. The only time it is used is when
- * propagating an expose event to a child %NO_WINDOW widget, and
- * that is normally done using gtk_container_propagate_expose().
+ * an expose event on a widget. This function is not normally used
+ * directly. The only time it is used is when propagating an expose
+ * event to a child %NO_WINDOW widget, and that is normally done
+ * using gtk_container_propagate_draw().
*
* If you want to force an area of a window to be redrawn,
* use gdk_window_invalidate_rect() or gdk_window_invalidate_region().
gtk_widget_send_expose (GtkWidget *widget,
GdkEvent *event)
{
+ gboolean result = FALSE;
+ cairo_t *cr;
+ int x, y;
+ gboolean do_clip;
+
g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
g_return_val_if_fail (gtk_widget_get_realized (widget), TRUE);
g_return_val_if_fail (event != NULL, TRUE);
g_return_val_if_fail (event->type == GDK_EXPOSE, TRUE);
- return gtk_widget_event_internal (widget, event);
+ cr = gdk_cairo_create (event->expose.window);
+ gtk_cairo_set_event (cr, &event->expose);
+
+ gdk_cairo_region (cr, event->expose.region);
+ cairo_clip (cr);
+
+ do_clip = gtk_widget_get_translation_to_window (widget,
+ event->expose.window,
+ &x, &y);
+ cairo_translate (cr, -x, -y);
+
+ _gtk_widget_draw_internal (widget, cr, do_clip);
+
+ /* unset here, so if someone keeps a reference to cr we
+ * don't leak the window. */
+ gtk_cairo_set_event (cr, NULL);
+ cairo_destroy (cr);
+
+ return result;
}
static gboolean
signal_num = VISIBILITY_NOTIFY_EVENT;
break;
case GDK_GRAB_BROKEN:
- signal_num = GRAB_BROKEN;
+ signal_num = GRAB_BROKEN_EVENT;
break;
case GDK_DAMAGE:
signal_num = DAMAGE_EVENT;
return FALSE;
}
-/**
- * gtk_widget_set_scroll_adjustments:
- * @widget: a #GtkWidget
- * @hadjustment: (allow-none): an adjustment for horizontal scrolling, or %NULL
- * @vadjustment: (allow-none): an adjustment for vertical scrolling, or %NULL
- *
- * For widgets that support scrolling, sets the scroll adjustments and
- * returns %TRUE. For widgets that don't support scrolling, does
- * nothing and returns %FALSE. Widgets that don't support scrolling
- * can be scrolled by placing them in a #GtkViewport, which does
- * support scrolling.
- *
- * Return value: %TRUE if the widget supports scrolling
- **/
-gboolean
-gtk_widget_set_scroll_adjustments (GtkWidget *widget,
- GtkAdjustment *hadjustment,
- GtkAdjustment *vadjustment)
-{
- guint signal_id;
- GSignalQuery query;
-
- g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
-
- if (hadjustment)
- g_return_val_if_fail (GTK_IS_ADJUSTMENT (hadjustment), FALSE);
- if (vadjustment)
- g_return_val_if_fail (GTK_IS_ADJUSTMENT (vadjustment), FALSE);
-
- signal_id = WIDGET_CLASS (widget)->set_scroll_adjustments_signal;
- if (!signal_id)
- return FALSE;
-
- g_signal_query (signal_id, &query);
- if (!query.signal_id ||
- !g_type_is_a (query.itype, GTK_TYPE_WIDGET) ||
- query.return_type != G_TYPE_NONE ||
- query.n_params != 2 ||
- query.param_types[0] != GTK_TYPE_ADJUSTMENT ||
- query.param_types[1] != GTK_TYPE_ADJUSTMENT)
- {
- g_warning (G_STRLOC ": signal \"%s::%s\" has wrong signature",
- G_OBJECT_TYPE_NAME (widget), query.signal_name);
- return FALSE;
- }
-
- g_signal_emit (widget, signal_id, 0, hadjustment, vadjustment);
- return TRUE;
-}
-
static void
gtk_widget_reparent_subwindows (GtkWidget *widget,
GdkWindow *new_window)
* that gtk_widget_unparent doesn't unrealize widget
*/
if (gtk_widget_get_realized (widget) && gtk_widget_get_realized (new_parent))
- GTK_PRIVATE_SET_FLAG (widget, GTK_IN_REPARENT);
+ priv->in_reparent = TRUE;
g_object_ref (widget);
gtk_container_remove (GTK_CONTAINER (priv->parent), widget);
gtk_container_add (GTK_CONTAINER (new_parent), widget);
g_object_unref (widget);
- if (GTK_WIDGET_IN_REPARENT (widget))
+ if (priv->in_reparent)
{
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_IN_REPARENT);
+ priv->in_reparent = FALSE;
gtk_widget_reparent_subwindows (widget, gtk_widget_get_parent_window (widget));
gtk_widget_reparent_fixup_child (widget,
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
- if (GTK_IS_WINDOW (toplevel) &&
- GTK_WINDOW_GET_CLASS (toplevel)->move_focus)
+ if (widget != toplevel && GTK_IS_WINDOW (toplevel))
{
- GTK_WINDOW_GET_CLASS (toplevel)->move_focus (GTK_WINDOW (toplevel),
- direction);
+ g_signal_emit (toplevel, widget_signals[MOVE_FOCUS], 0,
+ direction);
}
}
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (can_focus != gtk_widget_get_can_focus (widget))
+ if (widget->priv->can_focus != can_focus)
{
- if (can_focus)
- GTK_OBJECT_FLAGS (widget) |= GTK_CAN_FOCUS;
- else
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_CAN_FOCUS);
+ widget->priv->can_focus = can_focus;
gtk_widget_queue_resize (widget);
g_object_notify (G_OBJECT (widget), "can-focus");
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_CAN_FOCUS) != 0;
+ return widget->priv->can_focus;
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_HAS_FOCUS) != 0;
+ return widget->priv->has_focus;
}
/**
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (can_default != gtk_widget_get_can_default (widget))
+ if (widget->priv->can_default != can_default)
{
- if (can_default)
- GTK_OBJECT_FLAGS (widget) |= GTK_CAN_DEFAULT;
- else
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_CAN_DEFAULT);
+ widget->priv->can_default = can_default;
gtk_widget_queue_resize (widget);
g_object_notify (G_OBJECT (widget), "can-default");
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_CAN_DEFAULT) != 0;
+ return widget->priv->can_default;
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_HAS_DEFAULT) != 0;
+ return widget->priv->has_default;
}
void
_gtk_widget_set_has_default (GtkWidget *widget,
gboolean has_default)
{
- if (has_default)
- GTK_OBJECT_FLAGS (widget) |= GTK_HAS_DEFAULT;
- else
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_HAS_DEFAULT);
+ widget->priv->has_default = has_default;
}
/**
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (receives_default != gtk_widget_get_receives_default (widget))
+ if (widget->priv->receives_default != receives_default)
{
- if (receives_default)
- GTK_OBJECT_FLAGS (widget) |= GTK_RECEIVES_DEFAULT;
- else
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_RECEIVES_DEFAULT);
+ widget->priv->receives_default = receives_default;
g_object_notify (G_OBJECT (widget), "receives-default");
}
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_RECEIVES_DEFAULT) != 0;
+ return widget->priv->receives_default;
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_HAS_GRAB) != 0;
+ return widget->priv->has_grab;
}
void
_gtk_widget_set_has_grab (GtkWidget *widget,
gboolean has_grab)
{
- if (has_grab)
- GTK_OBJECT_FLAGS (widget) |= GTK_HAS_GRAB;
- else
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_HAS_GRAB);
+ widget->priv->has_grab = has_grab;
}
/**
g_free (priv->name);
priv->name = new_name;
- if (gtk_widget_has_rc_style (widget))
+ if (priv->rc_style)
gtk_widget_reset_rc_style (widget);
g_object_notify (G_OBJECT (widget), "name");
}
}
+void
+_gtk_widget_set_visible_flag (GtkWidget *widget,
+ gboolean visible)
+{
+ widget->priv->visible = visible;
+}
+
/**
* gtk_widget_get_visible:
* @widget: a #GtkWidget
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_VISIBLE) != 0;
+ return widget->priv->visible;
}
/**
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (has_window)
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_NO_WINDOW);
- else
- GTK_OBJECT_FLAGS (widget) |= GTK_NO_WINDOW;
+ widget->priv->no_window = !has_window;
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return !((GTK_OBJECT_FLAGS (widget) & GTK_NO_WINDOW) != 0);
+ return ! widget->priv->no_window;
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_TOPLEVEL) != 0;
+ return widget->priv->toplevel;
}
void
_gtk_widget_set_is_toplevel (GtkWidget *widget,
gboolean is_toplevel)
{
- if (is_toplevel)
- GTK_OBJECT_FLAGS (widget) |= GTK_TOPLEVEL;
- else
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_TOPLEVEL);
+ widget->priv->toplevel = is_toplevel;
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_REALIZED) != 0;
+ return widget->priv->realized;
}
/**
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (realized)
- GTK_OBJECT_FLAGS (widget) |= GTK_REALIZED;
- else
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_REALIZED);
+ widget->priv->realized = realized;
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_MAPPED) != 0;
+ return widget->priv->mapped;
}
/**
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (mapped)
- GTK_OBJECT_FLAGS (widget) |= GTK_MAPPED;
- else
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_MAPPED);
+ widget->priv->mapped = mapped;
}
/**
* @app_paintable: %TRUE if the application will paint on the widget
*
* Sets whether the application intends to draw on the widget in
- * an #GtkWidget::expose-event handler.
+ * an #GtkWidget::draw handler.
*
* This is a hint to the widget and does not affect the behavior of
* the GTK+ core; many widgets ignore this flag entirely. For widgets
app_paintable = (app_paintable != FALSE);
- if (gtk_widget_get_app_paintable (widget) != app_paintable)
+ if (widget->priv->app_paintable != app_paintable)
{
- if (app_paintable)
- GTK_OBJECT_FLAGS (widget) |= GTK_APP_PAINTABLE;
- else
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_APP_PAINTABLE);
+ widget->priv->app_paintable = app_paintable;
if (gtk_widget_is_drawable (widget))
gtk_widget_queue_draw (widget);
* @widget: a #GtkWidget
*
* Determines whether the application intends to draw on the widget in
- * an #GtkWidget::expose-event handler.
+ * an #GtkWidget::draw handler.
*
* See gtk_widget_set_app_paintable()
*
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_APP_PAINTABLE) != 0;
+ return widget->priv->app_paintable;
}
/**
double_buffered = (double_buffered != FALSE);
- if (double_buffered != gtk_widget_get_double_buffered (widget))
+ if (widget->priv->double_buffered != double_buffered)
{
- if (double_buffered)
- GTK_OBJECT_FLAGS (widget) |= GTK_DOUBLE_BUFFERED;
- else
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_DOUBLE_BUFFERED);
+ widget->priv->double_buffered = double_buffered;
g_object_notify (G_OBJECT (widget), "double-buffered");
}
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_DOUBLE_BUFFERED) != 0;
+ return widget->priv->double_buffered;
}
/**
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (redraw_on_allocate)
- GTK_PRIVATE_SET_FLAG (widget, GTK_REDRAW_ON_ALLOC);
- else
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_REDRAW_ON_ALLOC);
+ widget->priv->redraw_on_alloc = redraw_on_allocate;
}
/**
sensitive = (sensitive != FALSE);
- if (sensitive == (gtk_widget_get_sensitive (widget) != FALSE))
+ if (widget->priv->sensitive == sensitive)
return;
if (sensitive)
{
- GTK_OBJECT_FLAGS (widget) |= GTK_SENSITIVE;
+ widget->priv->sensitive = TRUE;
data.state = priv->saved_state;
}
else
{
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_SENSITIVE);
+ widget->priv->sensitive = FALSE;
data.state = gtk_widget_get_state (widget);
}
data.state_restoration = TRUE;
data.use_forall = TRUE;
if (priv->parent)
- data.parent_sensitive = (gtk_widget_is_sensitive (priv->parent) != FALSE);
+ data.parent_sensitive = gtk_widget_is_sensitive (priv->parent);
else
data.parent_sensitive = TRUE;
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_SENSITIVE) != 0;
+ return widget->priv->sensitive;
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (gtk_widget_get_sensitive (widget) &&
- (GTK_OBJECT_FLAGS (widget) & GTK_PARENT_SENSITIVE) != 0);
+ return widget->priv->sensitive && widget->priv->parent_sensitive;
}
/**
gtk_widget_reset_rc_styles (widget);
g_signal_emit (widget, widget_signals[PARENT_SET], 0, NULL);
- if (GTK_WIDGET_ANCHORED (priv->parent))
+ if (priv->parent->priv->anchored)
_gtk_widget_propagate_hierarchy_changed (widget, NULL);
g_object_notify (G_OBJECT (widget), "parent");
if (gtk_widget_get_visible (priv->parent) &&
gtk_widget_get_visible (widget))
{
- if (GTK_WIDGET_CHILD_VISIBLE (widget) &&
+ if (gtk_widget_get_child_visible (widget) &&
gtk_widget_get_mapped (priv->parent))
gtk_widget_map (widget);
gtk_widget_queue_resize (widget);
}
+
+ /* child may cause parent's expand to change, if the child is
+ * expanded. If child is not expanded, then it can't modify the
+ * parent's expand. If the child becomes expanded later then it will
+ * queue compute_expand then. This optimization plus defaulting
+ * newly-constructed widgets to need_compute_expand=FALSE should
+ * mean that initially building a widget tree doesn't have to keep
+ * walking up setting need_compute_expand on parents over and over.
+ *
+ * We can't change a parent to need to expand unless we're visible.
+ */
+ if (gtk_widget_get_visible (widget) &&
+ (priv->need_compute_expand ||
+ priv->computed_hexpand ||
+ priv->computed_vexpand))
+ {
+ gtk_widget_queue_compute_expand (parent);
+ }
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_OBJECT_FLAGS (widget) & GTK_RC_STYLE) != 0;
+ return widget->priv->rc_style;
}
/**
{
gboolean initial_emission;
- initial_emission = !gtk_widget_has_rc_style (widget) && !GTK_WIDGET_USER_STYLE (widget);
+ initial_emission = !widget->priv->rc_style && !widget->priv->user_style;
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_RC_STYLE);
- GTK_PRIVATE_SET_FLAG (widget, GTK_USER_STYLE);
+ widget->priv->rc_style = FALSE;
+ widget->priv->user_style = TRUE;
gtk_widget_set_style_internal (widget, style, initial_emission);
}
else
{
- if (GTK_WIDGET_USER_STYLE (widget))
+ if (widget->priv->user_style)
gtk_widget_reset_rc_style (widget);
}
}
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (!GTK_WIDGET_USER_STYLE (widget) &&
- !gtk_widget_has_rc_style (widget))
+ if (!widget->priv->rc_style && !widget->priv->user_style)
gtk_widget_reset_rc_style (widget);
}
GtkWidgetPrivate *priv = widget->priv;
GtkStyle *new_style = NULL;
gboolean initial_emission;
-
- initial_emission = !gtk_widget_has_rc_style (widget) && !GTK_WIDGET_USER_STYLE (widget);
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_USER_STYLE);
- GTK_OBJECT_FLAGS (widget) |= GTK_RC_STYLE;
-
+ initial_emission = !priv->rc_style && !priv->user_style;
+
+ priv->user_style = FALSE;
+ priv->rc_style = TRUE;
+
if (gtk_widget_has_screen (widget))
new_style = gtk_rc_get_style (widget);
if (!new_style)
* modifier style and the only reference was our own.
*/
- if (gtk_widget_has_rc_style (widget))
+ if (widget->priv->rc_style)
gtk_widget_reset_rc_style (widget);
}
initial_emission ? NULL : previous_style);
g_object_unref (previous_style);
- if (GTK_WIDGET_ANCHORED (widget) && !initial_emission)
+ if (priv->anchored && !initial_emission)
gtk_widget_queue_resize (widget);
}
else if (initial_emission)
GtkWidgetPrivate *priv = widget->priv;
HierarchyChangedInfo *info = client_data;
gboolean new_anchored = gtk_widget_is_toplevel (widget) ||
- (priv->parent && GTK_WIDGET_ANCHORED (priv->parent));
+ (priv->parent && priv->parent->priv->anchored);
- if (GTK_WIDGET_ANCHORED (widget) != new_anchored)
+ if (priv->anchored != new_anchored)
{
g_object_ref (widget);
-
- if (new_anchored)
- GTK_PRIVATE_SET_FLAG (widget, GTK_ANCHORED);
- else
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_ANCHORED);
+
+ priv->anchored = new_anchored;
g_signal_emit (widget, widget_signals[HIERARCHY_CHANGED], 0, info->previous_toplevel);
do_screen_change (widget, info->previous_screen, info->new_screen);
* emitting #GtkWidget::hierarchy-changed.
**/
void
-_gtk_widget_propagate_hierarchy_changed (GtkWidget *widget,
- GtkWidget *previous_toplevel)
+_gtk_widget_propagate_hierarchy_changed (GtkWidget *widget,
+ GtkWidget *previous_toplevel)
{
GtkWidgetPrivate *priv = widget->priv;
HierarchyChangedInfo info;
info.previous_screen = previous_toplevel ? gtk_widget_get_screen (previous_toplevel) : NULL;
if (gtk_widget_is_toplevel (widget) ||
- (priv->parent && GTK_WIDGET_ANCHORED (priv->parent)))
+ (priv->parent && priv->parent->priv->anchored))
info.new_screen = gtk_widget_get_screen (widget);
else
info.new_screen = NULL;
static void
reset_rc_styles_recurse (GtkWidget *widget, gpointer data)
{
- if (gtk_widget_has_rc_style (widget))
+ if (widget->priv->rc_style)
gtk_widget_reset_rc_style (widget);
if (GTK_IS_CONTAINER (widget))
g_object_ref (widget);
if (is_visible)
- GTK_PRIVATE_SET_FLAG (widget, GTK_CHILD_VISIBLE);
+ priv->child_visible = TRUE;
else
{
GtkWidget *toplevel;
-
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_CHILD_VISIBLE);
+
+ priv->child_visible = FALSE;
toplevel = gtk_widget_get_toplevel (widget);
if (toplevel != widget && gtk_widget_is_toplevel (toplevel))
if (priv->parent && gtk_widget_get_realized (priv->parent))
{
if (gtk_widget_get_mapped (priv->parent) &&
- GTK_WIDGET_CHILD_VISIBLE (widget) &&
+ priv->child_visible &&
gtk_widget_get_visible (widget))
gtk_widget_map (widget);
else
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return GTK_WIDGET_CHILD_VISIBLE (widget);
+ return widget->priv->child_visible;
}
static GdkScreen *
}
static void
-gtk_widget_set_usize_internal (GtkWidget *widget,
- gint width,
- gint height)
+gtk_widget_set_usize_internal (GtkWidget *widget,
+ gint width,
+ gint height,
+ GtkQueueResizeFlags flags)
{
GtkWidgetAuxInfo *aux_info;
gboolean changed = FALSE;
if (width > -2 && aux_info->width != width)
{
- g_object_notify (G_OBJECT (widget), "width-request");
+ if ((flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY) == 0)
+ g_object_notify (G_OBJECT (widget), "width-request");
aux_info->width = width;
changed = TRUE;
}
if (height > -2 && aux_info->height != height)
{
- g_object_notify (G_OBJECT (widget), "height-request");
+ if ((flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY) == 0)
+ g_object_notify (G_OBJECT (widget), "height-request");
aux_info->height = height;
changed = TRUE;
}
if (gtk_widget_get_visible (widget) && changed)
- gtk_widget_queue_resize (widget);
+ {
+ if ((flags & GTK_QUEUE_RESIZE_INVALIDATE_ONLY) == 0)
+ gtk_widget_queue_resize (widget);
+ else
+ _gtk_size_group_queue_resize (widget, GTK_QUEUE_RESIZE_INVALIDATE_ONLY);
+ }
g_object_thaw_notify (G_OBJECT (widget));
}
if (height == 0)
height = 1;
- gtk_widget_set_usize_internal (widget, width, height);
+ gtk_widget_set_usize_internal (widget, width, height, 0);
}
* @height indicates that that dimension has not been set explicitly
* and the natural requisition of the widget will be used intead. See
* gtk_widget_set_size_request(). To get the size a widget will
- * actually request, call gtk_size_request_get_size() instead of
+ * actually request, call gtk_widget_get_preferred_size() instead of
* this function.
**/
void
*height = aux_info->height;
}
+/**
+ * _gtk_widget_override_size_request:
+ * @widget: a #GtkWidget
+ * @width: new forced minimum width
+ * @height: new forced minimum height
+ * @old_width: location to store previous forced minimum width
+ * @old_width: location to store previous forced minumum height
+ *
+ * Temporarily establishes a forced minimum size for a widget; this
+ * is used by GtkWindow when calculating the size to add to the
+ * window's geometry widget. Cached sizes for the widget and its
+ * parents are invalidated, so that subsequent calls to the size
+ * negotiation machinery produce the overriden result, but the
+ * widget is not queued for relayout or redraw. The old size must
+ * be restored with _gtk_widget_restore_size_request() or things
+ * will go screwy.
+ */
+void
+_gtk_widget_override_size_request (GtkWidget *widget,
+ int width,
+ int height,
+ int *old_width,
+ int *old_height)
+{
+ gtk_widget_get_size_request (widget, old_width, old_height);
+ gtk_widget_set_usize_internal (widget, width, height,
+ GTK_QUEUE_RESIZE_INVALIDATE_ONLY);
+}
+
+/**
+ * _gtk_widget_restore_size_request:
+ * @widget: a #GtkWidget
+ * @old_width: saved forced minimum size
+ * @old_height: saved forced minimum size
+ *
+ * Undoes the operation of_gtk_widget_override_size_request().
+ */
+void
+_gtk_widget_restore_size_request (GtkWidget *widget,
+ int old_width,
+ int old_height)
+{
+ gtk_widget_set_usize_internal (widget, old_width, old_height,
+ GTK_QUEUE_RESIZE_INVALIDATE_ONLY);
+}
+
/**
* gtk_widget_set_events:
* @widget: a #GtkWidget
return widget;
}
+/**
+ * gtk_widget_set_visual:
+ * @widget: a #GtkWidget
+ * @visual: visual to be used or %NULL to unset a previous one
+ *
+ * Sets the visual that should be used for by widget and its children for
+ * creating #GdkWindows. The visual must be on the same #GdkScreen as
+ * returned by gdk_widget_get_screen(), so handling the
+ * GtkWidget::screen-changed signal is necessary.
+ *
+ * Setting a new @visual will not cause @widget to recreate its windows,
+ * so you should call this function before @widget is realized.
+ **/
+void
+gtk_widget_set_visual (GtkWidget *widget,
+ GdkVisual *visual)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (visual == NULL || GDK_IS_VISUAL (visual));
+ if (visual)
+ {
+ g_return_if_fail (gtk_widget_get_screen (widget) == gdk_visual_get_screen (visual));
+ }
+
+ g_object_set_qdata_full (G_OBJECT (widget),
+ quark_visual,
+ g_object_ref (visual),
+ g_object_unref);
+}
+
/**
* gtk_widget_get_visual:
* @widget: a #GtkWidget
gtk_widget_get_visual (GtkWidget *widget)
{
GtkWidget *w;
+ GdkVisual *visual;
+ GdkScreen *screen;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+ if (gtk_widget_get_has_window (widget) &&
+ widget->priv->window)
+ return gdk_window_get_visual (widget->priv->window);
+
+ screen = gtk_widget_get_screen (widget);
+
for (w = widget; w != NULL; w = w->priv->parent)
{
- if (gtk_widget_get_has_window (w) &&
- w->priv->window)
- return gdk_window_get_visual (w->priv->window);
+ visual = g_object_get_qdata (G_OBJECT (w), quark_visual);
+ if (visual)
+ {
+ if (gdk_visual_get_screen (visual) == screen)
+ return visual;
- if (GTK_IS_WINDOW (w))
- return _gtk_window_get_visual (GTK_WINDOW (w));
+ g_warning ("Ignoring visual set on widget `%s' that is not on the correct screen.",
+ gtk_widget_get_name (widget));
+ }
}
- return gdk_screen_get_system_visual (gdk_screen_get_default ());
+ return gdk_screen_get_system_visual (screen);
}
/**
const gchar *name)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail ((GTK_OBJECT_FLAGS (widget) & GTK_COMPOSITE_CHILD) != 0);
+ g_return_if_fail (widget->priv->composite_child);
g_return_if_fail (name != NULL);
if (!quark_composite_name)
priv = widget->priv;
- if (((GTK_OBJECT_FLAGS (widget) & GTK_COMPOSITE_CHILD) != 0) && priv->parent)
+ if (widget->priv->composite_child && priv->parent)
return _gtk_container_child_composite_name (GTK_CONTAINER (priv->parent),
widget);
else
g_return_if_fail (dir >= GTK_TEXT_DIR_NONE && dir <= GTK_TEXT_DIR_RTL);
old_dir = gtk_widget_get_direction (widget);
-
- if (dir == GTK_TEXT_DIR_NONE)
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_DIRECTION_SET);
- else
- {
- GTK_PRIVATE_SET_FLAG (widget, GTK_DIRECTION_SET);
- if (dir == GTK_TEXT_DIR_LTR)
- GTK_PRIVATE_SET_FLAG (widget, GTK_DIRECTION_LTR);
- else
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_DIRECTION_LTR);
- }
+
+ widget->priv->direction = dir;
if (old_dir != gtk_widget_get_direction (widget))
gtk_widget_emit_direction_changed (widget, old_dir);
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_TEXT_DIR_LTR);
- if (GTK_WIDGET_DIRECTION_SET (widget))
- return GTK_WIDGET_DIRECTION_LTR (widget) ? GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
- else
+ if (widget->priv->direction == GTK_TEXT_DIR_NONE)
return gtk_default_direction;
+ else
+ return widget->priv->direction;
}
static void
g_object_ref (widget);
- if (!GTK_WIDGET_DIRECTION_SET (widget))
+ if (widget->priv->direction == GTK_TEXT_DIR_NONE)
gtk_widget_emit_direction_changed (widget, old_dir);
if (GTK_IS_CONTAINER (widget))
else if (gtk_widget_get_visible (widget))
gtk_widget_hide (widget);
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
+ priv->visible = FALSE;
if (gtk_widget_get_realized (widget))
gtk_widget_unrealize (widget);
-
+
+ if (!priv->in_destruction)
+ {
+ priv->in_destruction = TRUE;
+ g_signal_emit (object, widget_signals[DESTROY], 0);
+ priv->in_destruction = FALSE;
+ }
+
G_OBJECT_CLASS (gtk_widget_parent_class)->dispose (object);
}
static void
-gtk_widget_real_destroy (GtkObject *object)
+gtk_widget_real_destroy (GtkWidget *object)
{
/* gtk_object_destroy() will already hold a refcount on object */
GtkWidget *widget = GTK_WIDGET (object);
/* Callers of add_mnemonic_label() should disconnect on ::destroy */
g_object_set_qdata (G_OBJECT (widget), quark_mnemonic_labels, NULL);
-
+
gtk_grab_remove (widget);
g_object_unref (priv->style);
priv->style = gtk_widget_get_default_style ();
g_object_ref (priv->style);
-
- GTK_OBJECT_CLASS (gtk_widget_parent_class)->destroy (object);
}
static void
if (accessible)
g_object_unref (accessible);
+ if (g_object_is_floating (object))
+ g_warning ("A floating object was finalized. This means that someone\n"
+ "called g_object_unref() on an object that had only a floating\n"
+ "reference; the initial floating reference is not owned by anyone\n"
+ "and must be removed with g_object_ref_sink().");
+
G_OBJECT_CLASS (gtk_widget_parent_class)->finalize (object);
}
static void
gtk_widget_real_adjust_size_request (GtkWidget *widget,
GtkOrientation orientation,
- gint for_size,
gint *minimum_size,
gint *natural_size)
{
*/
- if (data->parent_sensitive)
- GTK_OBJECT_FLAGS (widget) |= GTK_PARENT_SENSITIVE;
- else
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_PARENT_SENSITIVE);
+ priv->parent_sensitive = data->parent_sensitive;
if (gtk_widget_is_sensitive (widget))
{
g_signal_emit (widget, widget_signals[STATE_CHANGED], 0, old_state);
- if (!GTK_WIDGET_SHADOWED (widget))
+ if (!priv->shadowed)
{
GList *event_windows = NULL;
GList *devices, *d;
if (region == NULL)
{
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_HAS_SHAPE_MASK);
-
+ priv->has_shape_mask = FALSE;
+
if (priv->window)
gdk_window_shape_combine_region (priv->window, NULL, 0, 0);
}
else
{
- GTK_PRIVATE_SET_FLAG (widget, GTK_HAS_SHAPE_MASK);
+ priv->has_shape_mask = TRUE;
g_object_set_qdata_full (G_OBJECT (widget), quark_shape_info,
cairo_region_copy (region),
priv = widget->priv;
- if (!GTK_WIDGET_HAS_SHAPE_MASK (widget))
+ if (!priv->has_shape_mask)
gtk_reset_shapes_recurse (widget, priv->window);
}
return accessible;
}
+/*
+ * Expand flag management
+ */
+
+static void
+gtk_widget_update_computed_expand (GtkWidget *widget)
+{
+ GtkWidgetPrivate *priv;
+
+ priv = widget->priv;
+
+ if (priv->need_compute_expand)
+ {
+ gboolean h, v;
+
+ if (priv->hexpand_set)
+ h = priv->hexpand;
+ else
+ h = FALSE;
+
+ if (priv->vexpand_set)
+ v = priv->vexpand;
+ else
+ v = FALSE;
+
+ /* we don't need to use compute_expand if both expands are
+ * forced by the app
+ */
+ if (!(priv->hexpand_set && priv->vexpand_set))
+ {
+ if (GTK_WIDGET_GET_CLASS (widget)->compute_expand != NULL)
+ {
+ gboolean ignored;
+
+ GTK_WIDGET_GET_CLASS (widget)->compute_expand (widget,
+ priv->hexpand_set ? &ignored : &h,
+ priv->vexpand_set ? &ignored : &v);
+ }
+ }
+
+ priv->need_compute_expand = FALSE;
+ priv->computed_hexpand = h != FALSE;
+ priv->computed_vexpand = v != FALSE;
+ }
+}
+
+/**
+ * gtk_widget_queue_compute_expand:
+ * @widget: a #GtkWidget
+ *
+ * Mark @widget as needing to recompute its expand flags. Call
+ * this function when setting legacy expand child properties
+ * on the child of a container.
+ *
+ * See gtk_widget_compute_expand().
+ */
+void
+gtk_widget_queue_compute_expand (GtkWidget *widget)
+{
+ GtkWidget *parent;
+ gboolean changed_anything;
+
+ if (widget->priv->need_compute_expand)
+ return;
+
+ changed_anything = FALSE;
+ parent = widget;
+ while (parent != NULL)
+ {
+ if (!parent->priv->need_compute_expand)
+ {
+ parent->priv->need_compute_expand = TRUE;
+ changed_anything = TRUE;
+ }
+
+ /* Note: if we had an invariant that "if a child needs to
+ * compute expand, its parents also do" then we could stop going
+ * up when we got to a parent that already needed to
+ * compute. However, in general we compute expand lazily (as
+ * soon as we see something in a subtree that is expand, we know
+ * we're expanding) and so this invariant does not hold and we
+ * have to always walk all the way up in case some ancestor
+ * is not currently need_compute_expand.
+ */
+
+ parent = parent->priv->parent;
+ }
+
+ /* recomputing expand always requires
+ * a relayout as well
+ */
+ if (changed_anything)
+ gtk_widget_queue_resize (widget);
+}
+
+/**
+ * gtk_widget_compute_expand:
+ * @widget: the widget
+ * @orientation: expand direction
+ *
+ * Computes whether a container should give this widget extra space
+ * when possible. Containers should check this, rather than
+ * looking at gtk_widget_get_hexpand() or gtk_widget_get_vexpand().
+ *
+ * This function already checks whether the widget is visible, so
+ * visibility does not need to be checked separately. Non-visible
+ * widgets are not expanded.
+ *
+ * The computed expand value uses either the expand setting explicitly
+ * set on the widget itself, or, if none has been explicitly set,
+ * the widget may expand if some of its children do.
+ *
+ * Return value: whether widget tree rooted here should be expanded
+ */
+gboolean
+gtk_widget_compute_expand (GtkWidget *widget,
+ GtkOrientation orientation)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ /* We never make a widget expand if not even showing. */
+ if (!gtk_widget_get_visible (widget))
+ return FALSE;
+
+ gtk_widget_update_computed_expand (widget);
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ return widget->priv->computed_hexpand;
+ }
+ else
+ {
+ return widget->priv->computed_vexpand;
+ }
+}
+
+static void
+gtk_widget_set_expand (GtkWidget *widget,
+ GtkOrientation orientation,
+ gboolean expand)
+{
+ const char *expand_prop;
+ const char *expand_set_prop;
+ gboolean was_both;
+ GtkWidgetPrivate *priv;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ priv = widget->priv;
+
+ expand = expand != FALSE;
+
+ was_both = priv->hexpand && priv->vexpand;
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ if (priv->hexpand_set &&
+ priv->hexpand == expand)
+ return;
+
+ priv->hexpand_set = TRUE;
+ priv->hexpand = expand;
+
+ expand_prop = "hexpand";
+ expand_set_prop = "hexpand-set";
+ }
+ else
+ {
+ if (priv->vexpand_set &&
+ priv->vexpand == expand)
+ return;
+
+ priv->vexpand_set = TRUE;
+ priv->vexpand = expand;
+
+ expand_prop = "vexpand";
+ expand_set_prop = "vexpand-set";
+ }
+
+ gtk_widget_queue_compute_expand (widget);
+
+ g_object_freeze_notify (G_OBJECT (widget));
+ g_object_notify (G_OBJECT (widget), expand_prop);
+ g_object_notify (G_OBJECT (widget), expand_set_prop);
+ if (was_both != (priv->hexpand && priv->vexpand))
+ g_object_notify (G_OBJECT (widget), "expand");
+ g_object_thaw_notify (G_OBJECT (widget));
+}
+
+static void
+gtk_widget_set_expand_set (GtkWidget *widget,
+ GtkOrientation orientation,
+ gboolean set)
+{
+ GtkWidgetPrivate *priv;
+ const char *prop;
+
+ priv = widget->priv;
+
+ set = set != FALSE;
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ if (set == priv->hexpand_set)
+ return;
+
+ priv->hexpand_set = set;
+ prop = "hexpand-set";
+ }
+ else
+ {
+ if (set == priv->vexpand_set)
+ return;
+
+ priv->vexpand_set = set;
+ prop = "vexpand-set";
+ }
+
+ gtk_widget_queue_compute_expand (widget);
+
+ g_object_notify (G_OBJECT (widget), prop);
+}
+
+/**
+ * gtk_widget_get_hexpand:
+ * @widget: the widget
+ *
+ * Gets whether the widget would like any available extra horizontal
+ * space. When a user resizes a #GtkWindow, widgets with expand=TRUE
+ * generally receive the extra space. For example, a list or
+ * scrollable area or document in your window would often be set to
+ * expand.
+ *
+ * Containers should use gtk_widget_compute_expand() rather than
+ * this function, to see whether a widget, or any of its children,
+ * has the expand flag set. If any child of a widget wants to
+ * expand, the parent may ask to expand also.
+ *
+ * This function only looks at the widget's own hexpand flag, rather
+ * than computing whether the entire widget tree rooted at this widget
+ * wants to expand.
+ *
+ * Return value: whether hexpand flag is set
+ */
+gboolean
+gtk_widget_get_hexpand (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return widget->priv->hexpand;
+}
+
+/**
+ * gtk_widget_set_hexpand:
+ * @widget: the widget
+ * @expand: whether to expand
+ *
+ * Sets whether the widget would like any available extra horizontal
+ * space. When a user resizes a #GtkWindow, widgets with expand=TRUE
+ * generally receive the extra space. For example, a list or
+ * scrollable area or document in your window would often be set to
+ * expand.
+ *
+ * Call this function to set the expand flag if you would like your
+ * widget to become larger horizontally when the window has extra
+ * room.
+ *
+ * By default, widgets automatically expand if any of their children
+ * want to expand. (To see if a widget will automatically expand given
+ * its current children and state, call gtk_widget_compute_expand(). A
+ * container can decide how the expandability of children affects the
+ * expansion of the container by overriding the compute_expand virtual
+ * method on #GtkWidget.).
+ *
+ * Setting hexpand explicitly with this function will override the
+ * automatic expand behavior.
+ *
+ * This function forces the widget to expand or not to expand,
+ * regardless of children. The override occurs because
+ * gtk_widget_set_hexpand() sets the hexpand-set property (see
+ * gtk_widget_set_hexpand_set()) which causes the widget's hexpand
+ * value to be used, rather than looking at children and widget state.
+ */
+void
+gtk_widget_set_hexpand (GtkWidget *widget,
+ gboolean expand)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ gtk_widget_set_expand (widget, GTK_ORIENTATION_HORIZONTAL, expand);
+}
+
+/**
+ * gtk_widget_get_hexpand_set:
+ * @widget: the widget
+ *
+ * Gets whether gtk_widget_set_hexpand() has been used to
+ * explicitly set the expand flag on this widget.
+ *
+ * If hexpand is set, then it overrides any computed
+ * expand value based on child widgets. If hexpand is not
+ * set, then the expand value depends on whether any
+ * children of the widget would like to expand.
+ *
+ * There are few reasons to use this function, but it's here
+ * for completeness and consistency.
+ *
+ * Return value: whether hexpand has been explicitly set
+ */
+gboolean
+gtk_widget_get_hexpand_set (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return widget->priv->hexpand_set;
+}
+
+/**
+ * gtk_widget_set_hexpand_set:
+ * @widget: the widget
+ * @set: value for hexpand-set property
+ *
+ * Sets whether the hexpand flag (see gtk_widget_get_hexpand()) will
+ * be used.
+ *
+ * The hexpand-set property will be set automatically when you call
+ * gtk_widget_set_hexpand() to set hexpand, so the most likely
+ * reason to use this function would be to unset an explicit expand
+ * flag.
+ *
+ * If hexpand is set, then it overrides any computed
+ * expand value based on child widgets. If hexpand is not
+ * set, then the expand value depends on whether any
+ * children of the widget would like to expand.
+ *
+ * There are few reasons to use this function, but it's here
+ * for completeness and consistency.
+ *
+ * Return value: whether hexpand has been explicitly set
+ */
+void
+gtk_widget_set_hexpand_set (GtkWidget *widget,
+ gboolean set)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ gtk_widget_set_expand_set (widget, GTK_ORIENTATION_HORIZONTAL, set);
+}
+
+
+/**
+ * gtk_widget_get_vexpand:
+ * @widget: the widget
+ *
+ * Gets whether the widget would like any available extra vertical
+ * space.
+ *
+ * See gtk_widget_get_hexpand() for more detail.
+ *
+ * Return value: whether vexpand flag is set
+ */
+gboolean
+gtk_widget_get_vexpand (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return widget->priv->vexpand;
+}
+
+/**
+ * gtk_widget_set_vexpand:
+ * @widget: the widget
+ * @expand: whether to expand
+ *
+ * Sets whether the widget would like any available extra vertical
+ * space.
+ *
+ * See gtk_widget_set_hexpand() for more detail.
+ */
+void
+gtk_widget_set_vexpand (GtkWidget *widget,
+ gboolean expand)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ gtk_widget_set_expand (widget, GTK_ORIENTATION_VERTICAL, expand);
+}
+
+/**
+ * gtk_widget_get_vexpand_set:
+ * @widget: the widget
+ *
+ * Gets whether gtk_widget_set_vexpand() has been used to
+ * explicitly set the expand flag on this widget.
+ *
+ * See gtk_widget_get_hexpand_set() for more detail.
+ *
+ * Return value: whether vexpand has been explicitly set
+ */
+gboolean
+gtk_widget_get_vexpand_set (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return widget->priv->vexpand_set;
+}
+
+/**
+ * gtk_widget_set_vexpand_set:
+ * @widget: the widget
+ * @set: value for vexpand-set property
+ *
+ * Sets whether the vexpand flag (see gtk_widget_get_vexpand()) will
+ * be used.
+ *
+ * See gtk_widget_set_hexpand_set() for more detail.
+ *
+ * Return value: whether vexpand has been explicitly set
+ */
+void
+gtk_widget_set_vexpand_set (GtkWidget *widget,
+ gboolean set)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ gtk_widget_set_expand_set (widget, GTK_ORIENTATION_VERTICAL, set);
+}
+
/*
* GtkBuildable implementation
*/
}
}
-/*
- * GtkSizeRequest implementation
- */
static void
-gtk_widget_real_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_widget_real_get_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
if (minimum_size)
*minimum_size = 0;
}
static void
-gtk_widget_real_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_widget_real_get_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
if (minimum_size)
*minimum_size = 0;
}
static void
-gtk_widget_real_get_height_for_width (GtkSizeRequest *layout,
+gtk_widget_real_get_height_for_width (GtkWidget *widget,
gint width,
gint *minimum_height,
gint *natural_height)
{
- GTK_SIZE_REQUEST_GET_IFACE (layout)->get_height(layout, minimum_height, natural_height);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, minimum_height, natural_height);
}
static void
-gtk_widget_real_get_width_for_height (GtkSizeRequest *layout,
+gtk_widget_real_get_width_for_height (GtkWidget *widget,
gint height,
gint *minimum_width,
gint *natural_width)
{
- GTK_SIZE_REQUEST_GET_IFACE (layout)->get_width(layout, minimum_width, natural_width);
-}
-
-static void
-gtk_widget_size_request_init (GtkSizeRequestIface *iface)
-{
- 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;
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width);
}
/**
/**
* gtk_widget_get_no_show_all:
* @widget: a #GtkWidget
- *
- * Returns the current value of the GtkWidget:no-show-all property,
- * which determines whether calls to gtk_widget_show_all() and
- * gtk_widget_hide_all() will affect this widget.
- *
+ *
+ * Returns the current value of the GtkWidget:no-show-all property,
+ * which determines whether calls to gtk_widget_show_all()
+ * will affect this widget.
+ *
* Return value: the current value of the "no-show-all" property.
*
* Since: 2.4
gtk_widget_get_no_show_all (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
-
- return (GTK_OBJECT_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0;
+
+ return widget->priv->no_show_all;
}
/**
* gtk_widget_set_no_show_all:
* @widget: a #GtkWidget
* @no_show_all: the new value for the "no-show-all" property
- *
- * Sets the #GtkWidget:no-show-all property, which determines whether
- * calls to gtk_widget_show_all() and gtk_widget_hide_all() will affect
- * this widget.
+ *
+ * Sets the #GtkWidget:no-show-all property, which determines whether
+ * calls to gtk_widget_show_all() will affect this widget.
*
* This is mostly for use in constructing widget hierarchies with externally
* controlled visibility, see #GtkUIManager.
no_show_all = (no_show_all != FALSE);
- if (no_show_all == gtk_widget_get_no_show_all (widget))
- return;
+ if (widget->priv->no_show_all != no_show_all)
+ {
+ widget->priv->no_show_all = no_show_all;
- if (no_show_all)
- GTK_OBJECT_FLAGS (widget) |= GTK_NO_SHOW_ALL;
- else
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_NO_SHOW_ALL);
-
- g_object_notify (G_OBJECT (widget), "no-show-all");
+ g_object_notify (G_OBJECT (widget), "no-show-all");
+ }
}
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (requisition != NULL);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
+ gtk_widget_get_preferred_size (widget, requisition, NULL);
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return GTK_WIDGET_FLAGS (widget) & GTK_MULTIDEVICE;
+ return widget->priv->multidevice;
}
/**
if (support_multidevice)
{
- GTK_WIDGET_SET_FLAGS (widget, GTK_MULTIDEVICE);
+ priv->multidevice = TRUE;
gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_ALL);
}
else
{
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MULTIDEVICE);
+ priv->multidevice = FALSE;
gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_NONE);
}
_gtk_widget_set_has_focus (GtkWidget *widget,
gboolean has_focus)
{
- if (has_focus)
- GTK_OBJECT_FLAGS (widget) |= GTK_HAS_FOCUS;
- else
- GTK_OBJECT_FLAGS (widget) &= ~(GTK_HAS_FOCUS);
+ widget->priv->has_focus = has_focus;
}
/**
return res;
}
+
+/**
+ * gtk_widget_in_destruction:
+ * @widget: a #GtkWidget
+ *
+ * Returns whether the widget is currently being destroyed.
+ * This information can sometimes be used to avoid doing
+ * unnecessary work.
+ *
+ * Returns: %TRUE if @widget is being destroyed
+ */
+gboolean
+gtk_widget_in_destruction (GtkWidget *widget)
+{
+ return widget->priv->in_destruction;
+}
+
+gboolean
+_gtk_widget_get_resize_pending (GtkWidget *widget)
+{
+ return widget->priv->resize_pending;
+}
+
+void
+_gtk_widget_set_resize_pending (GtkWidget *widget,
+ gboolean resize_pending)
+{
+ widget->priv->resize_pending = resize_pending;
+}
+
+gboolean
+_gtk_widget_get_in_reparent (GtkWidget *widget)
+{
+ return widget->priv->in_reparent;
+}
+
+void
+_gtk_widget_set_in_reparent (GtkWidget *widget,
+ gboolean in_reparent)
+{
+ widget->priv->in_reparent = in_reparent;
+}
+
+gboolean
+_gtk_widget_get_anchored (GtkWidget *widget)
+{
+ return widget->priv->anchored;
+}
+
+void
+_gtk_widget_set_anchored (GtkWidget *widget,
+ gboolean anchored)
+{
+ widget->priv->anchored = anchored;
+}
+
+gboolean
+_gtk_widget_get_shadowed (GtkWidget *widget)
+{
+ return widget->priv->shadowed;
+}
+
+void
+_gtk_widget_set_shadowed (GtkWidget *widget,
+ gboolean shadowed)
+{
+ widget->priv->shadowed = shadowed;
+}
+
+gboolean
+_gtk_widget_get_alloc_needed (GtkWidget *widget)
+{
+ return widget->priv->alloc_needed;
+}
+
+void
+_gtk_widget_set_alloc_needed (GtkWidget *widget,
+ gboolean alloc_needed)
+{
+ widget->priv->alloc_needed = alloc_needed;
+}
+
+gboolean
+_gtk_widget_get_width_request_needed (GtkWidget *widget)
+{
+ return widget->priv->width_request_needed;
+}
+
+void
+_gtk_widget_set_width_request_needed (GtkWidget *widget,
+ gboolean width_request_needed)
+{
+ widget->priv->width_request_needed = width_request_needed;
+}
+
+gboolean
+_gtk_widget_get_height_request_needed (GtkWidget *widget)
+{
+ return widget->priv->height_request_needed;
+}
+
+void
+_gtk_widget_set_height_request_needed (GtkWidget *widget,
+ gboolean height_request_needed)
+{
+ widget->priv->height_request_needed = height_request_needed;
+}