* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+#include <config.h>
#include <stdarg.h>
#include <string.h>
#include <locale.h>
#include "gtkaccessible.h"
#include "gtktooltips.h"
#include "gtkinvisible.h"
+#include "gtkalias.h"
#define WIDGET_CLASS(w) GTK_WIDGET_GET_CLASS (w)
#define INIT_PATH_SIZE (512)
ACCEL_CLOSURES_CHANGED,
SCREEN_CHANGED,
CAN_ACTIVATE_ACCEL,
+ GRAB_BROKEN,
+ COMPOSITED_CHANGED,
LAST_SIGNAL
};
/* --- prototypes --- */
-static void gtk_widget_class_init (GtkWidgetClass *klass);
-static void gtk_widget_init (GtkWidget *widget);
+static void gtk_widget_class_init (GtkWidgetClass *klass);
+static void gtk_widget_base_class_finalize (GtkWidgetClass *klass);
+static void gtk_widget_init (GtkWidget *widget);
static void gtk_widget_set_property (GObject *object,
guint prop_id,
const GValue *value,
static gboolean gtk_widget_real_focus (GtkWidget *widget,
GtkDirectionType direction);
static PangoContext* gtk_widget_peek_pango_context (GtkWidget *widget);
+static void gtk_widget_update_pango_context (GtkWidget *widget);
static void gtk_widget_propagate_state (GtkWidget *widget,
GtkStateData *data);
static void gtk_widget_reset_rc_style (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);
/* --- variables --- */
-static gpointer parent_class = NULL;
+static gpointer gtk_widget_parent_class = NULL;
static guint widget_signals[LAST_SIGNAL] = { 0 };
-static GMemChunk *aux_info_mem_chunk = NULL;
static GtkStyle *gtk_default_style = NULL;
static GSList *colormap_stack = NULL;
static guint composite_child_stack = 0;
static GQuark quark_extension_event_mode = 0;
static GQuark quark_parent_window = 0;
static GQuark quark_shape_info = 0;
+static GQuark quark_input_shape_info = 0;
static GQuark quark_colormap = 0;
static GQuark quark_pango_context = 0;
static GQuark quark_rc_style = 0;
static GQuark quark_accessible_object = 0;
+static GQuark quark_mnemonic_labels = 0;
GParamSpecPool *_gtk_widget_child_property_pool = NULL;
GObjectNotifyContext *_gtk_widget_child_property_notify_context = NULL;
gtk_widget_get_type (void)
{
static GType widget_type = 0;
-
- if (!widget_type)
+
+ if (G_UNLIKELY (widget_type == 0))
{
- static const GTypeInfo widget_info =
+ const GTypeInfo widget_info =
{
sizeof (GtkWidgetClass),
NULL, /* base_init */
- NULL, /* base_finalize */
+ (GBaseFinalizeFunc) gtk_widget_base_class_finalize,
(GClassInitFunc) gtk_widget_class_init,
NULL, /* class_finalize */
NULL, /* class_init */
(GInstanceInitFunc) gtk_widget_init,
NULL, /* value_table */
};
-
- static const GInterfaceInfo accessibility_info =
+
+ const GInterfaceInfo accessibility_info =
{
- (GInterfaceInitFunc) gtk_widget_accessible_interface_init,
- (GInterfaceFinalizeFunc) NULL,
- NULL /* interface data */
+ (GInterfaceInitFunc) gtk_widget_accessible_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL /* interface data */
};
- widget_type = g_type_register_static (GTK_TYPE_OBJECT, "GtkWidget",
- &widget_info, G_TYPE_FLAG_ABSTRACT);
+ widget_type = g_type_register_static (GTK_TYPE_OBJECT, "GtkWidget",
+ &widget_info, G_TYPE_FLAG_ABSTRACT);
g_type_add_interface_static (widget_type, ATK_TYPE_IMPLEMENTOR,
&accessibility_info) ;
}
-
+
return widget_type;
}
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkBindingSet *binding_set;
-
- parent_class = g_type_class_peek_parent (klass);
+
+ gtk_widget_parent_class = g_type_class_peek_parent (klass);
quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser");
quark_aux_info = g_quark_from_static_string ("gtk-aux-info");
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_shape_info = g_quark_from_static_string ("gtk-shape-info");
+ quark_input_shape_info = g_quark_from_static_string ("gtk-input-shape-info");
quark_colormap = g_quark_from_static_string ("gtk-colormap");
quark_pango_context = g_quark_from_static_string ("gtk-pango-context");
quark_rc_style = g_quark_from_static_string ("gtk-rc-style");
quark_accessible_object = g_quark_from_static_string ("gtk-accessible-object");
+ quark_mnemonic_labels = g_quark_from_static_string ("gtk-mnemonic-labels");
style_property_spec_pool = g_param_spec_pool_new (FALSE);
_gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE);
klass->drag_data_received = NULL;
klass->screen_changed = NULL;
klass->can_activate_accel = gtk_widget_real_can_activate_accel;
+ klass->grab_broken_event = NULL;
klass->show_help = gtk_widget_real_show_help;
P_("Widget name"),
P_("The name of the widget"),
NULL,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_PARENT,
g_param_spec_object ("parent",
P_("Parent widget"),
P_("The parent widget of this widget. Must be a Container widget"),
GTK_TYPE_CONTAINER,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_WIDTH_REQUEST,
- g_param_spec_int ("width_request",
+ g_param_spec_int ("width-request",
P_("Width request"),
P_("Override for width request of the widget, or -1 if natural request should be used"),
-1,
G_MAXINT,
-1,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_HEIGHT_REQUEST,
- g_param_spec_int ("height_request",
+ g_param_spec_int ("height-request",
P_("Height request"),
P_("Override for height request of the widget, or -1 if natural request should be used"),
-1,
G_MAXINT,
-1,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_VISIBLE,
g_param_spec_boolean ("visible",
P_("Visible"),
P_("Whether the widget is visible"),
FALSE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_SENSITIVE,
g_param_spec_boolean ("sensitive",
P_("Sensitive"),
P_("Whether the widget responds to input"),
TRUE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_APP_PAINTABLE,
- g_param_spec_boolean ("app_paintable",
+ g_param_spec_boolean ("app-paintable",
P_("Application paintable"),
P_("Whether the application will paint directly on the widget"),
FALSE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_CAN_FOCUS,
- g_param_spec_boolean ("can_focus",
+ g_param_spec_boolean ("can-focus",
P_("Can focus"),
P_("Whether the widget can accept the input focus"),
FALSE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_HAS_FOCUS,
- g_param_spec_boolean ("has_focus",
+ g_param_spec_boolean ("has-focus",
P_("Has focus"),
P_("Whether the widget has the input focus"),
FALSE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_IS_FOCUS,
- g_param_spec_boolean ("is_focus",
+ g_param_spec_boolean ("is-focus",
P_("Is focus"),
P_("Whether the widget is the focus widget within the toplevel"),
FALSE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_CAN_DEFAULT,
- g_param_spec_boolean ("can_default",
+ g_param_spec_boolean ("can-default",
P_("Can default"),
P_("Whether the widget can be the default widget"),
FALSE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_HAS_DEFAULT,
- g_param_spec_boolean ("has_default",
+ g_param_spec_boolean ("has-default",
P_("Has default"),
P_("Whether the widget is the default widget"),
FALSE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_RECEIVES_DEFAULT,
- g_param_spec_boolean ("receives_default",
+ g_param_spec_boolean ("receives-default",
P_("Receives default"),
P_("If TRUE, the widget will receive the default action when it is focused"),
FALSE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_COMPOSITE_CHILD,
- g_param_spec_boolean ("composite_child",
+ g_param_spec_boolean ("composite-child",
P_("Composite child"),
P_("Whether the widget is part of a composite widget"),
FALSE,
- G_PARAM_READABLE));
+ GTK_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_STYLE,
g_param_spec_object ("style",
P_("Style"),
P_("The style of the widget, which contains information about how it will look (colors etc)"),
GTK_TYPE_STYLE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_EVENTS,
g_param_spec_flags ("events",
P_("The event mask that decides what kind of GdkEvents this widget gets"),
GDK_TYPE_EVENT_MASK,
GDK_STRUCTURE_MASK,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_EXTENSION_EVENTS,
- g_param_spec_enum ("extension_events",
+ g_param_spec_enum ("extension-events",
P_("Extension events"),
P_("The mask that decides what kind of extension events this widget gets"),
GDK_TYPE_EXTENSION_MODE,
GDK_EXTENSION_EVENTS_NONE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_NO_SHOW_ALL,
- g_param_spec_boolean ("no_show_all",
+ g_param_spec_boolean ("no-show-all",
P_("No show all"),
P_("Whether gtk_widget_show_all() should not affect this widget"),
FALSE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
widget_signals[SHOW] =
- g_signal_new ("show",
+ g_signal_new (I_("show"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, show),
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
widget_signals[HIDE] =
- g_signal_new ("hide",
+ g_signal_new (I_("hide"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, hide),
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
widget_signals[MAP] =
- g_signal_new ("map",
+ g_signal_new (I_("map"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, map),
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
widget_signals[UNMAP] =
- g_signal_new ("unmap",
+ g_signal_new (I_("unmap"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, unmap),
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
widget_signals[REALIZE] =
- g_signal_new ("realize",
+ g_signal_new (I_("realize"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, realize),
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
widget_signals[UNREALIZE] =
- g_signal_new ("unrealize",
+ g_signal_new (I_("unrealize"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, unrealize),
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
widget_signals[SIZE_REQUEST] =
- g_signal_new ("size_request",
+ g_signal_new (I_("size_request"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, size_request),
G_TYPE_NONE, 1,
GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[SIZE_ALLOCATE] =
- g_signal_new ("size_allocate",
+ g_signal_new (I_("size_allocate"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, size_allocate),
G_TYPE_NONE, 1,
GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[STATE_CHANGED] =
- g_signal_new ("state_changed",
+ g_signal_new (I_("state_changed"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, state_changed),
G_TYPE_NONE, 1,
GTK_TYPE_STATE_TYPE);
widget_signals[PARENT_SET] =
- g_signal_new ("parent_set",
+ g_signal_new (I_("parent_set"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, parent_set),
G_TYPE_NONE, 1,
GTK_TYPE_WIDGET);
widget_signals[HIERARCHY_CHANGED] =
- g_signal_new ("hierarchy_changed",
+ g_signal_new (I_("hierarchy_changed"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, hierarchy_changed),
_gtk_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GTK_TYPE_WIDGET);
+ /**
+ * GtkWidget::style-set:
+ * @widget: the object on which the signal is emitted
+ * @previous_style: 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
+ * on a widget. Note that style-modifying functions like
+ * gtk_widget_modify_base() also cause this signal to be emitted.
+ */
widget_signals[STYLE_SET] =
- g_signal_new ("style_set",
+ g_signal_new (I_("style_set"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, style_set),
G_TYPE_NONE, 1,
GTK_TYPE_STYLE);
widget_signals[DIRECTION_CHANGED] =
- g_signal_new ("direction_changed",
+ g_signal_new (I_("direction_changed"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, direction_changed),
_gtk_marshal_VOID__ENUM,
G_TYPE_NONE, 1,
GTK_TYPE_TEXT_DIRECTION);
+
+ /**
+ * GtkWidget::grab-notify:
+ * @widget: the object which received the signal
+ * @was_grabbed: %FALSE if the widget becomes shadowed, %TRUE
+ * if it becomes unshadowed
+ *
+ * The ::grab-notify signal is emitted when a widget becomes
+ * shadowed by a GTK+ grab (not a pointer or keyboard grab) on
+ * another widget, or when it becomes unshadowed due to a grab
+ * being removed.
+ *
+ * A widget is shadowed by a gtk_grab_add() when the topmost
+ * grab widget in the grab stack of its window group is not
+ * its ancestor.
+ */
widget_signals[GRAB_NOTIFY] =
- g_signal_new ("grab_notify",
+ g_signal_new (I_("grab_notify"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, grab_notify),
* changed on an object. The signal's detail holds the property name.
*/
widget_signals[CHILD_NOTIFY] =
- g_signal_new ("child_notify",
+ g_signal_new (I_("child_notify"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS,
G_STRUCT_OFFSET (GtkWidgetClass, child_notify),
G_TYPE_NONE, 1,
G_TYPE_PARAM);
widget_signals[MNEMONIC_ACTIVATE] =
- g_signal_new ("mnemonic_activate",
+ g_signal_new (I_("mnemonic_activate"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, mnemonic_activate),
G_TYPE_BOOLEAN, 1,
G_TYPE_BOOLEAN);
widget_signals[GRAB_FOCUS] =
- g_signal_new ("grab_focus",
+ g_signal_new (I_("grab_focus"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkWidgetClass, grab_focus),
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
widget_signals[FOCUS] =
- g_signal_new ("focus",
+ g_signal_new (I_("focus"),
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, focus),
G_TYPE_BOOLEAN, 1,
GTK_TYPE_DIRECTION_TYPE);
widget_signals[EVENT] =
- g_signal_new ("event",
+ g_signal_new (I_("event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[EVENT_AFTER] =
- g_signal_new ("event-after",
+ g_signal_new (I_("event-after"),
G_TYPE_FROM_CLASS (gobject_class),
0,
0,
G_TYPE_NONE, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[BUTTON_PRESS_EVENT] =
- g_signal_new ("button_press_event",
+ g_signal_new (I_("button_press_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, button_press_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[BUTTON_RELEASE_EVENT] =
- g_signal_new ("button_release_event",
+ g_signal_new (I_("button_release_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, button_release_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[SCROLL_EVENT] =
- g_signal_new ("scroll_event",
+ g_signal_new (I_("scroll_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, scroll_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[MOTION_NOTIFY_EVENT] =
- g_signal_new ("motion_notify_event",
+ g_signal_new (I_("motion_notify_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, motion_notify_event),
_gtk_marshal_BOOLEAN__BOXED,
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+ widget_signals[COMPOSITED_CHANGED] =
+ g_signal_new (I_("composited_changed"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtkWidgetClass, composited_changed),
+ NULL, NULL,
+ _gtk_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+/**
+ * GtkWidget::delete-event:
+ * @widget: the object which received the signal.
+ * @event: the event which triggered this signal
+ *
+ * The ::delete-event signal is emitted if a user requests that
+ * a toplevel window is closed. The default handler for this signal
+ * destroys the window. Connecting gtk_widget_hide_on_delete() to
+ * this signal will cause the window to be hidden instead, so that
+ * it can later be shown again without reconstructing it.
+ *
+ * Returns: %TRUE to stop other handlers from being invoked for the event.
+ * %FALSE to propagate the event further.
+ */
widget_signals[DELETE_EVENT] =
- g_signal_new ("delete_event",
+ g_signal_new (I_("delete_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, delete_event),
_gtk_marshal_BOOLEAN__BOXED,
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+/**
+ * GtkWidget::destroy-event:
+ * @widget: the object which received the signal.
+ * @event: the event which triggered this signal
+ *
+ * The ::destroy-event signal is emitted when a #GdkWindow is destroyed.
+ * You rarely get this signal, because most widgets disconnect themselves
+ * from their window before they destroy it, so no widget owns the
+ * window at destroy time.
+ *
+ * Returns: %TRUE to stop other handlers from being invoked for the event.
+ * %FALSE to propagate the event further.
+ */
widget_signals[DESTROY_EVENT] =
- g_signal_new ("destroy_event",
+ g_signal_new (I_("destroy_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, destroy_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[EXPOSE_EVENT] =
- g_signal_new ("expose_event",
+ g_signal_new (I_("expose_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, expose_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[KEY_PRESS_EVENT] =
- g_signal_new ("key_press_event",
+ g_signal_new (I_("key_press_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, key_press_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[KEY_RELEASE_EVENT] =
- g_signal_new ("key_release_event",
+ g_signal_new (I_("key_release_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, key_release_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[ENTER_NOTIFY_EVENT] =
- g_signal_new ("enter_notify_event",
+ g_signal_new (I_("enter_notify_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, enter_notify_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[LEAVE_NOTIFY_EVENT] =
- g_signal_new ("leave_notify_event",
+ g_signal_new (I_("leave_notify_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, leave_notify_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[CONFIGURE_EVENT] =
- g_signal_new ("configure_event",
+ g_signal_new (I_("configure_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, configure_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[FOCUS_IN_EVENT] =
- g_signal_new ("focus_in_event",
+ g_signal_new (I_("focus_in_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, focus_in_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[FOCUS_OUT_EVENT] =
- g_signal_new ("focus_out_event",
+ g_signal_new (I_("focus_out_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, focus_out_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[MAP_EVENT] =
- g_signal_new ("map_event",
+ g_signal_new (I_("map_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, map_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[UNMAP_EVENT] =
- g_signal_new ("unmap_event",
+ g_signal_new (I_("unmap_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, unmap_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[PROPERTY_NOTIFY_EVENT] =
- g_signal_new ("property_notify_event",
+ g_signal_new (I_("property_notify_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, property_notify_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[SELECTION_CLEAR_EVENT] =
- g_signal_new ("selection_clear_event",
+ g_signal_new (I_("selection_clear_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, selection_clear_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[SELECTION_REQUEST_EVENT] =
- g_signal_new ("selection_request_event",
+ g_signal_new (I_("selection_request_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, selection_request_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[SELECTION_NOTIFY_EVENT] =
- g_signal_new ("selection_notify_event",
+ g_signal_new (I_("selection_notify_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, selection_notify_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[SELECTION_RECEIVED] =
- g_signal_new ("selection_received",
+ g_signal_new (I_("selection_received"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, selection_received),
GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
G_TYPE_UINT);
widget_signals[SELECTION_GET] =
- g_signal_new ("selection_get",
+ g_signal_new (I_("selection_get"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, selection_get),
G_TYPE_UINT,
G_TYPE_UINT);
widget_signals[PROXIMITY_IN_EVENT] =
- g_signal_new ("proximity_in_event",
+ g_signal_new (I_("proximity_in_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, proximity_in_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[PROXIMITY_OUT_EVENT] =
- g_signal_new ("proximity_out_event",
+ g_signal_new (I_("proximity_out_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, proximity_out_event),
* @drag_context: the drag context
* @time: the timestamp of the motion event
*
- * The ::drag-leave signal is emitted on the drop site when the cursor leaves the widget.
- * A typical reason to connect to this signal is to undo things done in ::drag-motion, e.g.
- * undo highlighting with gtk_drag_unhighlight()
+ * The ::drag-leave signal is emitted on the drop site when the cursor
+ * leaves the widget. A typical reason to connect to this signal is to
+ * undo things done in ::drag-motion, e.g. undo highlighting with
+ * gtk_drag_unhighlight()
*/
widget_signals[DRAG_LEAVE] =
- g_signal_new ("drag_leave",
+ g_signal_new (I_("drag_leave"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_leave),
* gtk_drag_source_set_icon().
*/
widget_signals[DRAG_BEGIN] =
- g_signal_new ("drag_begin",
+ g_signal_new (I_("drag_begin"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_begin),
* A typical reason to connect to this signal is to undo things done in ::drag-begin.
*/
widget_signals[DRAG_END] =
- g_signal_new ("drag_end",
+ g_signal_new (I_("drag_end"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_end),
* @widget: the object which received the signal.
* @drag_context: the drag context
*
- * The ::drag-data-delete signal is emitted on the drag source when a drag with the action
- * %GDK_ACTION_MOVE is successfully completed. The signal handler is responsible for deleting
- * the data that has been dropped. What "delete" means, depends on the context of the drag
- * operation.
+ * The ::drag-data-delete signal is emitted on the drag source when a drag
+ * with the action %GDK_ACTION_MOVE is successfully completed. The signal
+ * handler is responsible for deleting the data that has been dropped. What
+ * "delete" means, depends on the context of the drag operation.
*/
widget_signals[DRAG_DATA_DELETE] =
- g_signal_new ("drag_data_delete",
+ g_signal_new (I_("drag_data_delete"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_data_delete),
* @time: the timestamp of the motion event
* @returns: whether the cursor position is in a drop zone
*
- * The ::drag-motion signal is emitted on the drop site when the user moves the cursor over
- * the widget during a drag. The signal handler must determine whether the cursor position is in
- * a drop zone or not. If it is not in a drop zone, it returns %FALSE and no further processing is
- * necessary. Otherwise, the handler returns %TRUE. In this case, the handler is responsible for
- * providing the necessary information for displaying feedback to the user, by calling
- * gdk_drag_status(). If the decision whether the drop will be accepted or rejected can't be made
- * based solely on the cursor position and the type of the data, the handler may inspect the dragged
- * data by calling gtk_drag_get_data() and defer the gdk_drag_status() call to the ::drag-data-received
- * handler.
+ * The ::drag-motion signal is emitted on the drop site when the user
+ * moves the cursor over the widget during a drag. The signal handler
+ * must determine whether the cursor position is in a drop zone or not.
+ * If it is not in a drop zone, it returns %FALSE and no further processing
+ * is necessary. Otherwise, the handler returns %TRUE. In this case, the
+ * handler is responsible for providing the necessary information for
+ * displaying feedback to the user, by calling gdk_drag_status(). If the
+ * decision whether the drop will be accepted or rejected can't be made
+ * based solely on the cursor position and the type of the data, the handler
+ * may inspect the dragged data by calling gtk_drag_get_data() and defer the
+ * gdk_drag_status() call to the ::drag-data-received handler.
*
- * Note that there is no ::drag-enter signal. The drag receiver has to keep track of whether
- * he has received any ::drag-motion signals since the last ::drag-leave and if not, treat the
- * ::drag-motion signal as an "enter" signal. Upon an "enter", the handler will typically highlight
- * the drop site with gtk_drag_highlight().
+ * Note that there is no ::drag-enter signal. The drag receiver has to keep
+ * track of whether he has received any ::drag-motion signals since the last
+ * ::drag-leave and if not, treat the ::drag-motion signal as an "enter" signal.
+ * Upon an "enter", the handler will typically highlight the drop site with
+ * gtk_drag_highlight().
*
* <informalexample><programlisting>
* static void
*
* /<!-- -->* We are getting this data due to a request in drag_motion,
* * rather than due to a request in drag_drop, so we are just
- * * supposed to call gdk_drag_status(<!-- -->), not actually paste in the data.
+ * * supposed to call gdk_drag_status(<!-- -->), not actually paste in
+ * * the data.
* *<!-- -->/
* str = gtk_selection_data_get_text (selection_data);
* if (!data_is_acceptable (str))
* </programlisting></informalexample>
*/
widget_signals[DRAG_MOTION] =
- g_signal_new ("drag_motion",
+ g_signal_new (I_("drag_motion"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_motion),
* @time: the timestamp of the motion event
* @returns: whether the cursor position is in a drop zone
*
- * The ::drag-drop signal is emitted on the drop site when the user drops the data
- * onto the widget. The signal handler must determine whether the cursor position is in
- * a drop zone or not. If it is not in a drop zone, it returns %FALSE and no further
- * processing is necessary. Otherwise, the handler returns %TRUE. In this case, the handler
- * must ensure that gtk_drag_finish() is called to let the source know that the drop is done.
- * The call to gtk_drag_finish() can be done either directly or in a ::drag-data-received handler
- * which gets triggered by calling gtk_drop_get_data() to receive the data for one or more of the
- * supported targets.
+ * The ::drag-drop signal is emitted on the drop site when the user drops the
+ * data onto the widget. The signal handler must determine whether the cursor
+ * position is in a drop zone or not. If it is not in a drop zone, it returns
+ * %FALSE and no further processing is necessary. Otherwise, the handler returns
+ * %TRUE. In this case, the handler must ensure that gtk_drag_finish() is called
+ * to let the source know that the drop is done. The call to gtk_drag_finish()
+ * can be done either directly or in a ::drag-data-received handler which gets
+ * triggered by calling gtk_drop_get_data() to receive the data for one or more
+ * of the supported targets.
*/
widget_signals[DRAG_DROP] =
- g_signal_new ("drag_drop",
+ g_signal_new (I_("drag_drop"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_drop),
* @info: the info that has been registered with the target in the #GtkTargetList.
* @time: the timestamp at which the data was requested
*
- * The ::drag-data-get signal is emitted on the drag source when the drop site requests
- * the data which is dragged. It is the responsibility of the signal handler to fill @data
- * with the data in the format which is indicated by @info. See gtk_selection_data_set() and
- * gtk_selection_data_set_text().
+ * The ::drag-data-get signal is emitted on the drag source when the drop site
+ * requests the data which is dragged. It is the responsibility of the signal
+ * handler to fill @data with the data in the format which is indicated by @info.
+ * See gtk_selection_data_set() and gtk_selection_data_set_text().
*/
widget_signals[DRAG_DATA_GET] =
- g_signal_new ("drag_data_get",
+ g_signal_new (I_("drag_data_get"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_data_get),
* @info: the info that has been registered with the target in the #GtkTargetList.
* @time: the timestamp at which the data was received
*
- * The ::drag-data-received signal is emitted on the drop site when the dragged data has been
- * received. If the data was received in order to determine whether the drop will be accepted,
- * the handler is expected to call gdk_drag_status() and <emphasis>not</emphasis> finish the drag.
- * If the data was received in response to a ::drag-drop signal (and this is the last target to be
- * received), the handler for this signal is expected to process the received data and then call
- * gtk_drag_finish(), setting the @success parameter depending on whether the data was processed
- * successfully.
- *
- * The handler may inspect and modify @drag_context->action before calling gtk_drag_finish(),
- * e.g. to implement %GDK_ACTION_ASK as shown in the following example:
+ * The ::drag-data-received signal is emitted on the drop site when the dragged
+ * data has been received. If the data was received in order to determine whether
+ * the drop will be accepted, the handler is expected to call gdk_drag_status()
+ * and <emphasis>not</emphasis> finish the drag. If the data was received in
+ * response to a ::drag-drop signal (and this is the last target to be received),
+ * the handler for this signal is expected to process the received data and then
+ * call gtk_drag_finish(), setting the @success parameter depending on whether
+ * the data was processed successfully.
+ *
+ * The handler may inspect and modify @drag_context->action before calling
+ * gtk_drag_finish(), e.g. to implement %GDK_ACTION_ASK as shown in the following
+ * example:
* <informalexample><programlisting>
* void
* drag_data_received (GtkWidget *widget,
* </programlisting></informalexample>
*/
widget_signals[DRAG_DATA_RECEIVED] =
- g_signal_new ("drag_data_received",
+ g_signal_new (I_("drag_data_received"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_data_received),
G_TYPE_UINT,
G_TYPE_UINT);
widget_signals[VISIBILITY_NOTIFY_EVENT] =
- g_signal_new ("visibility_notify_event",
+ g_signal_new (I_("visibility_notify_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, visibility_notify_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[CLIENT_EVENT] =
- g_signal_new ("client_event",
+ g_signal_new (I_("client_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, client_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[NO_EXPOSE_EVENT] =
- g_signal_new ("no_expose_event",
+ g_signal_new (I_("no_expose_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, no_expose_event),
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[WINDOW_STATE_EVENT] =
- g_signal_new ("window_state_event",
+ g_signal_new (I_("window_state_event"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, window_state_event),
_gtk_marshal_BOOLEAN__BOXED,
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+ /**
+ * GtkWidget::grab-broken-event:
+ * @widget: the object which received the signal
+ * @event: the #GdkEventGrabBroken event
+ *
+ * Emitted when a pointer or keyboard grab on a window belonging
+ * to @widget gets broken.
+ *
+ * On X11, this happens when the grab window becomes unviewable
+ * (i.e. it or one of its ancestors is unmapped), or if the same
+ * application grabs the pointer or keyboard again.
+ *
+ * Returns: %TRUE to stop other handlers from being invoked for the event.
+ * %FALSE to propagate the event further.
+ *
+ * Since: 2.8
+ */
+ widget_signals[GRAB_BROKEN] =
+ g_signal_new (I_("grab_broken_event"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkWidgetClass, grab_broken_event),
+ _gtk_boolean_handled_accumulator, NULL,
+ _gtk_marshal_BOOLEAN__BOXED,
+ G_TYPE_BOOLEAN, 1,
+ GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+/**
+ * GtkWidget::popup-menu
+ * @widget: the object which received the signal
+ * @returns: TRUE if a menu was activated
+ *
+ * This signal gets emitted whenever a widget should pop up a context-sensitive
+ * menu. This usually happens through the standard key binding mechanism; by
+ * pressing a certain key while a widget is focused, the user can cause the
+ * widget to pop up a menu. For example, the #GtkEntry widget creates a menu
+ * with clipboard commands. See <xref linkend="checklist-popup-menu"/> for an
+ * example of how to use this signal.
+ */
widget_signals[POPUP_MENU] =
- g_signal_new ("popup_menu",
+ g_signal_new (I_("popup_menu"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkWidgetClass, popup_menu),
_gtk_marshal_BOOLEAN__VOID,
G_TYPE_BOOLEAN, 0);
widget_signals[SHOW_HELP] =
- g_signal_new ("show_help",
+ g_signal_new (I_("show_help"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkWidgetClass, show_help),
G_TYPE_BOOLEAN, 1,
GTK_TYPE_WIDGET_HELP_TYPE);
widget_signals[ACCEL_CLOSURES_CHANGED] =
- g_signal_new ("accel_closures_changed",
+ g_signal_new (I_("accel_closures_changed"),
G_TYPE_FROM_CLASS (gobject_class),
0,
0,
_gtk_marshal_NONE__NONE,
G_TYPE_NONE, 0);
widget_signals[SCREEN_CHANGED] =
- g_signal_new ("screen_changed",
+ g_signal_new (I_("screen_changed"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, screen_changed),
* for determining whether an accelerator can be activated.
*/
widget_signals[CAN_ACTIVATE_ACCEL] =
- g_signal_new ("can_activate_accel",
+ g_signal_new (I_("can_activate_accel"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, can_activate_accel),
GTK_WIDGET_HELP_WHATS_THIS);
gtk_widget_class_install_style_property (klass,
- g_param_spec_boolean ("interior_focus",
+ g_param_spec_boolean ("interior-focus",
P_("Interior Focus"),
P_("Whether to draw the focus indicator inside widgets"),
TRUE,
- G_PARAM_READABLE));
+ GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (klass,
g_param_spec_int ("focus-line-width",
P_("Focus linewidth"),
P_("Width, in pixels, of the focus indicator line"),
0, G_MAXINT, 1,
- G_PARAM_READWRITE));
+ GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (klass,
g_param_spec_string ("focus-line-pattern",
P_("Focus line dash pattern"),
P_("Dash pattern used to draw the focus indicator"),
"\1\1",
- G_PARAM_READWRITE));
+ GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (klass,
g_param_spec_int ("focus-padding",
P_("Focus padding"),
P_("Width, in pixels, between focus indicator and the widget 'box'"),
0, G_MAXINT, 1,
- G_PARAM_READWRITE));
+ GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (klass,
g_param_spec_boxed ("cursor-color",
P_("Cursor color"),
P_("Color with which to draw insertion cursor"),
GDK_TYPE_COLOR,
- G_PARAM_READABLE));
+ GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (klass,
g_param_spec_boxed ("secondary-cursor-color",
P_("Secondary cursor color"),
P_("Color with which to draw the secondary insertion cursor when editing mixed right-to-left and left-to-right text"),
GDK_TYPE_COLOR,
- G_PARAM_READABLE));
+ GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (klass,
g_param_spec_float ("cursor-aspect-ratio",
P_("Cursor line aspect ratio"),
P_("Aspect ratio with which to draw insertion cursor"),
0.0, 1.0, 0.04,
- G_PARAM_READABLE));
+ GTK_PARAM_READABLE));
+
+/**
+ * GtkWidget:draw-border:
+ *
+ * The "draw-border" 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));
+
+/**
+ * GtkWidget:link-color:
+ *
+ * The "link-color" property defines the color of unvisited links.
+ *
+ * Since: 2.10
+ */
+ gtk_widget_class_install_style_property (klass,
+ g_param_spec_boxed ("link-color",
+ P_("Unvisited Link Color"),
+ P_("Color of unvisited links"),
+ GDK_TYPE_COLOR,
+ GTK_PARAM_READABLE));
+
+/**
+ * GtkWidget:visited-link-color:
+ *
+ * The "visited-link-color" property defines the color of visited links.
+ *
+ * Since: 2.10
+ */
+ gtk_widget_class_install_style_property (klass,
+ g_param_spec_boxed ("visited-link-color",
+ P_("Visited Link Color"),
+ P_("Color of visited links"),
+ GDK_TYPE_COLOR,
+ GTK_PARAM_READABLE));
+
+/**
+ * GtkWidget:wide-separators:
+ *
+ * The "wide-separators" property defines whether separators have
+ * configurable width and should be drawn using a box instead of a line.
+ *
+ * Since: 2.10
+ */
+ gtk_widget_class_install_style_property (klass,
+ g_param_spec_boolean ("wide-separators",
+ P_("Wide Separators"),
+ P_("Whether separators have configurable width and should be drawn using a box instead of a line"),
+ FALSE,
+ GTK_PARAM_READABLE));
+
+/**
+ * GtkWidget:separator-width:
+ *
+ * The "separator-width" property defines the width of separators.
+ * This property only takes effect if "wide-separators" is %TRUE.
+ *
+ * Since: 2.10
+ */
+ gtk_widget_class_install_style_property (klass,
+ g_param_spec_int ("separator-width",
+ P_("Separator Width"),
+ P_("The width of separators if wide-separators is TRUE"),
+ 0, G_MAXINT, 0,
+ GTK_PARAM_READABLE));
+
+/**
+ * GtkWidget:separator-height:
+ *
+ * The "separator-height" property defines the height of separators.
+ * This property only takes effect if "wide-separators" is %TRUE.
+ *
+ * Since: 2.10
+ */
+ gtk_widget_class_install_style_property (klass,
+ g_param_spec_int ("separator-height",
+ P_("Separator Height"),
+ P_("The height of separators if \"wide-separators\" is TRUE"),
+ 0, G_MAXINT, 0,
+ GTK_PARAM_READABLE));
+
+/**
+ * GtkWidget:scroll-arrow-hlength:
+ *
+ * The "scroll-arrow-hlength" property defines the length of
+ * horizontal scroll arrows.
+ *
+ * Since: 2.10
+ */
+ gtk_widget_class_install_style_property (klass,
+ g_param_spec_int ("scroll-arrow-hlength",
+ P_("Horizontal Scroll Arrow Length"),
+ P_("The length of horizontal scroll arrows"),
+ 1, G_MAXINT, 16,
+ GTK_PARAM_READABLE));
+
+/**
+ * GtkWidget:scroll-arrow-vlength:
+ *
+ * The "scroll-arrow-vlength" property defines the length of
+ * vertical scroll arrows.
+ *
+ * Since: 2.10
+ */
+ gtk_widget_class_install_style_property (klass,
+ g_param_spec_int ("scroll-arrow-vlength",
+ P_("Vertical Scroll Arrow Length"),
+ P_("The length of vertical scroll arrows"),
+ 1, G_MAXINT, 16,
+ GTK_PARAM_READABLE));
+}
+
+static void
+gtk_widget_base_class_finalize (GtkWidgetClass *klass)
+{
+ GList *list, *node;
+
+ list = g_param_spec_pool_list_owned (style_property_spec_pool, G_OBJECT_CLASS_TYPE (klass));
+ for (node = list; node; node = node->next)
+ {
+ GParamSpec *pspec = node->data;
+
+ g_param_spec_pool_remove (style_property_spec_pool, pspec);
+ g_param_spec_unref (pspec);
+ }
+ g_list_free (list);
}
static void
widget->allocation.width = 1;
widget->allocation.height = 1;
- if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_IN_REPARENT (widget))
- gtk_widget_unrealize (widget);
+ if (GTK_WIDGET_REALIZED (widget))
+ {
+ if (GTK_WIDGET_IN_REPARENT (widget))
+ gtk_widget_unmap (widget);
+ else
+ gtk_widget_unrealize (widget);
+ }
/* Removing a widget from a container restores the child visible
* flag to the default state, so it doesn't affect the child
if (GTK_WIDGET_VISIBLE (widget))
{
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
+
+ g_object_ref (widget);
if (toplevel != widget && GTK_WIDGET_TOPLEVEL (toplevel))
_gtk_window_unset_focus_and_default (GTK_WINDOW (toplevel), widget);
- g_object_ref (widget);
g_signal_emit (widget, widget_signals[HIDE], 0);
if (!GTK_WIDGET_TOPLEVEL (widget))
gtk_widget_queue_resize (widget);
shape_info->offset_y);
}
+ shape_info = g_object_get_qdata (G_OBJECT (widget), quark_input_shape_info);
+ if (shape_info)
+ gdk_window_input_shape_combine_mask (widget->window,
+ shape_info->shape_mask,
+ shape_info->offset_x,
+ shape_info->offset_y);
+
if (!GTK_WIDGET_NO_WINDOW (widget))
{
mode = gtk_widget_get_extension_events (widget);
g_return_if_fail (GTK_IS_WIDGET (widget));
if (GTK_WIDGET_HAS_SHAPE_MASK (widget))
- gtk_widget_shape_combine_mask (widget, NULL, -1, -1);
+ gtk_widget_shape_combine_mask (widget, NULL, 0, 0);
+
+ 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))
{
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->top;
+ rect->y -= draw_border->left;
+ rect->width += draw_border->left + draw_border->right;
+ rect->height += draw_border->top + draw_border->bottom;
+ }
+
+ 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
void
gtk_widget_queue_draw (GtkWidget *widget)
{
+ GdkRectangle rect;
+
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (widget->allocation.width || widget->allocation.height)
- {
- if (GTK_WIDGET_NO_WINDOW (widget))
- gtk_widget_queue_draw_area (widget, widget->allocation.x,
- widget->allocation.y,
- widget->allocation.width,
- widget->allocation.height);
- else
- gtk_widget_queue_draw_area (widget, 0, 0,
- widget->allocation.width,
- widget->allocation.height);
- }
+ 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)
gtk_widget_invalidate_widget_windows (GtkWidget *widget,
GdkRegion *region)
{
+ if (!GTK_WIDGET_REALIZED (widget))
+ return;
+
if (!GTK_WIDGET_NO_WINDOW (widget) && widget->parent)
{
int x, y;
static void
gtk_widget_queue_shallow_draw (GtkWidget *widget)
{
+ GdkRectangle rect;
GdkRegion *region;
- g_return_if_fail (GTK_IS_WIDGET (widget));
+ if (!GTK_WIDGET_REALIZED (widget))
+ return;
+
+ gtk_widget_get_draw_rectangle (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 (&widget->allocation);
+ region = gdk_region_rectangle (&rect);
gtk_widget_invalidate_widget_windows (widget, region);
gdk_region_destroy (region);
}
gboolean position_changed;
g_return_if_fail (GTK_IS_WIDGET (widget));
+
+#ifdef G_ENABLE_DEBUG
+ if (gtk_debug_flags & GTK_DEBUG_GEOMETRY)
+ {
+ gint depth;
+ GtkWidget *parent;
+ const gchar *name;
+ depth = 0;
+ parent = widget;
+ while (parent)
+ {
+ depth++;
+ parent = gtk_widget_get_parent (parent);
+ }
+
+ name = g_type_name (G_OBJECT_TYPE (G_OBJECT (widget)));
+ g_print ("gtk_widget_size_allocate: %*s%s %d %d\n",
+ 2 * depth, " ", name,
+ allocation->width, allocation->height);
+ }
+#endif /* G_ENABLE_DEBUG */
+
alloc_needed = GTK_WIDGET_ALLOC_NEEDED (widget);
- GTK_PRIVATE_UNSET_FLAG (widget, GTK_ALLOC_NEEDED);
+ if (!GTK_WIDGET_REQUEST_NEEDED (widget)) /* Preserve request/allocate ordering */
+ GTK_PRIVATE_UNSET_FLAG (widget, GTK_ALLOC_NEEDED);
old_allocation = widget->allocation;
real_allocation = *allocation;
* Determines whether an accelerator that activates the signal
* identified by @signal_id can currently be activated.
* This is done by emitting the GtkWidget::can-activate-accel
- * signal on @widget; if the signal isn't overriden by a
+ * signal on @widget; if the signal isn't overridden by a
* handler or in a derived widget, then the default check is
* that the widget must be sensitive, and the widget and all
- * its parents mapped.
+ * its ancestors mapped.
*
* Return value: %TRUE if the accelerator can be activated.
+ *
+ * Since: 2.4
**/
gboolean
gtk_widget_can_activate_accel (GtkWidget *widget,
typedef struct {
GQuark path_quark;
- GtkWidget *widget;
GtkAccelGroup *accel_group;
GClosure *closure;
} AccelPath;
/* closures_destroy takes care of unrefing the closure */
g_object_unref (apath->accel_group);
- g_free (apath);
+ g_slice_free (AccelPath, apath);
}
/**
* gtk_widget_set_accel_path:
* @widget: a #GtkWidget
- * @accel_path: path used to look up the the accelerator
+ * @accel_path: path used to look up the accelerator
* @accel_group: a #GtkAccelGroup.
*
* Given an accelerator group, @accel_group, and an accelerator path,
g_return_if_fail (_gtk_accel_path_is_valid (accel_path));
gtk_accel_map_add_entry (accel_path, 0, 0);
- apath = g_new (AccelPath, 1);
- apath->widget = widget;
+ apath = g_slice_new (AccelPath);
apath->accel_group = g_object_ref (accel_group);
apath->path_quark = g_quark_from_string (accel_path);
- apath->closure = widget_new_accel_closure (apath->widget, GTK_WIDGET_GET_CLASS (apath->widget)->activate_signal);
+ apath->closure = widget_new_accel_closure (widget, GTK_WIDGET_GET_CLASS (widget)->activate_signal);
}
else
apath = NULL;
gtk_widget_real_key_press_event (GtkWidget *widget,
GdkEventKey *event)
{
- return _gtk_bindings_activate_event (GTK_OBJECT (widget), event);
+ return gtk_bindings_activate_event (GTK_OBJECT (widget), event);
}
static gboolean
gtk_widget_real_key_release_event (GtkWidget *widget,
GdkEventKey *event)
{
- return _gtk_bindings_activate_event (GTK_OBJECT (widget), event);
+ return gtk_bindings_activate_event (GTK_OBJECT (widget), event);
}
static gboolean
g_return_val_if_fail (event != NULL, TRUE);
g_return_val_if_fail (event->type == GDK_EXPOSE, TRUE);
- if (event->type != GDK_EXPOSE)
- return TRUE;
-
return gtk_widget_event_internal (widget, event);
}
case GDK_VISIBILITY_NOTIFY:
signal_num = VISIBILITY_NOTIFY_EVENT;
break;
+ case GDK_GRAB_BROKEN:
+ signal_num = GRAB_BROKEN;
+ break;
default:
g_warning ("gtk_widget_event(): unhandled event type: %d", event->type);
signal_num = -1;
g_list_free (children);
}
else
- gdk_window_reparent (widget->window, new_window, 0, 0);
+ {
+ GdkWindow *parent;
+ GList *tmp_list, *children;
+
+ parent = gdk_window_get_parent (widget->window);
+
+ if (parent == NULL)
+ gdk_window_reparent (widget->window, new_window, 0, 0);
+ else
+ {
+ children = gdk_window_get_children (parent);
+
+ for (tmp_list = children; tmp_list; tmp_list = tmp_list->next)
+ {
+ GtkWidget *child;
+ GdkWindow *window = tmp_list->data;
+
+ gdk_window_get_user_data (window, (void **)&child);
+ if (child == widget)
+ gdk_window_reparent (window, new_window, 0, 0);
+ }
+
+ g_list_free (children);
+ }
+ }
}
static void
gtk_widget_reparent_fixup_child (GtkWidget *widget,
gpointer client_data)
{
- g_return_if_fail (client_data != NULL);
+ g_assert (client_data != NULL);
if (GTK_WIDGET_NO_WINDOW (widget))
{
gtk_widget_region_intersect (GtkWidget *widget,
GdkRegion *region)
{
+ GdkRectangle rect;
GdkRegion *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);
- dest = gdk_region_rectangle (&widget->allocation);
+ dest = gdk_region_rectangle (&rect);
gdk_region_intersect (dest, region);
return dest;
}
+/**
+ * _gtk_widget_grab_notify:
+ * @widget: a #GtkWidget
+ * @was_grabbed: whether a grab is now in effect
+ *
+ * Emits the signal "grab_notify" on @widget.
+ *
+ * Since: 2.6
+ **/
+void
+_gtk_widget_grab_notify (GtkWidget *widget,
+ gboolean was_grabbed)
+{
+ g_signal_emit (widget, widget_signals[GRAB_NOTIFY], 0, was_grabbed);
+}
+
/**
* gtk_widget_grab_focus:
* @widget: a #GtkWidget
g_object_ref (widget);
g_signal_emit (widget, widget_signals[GRAB_FOCUS], 0);
- g_object_notify (G_OBJECT (widget), "has_focus");
+ g_object_notify (G_OBJECT (widget), "has-focus");
g_object_unref (widget);
}
gtk_widget_set_state (GtkWidget *widget,
GtkStateType state)
{
+ gboolean touchscreen;
+
g_return_if_fail (GTK_IS_WIDGET (widget));
if (state == GTK_WIDGET_STATE (widget))
return;
+ g_object_get (gtk_widget_get_settings (widget),
+ "gtk-touchscreen-mode", &touchscreen,
+ NULL);
+
+ if (touchscreen && state == GTK_STATE_PRELIGHT)
+ state = GTK_STATE_NORMAL;
+
if (state == GTK_STATE_INSENSITIVE)
gtk_widget_set_sensitive (widget, FALSE);
else
}
}
+
+/**
+ * gtk_widget_set_app_paintable:
+ * @widget: a #GtkWidget
+ * @app_paintable: %TRUE if the application will paint on the widget
+ *
+ * Sets whether the application intends to draw on the widget in
+ * an ::expose-event handler.
+ *
+ * This is a hint to the widget and does not affect the behavior of
+ * the GTK+ core; many widgets ignore this flag entirely. For widgets
+ * that do pay attention to the flag, such as #GtkEventBox and #GtkWindow,
+ * the effect is to suppress default themed drawing of the widget's
+ * background. (Children of the widget will still be drawn.) The application
+ * is then entirely responsible for drawing the widget background.
+ *
+ * Note that the background is still drawn when the widget is mapped.
+ * If this is not suitable (e.g. because you want to make a transparent
+ * window using an RGBA visual), you can work around this by doing:
+ * <informalexample><programlisting>
+ * gtk_widget_realize (window);
+ * gdk_window_set_back_pixmap (window->window, NULL, FALSE);
+ * gtk_widget_show (window);
+ * </programlisting></informalexample>
+ **/
void
gtk_widget_set_app_paintable (GtkWidget *widget,
gboolean app_paintable)
if (GTK_WIDGET_DRAWABLE (widget))
gtk_widget_queue_draw (widget);
- g_object_notify (G_OBJECT (widget), "app_paintable");
+ g_object_notify (G_OBJECT (widget), "app-paintable");
}
}
* so you would only use this function to turn off double buffering
* if you had special needs and really knew what you were doing.
*
+ * Note: if you turn off double-buffering, you have to handle
+ * expose events, since even the clearing to the background color or
+ * pixmap will not happen automatically (as it is done in
+ * gdk_window_begin_paint()).
+ *
**/
void
gtk_widget_set_double_buffered (GtkWidget *widget,
* when it is allocated to a new size. Otherwise, only the
* new portion of the widget will be redrawn.
*
- * Sets whether a when a widgets size allocation changes, the entire
- * widget is queued for drawing. By default, this setting is %TRUE and
+ * Sets whether the entire widget is queued for drawing when its size
+ * allocation changes. By default, this setting is %TRUE and
* the entire widget is redrawn on every size change. If your widget
* leaves the upper left unchanged when made bigger, turning this
* setting on will improve performance.
GtkStateData data;
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (widget->parent == NULL);
- g_return_if_fail (!GTK_WIDGET_TOPLEVEL (widget));
g_return_if_fail (GTK_IS_WIDGET (parent));
g_return_if_fail (widget != parent);
+ if (widget->parent != NULL)
+ {
+ g_warning ("Can't set a parent on widget which has a parent\n");
+ return;
+ }
+ if (GTK_WIDGET_TOPLEVEL (widget))
+ {
+ g_warning ("Can't set a parent on a toplevel widget\n");
+ return;
+ }
/* keep this function in sync with gtk_menu_attach_to_widget()
*/
- g_object_ref (widget);
- gtk_object_sink (GTK_OBJECT (widget));
+ g_object_ref_sink (widget);
widget->parent = parent;
if (GTK_WIDGET_STATE (parent) != GTK_STATE_NORMAL)
GtkStyle *new_style = NULL;
gboolean initial_emission;
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
initial_emission = !GTK_WIDGET_RC_STYLE (widget) && !GTK_WIDGET_USER_STYLE (widget);
GTK_PRIVATE_UNSET_FLAG (widget, GTK_USER_STYLE);
gtk_widget_modify_style (GtkWidget *widget,
GtkRcStyle *style)
{
- GtkRcStyle *old_style;
-
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (GTK_IS_RC_STYLE (style));
- old_style = g_object_get_qdata (G_OBJECT (widget), quark_rc_style);
-
g_object_set_qdata_full (G_OBJECT (widget),
quark_rc_style,
gtk_rc_style_copy (style),
}
static void
-gtk_widget_modify_color_component (GtkWidget *widget,
- GtkRcFlags component,
- GtkStateType state,
- GdkColor *color)
+gtk_widget_modify_color_component (GtkWidget *widget,
+ GtkRcFlags component,
+ GtkStateType state,
+ const GdkColor *color)
{
GtkRcStyle *rc_style = gtk_widget_get_modifier_style (widget);
* gtk_widget_modify_style().
**/
void
-gtk_widget_modify_fg (GtkWidget *widget,
- GtkStateType state,
- GdkColor *color)
+gtk_widget_modify_fg (GtkWidget *widget,
+ GtkStateType state,
+ const GdkColor *color)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
*
* Sets the background color for a widget in a particular state. All
* other style values are left untouched. See also
- * gtk_widget_modify_style().
+ * gtk_widget_modify_style().
+ *
+ * Note that "no window" widgets (which have the %GTK_NO_WINDOW flag set)
+ * draw on their parent container's window and thus may not draw any background
+ * themselves. This is the case for e.g. #GtkLabel. To modify the background
+ * of such widgets, you have to set the background color on their parent; if you want
+ * to set the background of a rectangular area around a label, try placing the
+ * label in a #GtkEventBox widget and setting the background color on that.
**/
void
-gtk_widget_modify_bg (GtkWidget *widget,
- GtkStateType state,
- GdkColor *color)
+gtk_widget_modify_bg (GtkWidget *widget,
+ GtkStateType state,
+ const GdkColor *color)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
* gtk_widget_modify_style().
**/
void
-gtk_widget_modify_text (GtkWidget *widget,
- GtkStateType state,
- GdkColor *color)
+gtk_widget_modify_text (GtkWidget *widget,
+ GtkStateType state,
+ const GdkColor *color)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
* is the background color used along with the text color
* (see gtk_widget_modify_text()) for widgets such as #GtkEntry
* and #GtkTextView. See also gtk_widget_modify_style().
+ *
+ * Note that "no window" widgets (which have the %GTK_NO_WINDOW flag set)
+ * draw on their parent container's window and thus may not draw any background
+ * themselves. This is the case for e.g. #GtkLabel. To modify the background
+ * of such widgets, you have to set the base color on their parent; if you want
+ * to set the background of a rectangular area around a label, try placing the
+ * label in a #GtkEventBox widget and setting the base color on that.
**/
void
-gtk_widget_modify_base (GtkWidget *widget,
- GtkStateType state,
- GdkColor *color)
+gtk_widget_modify_base (GtkWidget *widget,
+ GtkStateType state,
+ const GdkColor *color)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (state >= GTK_STATE_NORMAL && state <= GTK_STATE_INSENSITIVE);
g_object_ref (widget);
g_object_freeze_notify (G_OBJECT (widget));
- if (widget->style != style || initial_emission)
- {
- PangoContext *context = gtk_widget_peek_pango_context (widget);
- if (context)
- pango_context_set_font_description (context, style->font_desc);
- }
-
if (widget->style != style)
{
GtkStyle *previous_style;
if (GTK_WIDGET_REALIZED (widget))
widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_widget_update_pango_context (widget);
g_signal_emit (widget,
widget_signals[STYLE_SET],
0,
gtk_widget_queue_resize (widget);
}
else if (initial_emission)
- g_signal_emit (widget,
- widget_signals[STYLE_SET],
- 0,
- NULL);
+ {
+ gtk_widget_update_pango_context (widget);
+ g_signal_emit (widget,
+ widget_signals[STYLE_SET],
+ 0,
+ NULL);
+ }
g_object_notify (G_OBJECT (widget), "style");
g_object_thaw_notify (G_OBJECT (widget));
g_object_unref (widget);
g_object_unref (widget);
}
+/**
+ * gtk_widget_is_composited:
+ * @widget:
+ *
+ * Whether @widget can rely on having its alpha channel
+ * drawn correctly. On X11 this function returns whether a
+ * compositing manager is running for @widget's screen
+ *
+ * Return value: #TRUE if the widget can rely on its alpha
+ * channel being drawn correctly.
+ *
+ * Since: 2.10
+ **/
+gboolean
+gtk_widget_is_composited (GtkWidget *widget)
+{
+ GdkScreen *screen;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+
+ screen = gtk_widget_get_screen (widget);
+
+ return gdk_screen_is_composited (screen);
+}
+
+static void
+propagate_composited_changed (GtkWidget *widget,
+ gpointer dummy)
+{
+ if (GTK_IS_CONTAINER (widget))
+ {
+ gtk_container_forall (GTK_CONTAINER (widget),
+ propagate_composited_changed,
+ NULL);
+ }
+
+ g_signal_emit (widget, widget_signals[COMPOSITED_CHANGED], 0);
+}
+
+void
+_gtk_widget_propagate_composited_changed (GtkWidget *widget)
+{
+ propagate_composited_changed (widget, NULL);
+}
+
/**
* _gtk_widget_propagate_screen_changed:
* @widget: a #GtkWidget
* gtk_widget_get_pango_context:
* @widget: a #GtkWidget
*
- * Gets a #PangoContext with the appropriate colormap, font description
+ * Gets a #PangoContext with the appropriate font map, font description,
* and base direction for this widget. Unlike the context returned
* by gtk_widget_create_pango_context(), this context is owned by
* the widget (it can be used until the screen for the widget changes
return context;
}
+static void
+update_pango_context (GtkWidget *widget,
+ PangoContext *context)
+{
+ pango_context_set_font_description (context, widget->style->font_desc);
+ pango_context_set_base_dir (context,
+ gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
+ PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
+}
+
+static void
+gtk_widget_update_pango_context (GtkWidget *widget)
+{
+ PangoContext *context = gtk_widget_peek_pango_context (widget);
+
+ if (context)
+ {
+ GdkScreen *screen;
+
+ update_pango_context (widget, context);
+
+ screen = gtk_widget_get_screen_unchecked (widget);
+ if (screen)
+ {
+ pango_cairo_context_set_resolution (context,
+ gdk_screen_get_resolution (screen));
+ pango_cairo_context_set_font_options (context,
+ gdk_screen_get_font_options (screen));
+ }
+ }
+}
+
/**
* gtk_widget_create_pango_context:
* @widget: a #GtkWidget
*
- * Creates a new #PangoContext with the appropriate colormap,
+ * Creates a new #PangoContext with the appropriate font map,
* font description, and base direction for drawing text for
* this widget. See also gtk_widget_get_pango_context().
*
{
GTK_NOTE (MULTIHEAD,
g_warning ("gtk_widget_create_pango_context ()) called without screen"));
-
+
screen = gdk_screen_get_default ();
}
context = gdk_pango_context_get_for_screen (screen);
- gdk_pango_context_set_colormap (context, gtk_widget_get_colormap (widget));
- pango_context_set_base_dir (context,
- gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
- PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
- pango_context_set_font_description (context, widget->style->font_desc);
+ update_pango_context (widget, context);
pango_context_set_language (context, gtk_get_default_language ());
return context;
* @widget: a #GtkWidget
* @text: text to set on the layout (can be %NULL)
*
- * Creates a new #PangoLayout with the appropriate colormap,
+ * Creates a new #PangoLayout with the appropriate font map,
* font description, and base direction for drawing text for
* this widget.
*
- * If you keep a #PangoLayout created in this way around, in order
+ * If you keep a #PangoLayout created in this way around, in order to
* notify the layout of changes to the base direction or font of this
* widget, you must call pango_layout_context_changed() in response to
* the ::style-set and ::direction-changed signals for the widget.
* gtk_widget_render_icon:
* @widget: a #GtkWidget
* @stock_id: a stock ID
- * @size: a stock size
+ * @size: a stock size. A size of (GtkIconSize)-1 means render at
+ * the size of the source and don't scale (if there are multiple
+ * source sizes, GTK+ picks one of the available sizes).
* @detail: render detail to pass to theme engine
*
* A convenience function that uses the theme engine and RC file
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
g_return_val_if_fail (stock_id != NULL, NULL);
- g_return_val_if_fail (size > GTK_ICON_SIZE_INVALID, NULL);
+ g_return_val_if_fail (size > GTK_ICON_SIZE_INVALID || size == -1, NULL);
gtk_widget_ensure_style (widget);
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (!GTK_WIDGET_TOPLEVEL (widget));
+ g_object_ref (widget);
+
if (is_visible)
GTK_PRIVATE_SET_FLAG (widget, GTK_CHILD_VISIBLE);
else
else
gtk_widget_unmap (widget);
}
+
+ g_object_unref (widget);
}
/**
GdkWindow *parent_window;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- g_return_val_if_fail (widget->parent != NULL, NULL);
parent_window = g_object_get_qdata (G_OBJECT (widget), quark_parent_window);
- return (parent_window != NULL) ? parent_window : widget->parent->window;
+ return (parent_window != NULL) ? parent_window :
+ (widget->parent != NULL) ? widget->parent->window : NULL;
}
/**
gint height)
{
GtkWidgetAuxInfo *aux_info;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
+ gboolean changed = FALSE;
g_object_freeze_notify (G_OBJECT (widget));
- aux_info =_gtk_widget_get_aux_info (widget, TRUE);
+ aux_info = _gtk_widget_get_aux_info (widget, TRUE);
- if (width > -2)
+ if (width > -2 && aux_info->width != width)
{
- g_object_notify (G_OBJECT (widget), "width_request");
+ g_object_notify (G_OBJECT (widget), "width-request");
aux_info->width = width;
+ changed = TRUE;
}
- if (height > -2)
+ if (height > -2 && aux_info->height != height)
{
- g_object_notify (G_OBJECT (widget), "height_request");
+ g_object_notify (G_OBJECT (widget), "height-request");
aux_info->height = height;
+ changed = TRUE;
}
- if (GTK_WIDGET_VISIBLE (widget))
+ if (GTK_WIDGET_VISIBLE (widget) && changed)
gtk_widget_queue_resize (widget);
g_object_thaw_notify (G_OBJECT (widget));
* gtk_widget_set_size_request(). To get the size a widget will
* actually use, call gtk_widget_size_request() instead of
* this function.
- *
**/
-
void
gtk_widget_get_size_request (GtkWidget *widget,
gint *width,
* 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.
- *
**/
void
gtk_widget_set_events (GtkWidget *widget,
if (events)
{
if (!eventp)
- eventp = g_new (gint, 1);
+ eventp = g_slice_new (gint);
*eventp = events;
g_object_set_qdata (G_OBJECT (widget), quark_event_mask, eventp);
}
else if (eventp)
{
- g_free (eventp);
+ g_slice_free (gint, eventp);
g_object_set_qdata (G_OBJECT (widget), quark_event_mask, NULL);
}
g_object_notify (G_OBJECT (widget), "events");
}
+static void
+gtk_widget_add_events_internal (GtkWidget *widget,
+ gint events,
+ GList *window_list)
+{
+ GList *l;
+
+ for (l = window_list; l != NULL; l = l->next)
+ {
+ GdkWindow *window = l->data;
+ gpointer user_data;
+
+ gdk_window_get_user_data (window, &user_data);
+ if (user_data == widget)
+ {
+ GList *children;
+
+ 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);
+ }
+ }
+}
+
/**
* gtk_widget_add_events:
* @widget: a #GtkWidget
{
if (!eventp)
{
- eventp = g_new (gint, 1);
+ eventp = g_slice_new (gint);
*eventp = 0;
}
}
else if (eventp)
{
- g_free (eventp);
+ g_slice_free (gint, eventp);
g_object_set_qdata (G_OBJECT (widget), quark_event_mask, NULL);
}
if (GTK_WIDGET_REALIZED (widget))
{
- if (GTK_WIDGET_NO_WINDOW (widget))
- {
- GList *children = gdk_window_get_children (widget->window);
- GList *tmp_list = children;
+ GList *window_list;
- while (tmp_list)
- {
- GdkWindow *window = tmp_list->data;
- gpointer user_data;
+ if (GTK_WIDGET_NO_WINDOW (widget))
+ window_list = gdk_window_get_children (widget->window);
+ else
+ window_list = g_list_prepend (NULL, widget->window);
- gdk_window_get_user_data (window, &user_data);
- if (user_data == widget)
- gdk_window_set_events (window, gdk_window_get_events (window) | events);
- tmp_list = tmp_list->next;
- }
+ gtk_widget_add_events_internal (widget, events, window_list);
- g_list_free (children);
- }
- else
- {
- gdk_window_set_events (widget->window, gdk_window_get_events (widget->window) | events);
- }
+ g_list_free (window_list);
}
g_object_notify (G_OBJECT (widget), "events");
modep = g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode);
if (!modep)
- modep = g_new (GdkExtensionMode, 1);
+ modep = g_slice_new (GdkExtensionMode);
*modep = mode;
g_object_set_qdata (G_OBJECT (widget), quark_extension_event_mode, modep);
- g_object_notify (G_OBJECT (widget), "extension_events");
+ g_object_notify (G_OBJECT (widget), "extension-events");
}
/**
gtk_widget_emit_direction_changed (GtkWidget *widget,
GtkTextDirection old_dir)
{
- PangoContext *context = gtk_widget_peek_pango_context (widget);
-
- if (context)
- pango_context_set_base_dir (context,
- gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
- PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
+ gtk_widget_update_pango_context (widget);
g_signal_emit (widget, widget_signals[DIRECTION_CHANGED], 0, old_dir);
}
if (widget->parent)
gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
+ else if (GTK_WIDGET_VISIBLE (widget))
+ gtk_widget_hide (widget);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
if (GTK_WIDGET_REALIZED (widget))
gtk_widget_unrealize (widget);
- G_OBJECT_CLASS (parent_class)->dispose (object);
+ G_OBJECT_CLASS (gtk_widget_parent_class)->dispose (object);
}
static void
g_object_set_qdata (G_OBJECT (widget), quark_accel_path, NULL);
g_object_set_qdata (G_OBJECT (widget), quark_accel_closures, NULL);
+ /* Callers of add_mnemonic_label() should disconnect on ::destroy */
+ g_object_set_qdata (G_OBJECT (widget), quark_mnemonic_labels, NULL);
+
gtk_grab_remove (widget);
g_object_unref (widget->style);
widget->style = gtk_widget_get_default_style ();
g_object_ref (widget->style);
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
+ GTK_OBJECT_CLASS (gtk_widget_parent_class)->destroy (object);
}
static void
events = g_object_get_qdata (G_OBJECT (widget), quark_event_mask);
if (events)
- g_free (events);
+ g_slice_free (gint, events);
mode = g_object_get_qdata (G_OBJECT (widget), quark_extension_event_mode);
if (mode)
- g_free (mode);
+ g_slice_free (GdkExtensionMode, mode);
accessible = g_object_get_qdata (G_OBJECT (widget), quark_accessible_object);
if (accessible)
g_object_unref (accessible);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtk_widget_parent_class)->finalize (object);
}
/*****************************************
static void
gtk_widget_real_map (GtkWidget *widget)
{
- g_return_if_fail (GTK_WIDGET_REALIZED (widget) == TRUE);
+ g_assert (GTK_WIDGET_REALIZED (widget));
if (!GTK_WIDGET_MAPPED (widget))
{
static void
gtk_widget_real_realize (GtkWidget *widget)
{
- g_return_if_fail (GTK_WIDGET_NO_WINDOW (widget));
+ g_assert (GTK_WIDGET_NO_WINDOW (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
if (widget->parent)
aux_info = g_object_get_qdata (G_OBJECT (widget), quark_aux_info);
if (!aux_info && create)
{
- if (!aux_info_mem_chunk)
- aux_info_mem_chunk = g_mem_chunk_new ("widget aux info mem chunk",
- sizeof (GtkWidgetAuxInfo),
- 1024, G_ALLOC_AND_FREE);
- aux_info = g_chunk_new (GtkWidgetAuxInfo, aux_info_mem_chunk);
+ aux_info = g_slice_new (GtkWidgetAuxInfo);
aux_info->width = -1;
aux_info->height = -1;
static void
gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info)
{
- g_mem_chunk_free (aux_info_mem_chunk, aux_info);
+ g_slice_free (GtkWidgetAuxInfo, aux_info);
}
static void
gtk_widget_shape_info_destroy (GtkWidgetShapeInfo *info)
{
g_object_unref (info->shape_mask);
- g_free (info);
+ g_slice_free (GtkWidgetShapeInfo, info);
}
/**
{
GTK_PRIVATE_SET_FLAG (widget, GTK_HAS_SHAPE_MASK);
- shape_info = g_new (GtkWidgetShapeInfo, 1);
+ shape_info = g_slice_new (GtkWidgetShapeInfo);
g_object_set_qdata_full (G_OBJECT (widget), quark_shape_info, shape_info,
(GDestroyNotify) gtk_widget_shape_info_destroy);
shape_info->offset_x = offset_x;
shape_info->offset_y = offset_y;
- /* set shape if widget has a gdk window allready.
- * otherwise the shape is scheduled to be set by gtk_widget_realize.
+ /* set shape if widget has a gdk window already.
+ * otherwise the shape is scheduled to be set by gtk_widget_realize().
*/
if (widget->window)
gdk_window_shape_combine_mask (widget->window, shape_mask,
}
}
+/**
+ * gtk_widget_input_shape_combine_mask:
+ * @widget: a #GtkWidget.
+ * @shape_mask: 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.
+ *
+ * Sets an input shape for this widget's GDK window. This allows for
+ * windows which react to mouse click in a nonrectangular region, see
+ * gdk_window_input_shape_combine_mask() for more information.
+ *
+ * Since: 2.10
+ **/
+void
+gtk_widget_input_shape_combine_mask (GtkWidget *widget,
+ GdkBitmap *shape_mask,
+ gint offset_x,
+ gint offset_y)
+{
+ GtkWidgetShapeInfo* shape_info;
+
+ 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));
+
+ if (!shape_mask)
+ {
+ if (widget->window)
+ gdk_window_input_shape_combine_mask (widget->window, NULL, 0, 0);
+
+ g_object_set_qdata (G_OBJECT (widget), quark_input_shape_info, NULL);
+ }
+ else
+ {
+ shape_info = g_slice_new (GtkWidgetShapeInfo);
+ g_object_set_qdata_full (G_OBJECT (widget), quark_input_shape_info,
+ shape_info,
+ (GDestroyNotify) gtk_widget_shape_info_destroy);
+
+ shape_info->shape_mask = g_object_ref (shape_mask);
+ shape_info->offset_x = offset_x;
+ shape_info->offset_y = offset_y;
+
+ /* set shape if widget has a gdk window already.
+ * otherwise the shape is scheduled to be set by gtk_widget_realize().
+ */
+ if (widget->window)
+ gdk_window_input_shape_combine_mask (widget->window, shape_mask,
+ offset_x, offset_y);
+ }
+}
+
+
static void
gtk_reset_shapes_recurse (GtkWidget *widget,
GdkWindow *window)
return;
}
- g_param_spec_ref (pspec);
- g_param_spec_sink (pspec);
+ g_param_spec_ref_sink (pspec);
g_param_spec_set_qdata (pspec, quark_property_parser, (gpointer) parser);
g_param_spec_pool_insert (style_property_spec_pool, pspec, G_OBJECT_CLASS_TYPE (klass));
}
static GType our_type = 0;
if (our_type == 0)
- our_type = g_boxed_type_register_static ("GtkRequisition",
+ our_type = g_boxed_type_register_static (I_("GtkRequisition"),
(GBoxedCopyFunc) gtk_requisition_copy,
(GBoxedFreeFunc) gtk_requisition_free);
return our_type;
}
+/**
+ * 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
+ * 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>
+ * library contains more information about accessible objects and their uses.
+ *
+ * Returns: the #AtkObject associated with @widget
+ */
AtkObject*
gtk_widget_get_accessible (GtkWidget *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,
+ * gtk_label_set_mnemonic_widget()).
+
+ * The widgets in the list are not individually referenced. If you
+ * want to iterate through the list and perform actions involving
+ * callbacks that might destroy the widgets, you
+ * <emphasis>must</emphasis> call <literal>g_list_foreach (result,
+ * (GFunc)g_object_ref, NULL)</literal> first, and then unref all the
+ * widgets afterwards.
+
+ * Return value: the list of mnemonic labels; free this list
+ * with g_list_free() when you are done with it.
+ *
+ * Since: 2.4
+ **/
+GList *
+gtk_widget_list_mnemonic_labels (GtkWidget *widget)
+{
+ GList *list = NULL;
+ GSList *l;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+ for (l = g_object_get_qdata (G_OBJECT (widget), quark_mnemonic_labels); l; l = l->next)
+ list = g_list_prepend (list, l->data);
+
+ return list;
+}
+
+/**
+ * gtk_widget_add_mnemonic_label:
+ * @widget: a #GtkWidget
+ * @label: a #GtkWidget that acts as a mnemonic label for @widget.
+ *
+ * Adds a widget to the list of mnemonic labels for
+ * this widget. (See gtk_widget_list_mnemonic_labels()). Note the
+ * list of mnemonic labels for the widget is cleared when the
+ * widget is destroyed, so the caller must make sure to update
+ * its internal state at this point as well, by using a connection
+ * to the ::destroy signal or a weak notifier.
+ *
+ * Since: 2.4
+ **/
+void
+gtk_widget_add_mnemonic_label (GtkWidget *widget,
+ GtkWidget *label)
+{
+ GSList *old_list, *new_list;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GTK_IS_WIDGET (label));
+
+ old_list = g_object_steal_qdata (G_OBJECT (widget), quark_mnemonic_labels);
+ new_list = g_slist_prepend (old_list, label);
+
+ g_object_set_qdata_full (G_OBJECT (widget), quark_mnemonic_labels,
+ new_list, (GDestroyNotify) g_slist_free);
+}
+
+/**
+ * gtk_widget_remove_mnemonic_label:
+ * @widget: a #GtkWidget
+ * @label: a #GtkWidget that was previously set as a mnemnic label for
+ * @widget with gtk_widget_add_mnemonic_label().
+ *
+ * Removes a widget from the list of mnemonic labels for
+ * this widget. (See gtk_widget_list_mnemonic_labels()). The widget
+ * must have previously been added to the list with
+ * gtk_widget_add_mnemonic_label().
+ *
+ * Since: 2.4
+ **/
+void
+gtk_widget_remove_mnemonic_label (GtkWidget *widget,
+ GtkWidget *label)
+{
+ GSList *old_list, *new_list;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GTK_IS_WIDGET (label));
+
+ old_list = g_object_steal_qdata (G_OBJECT (widget), quark_mnemonic_labels);
+ new_list = g_slist_remove (old_list, label);
+
+ if (new_list)
+ g_object_set_qdata_full (G_OBJECT (widget), quark_mnemonic_labels,
+ new_list, (GDestroyNotify) g_slist_free);
+}
+
/**
* gtk_widget_get_no_show_all:
* @widget: a #GtkWidget
else
GTK_WIDGET_UNSET_FLAGS (widget, GTK_NO_SHOW_ALL);
- g_object_notify (G_OBJECT (widget), "no_show_all");
+ g_object_notify (G_OBJECT (widget), "no-show-all");
}
+
+#define __GTK_WIDGET_C__
+#include "gtkaliasdef.c"