#include "gdk/gdkprivate.h" /* Used in gtk_reset_shapes_recurse to avoid copy */
#include <gobject/gvaluecollector.h>
#include <gobject/gobjectnotifyqueue.c>
+#include <cairo-gobject.h>
#include "gdk/gdkkeysyms.h"
#include "gtkaccessible.h"
#include "gtktooltip.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
#include "gtksizerequest.h"
+#include "gtkdebug.h"
/**
*/
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;
/* 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,
DIRECTION_CHANGED,
GRAB_NOTIFY,
CHILD_NOTIFY,
+ DRAW,
MNEMONIC_ACTIVATE,
GRAB_FOCUS,
FOCUS,
PROP_TOOLTIP_MARKUP,
PROP_TOOLTIP_TEXT,
PROP_WINDOW,
- PROP_DOUBLE_BUFFERED
+ PROP_DOUBLE_BUFFERED,
+ PROP_HALIGN,
+ PROP_VALIGN,
+ PROP_MARGIN_LEFT,
+ PROP_MARGIN_RIGHT,
+ PROP_MARGIN_TOP,
+ PROP_MARGIN_BOTTOM,
+ PROP_MARGIN
};
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);
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 gpointer gtk_widget_parent_class = NULL;
static guint widget_signals[LAST_SIGNAL] = { 0 };
static GtkStyle *gtk_default_style = NULL;
-static GSList *colormap_stack = NULL;
static guint composite_child_stack = 0;
static GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR;
static GParamSpecPool *style_property_spec_pool = NULL;
static GQuark quark_pointer_window = 0;
static GQuark quark_shape_info = 0;
static GQuark quark_input_shape_info = 0;
-static GQuark quark_colormap = 0;
static GQuark quark_pango_context = 0;
static GQuark quark_rc_style = 0;
static GQuark quark_accessible_object = 0;
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;
GTK_WIDGET_GET_CLASS (object)->dispatch_child_properties_changed (GTK_WIDGET (object), n_pspecs, pspecs);
}
+/* We guard against the draw signal callbacks modifying the state of the
+ * cairo context by surounding it with save/restore.
+ * Maybe we should also cairo_new_path() just to be sure?
+ */
+static void
+gtk_widget_draw_marshaller (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ cairo_t *cr = g_value_get_boxed (¶m_values[1]);
+
+ cairo_save (cr);
+
+ _gtk_marshal_BOOLEAN__BOXED (closure,
+ return_value,
+ n_param_values,
+ param_values,
+ invocation_hint,
+ marshal_data);
+
+ cairo_restore (cr);
+}
+
static void
gtk_widget_class_init (GtkWidgetClass *klass)
{
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_pointer_window = g_quark_from_static_string ("gtk-pointer-window");
quark_shape_info = g_quark_from_static_string ("gtk-shape-info");
quark_input_shape_info = g_quark_from_static_string ("gtk-input-shape-info");
- quark_colormap = g_quark_from_static_string ("gtk-colormap");
quark_pango_context = g_quark_from_static_string ("gtk-pango-context");
quark_rc_style = g_quark_from_static_string ("gtk-rc-style");
quark_accessible_object = g_quark_from_static_string ("gtk-accessible-object");
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->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->direction_changed = gtk_widget_real_direction_changed;
klass->grab_notify = NULL;
klass->child_notify = NULL;
+ klass->draw = NULL;
klass->mnemonic_activate = gtk_widget_real_mnemonic_activate;
klass->grab_focus = gtk_widget_real_grab_focus;
klass->focus = gtk_widget_real_focus;
klass->motion_notify_event = NULL;
klass->delete_event = NULL;
klass->destroy_event = NULL;
- klass->expose_event = NULL;
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;
TRUE,
GTK_PARAM_READWRITE));
+ /**
+ * GtkWidget:halign:
+ *
+ * How to distribute horizontal space if widget gets extra space, see #GtkAlign
+ *
+ * Since: 3.0
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_HALIGN,
+ g_param_spec_enum ("halign",
+ P_("Horizontal Alignment"),
+ P_("How to position in extra horizontal space"),
+ GTK_TYPE_ALIGN,
+ GTK_ALIGN_FILL,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkWidget:valign:
+ *
+ * How to distribute vertical space if widget gets extra space, see #GtkAlign
+ *
+ * Since: 3.0
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_VALIGN,
+ g_param_spec_enum ("valign",
+ P_("Vertical Alignment"),
+ P_("How to position in extra vertical space"),
+ GTK_TYPE_ALIGN,
+ GTK_ALIGN_FILL,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkWidget:margin-left
+ *
+ * Margin on left side of widget.
+ *
+ * This property adds margin outside of the widget's normal size
+ * request, the margin will be added in addition to the size from
+ * gtk_widget_set_size_request() for example.
+ *
+ * Since: 3.0
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_MARGIN_LEFT,
+ g_param_spec_int ("margin-left",
+ P_("Margin on Left"),
+ P_("Pixels of extra space on the left side"),
+ 0,
+ G_MAXINT16,
+ 0,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkWidget:margin-right
+ *
+ * Margin on right side of widget.
+ *
+ * This property adds margin outside of the widget's normal size
+ * request, the margin will be added in addition to the size from
+ * gtk_widget_set_size_request() for example.
+ *
+ * Since: 3.0
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_MARGIN_RIGHT,
+ g_param_spec_int ("margin-right",
+ P_("Margin on Right"),
+ P_("Pixels of extra space on the right side"),
+ 0,
+ G_MAXINT16,
+ 0,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkWidget:margin-top
+ *
+ * Margin on top side of widget.
+ *
+ * This property adds margin outside of the widget's normal size
+ * request, the margin will be added in addition to the size from
+ * gtk_widget_set_size_request() for example.
+ *
+ * Since: 3.0
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_MARGIN_TOP,
+ g_param_spec_int ("margin-top",
+ P_("Margin on Top"),
+ P_("Pixels of extra space on the top side"),
+ 0,
+ G_MAXINT16,
+ 0,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkWidget:margin-bottom
+ *
+ * Margin on bottom side of widget.
+ *
+ * This property adds margin outside of the widget's normal size
+ * request, the margin will be added in addition to the size from
+ * gtk_widget_set_size_request() for example.
+ *
+ * Since: 3.0
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_MARGIN_BOTTOM,
+ g_param_spec_int ("margin-bottom",
+ P_("Margin on Bottom"),
+ P_("Pixels of extra space on the bottom side"),
+ 0,
+ G_MAXINT16,
+ 0,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkWidget:margin
+ *
+ * Sets all four sides' margin at once. If read, returns max
+ * margin on any side.
+ *
+ * Since: 3.0
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_MARGIN,
+ g_param_spec_int ("margin",
+ P_("All Margins"),
+ P_("Pixels of extra space on all four sides"),
+ 0,
+ G_MAXINT16,
+ 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::show:
* @widget: the object which received the signal.
_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),
G_TYPE_NONE, 1,
G_TYPE_PARAM);
+ /**
+ * 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.
+ *
+ * Signal handlers connected to this signal can modify the cairo
+ * context passed as @cr in any way they like and don't need to
+ * restore it. The signal emission takes care of calling cairo_save()
+ * before and cairo_restore() after invoking the handler.
+ */
+ widget_signals[DRAW] =
+ g_signal_new (I_("draw"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkWidgetClass, draw),
+ _gtk_boolean_handled_accumulator, NULL,
+ gtk_widget_draw_marshaller,
+ G_TYPE_BOOLEAN, 1,
+ CAIRO_GOBJECT_TYPE_CONTEXT);
+
/**
* GtkWidget::mnemonic-activate:
* @widget: the object which received the signal.
*/
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,
*/
widget_signals[MOVE_FOCUS] =
g_signal_new_class_handler (I_("move-focus"),
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_CALLBACK (gtk_widget_real_move_focus),
NULL, NULL,
G_TYPE_NONE,
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,
**/
widget_signals[KEYNAV_FAILED] =
g_signal_new_class_handler (I_("keynav-failed"),
- G_TYPE_FROM_CLASS (gobject_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_CALLBACK (gtk_widget_real_keynav_failed),
_gtk_boolean_handled_accumulator, NULL,
*/
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,
_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
*/
widget_signals[GRAB_BROKEN] =
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,
case PROP_DOUBLE_BUFFERED:
gtk_widget_set_double_buffered (widget, g_value_get_boolean (value));
break;
+ case PROP_HALIGN:
+ gtk_widget_set_halign (widget, g_value_get_enum (value));
+ break;
+ case PROP_VALIGN:
+ gtk_widget_set_valign (widget, g_value_get_enum (value));
+ break;
+ case PROP_MARGIN_LEFT:
+ gtk_widget_set_margin_left (widget, g_value_get_int (value));
+ break;
+ case PROP_MARGIN_RIGHT:
+ gtk_widget_set_margin_right (widget, g_value_get_int (value));
+ break;
+ case PROP_MARGIN_TOP:
+ gtk_widget_set_margin_top (widget, g_value_get_int (value));
+ break;
+ case PROP_MARGIN_BOTTOM:
+ gtk_widget_set_margin_bottom (widget, g_value_get_int (value));
+ break;
+ case PROP_MARGIN:
+ g_object_freeze_notify (G_OBJECT (widget));
+ gtk_widget_set_margin_left (widget, g_value_get_int (value));
+ gtk_widget_set_margin_right (widget, g_value_get_int (value));
+ gtk_widget_set_margin_top (widget, g_value_get_int (value));
+ gtk_widget_set_margin_bottom (widget, g_value_get_int (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));
case PROP_DOUBLE_BUFFERED:
g_value_set_boolean (value, gtk_widget_get_double_buffered (widget));
break;
+ case PROP_HALIGN:
+ g_value_set_enum (value, gtk_widget_get_halign (widget));
+ break;
+ case PROP_VALIGN:
+ g_value_set_enum (value, gtk_widget_get_valign (widget));
+ break;
+ case PROP_MARGIN_LEFT:
+ g_value_set_int (value, gtk_widget_get_margin_left (widget));
+ break;
+ case PROP_MARGIN_RIGHT:
+ g_value_set_int (value, gtk_widget_get_margin_right (widget));
+ break;
+ case PROP_MARGIN_TOP:
+ g_value_set_int (value, gtk_widget_get_margin_top (widget));
+ break;
+ case PROP_MARGIN_BOTTOM:
+ g_value_set_int (value, gtk_widget_get_margin_bottom (widget));
+ break;
+ case PROP_MARGIN:
+ {
+ GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (widget, FALSE);
+ if (aux_info == NULL)
+ {
+ g_value_set_int (value, 0);
+ }
+ else
+ {
+ g_value_set_int (value, MAX (MAX (aux_info->margin.left,
+ aux_info->margin.right),
+ MAX (aux_info->margin.top,
+ aux_info->margin.bottom)));
+ }
+ }
+ 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;
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_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));
}
/**
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 (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);
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;
{
GtkWidgetPrivate *priv;
GdkExtensionMode mode;
- GtkWidgetShapeInfo *shape_info;
+ 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)
{
- shape_info = g_object_get_qdata (G_OBJECT (widget), quark_shape_info);
- gdk_window_shape_combine_mask (priv->window,
- shape_info->shape_mask,
- shape_info->offset_x,
- shape_info->offset_y);
+ region = g_object_get_qdata (G_OBJECT (widget), quark_shape_info);
+ gdk_window_shape_combine_region (priv->window, region, 0, 0);
}
- shape_info = g_object_get_qdata (G_OBJECT (widget), quark_input_shape_info);
- if (shape_info)
- gdk_window_input_shape_combine_mask (priv->window,
- shape_info->shape_mask,
- shape_info->offset_x,
- shape_info->offset_y);
+ region = g_object_get_qdata (G_OBJECT (widget), quark_input_shape_info);
+ if (region)
+ gdk_window_input_shape_combine_region (priv->window, region, 0, 0);
mode = gtk_widget_get_extension_events (widget);
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))
- gtk_widget_shape_combine_mask (widget, NULL, 0, 0);
+ 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_input_shape_combine_mask (widget, NULL, 0, 0);
+ gtk_widget_input_shape_combine_region (widget, NULL);
if (gtk_widget_get_realized (widget))
{
x -= wx - priv->allocation.x;
y -= wy - priv->allocation.y;
- gdk_drawable_get_size (priv->window, &wwidth, &wheight);
+ wwidth = gdk_window_get_width (priv->window);
+ wheight = gdk_window_get_height (priv->window);
if (x + width <= 0 || y + height <= 0 ||
x >= wwidth || y >= wheight)
* 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
* and position to their child widgets.
*
* In this function, the allocation may be adjusted. It will be forced
- * to a 1x1 minimum size, and the adjust_size_allocation virtual method
- * on the child will be used to adjust the allocation.
+ * to a 1x1 minimum size, and the adjust_size_allocation virtual
+ * method on the child will be used to adjust the allocation. Standard
+ * adjustments include removing the widget's margins, and applying the
+ * widget's #GtkWidget:halign and #GtkWidget:valign properties.
**/
void
gtk_widget_size_allocate (GtkWidget *widget,
}
#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;
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)
+{
+ 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;
+ break;
+ case GTK_ALIGN_START:
+ coord = start_pad;
+ size = content_size;
+ break;
+ case GTK_ALIGN_END:
+ coord = allocated_outside_size - end_pad - content_size;
+ size = content_size;
+ break;
+ case GTK_ALIGN_CENTER:
+ coord = start_pad + (inside_allocated - content_size) / 2;
+ size = content_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);
+}
+
static void
gtk_widget_real_adjust_size_allocation (GtkWidget *widget,
GtkAllocation *allocation)
{
- /* We have no adjustments by default for now, but we have this empty
- * function here so subclasses can chain up in case we do add
- * something.
- */
+ const GtkWidgetAuxInfo *aux_info;
+ GtkRequisition min, natural;
+ int x, y, w, h;
+
+ aux_info = _gtk_widget_get_aux_info_or_defaults (widget);
+
+ gtk_widget_get_preferred_size (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;
}
static gboolean
}
/**
- * gtk_widget_list_accel_closures
+ * gtk_widget_list_accel_closures:
* @widget: widget to list accelerator closures for
- * @returns: a newly allocated #GList of closures
*
* Lists the closures used by @widget for accelerator group connections
* with gtk_accel_group_connect_by_path() or gtk_accel_group_connect().
* The closures can be used to monitor accelerator changes on @widget,
- * by connecting to the @GtkAccelGroup::accel-changed signal of the
- * #GtkAccelGroup of a closure which can be found out with
+ * by connecting to the @GtkAccelGroup::accel-changed signal of the
+ * #GtkAccelGroup of a closure which can be found out with
* gtk_accel_group_from_accel_closure().
+ *
+ * Return value: (transfer container) (element-type GClosure):
+ * a newly allocated #GList of closures
*/
GList*
gtk_widget_list_accel_closures (GtkWidget *widget)
return TRUE;
}
+static const cairo_user_data_key_t event_key;
+
+GdkEventExpose *
+_gtk_cairo_get_event (cairo_t *cr)
+{
+ g_return_val_if_fail (cr != NULL, NULL);
+
+ return cairo_get_user_data (cr, &event_key);
+}
+
+static void
+gtk_cairo_set_event (cairo_t *cr,
+ GdkEventExpose *event)
+{
+ cairo_set_user_data (cr, &event_key, event, NULL);
+}
+
+/**
+ * gtk_cairo_should_draw_window:
+ * @cr: a cairo context
+ * @window: the window to check
+ *
+ * This function is supposed to be called in GtkWidget::draw
+ * implementations for widgets that support multiple windows.
+ * @cr must be untransformed from invoking of the draw function.
+ * This function will return %TRUE if the contents of the given
+ * @window are supposed to be drawn and %FALSE otherwise. Note
+ * that when the drawing was not initiated by the windowing
+ * system this function will return %TRUE for all windows, so
+ * you need to draw the bottommost window first. Also, do not
+ * use "else if" statements to check which window should be drawn.
+ *
+ * Returns: %TRUE if @window should be drawn
+ **/
+gboolean
+gtk_cairo_should_draw_window (cairo_t *cr,
+ GdkWindow *window)
+{
+ GdkEventExpose *event;
+
+ g_return_val_if_fail (cr != NULL, FALSE);
+ g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
+
+ event = _gtk_cairo_get_event (cr);
+
+ return event == NULL ||
+ event->window == window;
+}
+
+/* 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)
+{
+ if (!gtk_widget_is_drawable (widget))
+ return;
+
+ if (clip_to_size)
+ {
+ cairo_rectangle (cr,
+ 0, 0,
+ widget->priv->allocation.width,
+ widget->priv->allocation.height);
+ cairo_clip (cr);
+ }
+
+ if (gdk_cairo_get_clip_rectangle (cr, NULL))
+ {
+ 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_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (!widget->priv->alloc_needed);
+ g_return_if_fail (cr != NULL);
+
+ 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);
+
+ _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;
-/**
- * gtk_widget_send_expose:
- * @widget: a #GtkWidget
+ 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:
+ * @widget: a #GtkWidget
* @event: a expose #GdkEvent
*
* Very rarely-used function. This function is used to emit
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
event_window_is_still_viewable (GdkEvent *event)
{
- /* Some programs, such as gnome-theme-manager, fake widgets
- * into exposing onto a pixmap by sending expose events with
- * event->window pointing to a pixmap
- */
- if (GDK_IS_PIXMAP (event->any.window))
- return event->type == GDK_EXPOSE;
-
/* Check that we think the event's window is viewable before
* delivering the event, to prevent suprises. We do this here
* at the last moment, since the event may have been queued
* 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,
{
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
* is then entirely responsible for drawing the widget background.
*
* Note that the background is still drawn when the widget is mapped.
- * If this is not suitable (e.g. because you want to make a transparent
- * window using an RGBA visual), you can work around this by doing:
- * |[
- * gtk_widget_realize (window);
- * gdk_window_set_back_pixmap (window->window, NULL, FALSE);
- * gtk_widget_show (window);
- * ]|
**/
void
gtk_widget_set_app_paintable (GtkWidget *widget,
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);
{
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))
/**
* gtk_widget_create_pango_context:
* @widget: a #GtkWidget
- *
+ *
* Creates a new #PangoContext with the appropriate font map,
* font description, and base direction for drawing text for
* this widget. See also gtk_widget_get_pango_context().
- *
- * Return value: the new #PangoContext
+ *
+ * Return value: (transfer full): the new #PangoContext
**/
PangoContext *
gtk_widget_create_pango_context (GtkWidget *widget)
* gtk_widget_create_pango_layout:
* @widget: a #GtkWidget
* @text: text to set on the layout (can be %NULL)
- *
+ *
* Creates a new #PangoLayout with the appropriate font map,
* font description, and base direction for drawing text for
* this widget.
* If you keep a #PangoLayout created in this way around, in order to
* notify the layout of changes to the base direction or font of this
* widget, you must call pango_layout_context_changed() in response to
- * the #GtkWidget::style-set and #GtkWidget::direction-changed signals
+ * the #GtkWidget::style-set and #GtkWidget::direction-changed signals
* for the widget.
- *
- * Return value: the new #PangoLayout
+ *
+ * Return value: (transfer full): the new #PangoLayout
**/
PangoLayout *
gtk_widget_create_pango_layout (GtkWidget *widget,
* gtk_widget_render_icon:
* @widget: a #GtkWidget
* @stock_id: a stock ID
- * @size: (type int) a stock size. A size of (GtkIconSize)-1 means
+ * @size: (type int): a stock size. A size of (GtkIconSize)-1 means
* render at the size of the source and don't scale (if there are
* multiple source sizes, GTK+ picks one of the available sizes).
* @detail: (allow-none): render detail to pass to theme engine
* the application and should not be modified. The pixbuf should be freed
* after use with g_object_unref().
*
- * Return value: a new pixbuf, or %NULL if the stock ID wasn't known
+ * Return value: (transfer full): a new pixbuf, or %NULL if the
+ * stock ID wasn't known
**/
GdkPixbuf*
gtk_widget_render_icon (GtkWidget *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 *
*
* Widgets can't actually be allocated a size less than 1 by 1, but
* you can pass 0,0 to this function to mean "as small as possible."
+ *
+ * The size request set here does not include any margin from the
+ * #GtkWidget properties margin-left, margin-right, margin-top, and
+ * margin-bottom, but it does include pretty much all other padding
+ * or border properties set by any subclass of #GtkWidget.
**/
void
gtk_widget_set_size_request (GtkWidget *widget,
* @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 use, call gtk_widget_size_request() instead of
+ * actually request, call gtk_size_request_get_preferred_size() instead of
* this function.
**/
void
return widget;
}
-/**
- * gtk_widget_get_colormap:
- * @widget: a #GtkWidget
- *
- * Gets the colormap that will be used to render @widget. No reference will
- * be added to the returned colormap; it should not be unreferenced.
- *
- * Return value: (transfer none): the colormap used by @widget
- **/
-GdkColormap*
-gtk_widget_get_colormap (GtkWidget *widget)
-{
- GtkWidgetPrivate *priv;
- GdkColormap *colormap;
- GtkWidget *tmp_widget;
-
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
- priv = widget->priv;
-
- if (priv->window)
- {
- colormap = gdk_drawable_get_colormap (priv->window);
- /* If window was destroyed previously, we'll get NULL here */
- if (colormap)
- return colormap;
- }
-
- tmp_widget = widget;
- while (tmp_widget)
- {
- colormap = g_object_get_qdata (G_OBJECT (tmp_widget), quark_colormap);
- if (colormap)
- return colormap;
-
- tmp_widget= tmp_widget->priv->parent;
- }
-
- return gdk_screen_get_default_colormap (gtk_widget_get_screen (widget));
-}
-
/**
* gtk_widget_get_visual:
* @widget: a #GtkWidget
GdkVisual*
gtk_widget_get_visual (GtkWidget *widget)
{
+ GtkWidget *w;
+
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- return gdk_colormap_get_visual (gtk_widget_get_colormap (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);
+
+ if (GTK_IS_WINDOW (w))
+ return _gtk_window_get_visual (GTK_WINDOW (w));
+ }
+
+ return gdk_screen_get_system_visual (gdk_screen_get_default ());
}
/**
return gtk_settings_get_for_screen (gtk_widget_get_screen (widget));
}
-/**
- * gtk_widget_set_colormap:
- * @widget: a #GtkWidget
- * @colormap: a colormap
- *
- * Sets the colormap for the widget to the given value. Widget must not
- * have been previously realized. This probably should only be used
- * from an <function>init()</function> function (i.e. from the constructor
- * for the widget).
- **/
-void
-gtk_widget_set_colormap (GtkWidget *widget,
- GdkColormap *colormap)
-{
- g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (!gtk_widget_get_realized (widget));
- g_return_if_fail (GDK_IS_COLORMAP (colormap));
-
- g_object_ref (colormap);
-
- g_object_set_qdata_full (G_OBJECT (widget),
- quark_colormap,
- colormap,
- g_object_unref);
-}
-
/**
* gtk_widget_get_events:
* @widget: a #GtkWidget
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
composite_child_stack--;
}
-/**
- * gtk_widget_push_colormap:
- * @cmap: a #GdkColormap
- *
- * Pushes @cmap onto a global stack of colormaps; the topmost
- * colormap on the stack will be used to create all widgets.
- * Remove @cmap with gtk_widget_pop_colormap(). There's little
- * reason to use this function.
- **/
-void
-gtk_widget_push_colormap (GdkColormap *cmap)
-{
- g_return_if_fail (!cmap || GDK_IS_COLORMAP (cmap));
-
- colormap_stack = g_slist_prepend (colormap_stack, cmap);
-}
-
-/**
- * gtk_widget_pop_colormap:
- *
- * Removes a colormap pushed with gtk_widget_push_colormap().
- **/
-void
-gtk_widget_pop_colormap (void)
-{
- if (colormap_stack)
- colormap_stack = g_slist_delete_link (colormap_stack, colormap_stack);
-}
-
-/**
- * gtk_widget_set_default_colormap:
- * @colormap: a #GdkColormap
- *
- * Sets the default colormap to use when creating widgets.
- * gtk_widget_push_colormap() is a better function to use if
- * you only want to affect a few widgets, rather than all widgets.
- **/
-void
-gtk_widget_set_default_colormap (GdkColormap *colormap)
-{
- g_return_if_fail (GDK_IS_COLORMAP (colormap));
-
- gdk_screen_set_default_colormap (gdk_colormap_get_screen (colormap),
- colormap);
-}
-
-/**
- * gtk_widget_get_default_colormap:
- *
- * Obtains the default colormap used to create widgets.
- *
- * Return value: (transfer none): default widget colormap
- **/
-GdkColormap*
-gtk_widget_get_default_colormap (void)
-{
- return gdk_screen_get_default_colormap (gdk_screen_get_default ());
-}
-
-/**
- * gtk_widget_get_default_visual:
- *
- * Obtains the visual of the default colormap. Not really useful;
- * used to be useful before gdk_colormap_get_visual() existed.
- *
- * Return value: (transfer none): visual of the default colormap
- **/
-GdkVisual*
-gtk_widget_get_default_visual (void)
-{
- return gdk_colormap_get_visual (gtk_widget_get_default_colormap ());
-}
-
static void
gtk_widget_emit_direction_changed (GtkWidget *widget,
GtkTextDirection old_dir)
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);
}
* in gtksizerequest.c when calling their size request vfuncs.
*/
*natural_size = MAX (*natural_size, *minimum_size);
-}
-/**
- * _gtk_widget_peek_colormap:
- *
- * Returns colormap currently pushed by gtk_widget_push_colormap, if any.
- *
- * Return value: the currently pushed colormap, or %NULL if there is none.
- **/
-GdkColormap*
-_gtk_widget_peek_colormap (void)
-{
- if (colormap_stack)
- return (GdkColormap*) colormap_stack->data;
- return NULL;
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ *minimum_size += (aux_info->margin.left + aux_info->margin.right);
+ *natural_size += (aux_info->margin.left + aux_info->margin.right);
+ }
+ else
+ {
+ *minimum_size += (aux_info->margin.top + aux_info->margin.bottom);
+ *natural_size += (aux_info->margin.top + aux_info->margin.bottom);
+ }
}
/**
if (!gtk_widget_get_realized (widget))
return;
- screen = gdk_drawable_get_screen (priv->window);
+ screen = gdk_window_get_screen (priv->window);
device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
if (G_UNLIKELY (!device_window))
if (!gtk_widget_get_realized (widget))
return NULL;
- screen = gdk_drawable_get_screen (priv->window);
+ screen = gdk_window_get_screen (priv->window);
device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
if (G_UNLIKELY (!device_window))
if (!gtk_widget_get_realized (widget))
return NULL;
- screen = gdk_drawable_get_screen (priv->window);
+ screen = gdk_window_get_screen (priv->window);
device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
if (G_UNLIKELY (!device_window))
*/
- 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;
}
static const GtkWidgetAuxInfo default_aux_info = {
- -1, -1
+ -1, -1,
+ GTK_ALIGN_FILL,
+ GTK_ALIGN_FILL,
+ { 0, 0, 0, 0 }
};
/*
g_slice_free (GtkWidgetAuxInfo, aux_info);
}
-static void
-gtk_widget_shape_info_destroy (GtkWidgetShapeInfo *info)
-{
- g_object_unref (info->shape_mask);
- g_slice_free (GtkWidgetShapeInfo, info);
-}
-
/**
- * gtk_widget_shape_combine_mask:
+ * gtk_widget_shape_combine_region:
* @widget: a #GtkWidget
- * @shape_mask: (allow-none): shape to be added, or %NULL to remove an existing shape
- * @offset_x: X position of shape mask with respect to @window
- * @offset_y: Y position of shape mask with respect to @window
+ * @region: (allow-none): shape to be added, or %NULL to remove an existing shape
*
* Sets a shape for this widget's GDK window. This allows for
- * transparent windows etc., see gdk_window_shape_combine_mask()
+ * transparent windows etc., see gdk_window_shape_combine_region()
* for more information.
+ *
+ * Since: 3.0
**/
void
-gtk_widget_shape_combine_mask (GtkWidget *widget,
- GdkBitmap *shape_mask,
- gint offset_x,
- gint offset_y)
+gtk_widget_shape_combine_region (GtkWidget *widget,
+ cairo_region_t *region)
{
GtkWidgetPrivate *priv;
- GtkWidgetShapeInfo* shape_info;
g_return_if_fail (GTK_IS_WIDGET (widget));
/* set_shape doesn't work on widgets without gdk window */
priv = widget->priv;
- if (!shape_mask)
+ if (region == NULL)
{
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_HAS_SHAPE_MASK);
+ priv->has_shape_mask = FALSE;
if (priv->window)
- gdk_window_shape_combine_mask (priv->window, NULL, 0, 0);
+ gdk_window_shape_combine_region (priv->window, NULL, 0, 0);
g_object_set_qdata (G_OBJECT (widget), quark_shape_info, NULL);
}
else
{
- GTK_PRIVATE_SET_FLAG (widget, GTK_HAS_SHAPE_MASK);
-
- shape_info = g_slice_new (GtkWidgetShapeInfo);
- g_object_set_qdata_full (G_OBJECT (widget), quark_shape_info, shape_info,
- (GDestroyNotify) gtk_widget_shape_info_destroy);
+ priv->has_shape_mask = TRUE;
- shape_info->shape_mask = g_object_ref (shape_mask);
- shape_info->offset_x = offset_x;
- shape_info->offset_y = offset_y;
+ g_object_set_qdata_full (G_OBJECT (widget), quark_shape_info,
+ cairo_region_copy (region),
+ (GDestroyNotify) cairo_region_destroy);
/* set shape if widget has a gdk window already.
* otherwise the shape is scheduled to be set by gtk_widget_realize().
*/
if (priv->window)
- gdk_window_shape_combine_mask (priv->window, shape_mask,
- offset_x, offset_y);
+ gdk_window_shape_combine_region (priv->window, region, 0, 0);
}
}
/**
- * gtk_widget_input_shape_combine_mask:
+ * gtk_widget_input_shape_combine_region:
* @widget: a #GtkWidget
- * @shape_mask: (allow-none): shape to be added, or %NULL to remove an existing shape
- * @offset_x: X position of shape mask with respect to @window
- * @offset_y: Y position of shape mask with respect to @window
+ * @region: (allow-none): shape to be added, or %NULL to remove an existing shape
*
* Sets an input shape for this widget's GDK window. This allows for
* windows which react to mouse click in a nonrectangular region, see
- * gdk_window_input_shape_combine_mask() for more information.
+ * gdk_window_input_shape_combine_region() for more information.
*
- * Since: 2.10
+ * Since: 3.0
**/
void
-gtk_widget_input_shape_combine_mask (GtkWidget *widget,
- GdkBitmap *shape_mask,
- gint offset_x,
- gint offset_y)
+gtk_widget_input_shape_combine_region (GtkWidget *widget,
+ cairo_region_t *region)
{
GtkWidgetPrivate *priv;
- GtkWidgetShapeInfo* shape_info;
g_return_if_fail (GTK_IS_WIDGET (widget));
/* set_shape doesn't work on widgets without gdk window */
priv = widget->priv;
- if (!shape_mask)
+ if (region == NULL)
{
if (priv->window)
- gdk_window_input_shape_combine_mask (priv->window, NULL, 0, 0);
-
+ gdk_window_input_shape_combine_region (priv->window, NULL, 0, 0);
+
g_object_set_qdata (G_OBJECT (widget), quark_input_shape_info, NULL);
}
else
{
- shape_info = g_slice_new (GtkWidgetShapeInfo);
g_object_set_qdata_full (G_OBJECT (widget), quark_input_shape_info,
- shape_info,
- (GDestroyNotify) gtk_widget_shape_info_destroy);
-
- shape_info->shape_mask = g_object_ref (shape_mask);
- shape_info->offset_x = offset_x;
- shape_info->offset_y = offset_y;
+ cairo_region_copy (region),
+ (GDestroyNotify) cairo_region_destroy);
/* set shape if widget has a gdk window already.
* otherwise the shape is scheduled to be set by gtk_widget_realize().
*/
if (priv->window)
- gdk_window_input_shape_combine_mask (priv->window, shape_mask,
- offset_x, offset_y);
+ gdk_window_input_shape_combine_region (priv->window, region, 0, 0);
}
}
if (data != widget)
return;
- gdk_window_shape_combine_mask (window, NULL, 0, 0);
+ gdk_window_shape_combine_region (window, NULL, 0, 0);
for (list = gdk_window_peek_children (window); list; list = list->next)
gtk_reset_shapes_recurse (widget, list->data);
}
priv = widget->priv;
- if (!GTK_WIDGET_HAS_SHAPE_MASK (widget))
+ if (!priv->has_shape_mask)
gtk_reset_shapes_recurse (widget, priv->window);
}
-static void
-expose_window (GdkWindow *window)
-{
- GdkEvent event;
- GList *l, *children;
- gpointer user_data;
- gboolean is_double_buffered;
-
- gdk_window_get_user_data (window, &user_data);
-
- if (user_data)
- is_double_buffered = gtk_widget_get_double_buffered (GTK_WIDGET (user_data));
- else
- is_double_buffered = FALSE;
-
- event.expose.type = GDK_EXPOSE;
- event.expose.window = g_object_ref (window);
- event.expose.send_event = FALSE;
- event.expose.count = 0;
- event.expose.area.x = 0;
- event.expose.area.y = 0;
- gdk_drawable_get_size (GDK_DRAWABLE (window),
- &event.expose.area.width,
- &event.expose.area.height);
- event.expose.region = cairo_region_create_rectangle (&event.expose.area);
-
- /* If this is not double buffered, force a double buffer so that
- redirection works. */
- if (!is_double_buffered)
- gdk_window_begin_paint_region (window, event.expose.region);
-
- gtk_main_do_event (&event);
+/* style properties
+ */
- if (!is_double_buffered)
- gdk_window_end_paint (window);
+/**
+ * gtk_widget_class_install_style_property_parser:
+ * @klass: a #GtkWidgetClass
+ * @pspec: the #GParamSpec for the style property
+ * @parser: the parser for the style property
+ *
+ * Installs a style property on a widget class.
+ **/
+void
+gtk_widget_class_install_style_property_parser (GtkWidgetClass *klass,
+ GParamSpec *pspec,
+ GtkRcPropertyParser parser)
+{
+ g_return_if_fail (GTK_IS_WIDGET_CLASS (klass));
+ g_return_if_fail (G_IS_PARAM_SPEC (pspec));
+ g_return_if_fail (pspec->flags & G_PARAM_READABLE);
+ g_return_if_fail (!(pspec->flags & (G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT)));
- children = gdk_window_peek_children (window);
- for (l = children; l != NULL; l = l->next)
+ if (g_param_spec_pool_lookup (style_property_spec_pool, pspec->name, G_OBJECT_CLASS_TYPE (klass), FALSE))
{
- GdkWindow *child = l->data;
-
- /* Don't expose input-only windows */
- if (gdk_drawable_get_depth (GDK_DRAWABLE (child)) != 0)
- expose_window (l->data);
+ g_warning (G_STRLOC ": class `%s' already contains a style property named `%s'",
+ G_OBJECT_CLASS_NAME (klass),
+ pspec->name);
+ return;
}
-
- g_object_unref (window);
+
+ g_param_spec_ref_sink (pspec);
+ g_param_spec_set_qdata (pspec, quark_property_parser, (gpointer) parser);
+ g_param_spec_pool_insert (style_property_spec_pool, pspec, G_OBJECT_CLASS_TYPE (klass));
}
/**
- * gtk_widget_get_snapshot:
- * @widget: a #GtkWidget
- * @clip_rect: (allow-none): a #GdkRectangle or %NULL
- *
- * Create a #GdkPixmap of the contents of the widget and its children.
- *
- * Works even if the widget is obscured. The depth and visual of the
- * resulting pixmap is dependent on the widget being snapshot and likely
- * differs from those of a target widget displaying the pixmap.
- * The function gdk_pixbuf_get_from_drawable() can be used to convert
- * the pixmap to a visual independant representation.
- *
- * The snapshot area used by this function is the @widget's allocation plus
- * any extra space occupied by additional windows belonging to this widget
- * (such as the arrows of a spin button).
- * Thus, the resulting snapshot pixmap is possibly larger than the allocation.
- *
- * If @clip_rect is non-%NULL, the resulting pixmap is shrunken to
- * match the specified clip_rect. The (x,y) coordinates of @clip_rect are
- * interpreted widget relative. If width or height of @clip_rect are 0 or
- * negative, the width or height of the resulting pixmap will be shrunken
- * by the respective amount.
- * For instance a @clip_rect <literal>{ +5, +5, -10, -10 }</literal> will
- * chop off 5 pixels at each side of the snapshot pixmap.
- * If non-%NULL, @clip_rect will contain the exact widget-relative snapshot
- * coordinates upon return. A @clip_rect of <literal>{ -1, -1, 0, 0 }</literal>
- * can be used to preserve the auto-grown snapshot area and use @clip_rect
- * as a pure output parameter.
- *
- * The returned pixmap can be %NULL, if the resulting @clip_area was empty.
- *
- * Return value: #GdkPixmap snapshot of the widget
+ * gtk_widget_class_install_style_property:
+ * @klass: a #GtkWidgetClass
+ * @pspec: the #GParamSpec for the property
*
- * Since: 2.14
+ * Installs a style property on a widget class. The parser for the
+ * style property is determined by the value type of @pspec.
**/
-GdkPixmap*
-gtk_widget_get_snapshot (GtkWidget *widget,
- GdkRectangle *clip_rect)
+void
+gtk_widget_class_install_style_property (GtkWidgetClass *klass,
+ GParamSpec *pspec)
{
- GtkWidgetPrivate *priv;
- int x, y, width, height;
- GdkWindow *parent_window = NULL;
- GdkPixmap *pixmap;
- GList *windows = NULL, *list;
+ GtkRcPropertyParser parser;
- priv = widget->priv;
-
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- if (!gtk_widget_get_visible (widget))
- return NULL;
-
- /* the widget (and parent_window) must be realized to be drawable */
- if (priv->parent && !gtk_widget_get_realized (priv->parent))
- gtk_widget_realize (priv->parent);
- if (!gtk_widget_get_realized (widget))
- gtk_widget_realize (widget);
-
- /* determine snapshot rectangle */
- x = priv->allocation.x;
- y = priv->allocation.y;
- width = priv->allocation.width;
- height = priv->allocation.height;
-
- if (priv->parent && gtk_widget_get_has_window (widget))
- {
- /* grow snapshot rectangle to cover all widget windows */
- parent_window = gtk_widget_get_parent_window (widget);
- for (list = gdk_window_peek_children (parent_window); list; list = list->next)
- {
- GdkWindow *subwin = list->data;
- gpointer windata;
- int wx, wy, ww, wh;
- gdk_window_get_user_data (subwin, &windata);
- if (windata != widget)
- continue;
- windows = g_list_prepend (windows, subwin);
- gdk_window_get_position (subwin, &wx, &wy);
- gdk_drawable_get_size (subwin, &ww, &wh);
- /* grow snapshot rectangle by extra widget sub window */
- if (wx < x)
- {
- width += x - wx;
- x = wx;
- }
- if (wy < y)
- {
- height += y - wy;
- y = wy;
- }
- if (x + width < wx + ww)
- width += wx + ww - (x + width);
- if (y + height < wy + wh)
- height += wy + wh - (y + height);
- }
- }
- else if (!priv->parent)
- x = y = 0; /* toplevel */
-
- /* at this point, (x,y,width,height) is the parent_window relative
- * snapshot area covering all of widget's windows.
- */
-
- /* shrink snapshot size by clip_rectangle */
- if (clip_rect)
- {
- GdkRectangle snap = { x, y, width, height }, clip = *clip_rect;
- clip.x = clip.x < 0 ? x : clip.x;
- clip.y = clip.y < 0 ? y : clip.y;
- clip.width = clip.width <= 0 ? MAX (0, width + clip.width) : clip.width;
- clip.height = clip.height <= 0 ? MAX (0, height + clip.height) : clip.height;
- if (priv->parent)
- {
- /* offset clip_rect, so it's parent_window relative */
- if (clip_rect->x >= 0)
- clip.x += priv->allocation.x;
- if (clip_rect->y >= 0)
- clip.y += priv->allocation.y;
- }
- if (!gdk_rectangle_intersect (&snap, &clip, &snap))
- {
- g_list_free (windows);
- clip_rect->width = clip_rect->height = 0;
- return NULL; /* empty snapshot area */
- }
- x = snap.x;
- y = snap.y;
- width = snap.width;
- height = snap.height;
- }
-
- /* render snapshot */
- pixmap = gdk_pixmap_new (priv->window, width, height, gdk_drawable_get_depth (priv->window));
- for (list = windows; list; list = list->next) /* !NO_WINDOW widgets */
- {
- GdkWindow *subwin = list->data;
- int wx, wy;
- if (gdk_drawable_get_depth (GDK_DRAWABLE (subwin)) == 0)
- continue; /* Input only window */
- gdk_window_get_position (subwin, &wx, &wy);
- gdk_window_redirect_to_drawable (subwin, pixmap, MAX (0, x - wx), MAX (0, y - wy),
- MAX (0, wx - x), MAX (0, wy - y), width, height);
-
- expose_window (subwin);
- }
- if (!windows) /* NO_WINDOW || toplevel => parent_window == NULL || parent_window == priv->window */
- {
- gdk_window_redirect_to_drawable (priv->window, pixmap, x, y, 0, 0, width, height);
- expose_window (priv->window);
- }
- for (list = windows; list; list = list->next)
- gdk_window_remove_redirection (list->data);
- if (!windows) /* NO_WINDOW || toplevel */
- gdk_window_remove_redirection (priv->window);
- g_list_free (windows);
-
- /* return pixmap and snapshot rectangle coordinates */
- if (clip_rect)
- {
- clip_rect->x = x;
- clip_rect->y = y;
- clip_rect->width = width;
- clip_rect->height = height;
- if (priv->parent)
- {
- /* offset clip_rect from parent_window so it's widget relative */
- clip_rect->x -= priv->allocation.x;
- clip_rect->y -= priv->allocation.y;
- }
- if (0)
- g_printerr ("gtk_widget_get_snapshot: %s (%d,%d, %dx%d)\n",
- G_OBJECT_TYPE_NAME (widget),
- clip_rect->x, clip_rect->y, clip_rect->width, clip_rect->height);
- }
- return pixmap;
-}
-
-/* style properties
- */
-
-/**
- * gtk_widget_class_install_style_property_parser:
- * @klass: a #GtkWidgetClass
- * @pspec: the #GParamSpec for the style property
- * @parser: the parser for the style property
- *
- * Installs a style property on a widget class.
- **/
-void
-gtk_widget_class_install_style_property_parser (GtkWidgetClass *klass,
- GParamSpec *pspec,
- GtkRcPropertyParser parser)
-{
- g_return_if_fail (GTK_IS_WIDGET_CLASS (klass));
- g_return_if_fail (G_IS_PARAM_SPEC (pspec));
- g_return_if_fail (pspec->flags & G_PARAM_READABLE);
- g_return_if_fail (!(pspec->flags & (G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT)));
-
- if (g_param_spec_pool_lookup (style_property_spec_pool, pspec->name, G_OBJECT_CLASS_TYPE (klass), FALSE))
- {
- g_warning (G_STRLOC ": class `%s' already contains a style property named `%s'",
- G_OBJECT_CLASS_NAME (klass),
- pspec->name);
- return;
- }
-
- g_param_spec_ref_sink (pspec);
- g_param_spec_set_qdata (pspec, quark_property_parser, (gpointer) parser);
- g_param_spec_pool_insert (style_property_spec_pool, pspec, G_OBJECT_CLASS_TYPE (klass));
-}
-
-/**
- * gtk_widget_class_install_style_property:
- * @klass: a #GtkWidgetClass
- * @pspec: the #GParamSpec for the property
- *
- * Installs a style property on a widget class. The parser for the
- * style property is determined by the value type of @pspec.
- **/
-void
-gtk_widget_class_install_style_property (GtkWidgetClass *klass,
- GParamSpec *pspec)
-{
- GtkRcPropertyParser parser;
-
- g_return_if_fail (GTK_IS_WIDGET_CLASS (klass));
- g_return_if_fail (G_IS_PARAM_SPEC (pspec));
+ g_return_if_fail (GTK_IS_WIDGET_CLASS (klass));
+ g_return_if_fail (G_IS_PARAM_SPEC (pspec));
parser = _gtk_rc_property_parser_from_type (G_PARAM_SPEC_VALUE_TYPE (pspec));
}
}
-/*
- * 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);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width);
}
-static void
-gtk_widget_size_request_init (GtkSizeRequestIface *iface)
+/**
+ * gtk_widget_get_halign:
+ * @widget: a #GtkWidget
+ *
+ * Gets the value of the #GtkWidget:halign property.
+ *
+ * Returns: the horizontal alignment of @widget
+ */
+GtkAlign
+gtk_widget_get_halign (GtkWidget *widget)
{
- 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;
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL);
+ return _gtk_widget_get_aux_info_or_defaults (widget)->halign;
}
-
-
+
+/**
+ * gtk_widget_set_halign:
+ * @widget: a #GtkWidget
+ * @align: the horizontal alignment
+ *
+ * Sets the horizontal alignment of @widget.
+ * See the #GtkWidget:halign property.
+ */
+void
+gtk_widget_set_halign (GtkWidget *widget,
+ GtkAlign align)
+{
+ GtkWidgetAuxInfo *aux_info;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ aux_info = _gtk_widget_get_aux_info (widget, TRUE);
+
+ if (aux_info->halign == align)
+ return;
+
+ aux_info->halign = align;
+ gtk_widget_queue_resize (widget);
+ g_object_notify (G_OBJECT (widget), "halign");
+}
+
+/**
+ * gtk_widget_get_valign:
+ * @widget: a #GtkWidget
+ *
+ * Gets the value of the #GtkWidget:valign property.
+ *
+ * Returns: the vertical alignment of @widget
+ */
+GtkAlign
+gtk_widget_get_valign (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL);
+ return _gtk_widget_get_aux_info_or_defaults (widget)->valign;
+}
+
+/**
+ * gtk_widget_set_valign:
+ * @widget: a #GtkWidget
+ * @align: the vertical alignment
+ *
+ * Sets the vertical alignment of @widget.
+ * See the #GtkWidget:valign property.
+ */
+void
+gtk_widget_set_valign (GtkWidget *widget,
+ GtkAlign align)
+{
+ GtkWidgetAuxInfo *aux_info;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ aux_info = _gtk_widget_get_aux_info (widget, TRUE);
+
+ if (aux_info->valign == align)
+ return;
+
+ aux_info->valign = align;
+ gtk_widget_queue_resize (widget);
+ g_object_notify (G_OBJECT (widget), "valign");
+}
+
+/**
+ * gtk_widget_get_margin_left:
+ * @widget: a #GtkWidget
+ *
+ * Gets the value of the #GtkWidget:margin-left property.
+ *
+ * Returns: The left margin of @widget
+ */
+gint
+gtk_widget_get_margin_left (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
+
+ return _gtk_widget_get_aux_info_or_defaults (widget)->margin.left;
+}
+
+/**
+ * gtk_widget_set_margin_left:
+ * @widget: a #GtkWidget
+ * @margin: the left margin
+ *
+ * Sets the left margin of @widget.
+ * See the #GtkWidget:margin-left property.
+ */
+void
+gtk_widget_set_margin_left (GtkWidget *widget,
+ gint margin)
+{
+ GtkWidgetAuxInfo *aux_info;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (margin <= G_MAXINT16);
+
+ aux_info = _gtk_widget_get_aux_info (widget, TRUE);
+
+ if (aux_info->margin.left == margin)
+ return;
+
+ aux_info->margin.left = margin;
+ gtk_widget_queue_resize (widget);
+ g_object_notify (G_OBJECT (widget), "margin-left");
+}
+
+/**
+ * gtk_widget_get_margin_right:
+ * @widget: a #GtkWidget
+ *
+ * Gets the value of the #GtkWidget:margin-right property.
+ *
+ * Returns: The left margin of @widget
+ */
+gint
+gtk_widget_get_margin_right (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
+
+ return _gtk_widget_get_aux_info_or_defaults (widget)->margin.right;
+}
+
+/**
+ * gtk_widget_set_margin_right:
+ * @widget: a #GtkWidget
+ * @margin: the right margin
+ *
+ * Sets the right margin of @widget.
+ * See the #GtkWidget:margin-right property.
+ */
+void
+gtk_widget_set_margin_right (GtkWidget *widget,
+ gint margin)
+{
+ GtkWidgetAuxInfo *aux_info;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (margin <= G_MAXINT16);
+
+ aux_info = _gtk_widget_get_aux_info (widget, TRUE);
+
+ if (aux_info->margin.right == margin)
+ return;
+
+ aux_info->margin.right = margin;
+ gtk_widget_queue_resize (widget);
+ g_object_notify (G_OBJECT (widget), "margin-right");
+}
+
+/**
+ * gtk_widget_get_margin_top:
+ * @widget: a #GtkWidget
+ *
+ * Gets the value of the #GtkWidget:margin-top property.
+ *
+ * Returns: The top margin of @widget
+ */
+gint
+gtk_widget_get_margin_top (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
+
+ return _gtk_widget_get_aux_info_or_defaults (widget)->margin.top;
+}
+
+/**
+ * gtk_widget_set_margin_top:
+ * @widget: a #GtkWidget
+ * @margin: the top margin
+ *
+ * Sets the top margin of @widget.
+ * See the #GtkWidget:margin-top property.
+ */
+void
+gtk_widget_set_margin_top (GtkWidget *widget,
+ gint margin)
+{
+ GtkWidgetAuxInfo *aux_info;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (margin <= G_MAXINT16);
+
+ aux_info = _gtk_widget_get_aux_info (widget, TRUE);
+
+ if (aux_info->margin.top == margin)
+ return;
+
+ aux_info->margin.top = margin;
+ gtk_widget_queue_resize (widget);
+ g_object_notify (G_OBJECT (widget), "margin-top");
+}
+
+/**
+ * gtk_widget_get_margin_bottom:
+ * @widget: a #GtkWidget
+ *
+ * Gets the value of the #GtkWidget:margin-bottom property.
+ *
+ * Returns: The bottom margin of @widget
+ */
+gint
+gtk_widget_get_margin_bottom (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
+
+ return _gtk_widget_get_aux_info_or_defaults (widget)->margin.bottom;
+}
+
+/**
+ * gtk_widget_set_margin_bottom:
+ * @widget: a #GtkWidget
+ * @margin: the bottom margin
+ *
+ * Sets the bottom margin of @widget.
+ * See the #GtkWidget:margin-bottom property.
+ */
+void
+gtk_widget_set_margin_bottom (GtkWidget *widget,
+ gint margin)
+{
+ GtkWidgetAuxInfo *aux_info;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (margin <= G_MAXINT16);
+
+ aux_info = _gtk_widget_get_aux_info (widget, TRUE);
+
+ if (aux_info->margin.bottom == margin)
+ return;
+
+ aux_info->margin.bottom = margin;
+ gtk_widget_queue_resize (widget);
+ g_object_notify (G_OBJECT (widget), "margin-bottom");
+}
+
/**
* gtk_widget_get_clipboard:
* @widget: a #GtkWidget
{
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;
}
/**
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");
+ }
}
*
* Retrieves the widget's allocation.
*
+ * Note, when implementing a #GtkContainer: a widget's allocation will
+ * be its "adjusted" allocation, that is, the widget's parent
+ * container typically calls gtk_widget_size_allocate() with an
+ * allocation, and that allocation is then adjusted (to handle margin
+ * and alignment for example) before assignment to the widget.
+ * gtk_widget_get_allocation() returns the adjusted allocation that
+ * was actually assigned to the widget. The adjusted allocation is
+ * guaranteed to be completely contained within the
+ * gtk_widget_size_allocate() allocation, however. So a #GtkContainer
+ * is guaranteed that its children stay inside the assigned bounds,
+ * but not that they have exactly the bounds the container assigned.
+ * There is no way to get the original allocation assigned by
+ * gtk_widget_size_allocate(), since it isn't stored; if a container
+ * implementation needs that information it will have to track it itself.
+ *
* Since: 2.18
*/
void
* Sets the widget's allocation. This should not be used
* directly, but from within a widget's size_allocate method.
*
+ * The allocation set should be the "adjusted" or actual
+ * allocation. If you're implementing a #GtkContainer, you want to use
+ * gtk_widget_size_allocate() instead of gtk_widget_set_allocation().
+ * The GtkWidgetClass::adjust_size_allocation virtual method adjusts the
+ * allocation inside gtk_widget_size_allocate() to create an adjusted
+ * allocation.
+ *
* Since: 2.18
*/
void
priv->allocation = *allocation;
}
+/**
+ * gtk_widget_get_allocated_width:
+ * @widget: the widget to query
+ *
+ * Returns the width that has currently been allocated to @widget.
+ * This function is intended to be used when implementing handlers
+ * for the GtkWidget::draw function.
+ *
+ * Returns: the width of the @widget
+ **/
+int
+gtk_widget_get_allocated_width (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
+
+ return widget->priv->allocation.width;
+}
+
+/**
+ * gtk_widget_get_allocated_height:
+ * @widget: the widget to query
+ *
+ * Returns the height that has currently been allocated to @widget.
+ * This function is intended to be used when implementing handlers
+ * for the GtkWidget::draw function.
+ *
+ * Returns: the height of the @widget
+ **/
+int
+gtk_widget_get_allocated_height (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
+
+ return widget->priv->allocation.height;
+}
+
/**
* gtk_widget_get_requisition:
* @widget: a #GtkWidget
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;
}
+
+gboolean
+gtk_widget_in_destruction (GtkWidget *widget)
+{
+ return widget->priv->in_destruction;
+}
+
+_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;
+}