* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+#undef GDK_DISABLE_DEPRECATED /* gdk_input_set_extension_events() */
+
#include "config.h"
#include <stdarg.h>
#include <string.h>
#include "gtkinvisible.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
-#include "gtkextendedlayout.h"
-#include "gtkalias.h"
+#include "gtksizerequest.h"
+
/**
* SECTION:gtkwidget
*
* GtkWidget is the base class all widgets in GTK+ derive from. It manages the
* widget lifecycle, states and style.
+ *
* <refsect2 id="style-properties">
* <para>
* <structname>GtkWidget</structname> introduces <firstterm>style
static void gtk_widget_accessible_interface_init (AtkImplementorIface *iface);
static AtkObject* gtk_widget_ref_accessible (AtkImplementor *implementor);
static void gtk_widget_invalidate_widget_windows (GtkWidget *widget,
- GdkRegion *region);
+ cairo_region_t *region);
static GdkScreen * gtk_widget_get_screen_unchecked (GtkWidget *widget);
static void gtk_widget_queue_shallow_draw (GtkWidget *widget);
static gboolean gtk_widget_real_can_activate_accel (GtkWidget *widget,
static void gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
GtkBuilder *builder);
-static void gtk_widget_layout_interface_init (GtkExtendedLayoutIface *iface);
-static void gtk_widget_real_get_desired_size (GtkExtendedLayout *layout,
- GtkRequisition *minimum_size,
- GtkRequisition *natural_size);
+static void gtk_widget_size_request_init (GtkSizeRequestIface *iface);
+static void gtk_widget_real_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_widget_real_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size);
static void gtk_widget_queue_tooltip_query (GtkWidget *widget);
static void gtk_widget_set_usize_internal (GtkWidget *widget,
gint width,
gint height);
-static void gtk_widget_get_draw_rectangle (GtkWidget *widget,
- GdkRectangle *rect);
+static void gtk_widget_add_events_internal (GtkWidget *widget,
+ GdkDevice *device,
+ gint events);
/* --- variables --- */
static gpointer gtk_widget_parent_class = NULL;
static GQuark quark_accel_path = 0;
static GQuark quark_accel_closures = 0;
static GQuark quark_event_mask = 0;
+static GQuark quark_device_event_mask = 0;
static GQuark quark_extension_event_mode = 0;
static GQuark quark_parent_window = 0;
static GQuark quark_pointer_window = 0;
const GInterfaceInfo layout_info =
{
- (GInterfaceInitFunc) gtk_widget_layout_interface_init,
+ (GInterfaceInitFunc) gtk_widget_size_request_init,
(GInterfaceFinalizeFunc) NULL,
NULL /* interface data */
};
&accessibility_info) ;
g_type_add_interface_static (widget_type, GTK_TYPE_BUILDABLE,
&buildable_info) ;
- g_type_add_interface_static (widget_type, GTK_TYPE_EXTENDED_LAYOUT,
+ g_type_add_interface_static (widget_type, GTK_TYPE_SIZE_REQUEST,
&layout_info) ;
}
quark_accel_path = g_quark_from_static_string ("gtk-accel-path");
quark_accel_closures = g_quark_from_static_string ("gtk-accel-closures");
quark_event_mask = g_quark_from_static_string ("gtk-event-mask");
+ quark_device_event_mask = g_quark_from_static_string ("gtk-device-event-mask");
quark_extension_event_mode = g_quark_from_static_string ("gtk-extension-event-mode");
quark_parent_window = g_quark_from_static_string ("gtk-parent-window");
quark_pointer_window = g_quark_from_static_string ("gtk-pointer-window");
klass->unmap_event = NULL;
klass->window_state_event = NULL;
klass->property_notify_event = _gtk_selection_property_notify;
- klass->selection_clear_event = gtk_selection_clear;
+ klass->selection_clear_event = _gtk_selection_clear;
klass->selection_request_event = _gtk_selection_request;
klass->selection_notify_event = _gtk_selection_notify;
klass->selection_received = NULL;
/**
* GtkWidget:double-buffered
*
- * Whether or not the widget is double buffered.
+ * Whether the widget is double buffered.
*
* Since: 2.18
*/
PROP_DOUBLE_BUFFERED,
g_param_spec_boolean ("double-buffered",
P_("Double Buffered"),
- P_("Whether or not the widget is double buffered"),
+ P_("Whether the widget is double buffered"),
TRUE,
GTK_PARAM_READWRITE));
/**
* GtkWidget::state-changed:
* @widget: the object which received the signal.
- * @state:
+ * @state: the previous state
+ *
+ * The ::state-changed signal is emitted when the widget state changes.
+ * See gtk_widget_get_state().
*/
widget_signals[STATE_CHANGED] =
g_signal_new (I_("state-changed"),
/**
* GtkWidget::parent-set:
* @widget: the object on which the signal is emitted
- * @old_parent: the previous parent, or %NULL if the widget
+ * @old_parent: (allow-none): the previous parent, or %NULL if the widget
* just got its initial parent.
*
* The ::parent-set signal is emitted when a new parent
/**
* GtkWidget::hierarchy-changed:
* @widget: the object on which the signal is emitted
- * @previous_toplevel: the previous toplevel ancestor, or %NULL
+ * @previous_toplevel: (allow-none): the previous toplevel ancestor, or %NULL
* if the widget was previously unanchored
*
* The ::hierarchy-changed signal is emitted when the
/**
* GtkWidget::style-set:
* @widget: the object on which the signal is emitted
- * @previous_style: the previous style, or %NULL if the widget
+ * @previous_style: (allow-none): the previous style, or %NULL if the widget
* just got its initial style
*
* The ::style-set signal is emitted when a new style has been set
/**
* GtkWidget::button-press-event:
* @widget: the object which received the signal.
- * @event: the #GdkEventButton which triggered this signal
+ * @event: (type Gdk.EventButton): the #GdkEventButton which triggered
+ * this signal.
*
* The ::button-press-event signal will be emitted when a button
* (typically from a mouse) is pressed.
/**
* GtkWidget::button-release-event:
* @widget: the object which received the signal.
- * @event: the #GdkEventButton which triggered this signal
+ * @event: (type Gdk.EventButton): the #GdkEventButton which triggered
+ * this signal.
*
* The ::button-release-event signal will be emitted when a button
* (typically from a mouse) is released.
/**
* GtkWidget::scroll-event:
* @widget: the object which received the signal.
- * @event: the #GdkEventScroll which triggered this signal
+ * @event: (type Gdk.EventScroll): the #GdkEventScroll which triggered
+ * this signal.
*
* The ::scroll-event signal is emitted when a button in the 4 to 7
* range is pressed. Wheel mice are usually configured to generate
/**
* GtkWidget::motion-notify-event:
* @widget: the object which received the signal.
- * @event: the #GdkEventMotion which triggered this signal
+ * @event: (type Gdk.EventMotion): the #GdkEventMotion which triggered
+ * this signal.
*
* The ::motion-notify-event signal is emitted when the pointer moves
* over the widget's #GdkWindow.
/**
* GtkWidget::expose-event:
* @widget: the object which received the signal.
- * @event: the #GdkEventExpose which triggered this 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.
/**
* GtkWidget::key-press-event:
* @widget: the object which received the signal
- * @event: the #GdkEventKey which triggered this signal
+ * @event: (type Gdk.EventKey): the #GdkEventKey which triggered this signal.
*
* The ::key-press-event signal is emitted when a key is pressed.
*
/**
* GtkWidget::key-release-event:
* @widget: the object which received the signal
- * @event: the #GdkEventKey which triggered this signal
+ * @event: (type Gdk.EventKey): the #GdkEventKey which triggered this signal.
*
* The ::key-release-event signal is emitted when a key is pressed.
*
/**
* GtkWidget::enter-notify-event:
* @widget: the object which received the signal
- * @event: the #GdkEventCrossing which triggered this signal
+ * @event: (type Gdk.EventCrossing): the #GdkEventCrossing which triggered
+ * this signal.
*
* The ::enter-notify-event will be emitted when the pointer enters
* the @widget's window.
/**
* GtkWidget::leave-notify-event:
* @widget: the object which received the signal
- * @event: the #GdkEventCrossing which triggered this signal
+ * @event: (type Gdk.EventCrossing): the #GdkEventCrossing which triggered
+ * this signal.
*
* The ::leave-notify-event will be emitted when the pointer leaves
* the @widget's window.
/**
* GtkWidget::configure-event
* @widget: the object which received the signal
- * @event: the #GdkEventConfigure which triggered this signal
+ * @event: (type Gdk.EventConfigure): the #GdkEventConfigure which triggered
+ * this signal.
*
* The ::configure-event signal will be emitted when the size, position or
* stacking of the @widget's window has changed.
/**
* GtkWidget::focus-in-event
* @widget: the object which received the signal
- * @event: the #GdkEventFocus which triggered this signal
+ * @event: (type Gdk.EventFocus): the #GdkEventFocus which triggered
+ * this signal.
*
* The ::focus-in-event signal will be emitted when the keyboard focus
* enters the @widget's window.
/**
* GtkWidget::focus-out-event
* @widget: the object which received the signal
- * @event: the #GdkEventFocus which triggered this signal
+ * @event: (type Gdk.EventFocus): the #GdkEventFocus which triggered this
+ * signal.
*
* The ::focus-out-event signal will be emitted when the keyboard focus
* leaves the @widget's window.
/**
* GtkWidget::map-event
* @widget: the object which received the signal
- * @event: the #GdkEventAny which triggered this signal
+ * @event: (type Gdk.EventAny): the #GdkEventAny which triggered this signal.
*
* The ::map-event signal will be emitted when the @widget's window is
* mapped. A window is mapped when it becomes visible on the screen.
/**
* GtkWidget::unmap-event
* @widget: the object which received the signal
- * @event: the #GdkEventAny which triggered this signal
+ * @event: (type Gdk.EventAny): the #GdkEventAny which triggered this signal
*
- * The ::unmap-event signal will be emitted when the @widget's window is
+ * The ::unmap-event signal may be emitted when the @widget's window is
* unmapped. A window is unmapped when it becomes invisible on the screen.
*
+ * For performance reasons GTK+ may not emit ::unmap-event, so one
+ * should always also implement ::unrealize in order to release
+ * resources and disconnect signal handlers.
+ *
* To receive this signal, the #GdkWindow associated to the widget needs
* to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask
* automatically for all new windows.
/**
* GtkWidget::property-notify-event
* @widget: the object which received the signal
- * @event: the #GdkEventProperty which triggered this signal
+ * @event: (type Gdk.EventProperty): the #GdkEventProperty which triggered
+ * this signal.
*
* The ::property-notify-event signal will be emitted when a property on
* the @widget's window has been changed or deleted.
/**
* GtkWidget::selection-clear-event
* @widget: the object which received the signal
- * @event: the #GdkEventSelection which triggered this signal
+ * @event: (type Gdk.EventSelection): the #GdkEventSelection which triggered
+ * this signal.
*
* The ::selection-clear-event signal will be emitted when the
* the @widget's window has lost ownership of a selection.
/**
* GtkWidget::selection-request-event
* @widget: the object which received the signal
- * @event: the #GdkEventSelection which triggered this signal
+ * @event: (type Gdk.EventSelection): the #GdkEventSelection which triggered
+ * this signal.
*
* The ::selection-request-event signal will be emitted when
* another client requests ownership of the selection owned by
/**
* GtkWidget::proximity-in-event
* @widget: the object which received the signal
- * @event: the #GdkEventProximity which triggered this signal
+ * @event: (type Gdk.EventProximity): the #GdkEventProximity which triggered
+ * this signal.
*
* To receive this signal the #GdkWindow associated to the widget needs
* to enable the #GDK_PROXIMITY_IN_MASK mask.
/**
* GtkWidget::proximity-out-event
* @widget: the object which received the signal
- * @event: the #GdkEventProximity which triggered this signal
+ * @event: (type Gdk.EventProximity): the #GdkEventProximity which triggered
+ * this signal.
*
* To receive this signal the #GdkWindow associated to the widget needs
* to enable the #GDK_PROXIMITY_OUT_MASK mask.
/**
* GtkWidget::visibility-notify-event:
* @widget: the object which received the signal
- * @event: the #GdkEventVisibility which triggered this signal
+ * @event: (type Gdk.EventVisibility): the #GdkEventVisibility which
+ * triggered this signal.
*
* The ::visibility-notify-event will be emitted when the @widget's window
* is obscured or unobscured.
/**
* GtkWidget::client-event:
* @widget: the object which received the signal
- * @event: the #GdkEventClient which triggered this signal
+ * @event: (type Gdk.EventClient): the #GdkEventClient which triggered
+ * this signal.
*
* The ::client-event will be emitted when the @widget's window
* receives a message (via a ClientMessage event) from another
/**
* GtkWidget::no-expose-event:
* @widget: the object which received the signal
- * @event: the #GdkEventNoExpose which triggered this signal
+ * @event: (type Gdk.EventNoExpose): the #GdkEventNoExpose which triggered
+ * this signal.
*
* The ::no-expose-event will be emitted when the @widget's window is
- * drawn as a copy of another #GdkDrawable (with gdk_draw_drawable() or
- * gdk_window_copy_area()) which was completely unobscured. If the source
- * window was partially obscured #GdkEventExpose events will be generated
- * for those areas.
+ * drawn as a copy of another #GdkDrawable which was completely unobscured.
+ * If the source window was partially obscured #GdkEventExpose events will
+ * be generated for those areas.
*
* Returns: %TRUE to stop other handlers from being invoked for the event.
* %FALSE to propagate the event further.
/**
* GtkWidget::window-state-event:
* @widget: the object which received the signal
- * @event: the #GdkEventWindowState which triggered this signal
+ * @event: (type Gdk.EventWindowState): the #GdkEventWindowState which
+ * triggered this signal.
*
* The ::window-state-event will be emitted when the state of the
* toplevel window associated to the @widget changes.
/**
* GtkWidget::screen-changed:
* @widget: the object on which the signal is emitted
- * @previous_screen: the previous screen, or %NULL if the
+ * @previous_screen: (allow-none): the previous screen, or %NULL if the
* widget was not associated with a screen before
*
* The ::screen-changed signal gets emitted when the
0.0, 1.0, 0.04,
GTK_PARAM_READABLE));
- /**
- * GtkWidget:draw-border:
- *
- * The "draw-border" style property defines the size of areas outside
- * the widget's allocation to draw.
- *
- * Since: 2.8
- */
gtk_widget_class_install_style_property (klass,
- g_param_spec_boxed ("draw-border",
- P_("Draw Border"),
- P_("Size of areas outside the widget's allocation to draw"),
- GTK_TYPE_BORDER,
- GTK_PARAM_READABLE));
+ g_param_spec_boolean ("window-dragging",
+ P_("Window dragging"),
+ P_("Whether windows can be dragged by clicking on empty areas"),
+ FALSE,
+ GTK_PARAM_READWRITE));
/**
* GtkWidget:link-color:
gtk_widget_set_style (widget, g_value_get_object (value));
break;
case PROP_EVENTS:
- if (!GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_realized (widget) && gtk_widget_get_has_window (widget))
gtk_widget_set_events (widget, g_value_get_flags (value));
break;
case PROP_EXTENSION_EVENTS:
tmp = (tooltip_window != NULL || tooltip_markup != NULL);
gtk_widget_real_set_has_tooltip (widget, tmp, FALSE);
- if (GTK_WIDGET_VISIBLE (widget))
+ if (gtk_widget_get_visible (widget))
gtk_widget_queue_tooltip_query (widget);
break;
case PROP_TOOLTIP_TEXT:
tmp = (tooltip_window != NULL || tooltip_markup != NULL);
gtk_widget_real_set_has_tooltip (widget, tmp, FALSE);
- if (GTK_WIDGET_VISIBLE (widget))
+ if (gtk_widget_get_visible (widget))
gtk_widget_queue_tooltip_query (widget);
break;
case PROP_DOUBLE_BUFFERED:
}
break;
case PROP_VISIBLE:
- g_value_set_boolean (value, (GTK_WIDGET_VISIBLE (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_get_visible (widget) != FALSE));
break;
case PROP_SENSITIVE:
- g_value_set_boolean (value, (GTK_WIDGET_SENSITIVE (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_get_sensitive (widget) != FALSE));
break;
case PROP_APP_PAINTABLE:
- g_value_set_boolean (value, (GTK_WIDGET_APP_PAINTABLE (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_get_app_paintable (widget) != FALSE));
break;
case PROP_CAN_FOCUS:
- g_value_set_boolean (value, (GTK_WIDGET_CAN_FOCUS (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_get_can_focus (widget) != FALSE));
break;
case PROP_HAS_FOCUS:
- g_value_set_boolean (value, (GTK_WIDGET_HAS_FOCUS (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_has_focus (widget) != FALSE));
break;
case PROP_IS_FOCUS:
g_value_set_boolean (value, (gtk_widget_is_focus (widget)));
break;
case PROP_CAN_DEFAULT:
- g_value_set_boolean (value, (GTK_WIDGET_CAN_DEFAULT (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_get_can_default (widget) != FALSE));
break;
case PROP_HAS_DEFAULT:
- g_value_set_boolean (value, (GTK_WIDGET_HAS_DEFAULT (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_has_default (widget) != FALSE));
break;
case PROP_RECEIVES_DEFAULT:
- g_value_set_boolean (value, (GTK_WIDGET_RECEIVES_DEFAULT (widget) != FALSE));
+ g_value_set_boolean (value, (gtk_widget_get_receives_default (widget) != FALSE));
break;
case PROP_COMPOSITE_CHILD:
- g_value_set_boolean (value, (GTK_WIDGET_COMPOSITE_CHILD (widget) != FALSE));
+ g_value_set_boolean (value, (GTK_OBJECT_FLAGS (widget) & GTK_COMPOSITE_CHILD) != 0 );
break;
case PROP_STYLE:
g_value_set_object (value, gtk_widget_get_style (widget));
if (escaped && !pango_parse_markup (escaped, -1, 0, NULL, &text, NULL, NULL))
g_assert (NULL == text); /* text should still be NULL in case of markup errors */
- g_value_set_string (value, text);
- g_free (text);
+ g_value_take_string (value, text);
}
break;
case PROP_TOOLTIP_MARKUP:
widget->window = NULL;
widget->parent = NULL;
- GTK_WIDGET_SET_FLAGS (widget,
- GTK_SENSITIVE |
- GTK_PARENT_SENSITIVE |
- (composite_child_stack ? GTK_COMPOSITE_CHILD : 0) |
- GTK_DOUBLE_BUFFERED);
+ 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_REQUEST_NEEDED);
+ 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);
widget->style = gtk_widget_get_default_style ();
return widget;
}
-/**
- * gtk_widget_set:
- * @widget: a #GtkWidget
- * @first_property_name: name of first property to set
- * @Varargs: value of first property, followed by more properties,
- * %NULL-terminated
- *
- * Precursor of g_object_set().
- *
- * Deprecated: 2.0: Use g_object_set() instead.
- **/
-void
-gtk_widget_set (GtkWidget *widget,
- const gchar *first_property_name,
- ...)
-{
- va_list var_args;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- va_start (var_args, first_property_name);
- g_object_set_valist (G_OBJECT (widget), first_property_name, var_args);
- va_end (var_args);
-}
-
static inline void
gtk_widget_queue_draw_child (GtkWidget *widget)
{
GtkWidget *parent;
parent = widget->parent;
- if (parent && GTK_WIDGET_DRAWABLE (parent))
+ if (parent && gtk_widget_is_drawable (parent))
gtk_widget_queue_draw_area (parent,
widget->allocation.x,
widget->allocation.y,
nqueue = g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
toplevel = gtk_widget_get_toplevel (widget);
- if (GTK_WIDGET_TOPLEVEL (toplevel))
+ if (gtk_widget_is_toplevel (toplevel))
_gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
- if (GTK_CONTAINER (widget->parent)->focus_child == widget)
+ if (gtk_container_get_focus_child (GTK_CONTAINER (widget->parent)) == widget)
gtk_container_set_focus_child (GTK_CONTAINER (widget->parent), NULL);
/* If we are unanchoring the child, we save around the toplevel
widget->allocation.width = 1;
widget->allocation.height = 1;
- if (GTK_WIDGET_REALIZED (widget))
+ if (gtk_widget_get_realized (widget))
{
if (GTK_WIDGET_IN_REPARENT (widget))
gtk_widget_unmap (widget);
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (!GTK_WIDGET_VISIBLE (widget))
+ if (!gtk_widget_get_visible (widget))
{
g_object_ref (widget);
- if (!GTK_WIDGET_TOPLEVEL (widget))
+ if (!gtk_widget_is_toplevel (widget))
gtk_widget_queue_resize (widget);
g_signal_emit (widget, widget_signals[SHOW], 0);
g_object_notify (G_OBJECT (widget), "visible");
static void
gtk_widget_real_show (GtkWidget *widget)
{
- if (!GTK_WIDGET_VISIBLE (widget))
+ if (!gtk_widget_get_visible (widget))
{
GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
if (widget->parent &&
- GTK_WIDGET_MAPPED (widget->parent) &&
+ gtk_widget_get_mapped (widget->parent) &&
GTK_WIDGET_CHILD_VISIBLE (widget) &&
- !GTK_WIDGET_MAPPED (widget))
+ !gtk_widget_get_mapped (widget))
gtk_widget_map (widget);
}
}
g_return_if_fail (GTK_IS_WIDGET (widget));
/* make sure we will get event */
- if (!GTK_WIDGET_MAPPED (widget) &&
- GTK_WIDGET_TOPLEVEL (widget))
+ if (!gtk_widget_get_mapped (widget) &&
+ gtk_widget_is_toplevel (widget))
{
gtk_widget_show (widget);
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (GTK_WIDGET_VISIBLE (widget))
+ if (gtk_widget_get_visible (widget))
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
g_object_ref (widget);
- if (toplevel != widget && GTK_WIDGET_TOPLEVEL (toplevel))
+ if (toplevel != widget && gtk_widget_is_toplevel (toplevel))
_gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
g_signal_emit (widget, widget_signals[HIDE], 0);
- if (!GTK_WIDGET_TOPLEVEL (widget))
+ if (!gtk_widget_is_toplevel (widget))
gtk_widget_queue_resize (widget);
g_object_notify (G_OBJECT (widget), "visible");
g_object_unref (widget);
static void
gtk_widget_real_hide (GtkWidget *widget)
{
- if (GTK_WIDGET_VISIBLE (widget))
+ if (gtk_widget_get_visible (widget))
{
GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
- if (GTK_WIDGET_MAPPED (widget))
+ if (gtk_widget_get_mapped (widget))
gtk_widget_unmap (widget);
}
}
g_return_if_fail (GTK_IS_WIDGET (widget));
- if ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0)
+ if (gtk_widget_get_no_show_all (widget))
return;
class = GTK_WIDGET_GET_CLASS (widget);
g_return_if_fail (GTK_IS_WIDGET (widget));
- if ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0)
+ if (gtk_widget_get_no_show_all (widget))
return;
class = GTK_WIDGET_GET_CLASS (widget);
gtk_widget_map (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (GTK_WIDGET_VISIBLE (widget));
+ g_return_if_fail (gtk_widget_get_visible (widget));
g_return_if_fail (GTK_WIDGET_CHILD_VISIBLE (widget));
- if (!GTK_WIDGET_MAPPED (widget))
+ if (!gtk_widget_get_mapped (widget))
{
- if (!GTK_WIDGET_REALIZED (widget))
+ if (!gtk_widget_get_realized (widget))
gtk_widget_realize (widget);
g_signal_emit (widget, widget_signals[MAP], 0);
- if (GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_has_window (widget))
gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
}
}
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (GTK_WIDGET_MAPPED (widget))
+ if (gtk_widget_get_mapped (widget))
{
- if (GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_has_window (widget))
gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
_gtk_tooltip_hide (widget);
g_signal_emit (widget, widget_signals[UNMAP], 0);
if (window_list == NULL)
{
- if (!GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_has_window (widget))
window_list = g_list_prepend (NULL, widget->window);
else
window_list = gdk_window_get_children (widget->window);
g_list_free (free_list);
}
+static void
+_gtk_widget_enable_device_events (GtkWidget *widget)
+{
+ GHashTable *device_events;
+ GHashTableIter iter;
+ gpointer key, value;
+
+ device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
+
+ if (!device_events)
+ return;
+
+ g_hash_table_iter_init (&iter, device_events);
+
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ GdkDevice *device;
+ GdkEventMask event_mask;
+
+ device = key;
+ event_mask = GPOINTER_TO_UINT (value);
+ gtk_widget_add_events_internal (widget, device, event_mask);
+ }
+}
+
/**
* gtk_widget_realize:
* @widget: a #GtkWidget
g_return_if_fail (GTK_WIDGET_ANCHORED (widget) ||
GTK_IS_INVISIBLE (widget));
- if (!GTK_WIDGET_REALIZED (widget))
+ if (!gtk_widget_get_realized (widget))
{
/*
- if (GTK_IS_CONTAINER (widget) && !GTK_WIDGET_NO_WINDOW (widget))
- g_message ("gtk_widget_realize(%s)", g_type_name (GTK_WIDGET_TYPE (widget)));
+ if (GTK_IS_CONTAINER (widget) && gtk_widget_get_has_window (widget))
+ g_message ("gtk_widget_realize(%s)", G_OBJECT_TYPE_NAME (widget));
*/
if (widget->parent == NULL &&
- !GTK_WIDGET_TOPLEVEL (widget))
+ !gtk_widget_is_toplevel (widget))
g_warning ("Calling gtk_widget_realize() on a widget that isn't "
"inside a toplevel window is not going to work very well. "
"Widgets must be inside a toplevel container before realizing them.");
- if (widget->parent && !GTK_WIDGET_REALIZED (widget->parent))
+ if (widget->parent && !gtk_widget_get_realized (widget->parent))
gtk_widget_realize (widget->parent);
gtk_widget_ensure_style (widget);
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)
+ gdk_window_set_support_multidevice (widget->window, TRUE);
+
+ _gtk_widget_enable_device_events (widget);
}
}
if (g_object_get_qdata (G_OBJECT (widget), quark_input_shape_info))
gtk_widget_input_shape_combine_mask (widget, NULL, 0, 0);
- if (GTK_WIDGET_REALIZED (widget))
+ if (gtk_widget_get_realized (widget))
{
g_object_ref (widget);
_gtk_tooltip_hide (widget);
g_signal_emit (widget, widget_signals[UNREALIZE], 0);
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED | GTK_MAPPED);
+ gtk_widget_set_realized (widget, FALSE);
+ gtk_widget_set_mapped (widget, FALSE);
g_object_unref (widget);
}
}
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (!GTK_WIDGET_REALIZED (widget))
+ if (!gtk_widget_get_realized (widget))
return;
/* Just return if the widget or one of its ancestors isn't mapped */
for (w = widget; w != NULL; w = w->parent)
- if (!GTK_WIDGET_MAPPED (w))
+ if (!gtk_widget_get_mapped (w))
return;
/* Find the correct widget */
- if (!GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_has_window (widget))
{
if (widget->parent)
{
gdk_window_invalidate_rect (widget->window, &invalid_rect, TRUE);
}
-static void
-widget_add_child_draw_rectangle (GtkWidget *widget,
- GdkRectangle *rect)
-{
- GdkRectangle child_rect;
-
- if (!GTK_WIDGET_MAPPED (widget) ||
- widget->window != widget->parent->window)
- return;
-
- gtk_widget_get_draw_rectangle (widget, &child_rect);
- gdk_rectangle_union (rect, &child_rect, rect);
-}
-
-static void
-gtk_widget_get_draw_rectangle (GtkWidget *widget,
- GdkRectangle *rect)
-{
- if (GTK_WIDGET_NO_WINDOW (widget))
- {
- GtkBorder *draw_border = NULL;
-
- *rect = widget->allocation;
-
- gtk_widget_style_get (widget,
- "draw-border", &draw_border,
- NULL);
- if (draw_border)
- {
- rect->x -= draw_border->left;
- rect->y -= draw_border->top;
- rect->width += draw_border->left + draw_border->right;
- rect->height += draw_border->top + draw_border->bottom;
-
- gtk_border_free (draw_border);
- }
-
- if (GTK_IS_CONTAINER (widget))
- gtk_container_forall (GTK_CONTAINER (widget),
- (GtkCallback)widget_add_child_draw_rectangle,
- rect);
- }
- else
- {
- rect->x = 0;
- rect->y = 0;
- rect->width = widget->allocation.width;
- rect->height = widget->allocation.height;
- }
-}
-
/**
* gtk_widget_queue_draw:
* @widget: a #GtkWidget
g_return_if_fail (GTK_IS_WIDGET (widget));
- gtk_widget_get_draw_rectangle (widget, &rect);
-
- gtk_widget_queue_draw_area (widget,
- rect.x, rect.y,
- rect.width, rect.height);
-}
-
-/* Invalidates the given area (allocation-relative-coordinates)
- * in all of the widget's windows
- */
-/**
- * gtk_widget_queue_clear_area:
- * @widget: a #GtkWidget
- * @x: x coordinate of upper-left corner of rectangle to redraw
- * @y: y coordinate of upper-left corner of rectangle to redraw
- * @width: width of region to draw
- * @height: height of region to draw
- *
- * This function is no longer different from
- * gtk_widget_queue_draw_area(), though it once was. Now it just calls
- * gtk_widget_queue_draw_area(). Originally
- * gtk_widget_queue_clear_area() would force a redraw of the
- * background for %GTK_NO_WINDOW widgets, and
- * gtk_widget_queue_draw_area() would not. Now both functions ensure
- * the background will be redrawn.
- *
- * Deprecated: 2.2: Use gtk_widget_queue_draw_area() instead.
- **/
-void
-gtk_widget_queue_clear_area (GtkWidget *widget,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- gtk_widget_queue_draw_area (widget, x, y, width, height);
-}
-
-/**
- * gtk_widget_queue_clear:
- * @widget: a #GtkWidget
- *
- * This function does the same as gtk_widget_queue_draw().
- *
- * Deprecated: 2.2: Use gtk_widget_queue_draw() instead.
- **/
-void
-gtk_widget_queue_clear (GtkWidget *widget)
-{
- g_return_if_fail (GTK_IS_WIDGET (widget));
+ gtk_widget_get_allocation (widget, &rect);
- gtk_widget_queue_draw (widget);
+ if (!gtk_widget_get_has_window (widget))
+ gtk_widget_queue_draw_area (widget,
+ rect.x, rect.y, rect.width, rect.height);
+ else
+ gtk_widget_queue_draw_area (widget,
+ 0, 0, rect.width, rect.height);
}
/**
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (GTK_WIDGET_REALIZED (widget))
+ if (gtk_widget_get_realized (widget))
gtk_widget_queue_shallow_draw (widget);
_gtk_size_group_queue_resize (widget);
_gtk_size_group_queue_resize (widget);
}
-/**
- * gtk_widget_draw:
- * @widget: a #GtkWidget
- * @area: area to draw
- *
- * In GTK+ 1.2, this function would immediately render the
- * region @area of a widget, by invoking the virtual draw method of a
- * widget. In GTK+ 2.0, the draw method is gone, and instead
- * gtk_widget_draw() simply invalidates the specified region of the
- * widget, then updates the invalid region of the widget immediately.
- * Usually you don't want to update the region immediately for
- * performance reasons, so in general gtk_widget_queue_draw_area() is
- * a better choice if you want to draw a region of a widget.
- **/
-void
-gtk_widget_draw (GtkWidget *widget,
- const GdkRectangle *area)
-{
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- if (GTK_WIDGET_DRAWABLE (widget))
- {
- if (area)
- gtk_widget_queue_draw_area (widget,
- area->x, area->y,
- area->width, area->height);
- else
- gtk_widget_queue_draw (widget);
-
- gdk_window_process_updates (widget->window, TRUE);
- }
-}
-
/**
* gtk_widget_size_request:
* @widget: a #GtkWidget
- * @requisition: a #GtkRequisition to be filled in
+ * @requisition: (out): a #GtkRequisition to be filled in
*
* This function is typically used when implementing a #GtkContainer
* subclass. Obtains the preferred size of a widget. The container
* Also remember that the size request is not necessarily the size
* a widget will actually be allocated.
*
- * See also gtk_widget_get_child_requisition().
+ * Deprecated: 3.0: Use gtk_size_request_get_size() instead.
**/
void
gtk_widget_size_request (GtkWidget *widget,
"to widget->requisition. gtk_widget_set_usize() may not work properly.");
#endif /* G_ENABLE_DEBUG */
- _gtk_size_group_compute_desired_size (widget, requisition, NULL);
+ gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
}
/**
* gtk_widget_get_child_requisition:
* @widget: a #GtkWidget
- * @requisition: a #GtkRequisition to be filled in
+ * @requisition: (out): a #GtkRequisition to be filled in
*
* This function is only for use in widget implementations. Obtains
* @widget->requisition, unless someone has forced a particular
* since the last time a resize was queued. In general, only container
* implementations have this information; applications should use
* gtk_widget_size_request().
+ *
+ *
+ * Deprecated: 3.0: Use gtk_size_request_get_size() instead.
**/
void
gtk_widget_get_child_requisition (GtkWidget *widget,
GtkRequisition *requisition)
{
- _gtk_size_group_get_child_requisition (widget, requisition);
+ gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
}
static gboolean
*/
static void
gtk_widget_invalidate_widget_windows (GtkWidget *widget,
- GdkRegion *region)
+ cairo_region_t *region)
{
- if (!GTK_WIDGET_REALIZED (widget))
+ if (!gtk_widget_get_realized (widget))
return;
- if (!GTK_WIDGET_NO_WINDOW (widget) && widget->parent)
+ if (gtk_widget_get_has_window (widget) && widget->parent)
{
int x, y;
gdk_window_get_position (widget->window, &x, &y);
- gdk_region_offset (region, -x, -y);
+ cairo_region_translate (region, -x, -y);
}
gdk_window_invalidate_maybe_recurse (widget->window, region,
gtk_widget_queue_shallow_draw (GtkWidget *widget)
{
GdkRectangle rect;
- GdkRegion *region;
-
- if (!GTK_WIDGET_REALIZED (widget))
+ cairo_region_t *region;
+
+ if (!gtk_widget_get_realized (widget))
return;
- gtk_widget_get_draw_rectangle (widget, &rect);
+ gtk_widget_get_allocation (widget, &rect);
- /* get_draw_rectangle() gives us window coordinates, we
- * need to convert to the coordinates that widget->allocation
- * is in.
- */
- if (!GTK_WIDGET_NO_WINDOW (widget) && widget->parent)
- {
- int wx, wy;
-
- gdk_window_get_position (widget->window, &wx, &wy);
-
- rect.x += wx;
- rect.y += wy;
- }
-
- region = gdk_region_rectangle (&rect);
+ region = cairo_region_create_rectangle (&rect);
gtk_widget_invalidate_widget_windows (widget, region);
- gdk_region_destroy (region);
+ cairo_region_destroy (region);
}
/**
* gtk_widget_size_allocate:
* @widget: a #GtkWidget
- * @allocation: position and size to be allocated to @widget
+ * @allocation: (inout): position and size to be allocated to @widget
*
* This function is only used by #GtkContainer subclasses, to assign a size
* and position to their child widgets.
g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0, &real_allocation);
- if (GTK_WIDGET_MAPPED (widget))
+ if (gtk_widget_get_mapped (widget))
{
- if (GTK_WIDGET_NO_WINDOW (widget) && GTK_WIDGET_REDRAW_ON_ALLOC (widget) && position_changed)
+ if (!gtk_widget_get_has_window (widget) && GTK_WIDGET_REDRAW_ON_ALLOC (widget) && position_changed)
{
/* Invalidate union(old_allaction,widget->allocation) in widget->window
*/
- GdkRegion *invalidate = gdk_region_rectangle (&widget->allocation);
- gdk_region_union_with_rect (invalidate, &old_allocation);
+ cairo_region_t *invalidate = cairo_region_create_rectangle (&widget->allocation);
+ cairo_region_union_rectangle (invalidate, &old_allocation);
gdk_window_invalidate_region (widget->window, invalidate, FALSE);
- gdk_region_destroy (invalidate);
+ cairo_region_destroy (invalidate);
}
if (size_changed)
{
/* Invalidate union(old_allaction,widget->allocation) in widget->window and descendents owned by widget
*/
- GdkRegion *invalidate = gdk_region_rectangle (&widget->allocation);
- gdk_region_union_with_rect (invalidate, &old_allocation);
+ cairo_region_t *invalidate = cairo_region_create_rectangle (&widget->allocation);
+ cairo_region_union_rectangle (invalidate, &old_allocation);
gtk_widget_invalidate_widget_windows (widget, invalidate);
- gdk_region_destroy (invalidate);
+ cairo_region_destroy (invalidate);
}
}
}
if ((size_changed || position_changed) && widget->parent &&
- GTK_WIDGET_REALIZED (widget->parent) && GTK_CONTAINER (widget->parent)->reallocate_redraws)
+ gtk_widget_get_realized (widget->parent) && _gtk_container_get_reallocate_redraws (GTK_CONTAINER (widget->parent)))
{
- GdkRegion *invalidate = gdk_region_rectangle (&widget->parent->allocation);
+ cairo_region_t *invalidate = cairo_region_create_rectangle (&widget->parent->allocation);
gtk_widget_invalidate_widget_windows (widget->parent, invalidate);
- gdk_region_destroy (invalidate);
+ cairo_region_destroy (invalidate);
}
}
{
GtkWidget *ancestor;
GdkWindow *window;
+ GList *dest_list = NULL;
g_return_val_if_fail (GTK_IS_WIDGET (src_widget), FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (dest_widget), FALSE);
ancestor = gtk_widget_common_ancestor (src_widget, dest_widget);
- if (!ancestor || !GTK_WIDGET_REALIZED (src_widget) || !GTK_WIDGET_REALIZED (dest_widget))
+ if (!ancestor || !gtk_widget_get_realized (src_widget) || !gtk_widget_get_realized (dest_widget))
return FALSE;
/* Translate from allocation relative to window relative */
- if (!GTK_WIDGET_NO_WINDOW (src_widget) && src_widget->parent)
+ if (gtk_widget_get_has_window (src_widget) && src_widget->parent)
{
gint wx, wy;
gdk_window_get_position (src_widget->window, &wx, &wy);
window = src_widget->window;
while (window != ancestor->window)
{
- gint dx, dy;
-
- gdk_window_get_position (window, &dx, &dy);
-
- src_x += dx;
- src_y += dy;
-
- window = gdk_window_get_parent (window);
+ gdouble dx, dy;
+
+ gdk_window_coords_to_parent (window, src_x, src_y, &dx, &dy);
+
+ src_x = dx;
+ src_y = dy;
+
+ window = gdk_window_get_effective_parent (window);
if (!window) /* Handle GtkHandleBox */
return FALSE;
window = dest_widget->window;
while (window != ancestor->window)
{
- gint dx, dy;
-
- gdk_window_get_position (window, &dx, &dy);
-
- src_x -= dx;
- src_y -= dy;
-
- window = gdk_window_get_parent (window);
-
+ dest_list = g_list_prepend (dest_list, window);
+
+ window = gdk_window_get_effective_parent (window);
+
if (!window) /* Handle GtkHandleBox */
- return FALSE;
+ {
+ g_list_free (dest_list);
+ return FALSE;
+ }
+ }
+
+ while (dest_list)
+ {
+ gdouble dx, dy;
+
+ gdk_window_coords_from_parent (dest_list->data, src_x, src_y, &dx, &dy);
+
+ src_x = dx;
+ src_y = dy;
+
+ dest_list = g_list_remove (dest_list, dest_list->data);
}
/* Translate from window relative to allocation relative */
- if (!GTK_WIDGET_NO_WINDOW (dest_widget) && dest_widget->parent)
+ if (gtk_widget_get_has_window (dest_widget) && dest_widget->parent)
{
gint wx, wy;
gdk_window_get_position (dest_widget->window, &wx, &wy);
{
widget->allocation = *allocation;
- if (GTK_WIDGET_REALIZED (widget) &&
- !GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_realized (widget) &&
+ gtk_widget_get_has_window (widget))
{
gdk_window_move_resize (widget->window,
allocation->x, allocation->y,
guint signal_id)
{
/* widgets must be onscreen for accels to take effect */
- return GTK_WIDGET_IS_SENSITIVE (widget) && GTK_WIDGET_DRAWABLE (widget) && gdk_window_is_viewable (widget->window);
+ return gtk_widget_is_sensitive (widget) &&
+ gtk_widget_is_drawable (widget) &&
+ gdk_window_is_viewable (widget->window);
}
/**
apath = g_object_get_qdata (G_OBJECT (widget), quark_accel_path);
if (locked)
- *locked = apath ? apath->accel_group->lock_count > 0 : TRUE;
+ *locked = apath ? gtk_accel_group_get_is_locked (apath->accel_group) : TRUE;
return apath ? g_quark_to_string (apath->path_quark) : NULL;
}
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
group_cycling = group_cycling != FALSE;
- if (!GTK_WIDGET_IS_SENSITIVE (widget))
+ if (!gtk_widget_is_sensitive (widget))
handled = TRUE;
else
g_signal_emit (widget,
{
if (!group_cycling && GTK_WIDGET_GET_CLASS (widget)->activate_signal)
gtk_widget_activate (widget);
- else if (GTK_WIDGET_CAN_FOCUS (widget))
+ else if (gtk_widget_get_can_focus (widget))
gtk_widget_grab_focus (widget);
else
{
}
#define WIDGET_REALIZED_FOR_EVENT(widget, event) \
- (event->type == GDK_FOCUS_CHANGE || GTK_WIDGET_REALIZED(widget))
+ (event->type == GDK_FOCUS_CHANGE || gtk_widget_get_realized(widget))
/**
* gtk_widget_event:
GdkEvent *event)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
- g_return_val_if_fail (GTK_WIDGET_REALIZED (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);
gtk_widget_reparent_subwindows (GtkWidget *widget,
GdkWindow *new_window)
{
- if (GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_has_window (widget))
{
GList *children = gdk_window_get_children (widget->window);
GList *tmp_list;
{
g_assert (client_data != NULL);
- if (GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_has_window (widget))
{
if (widget->window)
g_object_unref (widget->window);
* the widget as we reparent it. if so we set a flag so
* that gtk_widget_unparent doesn't unrealize widget
*/
- if (GTK_WIDGET_REALIZED (widget) && GTK_WIDGET_REALIZED (new_parent))
+ if (gtk_widget_get_realized (widget) && gtk_widget_get_realized (new_parent))
GTK_PRIVATE_SET_FLAG (widget, GTK_IN_REPARENT);
g_object_ref (widget);
return_val = gdk_rectangle_intersect (&widget->allocation, area, dest);
- if (return_val && intersection && !GTK_WIDGET_NO_WINDOW (widget))
+ if (return_val && intersection && gtk_widget_get_has_window (widget))
{
intersection->x -= widget->allocation.x;
intersection->y -= widget->allocation.y;
/**
* gtk_widget_region_intersect:
* @widget: a #GtkWidget
- * @region: a #GdkRegion, in the same coordinate system as
+ * @region: a #cairo_region_t, in the same coordinate system as
* @widget->allocation. That is, relative to @widget->window
* for %NO_WINDOW widgets; relative to the parent window
* of @widget->window for widgets with their own window.
* widgets with their own window.
*
* Computes the intersection of a @widget's area and @region, returning
- * the intersection. The result may be empty, use gdk_region_empty() to
+ * the intersection. The result may be empty, use cairo_region_is_empty() to
* check.
**/
-GdkRegion *
+cairo_region_t *
gtk_widget_region_intersect (GtkWidget *widget,
- const GdkRegion *region)
+ const cairo_region_t *region)
{
GdkRectangle rect;
- GdkRegion *dest;
+ cairo_region_t *dest;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
g_return_val_if_fail (region != NULL, NULL);
- gtk_widget_get_draw_rectangle (widget, &rect);
+ gtk_widget_get_allocation (widget, &rect);
- dest = gdk_region_rectangle (&rect);
+ dest = cairo_region_create_rectangle (&rect);
- gdk_region_intersect (dest, region);
+ cairo_region_intersect (dest, region);
return dest;
}
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (!GTK_WIDGET_IS_SENSITIVE (widget))
+ if (!gtk_widget_is_sensitive (widget))
return;
g_object_ref (widget);
static void
gtk_widget_real_grab_focus (GtkWidget *focus_widget)
{
- if (GTK_WIDGET_CAN_FOCUS (focus_widget))
+ if (gtk_widget_get_can_focus (focus_widget))
{
GtkWidget *toplevel;
GtkWidget *widget;
* be set by the next loop.
*/
toplevel = gtk_widget_get_toplevel (focus_widget);
- if (GTK_WIDGET_TOPLEVEL (toplevel) && GTK_IS_WINDOW (toplevel))
+ if (gtk_widget_is_toplevel (toplevel) && GTK_IS_WINDOW (toplevel))
{
widget = GTK_WINDOW (toplevel)->focus_widget;
* toplevel window can request the focus if necessary.
* This is needed when the toplevel is a GtkPlug
*/
- if (!GTK_WIDGET_HAS_FOCUS (widget))
+ if (!gtk_widget_has_focus (widget))
_gtk_window_internal_set_focus (GTK_WINDOW (toplevel), focus_widget);
return;
gtk_widget_real_focus (GtkWidget *widget,
GtkDirectionType direction)
{
- if (!GTK_WIDGET_CAN_FOCUS (widget))
+ if (!gtk_widget_get_can_focus (widget))
return FALSE;
if (!gtk_widget_is_focus (widget))
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (can_focus != GTK_WIDGET_CAN_FOCUS (widget))
+ if (can_focus != gtk_widget_get_can_focus (widget))
{
if (can_focus)
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+ GTK_OBJECT_FLAGS (widget) |= GTK_CAN_FOCUS;
else
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_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_WIDGET_CAN_FOCUS (widget);
+ return (GTK_OBJECT_FLAGS (widget) & GTK_CAN_FOCUS) != 0;
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return GTK_WIDGET_HAS_FOCUS (widget);
+ return (GTK_OBJECT_FLAGS (widget) & GTK_HAS_FOCUS) != 0;
}
/**
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (can_default != GTK_WIDGET_CAN_DEFAULT (widget))
+ if (can_default != gtk_widget_get_can_default (widget))
{
if (can_default)
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_DEFAULT);
+ GTK_OBJECT_FLAGS (widget) |= GTK_CAN_DEFAULT;
else
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_DEFAULT);
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_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_WIDGET_CAN_DEFAULT (widget);
+ return (GTK_OBJECT_FLAGS (widget) & GTK_CAN_DEFAULT) != 0;
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return GTK_WIDGET_HAS_DEFAULT (widget);
+ return (GTK_OBJECT_FLAGS (widget) & GTK_HAS_DEFAULT) != 0;
+}
+
+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);
}
/**
* yourself by calling <literal>gtk_widget_set_can_default (@widget,
* %TRUE)</literal>. The default widget is activated when
* the user presses Enter in a window. Default widgets must be
- * activatable, that is, gtk_widget_activate() should affect them.
+ * activatable, that is, gtk_widget_activate() should affect them. Note
+ * that #GtkEntry widgets require the "activates-default" property
+ * set to %TRUE before they activate the default widget when Enter
+ * is pressed and the #GtkEntry is focused.
**/
void
gtk_widget_grab_default (GtkWidget *widget)
GtkWidget *window;
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (GTK_WIDGET_CAN_DEFAULT (widget));
+ g_return_if_fail (gtk_widget_get_can_default (widget));
window = gtk_widget_get_toplevel (widget);
- if (window && GTK_WIDGET_TOPLEVEL (window))
+ if (window && gtk_widget_is_toplevel (window))
gtk_window_set_default (GTK_WINDOW (window), widget);
else
g_warning (G_STRLOC ": widget not within a GtkWindow");
if (receives_default != gtk_widget_get_receives_default (widget))
{
if (receives_default)
- GTK_WIDGET_SET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
+ GTK_OBJECT_FLAGS (widget) |= GTK_RECEIVES_DEFAULT;
else
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_RECEIVES_DEFAULT);
g_object_notify (G_OBJECT (widget), "receives-default");
}
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_WIDGET_FLAGS (widget) & GTK_RECEIVES_DEFAULT) != 0;
+ return (GTK_OBJECT_FLAGS (widget) & GTK_RECEIVES_DEFAULT) != 0;
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_WIDGET_FLAGS (widget) & GTK_HAS_GRAB) != 0;
+ return (GTK_OBJECT_FLAGS (widget) & GTK_HAS_GRAB) != 0;
+}
+
+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);
+}
+
+/**
+ * gtk_widget_device_is_shadowed:
+ * @widget: a #GtkWidget
+ * @device: a #GdkDevice
+ *
+ * Returns %TRUE if @device has been shadowed by a GTK+
+ * device grab on another widget, so it would stop sending
+ * events to @widget. This may be used in the
+ * #GtkWidget::grab-notify signal to check for specific
+ * devices. See gtk_device_grab_add().
+ *
+ * Returns: %TRUE if there is an ongoing grab on @device
+ * by another #GtkWidget than @widget.
+ *
+ * Since: 3.0
+ **/
+gboolean
+gtk_widget_device_is_shadowed (GtkWidget *widget,
+ GdkDevice *device)
+{
+ GtkWindowGroup *group;
+ GtkWidget *grab_widget, *toplevel;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
+
+ if (!gtk_widget_get_realized (widget))
+ return TRUE;
+
+ toplevel = gtk_widget_get_toplevel (widget);
+
+ if (GTK_IS_WINDOW (toplevel))
+ group = gtk_window_get_group (GTK_WINDOW (toplevel));
+ else
+ group = gtk_window_get_group (NULL);
+
+ grab_widget = gtk_window_group_get_current_device_grab (group, device);
+
+ /* Widget not inside the hierarchy of grab_widget */
+ if (grab_widget &&
+ widget != grab_widget &&
+ !gtk_widget_is_ancestor (widget, grab_widget))
+ return TRUE;
+
+ if (group->grabs)
+ {
+ grab_widget = group->grabs->data;
+
+ if (widget != grab_widget &&
+ !gtk_widget_is_ancestor (widget, grab_widget))
+ return TRUE;
+ }
+
+ return FALSE;
}
/**
g_free (widget->name);
widget->name = new_name;
- if (GTK_WIDGET_RC_STYLE (widget))
+ if (gtk_widget_has_rc_style (widget))
gtk_widget_reset_rc_style (widget);
g_object_notify (G_OBJECT (widget), "name");
if (widget->name)
return widget->name;
- return g_type_name (GTK_WIDGET_TYPE (widget));
+ return G_OBJECT_TYPE_NAME (widget);
}
/**
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (state == GTK_WIDGET_STATE (widget))
+ if (state == gtk_widget_get_state (widget))
return;
if (state == GTK_STATE_INSENSITIVE)
data.state_restoration = FALSE;
data.use_forall = FALSE;
if (widget->parent)
- data.parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (widget->parent) != FALSE);
+ data.parent_sensitive = (gtk_widget_is_sensitive (widget->parent) != FALSE);
else
data.parent_sensitive = TRUE;
gtk_widget_propagate_state (widget, &data);
- if (GTK_WIDGET_DRAWABLE (widget))
+ if (gtk_widget_is_drawable (widget))
gtk_widget_queue_draw (widget);
}
}
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (visible != GTK_WIDGET_VISIBLE (widget))
+ if (visible != gtk_widget_get_visible (widget))
{
if (visible)
gtk_widget_show (widget);
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_WIDGET_FLAGS (widget) & GTK_VISIBLE) != 0;
+ return (GTK_OBJECT_FLAGS (widget) & GTK_VISIBLE) != 0;
}
/**
* all realized widgets have a non-%NULL "window" pointer
* (gtk_widget_get_window() never returns a %NULL window when a widget
* is realized), but for many of them it's actually the #GdkWindow of
- * one of its parent widgets. Widgets that create a %window for
- * themselves in GtkWidget::realize() however must announce this by
- * calling this function with @has_window = %TRUE.
+ * one of its parent widgets. Widgets that do not create a %window for
+ * themselves in GtkWidget::realize() must announce this by
+ * calling this function with @has_window = %FALSE.
*
* This function should only be called by widget implementations,
* and they should call it in their init() function.
g_return_if_fail (GTK_IS_WIDGET (widget));
if (has_window)
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_NO_WINDOW);
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_NO_WINDOW);
else
- GTK_WIDGET_SET_FLAGS (widget, GTK_NO_WINDOW);
+ GTK_OBJECT_FLAGS (widget) |= GTK_NO_WINDOW;
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return !GTK_WIDGET_NO_WINDOW (widget);
+ return !((GTK_OBJECT_FLAGS (widget) & GTK_NO_WINDOW) != 0);
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_WIDGET_FLAGS (widget) & GTK_TOPLEVEL) != 0;
+ return (GTK_OBJECT_FLAGS (widget) & GTK_TOPLEVEL) != 0;
+}
+
+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);
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return ((GTK_WIDGET_FLAGS (widget) & GTK_VISIBLE) != 0 &&
- (GTK_WIDGET_FLAGS (widget) & GTK_MAPPED) != 0);
+ return (gtk_widget_get_visible (widget) &&
+ gtk_widget_get_mapped (widget));
+}
+
+/**
+ * gtk_widget_get_realized:
+ * @widget: a #GtkWidget
+ *
+ * Determines whether @widget is realized.
+ *
+ * Return value: %TRUE if @widget is realized, %FALSE otherwise
+ *
+ * Since: 2.20
+ **/
+gboolean
+gtk_widget_get_realized (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_OBJECT_FLAGS (widget) & GTK_REALIZED) != 0;
+}
+
+/**
+ * gtk_widget_set_realized:
+ * @widget: a #GtkWidget
+ * @realized: %TRUE to mark the widget as realized
+ *
+ * Marks the widget as being realized.
+ *
+ * This function should only ever be called in a derived widget's
+ * "realize" or "unrealize" implementation.
+ *
+ * Since: 2.20
+ */
+void
+gtk_widget_set_realized (GtkWidget *widget,
+ gboolean realized)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ if (realized)
+ GTK_OBJECT_FLAGS (widget) |= GTK_REALIZED;
+ else
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_REALIZED);
+}
+
+/**
+ * gtk_widget_get_mapped:
+ * @widget: a #GtkWidget
+ *
+ * Whether the widget is mapped.
+ *
+ * Return value: %TRUE if the widget is mapped, %FALSE otherwise.
+ *
+ * Since: 2.20
+ */
+gboolean
+gtk_widget_get_mapped (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_OBJECT_FLAGS (widget) & GTK_MAPPED) != 0;
+}
+
+/**
+ * gtk_widget_set_mapped:
+ * @widget: a #GtkWidget
+ * @mapped: %TRUE to mark the widget as mapped
+ *
+ * Marks the widget as being realized.
+ *
+ * This function should only ever be called in a derived widget's
+ * "map" or "unmap" implementation.
+ *
+ * Since: 2.20
+ */
+void
+gtk_widget_set_mapped (GtkWidget *widget,
+ gboolean mapped)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ if (mapped)
+ GTK_OBJECT_FLAGS (widget) |= GTK_MAPPED;
+ else
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_MAPPED);
}
/**
app_paintable = (app_paintable != FALSE);
- if (GTK_WIDGET_APP_PAINTABLE (widget) != app_paintable)
+ if (gtk_widget_get_app_paintable (widget) != app_paintable)
{
if (app_paintable)
- GTK_WIDGET_SET_FLAGS (widget, GTK_APP_PAINTABLE);
+ GTK_OBJECT_FLAGS (widget) |= GTK_APP_PAINTABLE;
else
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_APP_PAINTABLE);
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_APP_PAINTABLE);
- if (GTK_WIDGET_DRAWABLE (widget))
+ if (gtk_widget_is_drawable (widget))
gtk_widget_queue_draw (widget);
g_object_notify (G_OBJECT (widget), "app-paintable");
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_WIDGET_FLAGS (widget) & GTK_APP_PAINTABLE) != 0;
+ return (GTK_OBJECT_FLAGS (widget) & GTK_APP_PAINTABLE) != 0;
}
/**
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (double_buffered != GTK_WIDGET_DOUBLE_BUFFERED (widget))
+ double_buffered = (double_buffered != FALSE);
+
+ if (double_buffered != gtk_widget_get_double_buffered (widget))
{
if (double_buffered)
- GTK_WIDGET_SET_FLAGS (widget, GTK_DOUBLE_BUFFERED);
+ GTK_OBJECT_FLAGS (widget) |= GTK_DOUBLE_BUFFERED;
else
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_DOUBLE_BUFFERED);
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_DOUBLE_BUFFERED);
g_object_notify (G_OBJECT (widget), "double-buffered");
}
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_WIDGET_FLAGS (widget) & GTK_DOUBLE_BUFFERED) != 0;
+ return (GTK_OBJECT_FLAGS (widget) & GTK_DOUBLE_BUFFERED) != 0;
}
/**
sensitive = (sensitive != FALSE);
- if (sensitive == (GTK_WIDGET_SENSITIVE (widget) != FALSE))
+ if (sensitive == (gtk_widget_get_sensitive (widget) != FALSE))
return;
if (sensitive)
{
- GTK_WIDGET_SET_FLAGS (widget, GTK_SENSITIVE);
- data.state = GTK_WIDGET_SAVED_STATE (widget);
+ GTK_OBJECT_FLAGS (widget) |= GTK_SENSITIVE;
+ data.state = widget->saved_state;
}
else
{
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_SENSITIVE);
- data.state = GTK_WIDGET_STATE (widget);
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_SENSITIVE);
+ data.state = gtk_widget_get_state (widget);
}
data.state_restoration = TRUE;
data.use_forall = TRUE;
if (widget->parent)
- data.parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (widget->parent) != FALSE);
+ data.parent_sensitive = (gtk_widget_is_sensitive (widget->parent) != FALSE);
else
data.parent_sensitive = TRUE;
gtk_widget_propagate_state (widget, &data);
- if (GTK_WIDGET_DRAWABLE (widget))
+ if (gtk_widget_is_drawable (widget))
gtk_widget_queue_draw (widget);
g_object_notify (G_OBJECT (widget), "sensitive");
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return GTK_WIDGET_SENSITIVE (widget);
+ return (GTK_OBJECT_FLAGS (widget) & GTK_SENSITIVE) != 0;
}
/**
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return GTK_WIDGET_IS_SENSITIVE (widget);
+ return (gtk_widget_get_sensitive (widget) &&
+ (GTK_OBJECT_FLAGS (widget) & GTK_PARENT_SENSITIVE) != 0);
}
/**
g_warning ("Can't set a parent on widget which has a parent\n");
return;
}
- if (GTK_WIDGET_TOPLEVEL (widget))
+ if (gtk_widget_is_toplevel (widget))
{
g_warning ("Can't set a parent on a toplevel widget\n");
return;
g_object_ref_sink (widget);
widget->parent = parent;
- if (GTK_WIDGET_STATE (parent) != GTK_STATE_NORMAL)
- data.state = GTK_WIDGET_STATE (parent);
+ if (gtk_widget_get_state (parent) != GTK_STATE_NORMAL)
+ data.state = gtk_widget_get_state (parent);
else
- data.state = GTK_WIDGET_STATE (widget);
+ data.state = gtk_widget_get_state (widget);
data.state_restoration = FALSE;
- data.parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (parent) != FALSE);
- data.use_forall = GTK_WIDGET_IS_SENSITIVE (parent) != GTK_WIDGET_IS_SENSITIVE (widget);
+ data.parent_sensitive = (gtk_widget_is_sensitive (parent) != FALSE);
+ data.use_forall = gtk_widget_is_sensitive (parent) != gtk_widget_is_sensitive (widget);
gtk_widget_propagate_state (widget, &data);
/* Enforce realized/mapped invariants
*/
- if (GTK_WIDGET_REALIZED (widget->parent))
+ if (gtk_widget_get_realized (widget->parent))
gtk_widget_realize (widget);
- if (GTK_WIDGET_VISIBLE (widget->parent) &&
- GTK_WIDGET_VISIBLE (widget))
+ if (gtk_widget_get_visible (widget->parent) &&
+ gtk_widget_get_visible (widget))
{
if (GTK_WIDGET_CHILD_VISIBLE (widget) &&
- GTK_WIDGET_MAPPED (widget->parent))
+ gtk_widget_get_mapped (widget->parent))
gtk_widget_map (widget);
gtk_widget_queue_resize (widget);
*****************************************/
/**
- * gtk_widget_set_style:
+ * gtk_widget_style_attach:
* @widget: a #GtkWidget
- * @style: (allow-none): a #GtkStyle, or %NULL to remove the effect of a previous
- * gtk_widget_set_style() and go back to the default style
*
- * Sets the #GtkStyle for a widget (@widget->style). You probably don't
- * want to use this function; it interacts badly with themes, because
- * themes work by replacing the #GtkStyle. Instead, use
- * gtk_widget_modify_style().
+ * This function attaches the widget's #GtkStyle to the widget's
+ * #GdkWindow. It is a replacement for
+ *
+ * <programlisting>
+ * widget->style = gtk_style_attach (widget->style, widget->window);
+ * </programlisting>
+ *
+ * and should only ever be called in a derived widget's "realize"
+ * implementation which does not chain up to its parent class'
+ * "realize" implementation, because one of the parent classes
+ * (finally #GtkWidget) would attach the style itself.
+ *
+ * Since: 2.20
**/
void
-gtk_widget_set_style (GtkWidget *widget,
- GtkStyle *style)
+gtk_widget_style_attach (GtkWidget *widget)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (gtk_widget_get_realized (widget));
+
+ widget->style = gtk_style_attach (widget->style, widget->window);
+}
+
+/**
+ * gtk_widget_has_rc_style:
+ * @widget: a #GtkWidget
+ *
+ * Determines if the widget style has been looked up through the rc mechanism.
+ *
+ * Returns: %TRUE if the widget has been looked up through the rc
+ * mechanism, %FALSE otherwise.
+ *
+ * Since: 2.20
+ **/
+gboolean
+gtk_widget_has_rc_style (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return (GTK_OBJECT_FLAGS (widget) & GTK_RC_STYLE) != 0;
+}
+
+/**
+ * gtk_widget_set_style:
+ * @widget: a #GtkWidget
+ * @style: (allow-none): a #GtkStyle, or %NULL to remove the effect of a previous
+ * gtk_widget_set_style() and go back to the default style
+ *
+ * Sets the #GtkStyle for a widget (@widget->style). You probably don't
+ * want to use this function; it interacts badly with themes, because
+ * themes work by replacing the #GtkStyle. Instead, use
+ * gtk_widget_modify_style().
+ **/
+void
+gtk_widget_set_style (GtkWidget *widget,
+ GtkStyle *style)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
{
gboolean initial_emission;
- initial_emission = !GTK_WIDGET_RC_STYLE (widget) && !GTK_WIDGET_USER_STYLE (widget);
+ initial_emission = !gtk_widget_has_rc_style (widget) && !GTK_WIDGET_USER_STYLE (widget);
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_RC_STYLE);
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_RC_STYLE);
GTK_PRIVATE_SET_FLAG (widget, GTK_USER_STYLE);
gtk_widget_set_style_internal (widget, style, initial_emission);
g_return_if_fail (GTK_IS_WIDGET (widget));
if (!GTK_WIDGET_USER_STYLE (widget) &&
- !GTK_WIDGET_RC_STYLE (widget))
+ !gtk_widget_has_rc_style (widget))
gtk_widget_reset_rc_style (widget);
}
GtkStyle *new_style = NULL;
gboolean initial_emission;
- initial_emission = !GTK_WIDGET_RC_STYLE (widget) && !GTK_WIDGET_USER_STYLE (widget);
+ initial_emission = !gtk_widget_has_rc_style (widget) && !GTK_WIDGET_USER_STYLE (widget);
GTK_PRIVATE_UNSET_FLAG (widget, GTK_USER_STYLE);
- GTK_WIDGET_SET_FLAGS (widget, GTK_RC_STYLE);
+ GTK_OBJECT_FLAGS (widget) |= GTK_RC_STYLE;
if (gtk_widget_has_screen (widget))
new_style = gtk_rc_get_style (widget);
* modifier style and the only reference was our own.
*/
- if (GTK_WIDGET_RC_STYLE (widget))
+ if (gtk_widget_has_rc_style (widget))
gtk_widget_reset_rc_style (widget);
}
gtk_widget_modify_style (widget, rc_style);
}
+/**
+ * gtk_widget_modify_symbolic_color:
+ * @widget: a #GtkWidget
+ * @name: the name of the symbolic color to modify
+ * @color: (allow-none): the color to assign (does not need to be allocated),
+ * or %NULL to undo the effect of previous calls to
+ * of gtk_widget_modify_symbolic_color().
+ *
+ * Sets a symbolic color for a widget.
+ * All other style values are left untouched. See also
+ * gtk_widget_modify_style().
+ *
+ * Since: 3.0
+ **/
+void
+gtk_widget_modify_symbolic_color (GtkWidget *widget,
+ const gchar *name,
+ const GdkColor *color)
+{
+ GtkRcStyle *rc_style = gtk_widget_get_modifier_style (widget);
+
+ _gtk_rc_style_set_symbolic_color (rc_style, name, color);
+
+ gtk_widget_modify_style (widget, rc_style);
+}
+
/**
* gtk_widget_modify_fg:
* @widget: a #GtkWidget
gtk_widget_real_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
- if (GTK_WIDGET_REALIZED (widget) &&
- !GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_realized (widget) &&
+ gtk_widget_get_has_window (widget))
gtk_style_set_background (widget->style, widget->window, widget->state);
}
{
GtkStyle *previous_style;
- if (GTK_WIDGET_REALIZED (widget))
+ if (gtk_widget_get_realized (widget))
{
gtk_widget_reset_shapes (widget);
gtk_style_detach (widget->style);
widget->style = style;
g_object_ref (widget->style);
- if (GTK_WIDGET_REALIZED (widget))
+ if (gtk_widget_get_realized (widget))
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_widget_update_pango_context (widget);
gpointer client_data)
{
HierarchyChangedInfo *info = client_data;
- gboolean new_anchored = GTK_WIDGET_TOPLEVEL (widget) ||
+ gboolean new_anchored = gtk_widget_is_toplevel (widget) ||
(widget->parent && GTK_WIDGET_ANCHORED (widget->parent));
if (GTK_WIDGET_ANCHORED (widget) != new_anchored)
info.previous_toplevel = previous_toplevel;
info.previous_screen = previous_toplevel ? gtk_widget_get_screen (previous_toplevel) : NULL;
- if (GTK_WIDGET_TOPLEVEL (widget) ||
+ if (gtk_widget_is_toplevel (widget) ||
(widget->parent && GTK_WIDGET_ANCHORED (widget->parent)))
info.new_screen = gtk_widget_get_screen (widget);
else
static void
reset_rc_styles_recurse (GtkWidget *widget, gpointer data)
{
- if (GTK_WIDGET_RC_STYLE (widget))
+ if (gtk_widget_has_rc_style (widget))
gtk_widget_reset_rc_style (widget);
if (GTK_IS_CONTAINER (widget))
retval = gtk_icon_set_render_icon (icon_set,
widget->style,
gtk_widget_get_direction (widget),
- GTK_WIDGET_STATE (widget),
+ gtk_widget_get_state (widget),
size,
widget,
detail);
gboolean is_visible)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (!GTK_WIDGET_TOPLEVEL (widget));
+ g_return_if_fail (!gtk_widget_is_toplevel (widget));
g_object_ref (widget);
GTK_PRIVATE_UNSET_FLAG (widget, GTK_CHILD_VISIBLE);
toplevel = gtk_widget_get_toplevel (widget);
- if (toplevel != widget && GTK_WIDGET_TOPLEVEL (toplevel))
+ if (toplevel != widget && gtk_widget_is_toplevel (toplevel))
_gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
}
- if (widget->parent && GTK_WIDGET_REALIZED (widget->parent))
+ if (widget->parent && gtk_widget_get_realized (widget->parent))
{
- if (GTK_WIDGET_MAPPED (widget->parent) &&
+ if (gtk_widget_get_mapped (widget->parent) &&
GTK_WIDGET_CHILD_VISIBLE (widget) &&
- GTK_WIDGET_VISIBLE (widget))
+ gtk_widget_get_visible (widget))
gtk_widget_map (widget);
else
gtk_widget_unmap (widget);
toplevel = gtk_widget_get_toplevel (widget);
- if (GTK_WIDGET_TOPLEVEL (toplevel))
+ if (gtk_widget_is_toplevel (toplevel))
{
if (GTK_IS_WINDOW (toplevel))
return GTK_WINDOW (toplevel)->screen;
else if (GTK_IS_INVISIBLE (toplevel))
- return GTK_INVISIBLE (widget)->screen;
+ return gtk_invisible_get_screen (GTK_INVISIBLE (widget));
}
return NULL;
* around the window using keyboard shortcuts. @direction indicates
* what kind of motion is taking place (up, down, left, right, tab
* forward, tab backward). gtk_widget_child_focus() emits the
- * #GtkWidget::focus" signal; widgets override the default handler
+ * #GtkWidget::focus signal; widgets override the default handler
* for this signal in order to implement appropriate focus behavior.
*
* The default ::focus handler for a widget should return %TRUE if
* outside the widget. If returning %TRUE, widgets normally
* call gtk_widget_grab_focus() to place the focus accordingly;
* if returning %FALSE, they don't modify the current focus location.
- *
- * This function replaces gtk_container_focus() from GTK+ 1.2.
- * It was necessary to check that the child was visible, sensitive,
- * and focusable before calling gtk_container_focus().
- * gtk_widget_child_focus() returns %FALSE if the widget is not
- * currently in a focusable state, so there's no need for those checks.
- *
+ *
* Return value: %TRUE if focus ended up inside @widget
**/
gboolean
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- if (!GTK_WIDGET_VISIBLE (widget) ||
- !GTK_WIDGET_IS_SENSITIVE (widget))
+ if (!gtk_widget_get_visible (widget) ||
+ !gtk_widget_is_sensitive (widget))
return FALSE;
/* child widgets must set CAN_FOCUS, containers
* don't have to though.
*/
if (!GTK_IS_CONTAINER (widget) &&
- !GTK_WIDGET_CAN_FOCUS (widget))
+ !gtk_widget_get_can_focus (widget))
return FALSE;
g_signal_emit (widget,
gdk_window_beep (widget->window);
}
-/**
- * gtk_widget_set_uposition:
- * @widget: a #GtkWidget
- * @x: x position; -1 to unset x; -2 to leave x unchanged
- * @y: y position; -1 to unset y; -2 to leave y unchanged
- *
- *
- * Sets the position of a widget. The funny "u" in the name comes from
- * the "user position" hint specified by the X Window System, and
- * exists for legacy reasons. This function doesn't work if a widget
- * is inside a container; it's only really useful on #GtkWindow.
- *
- * Don't use this function to center dialogs over the main application
- * window; most window managers will do the centering on your behalf
- * if you call gtk_window_set_transient_for(), and it's really not
- * possible to get the centering to work correctly in all cases from
- * application code. But if you insist, use gtk_window_set_position()
- * to set #GTK_WIN_POS_CENTER_ON_PARENT, don't do the centering
- * manually.
- *
- * Note that although @x and @y can be individually unset, the position
- * is not honoured unless both @x and @y are set.
- **/
-void
-gtk_widget_set_uposition (GtkWidget *widget,
- gint x,
- gint y)
-{
- /* FIXME this function is the only place that aux_info->x and
- * aux_info->y are even used I believe, and this function is
- * deprecated. Should be cleaned up.
- *
- * (Actually, size_allocate uses them) -Yosh
- */
-
- GtkWidgetAuxInfo *aux_info;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- aux_info =_gtk_widget_get_aux_info (widget, TRUE);
-
- if (x > -2)
- {
- if (x == -1)
- aux_info->x_set = FALSE;
- else
- {
- aux_info->x_set = TRUE;
- aux_info->x = x;
- }
- }
-
- if (y > -2)
- {
- if (y == -1)
- aux_info->y_set = FALSE;
- else
- {
- aux_info->y_set = TRUE;
- aux_info->y = y;
- }
- }
-
- if (GTK_IS_WINDOW (widget) && aux_info->x_set && aux_info->y_set)
- _gtk_window_reposition (GTK_WINDOW (widget), aux_info->x, aux_info->y);
-
- if (GTK_WIDGET_VISIBLE (widget) && widget->parent)
- gtk_widget_size_allocate (widget, &widget->allocation);
-}
-
static void
gtk_widget_set_usize_internal (GtkWidget *widget,
gint width,
changed = TRUE;
}
- if (GTK_WIDGET_VISIBLE (widget) && changed)
+ if (gtk_widget_get_visible (widget) && changed)
gtk_widget_queue_resize (widget);
g_object_thaw_notify (G_OBJECT (widget));
}
-/**
- * gtk_widget_set_usize:
- * @widget: a #GtkWidget
- * @width: minimum width, or -1 to unset
- * @height: minimum height, or -1 to unset
- *
- * Sets the minimum size of a widget; that is, the widget's size
- * request will be @width by @height. You can use this function to
- * force a widget to be either larger or smaller than it is. The
- * strange "usize" name dates from the early days of GTK+, and derives
- * from X Window System terminology. In many cases,
- * gtk_window_set_default_size() is a better choice for toplevel
- * windows than this function; setting the default size will still
- * allow users to shrink the window. Setting the usize will force them
- * to leave the window at least as large as the usize. When dealing
- * with window sizes, gtk_window_set_geometry_hints() can be a useful
- * function as well.
- *
- * Note the inherent danger of setting any fixed size - themes,
- * translations into other languages, different fonts, and user action
- * can all change the appropriate size for a given widget. So, it's
- * basically impossible to hardcode a size that will always be
- * correct.
- *
- * Deprecated: 2.2: Use gtk_widget_set_size_request() instead.
- **/
-void
-gtk_widget_set_usize (GtkWidget *widget,
- gint width,
- gint height)
-{
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- gtk_widget_set_usize_internal (widget, width, height);
-}
-
/**
* gtk_widget_set_size_request:
* @widget: a #GtkWidget
/**
* gtk_widget_get_size_request:
* @widget: a #GtkWidget
- * @width: (out): return location for width, or %NULL
- * @height: (out): return location for height, or %NULL
+ * @width: (out) (allow-none): return location for width, or %NULL
+ * @height: (out) (allow-none): return location for height, or %NULL
*
* Gets the size request that was explicitly set for the widget using
* gtk_widget_set_size_request(). A value of -1 stored in @width or
gint events)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (!GTK_WIDGET_REALIZED (widget));
+ g_return_if_fail (!gtk_widget_get_realized (widget));
g_object_set_qdata (G_OBJECT (widget), quark_event_mask,
GINT_TO_POINTER (events));
g_object_notify (G_OBJECT (widget), "events");
}
+/**
+ * gtk_widget_set_device_events:
+ * @widget: a #GtkWidget
+ * @device: a #GdkDevice
+ * @events: event mask
+ *
+ * Sets the device event mask (see #GdkEventMask) for a widget. The event
+ * mask determines which events a widget will receive from @device. Keep
+ * in mind that different widgets have different default event masks, and by
+ * changing the event mask you may disrupt a widget's functionality,
+ * so be careful. This function must be called while a widget is
+ * unrealized. Consider gtk_widget_add_device_events() for widgets that are
+ * already realized, or if you want to preserve the existing event
+ * mask. This function can't be used with #GTK_NO_WINDOW widgets;
+ * to get events on those widgets, place them inside a #GtkEventBox
+ * and receive events on the event box.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_widget_set_device_events (GtkWidget *widget,
+ GdkDevice *device,
+ GdkEventMask events)
+{
+ GHashTable *device_events;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GDK_IS_DEVICE (device));
+ g_return_if_fail (!gtk_widget_get_realized (widget));
+
+ device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
+
+ if (G_UNLIKELY (!device_events))
+ {
+ device_events = g_hash_table_new (NULL, NULL);
+ g_object_set_qdata_full (G_OBJECT (widget), quark_device_event_mask, device_events,
+ (GDestroyNotify) g_hash_table_unref);
+ }
+
+ g_hash_table_insert (device_events, device, GUINT_TO_POINTER (events));
+}
+
static void
-gtk_widget_add_events_internal (GtkWidget *widget,
- gint events,
- GList *window_list)
+gtk_widget_add_events_internal_list (GtkWidget *widget,
+ GdkDevice *device,
+ gint events,
+ GList *window_list)
{
GList *l;
gdk_window_get_user_data (window, &user_data);
if (user_data == widget)
- {
- GList *children;
+ {
+ GList *children;
- gdk_window_set_events (window, gdk_window_get_events (window) | events);
+ if (device)
+ gdk_window_set_device_events (window, device, gdk_window_get_events (window) | events);
+ else
+ gdk_window_set_events (window, gdk_window_get_events (window) | events);
- children = gdk_window_get_children (window);
- gtk_widget_add_events_internal (widget, events, children);
- g_list_free (children);
- }
+ children = gdk_window_get_children (window);
+ gtk_widget_add_events_internal_list (widget, device, events, children);
+ g_list_free (children);
+ }
}
}
+static void
+gtk_widget_add_events_internal (GtkWidget *widget,
+ GdkDevice *device,
+ gint events)
+{
+ GList *window_list;
+
+ if (!gtk_widget_get_has_window (widget))
+ window_list = gdk_window_get_children (widget->window);
+ else
+ window_list = g_list_prepend (NULL, widget->window);
+
+ gtk_widget_add_events_internal_list (widget, device, events, window_list);
+
+ g_list_free (window_list);
+}
+
/**
* gtk_widget_add_events:
* @widget: a #GtkWidget
g_object_set_qdata (G_OBJECT (widget), quark_event_mask,
GINT_TO_POINTER (old_events | events));
- if (GTK_WIDGET_REALIZED (widget))
- {
- GList *window_list;
+ if (gtk_widget_get_realized (widget))
+ gtk_widget_add_events_internal (widget, NULL, events);
- if (GTK_WIDGET_NO_WINDOW (widget))
- window_list = gdk_window_get_children (widget->window);
- else
- window_list = g_list_prepend (NULL, widget->window);
+ g_object_notify (G_OBJECT (widget), "events");
+}
- gtk_widget_add_events_internal (widget, events, window_list);
+/**
+ * gtk_widget_add_device_events:
+ * @widget: a #GtkWidget
+ * @device: a #GdkDevice
+ * @events: an event mask, see #GdkEventMask
+ *
+ * Adds the device events in the bitfield @events to the event mask for
+ * @widget. See gtk_widget_set_device_events() for details.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_widget_add_device_events (GtkWidget *widget,
+ GdkDevice *device,
+ GdkEventMask events)
+{
+ GdkEventMask old_events;
+ GHashTable *device_events;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GDK_IS_DEVICE (device));
+
+ old_events = gtk_widget_get_device_events (widget, device);
+
+ device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
- g_list_free (window_list);
+ if (G_UNLIKELY (!device_events))
+ {
+ device_events = g_hash_table_new (NULL, NULL);
+ g_object_set_qdata_full (G_OBJECT (widget), quark_device_event_mask, device_events,
+ (GDestroyNotify) g_hash_table_unref);
}
+ g_hash_table_insert (device_events, device,
+ GUINT_TO_POINTER (old_events | events));
+
+ if (gtk_widget_get_realized (widget))
+ gtk_widget_add_events_internal (widget, device, events);
+
g_object_notify (G_OBJECT (widget), "events");
}
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (GTK_WIDGET_REALIZED (widget))
+ if (gtk_widget_get_realized (widget))
gtk_widget_set_extension_events_internal (widget, mode, NULL);
g_object_set_qdata (G_OBJECT (widget), quark_extension_event_mode,
* is set on the result.
* |[
* GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
- * if (GTK_WIDGET_TOPLEVEL (toplevel))
+ * if (gtk_widget_is_toplevel (toplevel))
* {
* /* Perform action on toplevel. */
* }
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- while (widget && !g_type_is_a (GTK_WIDGET_TYPE (widget), widget_type))
+ while (widget && !g_type_is_a (G_OBJECT_TYPE (widget), widget_type))
widget = widget->parent;
- if (!(widget && g_type_is_a (GTK_WIDGET_TYPE (widget), widget_type)))
+ if (!(widget && g_type_is_a (G_OBJECT_TYPE (widget), widget_type)))
return NULL;
return widget;
GdkColormap *colormap)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (!GTK_WIDGET_REALIZED (widget));
+ g_return_if_fail (!gtk_widget_get_realized (widget));
g_return_if_fail (GDK_IS_COLORMAP (colormap));
g_object_ref (colormap);
return GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (widget), quark_event_mask));
}
+/**
+ * gtk_widget_get_device_events:
+ * @widget: a #GtkWidget
+ * @device: a #GdkDevice
+ *
+ * Returns the events mask for the widget corresponding to an specific device. These
+ * are the events that the widget will receive when @device operates on it.
+ *
+ * Returns: device event mask for @widget
+ *
+ * Since: 3.0
+ **/
+GdkEventMask
+gtk_widget_get_device_events (GtkWidget *widget,
+ GdkDevice *device)
+{
+ GHashTable *device_events;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
+ g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
+
+ device_events = g_object_get_qdata (G_OBJECT (widget), quark_device_event_mask);
+
+ if (!device_events)
+ return 0;
+
+ return GPOINTER_TO_UINT (g_hash_table_lookup (device_events, device));
+}
+
/**
* gtk_widget_get_extension_events:
* @widget: a #GtkWidget
if (y)
*y = -1;
- if (GTK_WIDGET_REALIZED (widget))
+ if (gtk_widget_get_realized (widget))
{
gdk_window_get_pointer (widget->window, x, y, NULL);
- if (GTK_WIDGET_NO_WINDOW (widget))
+ if (!gtk_widget_get_has_window (widget))
{
if (x)
*x -= widget->allocation.x;
const gchar *name)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (GTK_WIDGET_COMPOSITE_CHILD (widget));
+ g_return_if_fail ((GTK_OBJECT_FLAGS (widget) & GTK_COMPOSITE_CHILD) != 0);
g_return_if_fail (name != NULL);
if (!quark_composite_name)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- if (GTK_WIDGET_COMPOSITE_CHILD (widget) && widget->parent)
+ if (((GTK_OBJECT_FLAGS (widget) & GTK_COMPOSITE_CHILD) != 0) && widget->parent)
return _gtk_container_child_composite_name (GTK_CONTAINER (widget->parent),
widget);
else
if (widget->parent)
gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
- else if (GTK_WIDGET_VISIBLE (widget))
+ else if (gtk_widget_get_visible (widget))
gtk_widget_hide (widget);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
- if (GTK_WIDGET_REALIZED (widget))
+ if (gtk_widget_get_realized (widget))
gtk_widget_unrealize (widget);
G_OBJECT_CLASS (gtk_widget_parent_class)->dispose (object);
static void
gtk_widget_real_map (GtkWidget *widget)
{
- g_assert (GTK_WIDGET_REALIZED (widget));
+ g_assert (gtk_widget_get_realized (widget));
- if (!GTK_WIDGET_MAPPED (widget))
+ if (!gtk_widget_get_mapped (widget))
{
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
+ gtk_widget_set_mapped (widget, TRUE);
- if (!GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_has_window (widget))
gdk_window_show (widget->window);
}
}
static void
gtk_widget_real_unmap (GtkWidget *widget)
{
- if (GTK_WIDGET_MAPPED (widget))
+ if (gtk_widget_get_mapped (widget))
{
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+ gtk_widget_set_mapped (widget, FALSE);
- if (!GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_has_window (widget))
gdk_window_hide (widget->window);
}
}
static void
gtk_widget_real_realize (GtkWidget *widget)
{
- g_assert (GTK_WIDGET_NO_WINDOW (widget));
+ g_assert (!gtk_widget_get_has_window (widget));
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+ gtk_widget_set_realized (widget, TRUE);
if (widget->parent)
{
widget->window = gtk_widget_get_parent_window (widget);
static void
gtk_widget_real_unrealize (GtkWidget *widget)
{
- if (GTK_WIDGET_MAPPED (widget))
+ if (gtk_widget_get_mapped (widget))
gtk_widget_real_unmap (widget);
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+ gtk_widget_set_mapped (widget, FALSE);
/* printf ("unrealizing %s\n", g_type_name (G_TYPE_FROM_INSTANCE (widget)));
*/
NULL);
gtk_style_detach (widget->style);
- if (!GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_has_window (widget))
{
gdk_window_set_user_data (widget->window, NULL);
gdk_window_destroy (widget->window);
gtk_selection_remove_all (widget);
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED);
+ gtk_widget_set_realized (widget, FALSE);
}
static void
}
/*
- * _gtk_widget_set_pointer_window:
+ * _gtk_widget_set_device_window:
* @widget: a #GtkWidget.
- * @pointer_window: the new pointer window.
+ * @device: a #GdkDevice.
+ * @window: the new device window.
*
- * Sets pointer window for @widget. Does not ref @pointer_window.
+ * Sets pointer window for @widget and @device. Does not ref @window.
* Actually stores it on the #GdkScreen, but you don't need to know that.
*/
void
-_gtk_widget_set_pointer_window (GtkWidget *widget,
- GdkWindow *pointer_window)
+_gtk_widget_set_device_window (GtkWidget *widget,
+ GdkDevice *device,
+ GdkWindow *window)
{
+ GdkScreen *screen;
+ GHashTable *device_window;
+
g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GDK_IS_DEVICE (device));
+ g_return_if_fail (!window || GDK_IS_WINDOW (window));
- if (GTK_WIDGET_REALIZED (widget))
- {
- GdkScreen *screen = gdk_drawable_get_screen (widget->window);
+ if (!gtk_widget_get_realized (widget))
+ return;
+
+ screen = gdk_drawable_get_screen (widget->window);
+ device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
- g_object_set_qdata (G_OBJECT (screen), quark_pointer_window,
- pointer_window);
+ if (G_UNLIKELY (!device_window))
+ {
+ device_window = g_hash_table_new (NULL, NULL);
+ g_object_set_qdata_full (G_OBJECT (screen),
+ quark_pointer_window,
+ device_window,
+ (GDestroyNotify) g_hash_table_destroy);
}
+
+ if (window)
+ g_hash_table_insert (device_window, device, window);
+ else
+ g_hash_table_remove (device_window, device);
}
/*
- * _gtk_widget_get_pointer_window:
+ * _gtk_widget_get_device_window:
* @widget: a #GtkWidget.
+ * @device: a #GdkDevice.
*
- * Return value: the pointer window set on the #GdkScreen @widget is attached
+ * Return value: the device window set on the #GdkScreen @widget is attached
* to, or %NULL.
*/
GdkWindow *
-_gtk_widget_get_pointer_window (GtkWidget *widget)
+_gtk_widget_get_device_window (GtkWidget *widget,
+ GdkDevice *device)
{
+ GdkScreen *screen;
+ GHashTable *device_window;
+ GdkWindow *window;
+ GtkWidget *w;
+
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
+
+ if (!gtk_widget_get_realized (widget))
+ return NULL;
- if (GTK_WIDGET_REALIZED (widget))
+ screen = gdk_drawable_get_screen (widget->window);
+ device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
+
+ if (G_UNLIKELY (!device_window))
+ return NULL;
+
+ window = g_hash_table_lookup (device_window, device);
+
+ if (!window)
+ return NULL;
+
+ gdk_window_get_user_data (window, (gpointer *) &w);
+
+ if (widget != w)
+ return NULL;
+
+ return window;
+}
+
+/*
+ * _gtk_widget_list_devices:
+ * @widget: a #GtkWidget.
+ *
+ * Returns the list of #GdkDevices that is currently on top of any widget #GdkWindow.
+ * Free the list with g_list_free(), the elements are owned by GTK+ and must not
+ * be freed.
+ */
+GList *
+_gtk_widget_list_devices (GtkWidget *widget)
+{
+ GdkScreen *screen;
+ GHashTableIter iter;
+ GHashTable *device_window;
+ GList *devices = NULL;
+ gpointer key, value;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+ if (!gtk_widget_get_realized (widget))
+ return NULL;
+
+ screen = gdk_drawable_get_screen (widget->window);
+ device_window = g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
+
+ if (G_UNLIKELY (!device_window))
+ return NULL;
+
+ g_hash_table_iter_init (&iter, device_window);
+
+ while (g_hash_table_iter_next (&iter, &key, &value))
{
- GdkScreen *screen = gdk_drawable_get_screen (widget->window);
+ GdkDevice *device = key;
+ GdkWindow *window = value;
+ GtkWidget *w;
+
+ if (window)
+ {
+ gdk_window_get_user_data (window, (gpointer *) &w);
- return g_object_get_qdata (G_OBJECT (screen), quark_pointer_window);
+ if (widget == w)
+ devices = g_list_prepend (devices, device);
+ }
}
- return NULL;
+ return devices;
}
static void
-synth_crossing (GtkWidget *widget,
- GdkEventType type,
- GdkWindow *window,
- GdkCrossingMode mode,
- GdkNotifyType detail)
+synth_crossing (GtkWidget *widget,
+ GdkEventType type,
+ GdkWindow *window,
+ GdkDevice *device,
+ GdkCrossingMode mode,
+ GdkNotifyType detail)
{
GdkEvent *event;
-
+
event = gdk_event_new (type);
event->crossing.window = g_object_ref (window);
event->crossing.detail = detail;
event->crossing.focus = FALSE;
event->crossing.state = 0;
+ gdk_event_set_device (event, device);
if (!widget)
widget = gtk_get_event_widget (event);
gdk_event_free (event);
}
-/*
- * _gtk_widget_is_pointer_widget:
- * @widget: a #GtkWidget
- *
- * Returns %TRUE if the pointer window belongs to @widget.
- */
-gboolean
-_gtk_widget_is_pointer_widget (GtkWidget *widget)
-{
- if (GTK_WIDGET_HAS_POINTER (widget))
- {
- GdkWindow *win;
- GtkWidget *wid;
-
- win = _gtk_widget_get_pointer_window (widget);
- if (win)
- {
- gdk_window_get_user_data (win, (gpointer *)&wid);
- if (wid == widget)
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
/*
* _gtk_widget_synthesize_crossing:
* @from: the #GtkWidget the virtual pointer is leaving.
* - enter notify on real pointer window, detail Ancestor
*/
void
-_gtk_widget_synthesize_crossing (GtkWidget *from,
- GtkWidget *to,
- GdkCrossingMode mode)
+_gtk_widget_synthesize_crossing (GtkWidget *from,
+ GtkWidget *to,
+ GdkDevice *device,
+ GdkCrossingMode mode)
{
GdkWindow *from_window = NULL, *to_window = NULL;
g_return_if_fail (from != NULL || to != NULL);
if (from != NULL)
- from_window = GTK_WIDGET_HAS_POINTER (from)
- ? _gtk_widget_get_pointer_window (from) : from->window;
+ {
+ from_window = _gtk_widget_get_device_window (from, device);
+
+ if (!from_window)
+ from_window = from->window;
+ }
+
if (to != NULL)
- to_window = GTK_WIDGET_HAS_POINTER (to)
- ? _gtk_widget_get_pointer_window (to) : to->window;
+ {
+ to_window = _gtk_widget_get_device_window (to, device);
+
+ if (!to_window)
+ to_window = to->window;
+ }
if (from_window == NULL && to_window == NULL)
;
while (from_ancestor != NULL)
{
- from_ancestor = gdk_window_get_parent (from_ancestor);
+ from_ancestor = gdk_window_get_effective_parent (from_ancestor);
if (from_ancestor == NULL)
break;
from_ancestors = g_list_prepend (from_ancestors, from_ancestor);
}
synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
- mode, GDK_NOTIFY_ANCESTOR);
+ device, mode, GDK_NOTIFY_ANCESTOR);
for (list = g_list_last (from_ancestors); list; list = list->prev)
{
synth_crossing (NULL, GDK_LEAVE_NOTIFY, (GdkWindow *) list->data,
- mode, GDK_NOTIFY_VIRTUAL);
+ device, mode, GDK_NOTIFY_VIRTUAL);
}
/* XXX: enter/inferior on root window? */
while (to_ancestor != NULL)
{
- to_ancestor = gdk_window_get_parent (to_ancestor);
+ to_ancestor = gdk_window_get_effective_parent (to_ancestor);
if (to_ancestor == NULL)
break;
to_ancestors = g_list_prepend (to_ancestors, to_ancestor);
for (list = to_ancestors; list; list = list->next)
{
synth_crossing (NULL, GDK_ENTER_NOTIFY, (GdkWindow *) list->data,
- mode, GDK_NOTIFY_VIRTUAL);
+ device, mode, GDK_NOTIFY_VIRTUAL);
}
synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
- mode, GDK_NOTIFY_ANCESTOR);
+ device, mode, GDK_NOTIFY_ANCESTOR);
g_list_free (to_ancestors);
}
{
if (from_ancestor != NULL)
{
- from_ancestor = gdk_window_get_parent (from_ancestor);
+ from_ancestor = gdk_window_get_effective_parent (from_ancestor);
if (from_ancestor == to_window)
break;
if (from_ancestor)
}
if (to_ancestor != NULL)
{
- to_ancestor = gdk_window_get_parent (to_ancestor);
+ to_ancestor = gdk_window_get_effective_parent (to_ancestor);
if (to_ancestor == from_window)
break;
if (to_ancestor)
{
if (mode != GDK_CROSSING_GTK_UNGRAB)
synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
- mode, GDK_NOTIFY_INFERIOR);
+ device, mode, GDK_NOTIFY_INFERIOR);
for (list = to_ancestors; list; list = list->next)
synth_crossing (NULL, GDK_ENTER_NOTIFY, (GdkWindow *) list->data,
- mode, GDK_NOTIFY_VIRTUAL);
+ device, mode, GDK_NOTIFY_VIRTUAL);
synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
- mode, GDK_NOTIFY_ANCESTOR);
+ device, mode, GDK_NOTIFY_ANCESTOR);
}
else if (from_ancestor == to_window)
{
synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
- mode, GDK_NOTIFY_ANCESTOR);
+ device, mode, GDK_NOTIFY_ANCESTOR);
for (list = g_list_last (from_ancestors); list; list = list->prev)
{
synth_crossing (NULL, GDK_LEAVE_NOTIFY, (GdkWindow *) list->data,
- mode, GDK_NOTIFY_VIRTUAL);
+ device, mode, GDK_NOTIFY_VIRTUAL);
}
if (mode != GDK_CROSSING_GTK_GRAB)
synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
- mode, GDK_NOTIFY_INFERIOR);
+ device, mode, GDK_NOTIFY_INFERIOR);
}
else
{
}
synth_crossing (from, GDK_LEAVE_NOTIFY, from_window,
- mode, GDK_NOTIFY_NONLINEAR);
+ device, mode, GDK_NOTIFY_NONLINEAR);
for (list = g_list_last (from_ancestors); list; list = list->prev)
{
synth_crossing (NULL, GDK_LEAVE_NOTIFY, (GdkWindow *) list->data,
- mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
+ device, mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
}
for (list = to_ancestors; list; list = list->next)
{
synth_crossing (NULL, GDK_ENTER_NOTIFY, (GdkWindow *) list->data,
- mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
+ device, mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
}
synth_crossing (to, GDK_ENTER_NOTIFY, to_window,
- mode, GDK_NOTIFY_NONLINEAR);
+ device, mode, GDK_NOTIFY_NONLINEAR);
}
g_list_free (from_ancestors);
g_list_free (to_ancestors);
gtk_widget_propagate_state (GtkWidget *widget,
GtkStateData *data)
{
- guint8 old_state = GTK_WIDGET_STATE (widget);
- guint8 old_saved_state = GTK_WIDGET_SAVED_STATE (widget);
+ guint8 old_state = gtk_widget_get_state (widget);
+ guint8 old_saved_state = widget->saved_state;
/* don't call this function with state==GTK_STATE_INSENSITIVE,
* parent_sensitive==TRUE on a sensitive widget
if (data->parent_sensitive)
- GTK_WIDGET_SET_FLAGS (widget, GTK_PARENT_SENSITIVE);
+ GTK_OBJECT_FLAGS (widget) |= GTK_PARENT_SENSITIVE;
else
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_PARENT_SENSITIVE);
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_PARENT_SENSITIVE);
- if (GTK_WIDGET_IS_SENSITIVE (widget))
+ if (gtk_widget_is_sensitive (widget))
{
if (data->state_restoration)
- GTK_WIDGET_STATE (widget) = GTK_WIDGET_SAVED_STATE (widget);
+ widget->state = widget->saved_state;
else
- GTK_WIDGET_STATE (widget) = data->state;
+ widget->state = data->state;
}
else
{
if (!data->state_restoration)
{
if (data->state != GTK_STATE_INSENSITIVE)
- GTK_WIDGET_SAVED_STATE (widget) = data->state;
+ widget->saved_state = data->state;
}
- else if (GTK_WIDGET_STATE (widget) != GTK_STATE_INSENSITIVE)
- GTK_WIDGET_SAVED_STATE (widget) = GTK_WIDGET_STATE (widget);
- GTK_WIDGET_STATE (widget) = GTK_STATE_INSENSITIVE;
+ else if (gtk_widget_get_state (widget) != GTK_STATE_INSENSITIVE)
+ widget->saved_state = gtk_widget_get_state (widget);
+ widget->state = GTK_STATE_INSENSITIVE;
}
- if (gtk_widget_is_focus (widget) && !GTK_WIDGET_IS_SENSITIVE (widget))
+ if (gtk_widget_is_focus (widget) && !gtk_widget_is_sensitive (widget))
{
GtkWidget *window;
window = gtk_widget_get_toplevel (widget);
- if (window && GTK_WIDGET_TOPLEVEL (window))
+ if (window && gtk_widget_is_toplevel (window))
gtk_window_set_focus (GTK_WINDOW (window), NULL);
}
- if (old_state != GTK_WIDGET_STATE (widget) ||
- old_saved_state != GTK_WIDGET_SAVED_STATE (widget))
+ if (old_state != gtk_widget_get_state (widget) ||
+ old_saved_state != widget->saved_state)
{
g_object_ref (widget);
- if (!GTK_WIDGET_IS_SENSITIVE (widget) && GTK_WIDGET_HAS_GRAB (widget))
+ if (!gtk_widget_is_sensitive (widget) && gtk_widget_has_grab (widget))
gtk_grab_remove (widget);
g_signal_emit (widget, widget_signals[STATE_CHANGED], 0, old_state);
- if (GTK_WIDGET_HAS_POINTER (widget) && !GTK_WIDGET_SHADOWED (widget))
- {
- if (!GTK_WIDGET_IS_SENSITIVE (widget))
- _gtk_widget_synthesize_crossing (widget, NULL,
- GDK_CROSSING_STATE_CHANGED);
- else if (old_state == GTK_STATE_INSENSITIVE)
- _gtk_widget_synthesize_crossing (NULL, widget,
- GDK_CROSSING_STATE_CHANGED);
- }
+ if (!GTK_WIDGET_SHADOWED (widget))
+ {
+ GList *event_windows = NULL;
+ GList *devices, *d;
+
+ devices = _gtk_widget_list_devices (widget);
+
+ for (d = devices; d; d = d->next)
+ {
+ GdkWindow *window;
+ GdkDevice *device;
+
+ device = d->data;
+ window = _gtk_widget_get_device_window (widget, device);
+
+ /* Do not propagate more than once to the
+ * same window if non-multidevice aware.
+ */
+ if (!gdk_window_get_support_multidevice (window) &&
+ g_list_find (event_windows, window))
+ continue;
+
+ if (!gtk_widget_is_sensitive (widget))
+ _gtk_widget_synthesize_crossing (widget, NULL, d->data,
+ GDK_CROSSING_STATE_CHANGED);
+ else if (old_state == GTK_STATE_INSENSITIVE)
+ _gtk_widget_synthesize_crossing (NULL, widget, d->data,
+ GDK_CROSSING_STATE_CHANGED);
+
+ event_windows = g_list_prepend (event_windows, window);
+ }
+
+ g_list_free (event_windows);
+ g_list_free (devices);
+ }
if (GTK_IS_CONTAINER (widget))
{
- data->parent_sensitive = (GTK_WIDGET_IS_SENSITIVE (widget) != FALSE);
+ data->parent_sensitive = (gtk_widget_is_sensitive (widget) != FALSE);
if (data->use_forall)
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback) gtk_widget_propagate_state,
return aux_info;
}
+
/*****************************************
* gtk_widget_aux_info_destroy:
*
/**
* gtk_widget_shape_combine_mask:
* @widget: a #GtkWidget
- * @shape_mask: shape to be added, or %NULL to remove an existing shape
+ * @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
*
g_return_if_fail (GTK_IS_WIDGET (widget));
/* set_shape doesn't work on widgets without gdk window */
- g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
+ g_return_if_fail (gtk_widget_get_has_window (widget));
if (!shape_mask)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
/* set_shape doesn't work on widgets without gdk window */
- g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
+ g_return_if_fail (gtk_widget_get_has_window (widget));
if (!shape_mask)
{
gtk_widget_reset_shapes (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (GTK_WIDGET_REALIZED (widget));
+ g_return_if_fail (gtk_widget_get_realized (widget));
if (!GTK_WIDGET_HAS_SHAPE_MASK (widget))
gtk_reset_shapes_recurse (widget, widget->window);
}
-/**
- * gtk_widget_ref:
- * @widget: a #GtkWidget
- *
- * Adds a reference to a widget. This function is exactly the same
- * as calling g_object_ref(), and exists mostly for historical
- * reasons. It can still be convenient to avoid casting a widget
- * to a #GObject, it saves a small amount of typing.
- *
- * Return value: the widget that was referenced
- *
- * Deprecated: 2.12: Use g_object_ref() instead.
- **/
-GtkWidget*
-gtk_widget_ref (GtkWidget *widget)
-{
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
- return (GtkWidget*) g_object_ref ((GObject*) widget);
-}
-
-/**
- * gtk_widget_unref:
- * @widget: a #GtkWidget
- *
- * Inverse of gtk_widget_ref(). Equivalent to g_object_unref().
- *
- * Deprecated: 2.12: Use g_object_unref() instead.
- **/
-void
-gtk_widget_unref (GtkWidget *widget)
-{
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- g_object_unref ((GObject*) widget);
-}
-
static void
expose_window (GdkWindow *window)
{
gdk_window_get_user_data (window, &user_data);
if (user_data)
- is_double_buffered = GTK_WIDGET_DOUBLE_BUFFERED (GTK_WIDGET (user_data));
+ is_double_buffered = gtk_widget_get_double_buffered (GTK_WIDGET (user_data));
else
is_double_buffered = FALSE;
gdk_drawable_get_size (GDK_DRAWABLE (window),
&event.expose.area.width,
&event.expose.area.height);
- event.expose.region = gdk_region_rectangle (&event.expose.area);
+ event.expose.region = cairo_region_create_rectangle (&event.expose.area);
/* If this is not double buffered, force a double buffer so that
redirection works. */
/**
* gtk_widget_get_snapshot:
* @widget: a #GtkWidget
- * @clip_rect: a #GdkRectangle or %NULL
+ * @clip_rect: (allow-none): a #GdkRectangle or %NULL
*
* Create a #GdkPixmap of the contents of the widget and its children.
*
GList *windows = NULL, *list;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- if (!GTK_WIDGET_VISIBLE (widget))
+ if (!gtk_widget_get_visible (widget))
return NULL;
/* the widget (and parent_window) must be realized to be drawable */
- if (widget->parent && !GTK_WIDGET_REALIZED (widget->parent))
+ if (widget->parent && !gtk_widget_get_realized (widget->parent))
gtk_widget_realize (widget->parent);
- if (!GTK_WIDGET_REALIZED (widget))
+ if (!gtk_widget_get_realized (widget))
gtk_widget_realize (widget);
/* determine snapshot rectangle */
width = widget->allocation.width;
height = widget->allocation.height;
- if (widget->parent && !GTK_WIDGET_NO_WINDOW (widget))
+ if (widget->parent && gtk_widget_get_has_window (widget))
{
/* grow snapshot rectangle to cover all widget windows */
parent_window = gtk_widget_get_parent_window (widget);
* gtk_widget_class_find_style_property:
* @klass: a #GtkWidgetClass
* @property_name: the name of the style property to find
- * @returns: the #GParamSpec of the style property or %NULL if @class has no
+ * @returns: (allow-none): the #GParamSpec of the style property or %NULL if @class has no
* style property with that name.
*
* Finds a style property of a widget class by name.
* gtk_widget_class_path:
* @widget: a #GtkWidget
* @path_length: (out) (allow-none): location to store the length of the class path, or %NULL
- * @path: (out) (allow-none) location to store the class path as an allocated string, or %NULL
- * @path_reversed: (out) (allow-none) location to store the reverse class path as an allocated
+ * @path: (out) (allow-none): location to store the class path as an allocated string, or %NULL
+ * @path_reversed: (out) (allow-none): location to store the reverse class path as an allocated
* string, or %NULL
*
* Same as gtk_widget_path(), but always uses the name of a widget's type,
gchar *d;
guint l;
- string = g_type_name (GTK_WIDGET_TYPE (widget));
+ string = g_type_name (G_OBJECT_TYPE (widget));
l = strlen (string);
while (tmp_path_len <= len + l + 1)
{
}
}
+/**
+ * gtk_requisition_new:
+ *
+ * Allocates a new #GtkRequisition structure and initializes its elements to zero.
+ *
+ * Returns: a new empty #GtkRequisition. The newly allocated #GtkRequisition should
+ * be freed with gtk_requisition_free().
+ *
+ * Since: 3.0
+ */
+GtkRequisition *
+gtk_requisition_new (void)
+{
+ return g_slice_new0 (GtkRequisition);
+}
+
/**
* gtk_requisition_copy:
* @requisition: a #GtkRequisition
GtkRequisition *
gtk_requisition_copy (const GtkRequisition *requisition)
{
- return (GtkRequisition *)g_memdup (requisition, sizeof (GtkRequisition));
+ return g_slice_dup (GtkRequisition, requisition);
}
/**
void
gtk_requisition_free (GtkRequisition *requisition)
{
- g_free (requisition);
+ g_slice_free (GtkRequisition, requisition);
}
-GType
-gtk_requisition_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static (I_("GtkRequisition"),
- (GBoxedCopyFunc) gtk_requisition_copy,
- (GBoxedFreeFunc) gtk_requisition_free);
-
- return our_type;
-}
+G_DEFINE_BOXED_TYPE (GtkRequisition, gtk_requisition,
+ gtk_requisition_copy,
+ gtk_requisition_free)
/**
* gtk_widget_get_accessible:
* @widget: a #GtkWidget
*
* Returns the accessible object that describes the widget to an
- * assistive technology.
- *
- * If no accessibility library is loaded (i.e. no ATK implementation library is
- * loaded via <envar>GTK_MODULES</envar> or via another application library,
- * such as libgnome), then this #AtkObject instance may be a no-op. Likewise,
- * if no class-specific #AtkObject implementation is available for the widget
- * instance in question, it will inherit an #AtkObject implementation from the
+ * assistive technology.
+ *
+ * If no accessibility library is loaded (i.e. no ATK implementation library is
+ * loaded via <envar>GTK_MODULES</envar> or via another application library,
+ * such as libgnome), then this #AtkObject instance may be a no-op. Likewise,
+ * if no class-specific #AtkObject implementation is available for the widget
+ * instance in question, it will inherit an #AtkObject implementation from the
* first ancestor class for which such an implementation is defined.
*
* The documentation of the <ulink url="http://developer.gnome.org/doc/API/2.0/atk/index.html">ATK</ulink>
}
/*
- * GtkExtendedLayout implementation
+ * GtkSizeRequest implementation
*/
static void
-gtk_widget_real_get_desired_size (GtkExtendedLayout *layout,
- GtkRequisition *minimum_size,
- GtkRequisition *natural_size)
+gtk_widget_real_get_width (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- GtkWidget *widget = GTK_WIDGET (layout);
- GtkRequisition requisition = widget->requisition;
+ /* Set the initial values so that unimplemented classes will fall back
+ * on the "size-request" collected values (see gtksizegroup.c:do_size_request()).
+ */
+ if (minimum_size)
+ *minimum_size = GTK_WIDGET (widget)->requisition.width;
- g_signal_emit (widget, widget_signals[SIZE_REQUEST], 0, &requisition);
+ if (natural_size)
+ *natural_size = GTK_WIDGET (widget)->requisition.width;
+}
+static void
+gtk_widget_real_get_height (GtkSizeRequest *widget,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ /* Set the initial values so that unimplemented classes will fall back
+ * on the "size-request" collected values (see gtksizegroup.c:do_size_request()).
+ */
if (minimum_size)
- *minimum_size = requisition;
+ *minimum_size = GTK_WIDGET (widget)->requisition.height;
+
if (natural_size)
- *natural_size = requisition;
+ *natural_size = GTK_WIDGET (widget)->requisition.height;
}
static void
-gtk_widget_real_get_height_for_width (GtkExtendedLayout *layout,
+gtk_widget_real_get_height_for_width (GtkSizeRequest *layout,
gint width,
gint *minimum_height,
gint *natural_height)
{
- GtkRequisition minimum_size;
- GtkRequisition natural_size;
-
- g_return_if_fail (GTK_IS_WIDGET (layout));
-
-#if 0
- TODO: integrate height-for-width with size-groups
-#else
- gtk_widget_get_desired_size (GTK_WIDGET(layout),
- minimum_height ? &minimum_size : NULL,
- natural_height ? &natural_size : NULL);
-
- if (minimum_height)
- *minimum_height = minimum_size.height;
- if (natural_height)
- *natural_height = natural_size.height;
-#endif
+ gtk_size_request_get_height (layout, minimum_height, natural_height);
}
static void
-gtk_widget_real_get_width_for_height (GtkExtendedLayout *layout,
+gtk_widget_real_get_width_for_height (GtkSizeRequest *layout,
gint height,
gint *minimum_width,
gint *natural_width)
-{
- GtkRequisition minimum_size;
- GtkRequisition natural_size;
-
- g_return_if_fail (GTK_IS_WIDGET (layout));
-
-#if 0
- TODO: integrate width-for-height with size-groups
-#else
- gtk_widget_get_desired_size (GTK_WIDGET(layout),
- minimum_width ? &minimum_size : NULL,
- natural_width ? &natural_size : NULL);
-
- if (minimum_width)
- *minimum_width = minimum_size.width;
- if (natural_width)
- *natural_width = natural_size.width;
-#endif
-}
-
-/**
- * gtk_widget_get_desired_size:
- * @widget: a #GtkWidget
- * @minimum_size: location for storing the @widget's minimum size, or %NULL
- * @natural_size: location for storing the @widget's preferred size, or %NULL
- *
- * Retreives a widget's desired size, considering restrictions imposed by
- * #GtkSizeGroup<!-- -->s. See also: gtk_extended_layout_get_desired_size().
- *
- * Since: 2.20
- */
-void
-gtk_widget_get_desired_size (GtkWidget *widget,
- GtkRequisition *minimum_size,
- GtkRequisition *natural_size)
-{
- g_return_if_fail (GTK_IS_WIDGET (widget));
- _gtk_size_group_compute_desired_size (widget, minimum_size, natural_size);
+{
+ gtk_size_request_get_width (layout, minimum_width, natural_width);
}
static void
-gtk_widget_layout_interface_init (GtkExtendedLayoutIface *iface)
+gtk_widget_size_request_init (GtkSizeRequestIface *iface)
{
- iface->get_desired_size = gtk_widget_real_get_desired_size;
+ 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), NULL);
g_return_val_if_fail (gtk_widget_has_screen (widget), NULL);
-
+
return gtk_clipboard_get_for_display (gtk_widget_get_display (widget),
selection);
}
/**
* gtk_widget_list_mnemonic_labels:
* @widget: a #GtkWidget
- *
- * Returns a newly allocated list of the widgets, normally labels, for
- * which this widget is a the target of a mnemonic (see for example,
+ *
+ * Returns a newly allocated list of the widgets, normally labels, for
+ * which this widget is the target of a mnemonic (see for example,
* gtk_label_set_mnemonic_widget()).
* The widgets in the list are not individually referenced. If you
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return (GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0;
+ return (GTK_OBJECT_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0;
}
/**
no_show_all = (no_show_all != FALSE);
- if (no_show_all == ((GTK_WIDGET_FLAGS (widget) & GTK_NO_SHOW_ALL) != 0))
+ if (no_show_all == gtk_widget_get_no_show_all (widget))
return;
if (no_show_all)
- GTK_WIDGET_SET_FLAGS (widget, GTK_NO_SHOW_ALL);
+ GTK_OBJECT_FLAGS (widget) |= GTK_NO_SHOW_ALL;
else
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_NO_SHOW_ALL);
+ GTK_OBJECT_FLAGS (widget) &= ~(GTK_NO_SHOW_ALL);
g_object_notify (G_OBJECT (widget), "no-show-all");
}
if (priv_has_tooltip)
{
- if (GTK_WIDGET_REALIZED (widget) && GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_realized (widget) && !gtk_widget_get_has_window (widget))
gdk_window_set_events (widget->window,
gdk_window_get_events (widget->window) |
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
- if (!GTK_WIDGET_NO_WINDOW (widget))
+ if (gtk_widget_get_has_window (widget))
gtk_widget_add_events (widget,
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK |
/**
* gtk_widget_set_tooltip_window:
* @widget: a #GtkWidget
- * @custom_window: a #GtkWindow, or %NULL
+ * @custom_window: (allow-none): a #GtkWindow, or %NULL
*
* Replaces the default, usually yellow, window used for displaying
* tooltips with @custom_window. GTK+ will take care of showing and
has_tooltip = (custom_window != NULL || tooltip_markup != NULL);
gtk_widget_real_set_has_tooltip (widget, has_tooltip, FALSE);
- if (has_tooltip && GTK_WIDGET_VISIBLE (widget))
+ if (has_tooltip && gtk_widget_get_visible (widget))
gtk_widget_queue_tooltip_query (widget);
}
/**
* gtk_widget_set_tooltip_markup:
* @widget: a #GtkWidget
- * @markup: the contents of the tooltip for @widget, or %NULL
+ * @markup: (allow-none): the contents of the tooltip for @widget, or %NULL
*
* Sets @markup as the contents of the tooltip, which is marked up with
* the <link linkend="PangoMarkupFormat">Pango text markup language</link>.
widget->allocation = *allocation;
}
+/**
+ * gtk_widget_get_requisition:
+ * @widget: a #GtkWidget
+ * @requisition: (out): a pointer to a #GtkRequisition to copy to
+ *
+ * Retrieves the widget's requisition.
+ *
+ * This function should only be used by widget implementations in
+ * order to figure whether the widget's requisition has actually
+ * changed after some internal state change (so that they can call
+ * gtk_widget_queue_resize() instead of gtk_widget_queue_draw()).
+ *
+ * Normally, gtk_widget_size_request() should be used.
+ *
+ * Since: 2.20
+ */
+void
+gtk_widget_get_requisition (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (requisition != NULL);
+
+ *requisition = widget->requisition;
+}
+
/**
* gtk_widget_set_window:
* @widget: a #GtkWidget
*
* Returns the widget's window if it is realized, %NULL otherwise
*
- * Return value: @widget's window.
+ * Return value: (transfer none): @widget's window.
*
* Since: 2.14
*/
return widget->window;
}
-#define __GTK_WIDGET_C__
-#include "gtkaliasdef.c"
+/**
+ * gtk_widget_get_support_multidevice:
+ * @widget: a #GtkWidget
+ *
+ * Returns %TRUE if @widget is multiple pointer aware. See
+ * gtk_widget_set_support_multidevice() for more information.
+ *
+ * Returns: %TRUE is @widget is multidevice aware.
+ **/
+gboolean
+gtk_widget_get_support_multidevice (GtkWidget *widget)
+{
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ return GTK_WIDGET_FLAGS (widget) & GTK_MULTIDEVICE;
+}
+
+/**
+ * gtk_widget_set_support_multidevice:
+ * @widget: a #GtkWidget
+ * @support_multidevice: %TRUE to support input from multiple devices.
+ *
+ * Enables or disables multiple pointer awareness. If this setting is %TRUE,
+ * @widget will start receiving multiple, per device enter/leave events. Note
+ * that if custom #GdkWindow<!-- -->s are created in #GtkWidget::realize,
+ * gdk_window_set_support_multidevice() will have to be called manually on them.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_widget_set_support_multidevice (GtkWidget *widget,
+ gboolean support_multidevice)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ if (support_multidevice)
+ {
+ GTK_WIDGET_SET_FLAGS (widget, GTK_MULTIDEVICE);
+ gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_ALL);
+ }
+ else
+ {
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_MULTIDEVICE);
+ gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_NONE);
+ }
+
+ if (gtk_widget_get_realized (widget))
+ gdk_window_set_support_multidevice (widget->window, support_multidevice);
+}
+
+static void
+_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);
+}
+
+/**
+ * gtk_widget_send_focus_change:
+ * @widget: a #GtkWidget
+ * @event: a #GdkEvent of type GDK_FOCUS_CHANGE
+ *
+ * Sends the focus change @event to @widget
+ *
+ * This function is not meant to be used by applications. The only time it
+ * should be used is when it is necessary for a #GtkWidget to assign focus
+ * to a widget that is semantically owned by the first widget even though
+ * it's not a direct child - for instance, a search entry in a floating
+ * window similar to the quick search in #GtkTreeView.
+ *
+ * An example of its usage is:
+ *
+ * |[
+ * GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE);
+ *
+ * fevent->focus_change.type = GDK_FOCUS_CHANGE;
+ * fevent->focus_change.in = TRUE;
+ * fevent->focus_change.window = gtk_widget_get_window (widget);
+ * if (fevent->focus_change.window != NULL)
+ * g_object_ref (fevent->focus_change.window);
+ *
+ * gtk_widget_send_focus_change (widget, fevent);
+ *
+ * gdk_event_free (event);
+ * ]|
+ *
+ * Return value: the return value from the event signal emission: %TRUE
+ * if the event was handled, and %FALSE otherwise
+ *
+ * Since: 2.20
+ */
+gboolean
+gtk_widget_send_focus_change (GtkWidget *widget,
+ GdkEvent *event)
+{
+ gboolean res;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (event != NULL && event->type == GDK_FOCUS_CHANGE, FALSE);
+
+ g_object_ref (widget);
+
+ _gtk_widget_set_has_focus (widget, event->focus_change.in);
+
+ res = gtk_widget_event (widget, event);
+
+ g_object_notify (G_OBJECT (widget), "has-focus");
+
+ g_object_unref (widget);
+
+ return res;
+}