gtkwidget.c 335 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
Elliot Lee's avatar
Elliot Lee committed
2
3
4
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 *
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
Elliot Lee's avatar
Elliot Lee committed
6
7
8
9
10
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
12
 * Lesser General Public License for more details.
Elliot Lee's avatar
Elliot Lee committed
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
16
17
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
18
 */
19
20

/*
21
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22
23
24
25
26
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
 */

27
#include "config.h"
Elliot Lee's avatar
Elliot Lee committed
28
29
#include <stdarg.h>
#include <string.h>
30
#include <locale.h>
Elliot Lee's avatar
Elliot Lee committed
31
#include "gtkcontainer.h"
32
#include "gtkaccelmap.h"
33
#include "gtkclipboard.h"
34
#include "gtkiconfactory.h"
35
#include "gtkintl.h"
Elliot Lee's avatar
Elliot Lee committed
36
#include "gtkmain.h"
37
#include "gtkmarshalers.h"
Elliot Lee's avatar
Elliot Lee committed
38
39
#include "gtkrc.h"
#include "gtkselection.h"
40
#include "gtksettings.h"
41
#include "gtksizegroup.h"
Elliot Lee's avatar
Elliot Lee committed
42
43
#include "gtkwidget.h"
#include "gtkwindow.h"
Tim Janik's avatar
Tim Janik committed
44
#include "gtkbindings.h"
45
#include "gtkprivate.h"
Elliot Lee's avatar
Elliot Lee committed
46
#include "gdk/gdk.h"
47
#include "gdk/gdkprivate.h" /* Used in gtk_reset_shapes_recurse to avoid copy */
Tim Janik's avatar
Tim Janik committed
48
49
#include <gobject/gvaluecollector.h>
#include <gobject/gobjectnotifyqueue.c>
Owen Taylor's avatar
Owen Taylor committed
50
#include "gdk/gdkkeysyms.h"
51
#include "gtkaccessible.h"
Kristian Rietveld's avatar
Kristian Rietveld committed
52
#include "gtktooltip.h"
53
#include "gtkinvisible.h"
Johan Dahlin's avatar
Johan Dahlin committed
54
#include "gtkbuildable.h"
55
#include "gtkbuilderprivate.h"
56
#include "gtkalias.h"
Elliot Lee's avatar
Elliot Lee committed
57

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
 * SECTION:gtkwidget
 * @Short_description: Base class for all widgets
 * @Title: 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
 * properties</firstterm> - these are basically object properties that are stored
 * not on the object, but in the style object associated to the widget. Style
 * properties are set in <link linkend="gtk-Resource-Files">resource files</link>.
 * This mechanism is used for configuring such things as the location of the
 * scrollbar arrows through the theme, giving theme authors more control over the
 * look of applications without the need to write a theme engine in C.
 * </para>
 * <para>
 * Use gtk_widget_class_install_style_property() to install style properties for
 * a widget class, gtk_widget_class_find_style_property() or
 * gtk_widget_class_list_style_properties() to get information about existing
 * style properties and gtk_widget_style_get_property(), gtk_widget_style_get() or
 * gtk_widget_style_get_valist() to obtain the value of a style property.
 * </para>
 * </refsect2>
 * <refsect2 id="GtkWidget-BUILDER-UI">
 * <title>GtkWidget as GtkBuildable</title>
 * <para>
 * The GtkWidget implementation of the GtkBuildable interface supports a
 * custom &lt;accelerator&gt; element, which has attributes named key,
 * modifiers and signal and allows to specify accelerators.
 * </para>
 * <example>
 * <title>A UI definition fragment specifying an accelerator</title>
 * <programlisting><![CDATA[
 * <object class="GtkButton">
 *   <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="clicked"/>
 * </object>
 * ]]></programlisting>
 * </example>
 * <para>
 * In addition to accelerators, <structname>GtkWidget</structname> also support a
 * custom &lt;accessible&gt; element, which supports actions and relations.
 * Properties on the accessible implementation of an object can be set by accessing the
 * internal child "accessible" of a <structname>GtkWidget</structname>.
 * </para>
 * <example>
 * <title>A UI definition fragment specifying an accessible</title>
 * <programlisting><![CDATA[
 * <object class="GtkButton" id="label1"/>
 *   <property name="label">I am a Label for a Button</property>
 * </object>
 * <object class="GtkButton" id="button1">
 *   <accessibility>
 *     <action action_name="click" translatable="yes">Click the button.</action>
 *     <relation target="label1" type="labelled-by"/>
 *   </accessibility>
 *   <child internal-child="accessible">
 *     <object class="AtkObject" id="a11y-button1">
 *       <property name="AtkObject::name">Clickable Button</property>
 *     </object>
 *   </child>
 * </object>
 * ]]></programlisting>
 * </example>
 * </refsect2>
 */

126
#define WIDGET_CLASS(w)	 GTK_WIDGET_GET_CLASS (w)
Tim Janik's avatar
Tim Janik committed
127
#define	INIT_PATH_SIZE	(512)
Elliot Lee's avatar
Elliot Lee committed
128
129
130
131
132
133
134
135
136
137
138
139


enum {
  SHOW,
  HIDE,
  MAP,
  UNMAP,
  REALIZE,
  UNREALIZE,
  SIZE_REQUEST,
  SIZE_ALLOCATE,
  STATE_CHANGED,
140
  PARENT_SET,
Owen Taylor's avatar
Owen Taylor committed
141
  HIERARCHY_CHANGED,
142
  STYLE_SET,
143
  DIRECTION_CHANGED,
144
  GRAB_NOTIFY,
Tim Janik's avatar
Tim Janik committed
145
  CHILD_NOTIFY,
146
  MNEMONIC_ACTIVATE,
147
  GRAB_FOCUS,
148
  FOCUS,
149
  MOVE_FOCUS,
Elliot Lee's avatar
Elliot Lee committed
150
  EVENT,
151
  EVENT_AFTER,
Elliot Lee's avatar
Elliot Lee committed
152
153
  BUTTON_PRESS_EVENT,
  BUTTON_RELEASE_EVENT,
154
  SCROLL_EVENT,
Elliot Lee's avatar
Elliot Lee committed
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
  MOTION_NOTIFY_EVENT,
  DELETE_EVENT,
  DESTROY_EVENT,
  EXPOSE_EVENT,
  KEY_PRESS_EVENT,
  KEY_RELEASE_EVENT,
  ENTER_NOTIFY_EVENT,
  LEAVE_NOTIFY_EVENT,
  CONFIGURE_EVENT,
  FOCUS_IN_EVENT,
  FOCUS_OUT_EVENT,
  MAP_EVENT,
  UNMAP_EVENT,
  PROPERTY_NOTIFY_EVENT,
  SELECTION_CLEAR_EVENT,
  SELECTION_REQUEST_EVENT,
  SELECTION_NOTIFY_EVENT,
172
  SELECTION_GET,
Elliot Lee's avatar
Elliot Lee committed
173
174
175
  SELECTION_RECEIVED,
  PROXIMITY_IN_EVENT,
  PROXIMITY_OUT_EVENT,
176
177
178
179
180
181
182
183
  DRAG_BEGIN,
  DRAG_END,
  DRAG_DATA_DELETE,
  DRAG_LEAVE,
  DRAG_MOTION,
  DRAG_DROP,
  DRAG_DATA_GET,
  DRAG_DATA_RECEIVED,
184
  CLIENT_EVENT,
185
  NO_EXPOSE_EVENT,
186
  VISIBILITY_NOTIFY_EVENT,
Havoc Pennington's avatar
Havoc Pennington committed
187
  WINDOW_STATE_EVENT,
Owen Taylor's avatar
Owen Taylor committed
188
  POPUP_MENU,
189
  SHOW_HELP,
190
  ACCEL_CLOSURES_CHANGED,
Owen Taylor's avatar
Owen Taylor committed
191
  SCREEN_CHANGED,
192
  CAN_ACTIVATE_ACCEL,
193
  GRAB_BROKEN,
Søren Sandmann's avatar
Søren Sandmann committed
194
  COMPOSITED_CHANGED,
Kristian Rietveld's avatar
Kristian Rietveld committed
195
  QUERY_TOOLTIP,
196
  KEYNAV_FAILED,
197
  DRAG_FAILED,
198
  DAMAGE_EVENT,
Elliot Lee's avatar
Elliot Lee committed
199
200
201
  LAST_SIGNAL
};

202
enum {
Alexander Larsson's avatar
Alexander Larsson committed
203
204
205
  PROP_0,
  PROP_NAME,
  PROP_PARENT,
Havoc Pennington's avatar
Havoc Pennington committed
206
207
  PROP_WIDTH_REQUEST,
  PROP_HEIGHT_REQUEST,
Alexander Larsson's avatar
Alexander Larsson committed
208
209
210
211
212
  PROP_VISIBLE,
  PROP_SENSITIVE,
  PROP_APP_PAINTABLE,
  PROP_CAN_FOCUS,
  PROP_HAS_FOCUS,
213
  PROP_IS_FOCUS,
Alexander Larsson's avatar
Alexander Larsson committed
214
215
216
217
218
219
  PROP_CAN_DEFAULT,
  PROP_HAS_DEFAULT,
  PROP_RECEIVES_DEFAULT,
  PROP_COMPOSITE_CHILD,
  PROP_STYLE,
  PROP_EVENTS,
220
  PROP_EXTENSION_EVENTS,
Kristian Rietveld's avatar
Kristian Rietveld committed
221
222
  PROP_NO_SHOW_ALL,
  PROP_HAS_TOOLTIP,
223
  PROP_TOOLTIP_MARKUP,
Tim Janik's avatar
Tim Janik committed
224
  PROP_TOOLTIP_TEXT,
225
226
  PROP_WINDOW,
  PROP_DOUBLE_BUFFERED
227
228
};

229
230
231
232
233
typedef	struct	_GtkStateData	 GtkStateData;

struct _GtkStateData
{
  GtkStateType  state;
234
  guint		state_restoration : 1;
235
  guint         parent_sensitive : 1;
236
  guint		use_forall : 1;
237
};
Elliot Lee's avatar
Elliot Lee committed
238

Tim Janik's avatar
Tim Janik committed
239
/* --- prototypes --- */
240
241
242
static void	gtk_widget_class_init		(GtkWidgetClass     *klass);
static void	gtk_widget_base_class_finalize	(GtkWidgetClass     *klass);
static void	gtk_widget_init			(GtkWidget          *widget);
Tim Janik's avatar
Tim Janik committed
243
static void	gtk_widget_set_property		 (GObject           *object,
Alexander Larsson's avatar
Alexander Larsson committed
244
245
246
						  guint              prop_id,
						  const GValue      *value,
						  GParamSpec        *pspec);
Tim Janik's avatar
Tim Janik committed
247
static void	gtk_widget_get_property		 (GObject           *object,
Alexander Larsson's avatar
Alexander Larsson committed
248
249
250
						  guint              prop_id,
						  GValue            *value,
						  GParamSpec        *pspec);
Tim Janik's avatar
Tim Janik committed
251
static void	gtk_widget_dispose		 (GObject	    *object);
Tim Janik's avatar
Tim Janik committed
252
253
254
255
256
257
258
259
260
static void	gtk_widget_real_destroy		 (GtkObject	    *object);
static void	gtk_widget_finalize		 (GObject	    *object);
static void	gtk_widget_real_show		 (GtkWidget	    *widget);
static void	gtk_widget_real_hide		 (GtkWidget	    *widget);
static void	gtk_widget_real_map		 (GtkWidget	    *widget);
static void	gtk_widget_real_unmap		 (GtkWidget	    *widget);
static void	gtk_widget_real_realize		 (GtkWidget	    *widget);
static void	gtk_widget_real_unrealize	 (GtkWidget	    *widget);
static void	gtk_widget_real_size_request	 (GtkWidget	    *widget,
261
						  GtkRequisition    *requisition);
Tim Janik's avatar
Tim Janik committed
262
static void	gtk_widget_real_size_allocate	 (GtkWidget	    *widget,
263
						  GtkAllocation	    *allocation);
264
265
266
267
static void	gtk_widget_real_style_set        (GtkWidget         *widget,
                                                  GtkStyle          *previous_style);
static void	gtk_widget_real_direction_changed(GtkWidget         *widget,
                                                  GtkTextDirection   previous_direction);
268

Tim Janik's avatar
Tim Janik committed
269
static void	gtk_widget_real_grab_focus	 (GtkWidget         *focus_widget);
Kristian Rietveld's avatar
Kristian Rietveld committed
270
271
272
273
274
static gboolean gtk_widget_real_query_tooltip    (GtkWidget         *widget,
						  gint               x,
						  gint               y,
						  gboolean           keyboard_tip,
						  GtkTooltip        *tooltip);
275
static gboolean gtk_widget_real_show_help        (GtkWidget         *widget,
276
277
                                                  GtkWidgetHelpType  help_type);

Tim Janik's avatar
Tim Janik committed
278
279
280
281
282
283
284
285
286
287
288
289
290
static void	gtk_widget_dispatch_child_properties_changed	(GtkWidget        *object,
								 guint             n_pspecs,
								 GParamSpec      **pspecs);
static gboolean		gtk_widget_real_key_press_event   	(GtkWidget        *widget,
								 GdkEventKey      *event);
static gboolean		gtk_widget_real_key_release_event 	(GtkWidget        *widget,
								 GdkEventKey      *event);
static gboolean		gtk_widget_real_focus_in_event   	 (GtkWidget       *widget,
								  GdkEventFocus   *event);
static gboolean		gtk_widget_real_focus_out_event   	(GtkWidget        *widget,
								 GdkEventFocus    *event);
static gboolean		gtk_widget_real_focus			(GtkWidget        *widget,
								 GtkDirectionType  direction);
291
292
static void             gtk_widget_real_move_focus              (GtkWidget        *widget,
                                                                 GtkDirectionType  direction);
293
294
static gboolean		gtk_widget_real_keynav_failed		(GtkWidget        *widget,
								 GtkDirectionType  direction);
Tim Janik's avatar
Tim Janik committed
295
static PangoContext*	gtk_widget_peek_pango_context		(GtkWidget	  *widget);
296
static void     	gtk_widget_update_pango_context		(GtkWidget	  *widget);
Tim Janik's avatar
Tim Janik committed
297
298
static void		gtk_widget_propagate_state		(GtkWidget	  *widget,
								 GtkStateData 	  *data);
299
static void             gtk_widget_reset_rc_style               (GtkWidget        *widget);
Tim Janik's avatar
Tim Janik committed
300
301
302
303
304
305
306
307
308
309
310
static void		gtk_widget_set_style_internal		(GtkWidget	  *widget,
								 GtkStyle	  *style,
								 gboolean	   initial_emission);
static gint		gtk_widget_event_internal		(GtkWidget	  *widget,
								 GdkEvent	  *event);
static gboolean		gtk_widget_real_mnemonic_activate	(GtkWidget	  *widget,
								 gboolean	   group_cycling);
static void		gtk_widget_aux_info_destroy		(GtkWidgetAuxInfo *aux_info);
static AtkObject*	gtk_widget_real_get_accessible		(GtkWidget	  *widget);
static void		gtk_widget_accessible_interface_init	(AtkImplementorIface *iface);
static AtkObject*	gtk_widget_ref_accessible		(AtkImplementor *implementor);
311
312
static void             gtk_widget_invalidate_widget_windows    (GtkWidget        *widget,
								 GdkRegion        *region);
313
static GdkScreen *      gtk_widget_get_screen_unchecked         (GtkWidget        *widget);
Soeren Sandmann's avatar
Soeren Sandmann committed
314
static void		gtk_widget_queue_shallow_draw		(GtkWidget        *widget);
315
316
static gboolean         gtk_widget_real_can_activate_accel      (GtkWidget *widget,
                                                                 guint      signal_id);
Kristian Rietveld's avatar
Kristian Rietveld committed
317

318
static void             gtk_widget_real_set_has_tooltip         (GtkWidget *widget,
Kristian Rietveld's avatar
Kristian Rietveld committed
319
320
								 gboolean   has_tooltip,
								 gboolean   force);
Johan Dahlin's avatar
Johan Dahlin committed
321
322
323
324
static void             gtk_widget_buildable_interface_init     (GtkBuildableIface *iface);
static void             gtk_widget_buildable_set_name           (GtkBuildable     *buildable,
                                                                 const gchar      *name);
static const gchar *    gtk_widget_buildable_get_name           (GtkBuildable     *buildable);
325
326
327
static GObject *        gtk_widget_buildable_get_internal_child (GtkBuildable *buildable,
								 GtkBuilder   *builder,
								 const gchar  *childname);
328
329
330
331
static void             gtk_widget_buildable_set_buildable_property (GtkBuildable     *buildable,
								     GtkBuilder       *builder,
								     const gchar      *name,
								     const GValue     *value);
Johan Dahlin's avatar
Johan Dahlin committed
332
333
334
335
336
337
static gboolean         gtk_widget_buildable_custom_tag_start   (GtkBuildable     *buildable,
                                                                 GtkBuilder       *builder,
                                                                 GObject          *child,
                                                                 const gchar      *tagname,
                                                                 GMarkupParser    *parser,
                                                                 gpointer         *data);
338
static void             gtk_widget_buildable_custom_finished    (GtkBuildable     *buildable,
Johan Dahlin's avatar
Johan Dahlin committed
339
340
341
342
                                                                 GtkBuilder       *builder,
                                                                 GObject          *child,
                                                                 const gchar      *tagname,
                                                                 gpointer          data);
343
static void             gtk_widget_buildable_parser_finished    (GtkBuildable     *buildable,
Johan Dahlin's avatar
Johan Dahlin committed
344
345
                                                                 GtkBuilder       *builder);

Matthias Clasen's avatar
Matthias Clasen committed
346
static void             gtk_widget_queue_tooltip_query          (GtkWidget *widget);
347
     
348
349
350
static void gtk_widget_set_usize_internal (GtkWidget *widget,
					   gint       width,
					   gint       height);
351
352
static void gtk_widget_get_draw_rectangle (GtkWidget    *widget,
					   GdkRectangle *rect);
353

Tim Janik's avatar
Tim Janik committed
354
355

/* --- variables --- */
356
static gpointer         gtk_widget_parent_class = NULL;
357
358
359
360
361
362
static guint            widget_signals[LAST_SIGNAL] = { 0 };
static GtkStyle        *gtk_default_style = NULL;
static GSList          *colormap_stack = NULL;
static guint            composite_child_stack = 0;
static GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR;
static GParamSpecPool  *style_property_spec_pool = NULL;
363

Tim Janik's avatar
Tim Janik committed
364
365
static GQuark		quark_property_parser = 0;
static GQuark		quark_aux_info = 0;
366
367
static GQuark		quark_accel_path = 0;
static GQuark		quark_accel_closures = 0;
Tim Janik's avatar
Tim Janik committed
368
369
370
static GQuark		quark_event_mask = 0;
static GQuark		quark_extension_event_mode = 0;
static GQuark		quark_parent_window = 0;
371
static GQuark		quark_pointer_window = 0;
Tim Janik's avatar
Tim Janik committed
372
static GQuark		quark_shape_info = 0;
373
static GQuark		quark_input_shape_info = 0;
Tim Janik's avatar
Tim Janik committed
374
375
376
377
static GQuark		quark_colormap = 0;
static GQuark		quark_pango_context = 0;
static GQuark		quark_rc_style = 0;
static GQuark		quark_accessible_object = 0;
378
static GQuark		quark_mnemonic_labels = 0;
Kristian Rietveld's avatar
Kristian Rietveld committed
379
380
381
static GQuark		quark_tooltip_markup = 0;
static GQuark		quark_has_tooltip = 0;
static GQuark		quark_tooltip_window = 0;
Tim Janik's avatar
Tim Janik committed
382
383
384
385
GParamSpecPool         *_gtk_widget_child_property_pool = NULL;
GObjectNotifyContext   *_gtk_widget_child_property_notify_context = NULL;

/* --- functions --- */
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
GType
gtk_widget_get_type (void)
{
  static GType widget_type = 0;

  if (G_UNLIKELY (widget_type == 0))
    {
      const GTypeInfo widget_info =
      {
	sizeof (GtkWidgetClass),
	NULL,		/* base_init */
	(GBaseFinalizeFunc) gtk_widget_base_class_finalize,
	(GClassInitFunc) gtk_widget_class_init,
	NULL,		/* class_finalize */
	NULL,		/* class_init */
	sizeof (GtkWidget),
	0,		/* n_preallocs */
	(GInstanceInitFunc) gtk_widget_init,
	NULL,		/* value_table */
      };

      const GInterfaceInfo accessibility_info =
      {
	(GInterfaceInitFunc) gtk_widget_accessible_interface_init,
	(GInterfaceFinalizeFunc) NULL,
	NULL /* interface data */
      };

Johan Dahlin's avatar
Johan Dahlin committed
414
415
416
417
418
419
420
      const GInterfaceInfo buildable_info =
      {
	(GInterfaceInitFunc) gtk_widget_buildable_interface_init,
	(GInterfaceFinalizeFunc) NULL,
	NULL /* interface data */
      };

421
422
423
424
425
      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) ;
Johan Dahlin's avatar
Johan Dahlin committed
426
427
      g_type_add_interface_static (widget_type, GTK_TYPE_BUILDABLE,
                                   &buildable_info) ;
428
429
430
431
432

    }

  return widget_type;
}
Elliot Lee's avatar
Elliot Lee committed
433

Tim Janik's avatar
Tim Janik committed
434
435
436
437
438
439
440
441
static void
child_property_notify_dispatcher (GObject     *object,
				  guint        n_pspecs,
				  GParamSpec **pspecs)
{
  GTK_WIDGET_GET_CLASS (object)->dispatch_child_properties_changed (GTK_WIDGET (object), n_pspecs, pspecs);
}

Elliot Lee's avatar
Elliot Lee committed
442
443
444
static void
gtk_widget_class_init (GtkWidgetClass *klass)
{
Tim Janik's avatar
Tim Janik committed
445
  static GObjectNotifyContext cpn_context = { 0, NULL, NULL };
446
447
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
Owen Taylor's avatar
Owen Taylor committed
448
  GtkBindingSet *binding_set;
449
450
451

  gtk_widget_parent_class = g_type_class_peek_parent (klass);

Tim Janik's avatar
Tim Janik committed
452
453
  quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser");
  quark_aux_info = g_quark_from_static_string ("gtk-aux-info");
454
455
  quark_accel_path = g_quark_from_static_string ("gtk-accel-path");
  quark_accel_closures = g_quark_from_static_string ("gtk-accel-closures");
Tim Janik's avatar
Tim Janik committed
456
457
458
  quark_event_mask = g_quark_from_static_string ("gtk-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");
459
  quark_pointer_window = g_quark_from_static_string ("gtk-pointer-window");
Tim Janik's avatar
Tim Janik committed
460
  quark_shape_info = g_quark_from_static_string ("gtk-shape-info");
461
  quark_input_shape_info = g_quark_from_static_string ("gtk-input-shape-info");
Tim Janik's avatar
Tim Janik committed
462
463
464
465
  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");
466
  quark_mnemonic_labels = g_quark_from_static_string ("gtk-mnemonic-labels");
Kristian Rietveld's avatar
Kristian Rietveld committed
467
468
469
  quark_tooltip_markup = g_quark_from_static_string ("gtk-tooltip-markup");
  quark_has_tooltip = g_quark_from_static_string ("gtk-has-tooltip");
  quark_tooltip_window = g_quark_from_static_string ("gtk-tooltip-window");
Tim Janik's avatar
Tim Janik committed
470
471
472
473
474
475

  style_property_spec_pool = g_param_spec_pool_new (FALSE);
  _gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE);
  cpn_context.quark_notify_queue = g_quark_from_static_string ("GtkWidget-child-property-notify-queue");
  cpn_context.dispatcher = child_property_notify_dispatcher;
  _gtk_widget_child_property_notify_context = &cpn_context;
476

Tim Janik's avatar
Tim Janik committed
477
  gobject_class->dispose = gtk_widget_dispose;
478
  gobject_class->finalize = gtk_widget_finalize;
Alexander Larsson's avatar
Alexander Larsson committed
479
480
  gobject_class->set_property = gtk_widget_set_property;
  gobject_class->get_property = gtk_widget_get_property;
481
482

  object_class->destroy = gtk_widget_real_destroy;
483
  
484
485
  klass->activate_signal = 0;
  klass->set_scroll_adjustments_signal = 0;
Tim Janik's avatar
Tim Janik committed
486
  klass->dispatch_child_properties_changed = gtk_widget_dispatch_child_properties_changed;
487
488
489
490
491
492
493
494
495
496
497
498
  klass->show = gtk_widget_real_show;
  klass->show_all = gtk_widget_show;
  klass->hide = gtk_widget_real_hide;
  klass->hide_all = gtk_widget_hide;
  klass->map = gtk_widget_real_map;
  klass->unmap = gtk_widget_real_unmap;
  klass->realize = gtk_widget_real_realize;
  klass->unrealize = gtk_widget_real_unrealize;
  klass->size_request = gtk_widget_real_size_request;
  klass->size_allocate = gtk_widget_real_size_allocate;
  klass->state_changed = NULL;
  klass->parent_set = NULL;
Owen Taylor's avatar
Owen Taylor committed
499
  klass->hierarchy_changed = NULL;
500
501
  klass->style_set = gtk_widget_real_style_set;
  klass->direction_changed = gtk_widget_real_direction_changed;
Tim Janik's avatar
Tim Janik committed
502
503
  klass->grab_notify = NULL;
  klass->child_notify = NULL;
504
  klass->mnemonic_activate = gtk_widget_real_mnemonic_activate;
505
  klass->grab_focus = gtk_widget_real_grab_focus;
506
  klass->focus = gtk_widget_real_focus;
507
508
509
510
511
512
513
514
515
516
517
518
  klass->event = NULL;
  klass->button_press_event = NULL;
  klass->button_release_event = NULL;
  klass->motion_notify_event = NULL;
  klass->delete_event = NULL;
  klass->destroy_event = NULL;
  klass->expose_event = NULL;
  klass->key_press_event = gtk_widget_real_key_press_event;
  klass->key_release_event = gtk_widget_real_key_release_event;
  klass->enter_notify_event = NULL;
  klass->leave_notify_event = NULL;
  klass->configure_event = NULL;
519
520
  klass->focus_in_event = gtk_widget_real_focus_in_event;
  klass->focus_out_event = gtk_widget_real_focus_out_event;
521
522
  klass->map_event = NULL;
  klass->unmap_event = NULL;
Havoc Pennington's avatar
Havoc Pennington committed
523
  klass->window_state_event = NULL;
524
  klass->property_notify_event = _gtk_selection_property_notify;
525
  klass->selection_clear_event = gtk_selection_clear;
526
527
  klass->selection_request_event = _gtk_selection_request;
  klass->selection_notify_event = _gtk_selection_notify;
528
529
530
531
532
533
534
535
536
537
  klass->selection_received = NULL;
  klass->proximity_in_event = NULL;
  klass->proximity_out_event = NULL;
  klass->drag_begin = NULL;
  klass->drag_end = NULL;
  klass->drag_data_delete = NULL;
  klass->drag_leave = NULL;
  klass->drag_motion = NULL;
  klass->drag_drop = NULL;
  klass->drag_data_received = NULL;
Owen Taylor's avatar
Owen Taylor committed
538
  klass->screen_changed = NULL;
539
  klass->can_activate_accel = gtk_widget_real_can_activate_accel;
540
  klass->grab_broken_event = NULL;
Kristian Rietveld's avatar
Kristian Rietveld committed
541
  klass->query_tooltip = gtk_widget_real_query_tooltip;
542
543
544
545
546
547

  klass->show_help = gtk_widget_real_show_help;
  
  /* Accessibility support */
  klass->get_accessible = gtk_widget_real_get_accessible;

548
549
  klass->no_expose_event = NULL;

Alexander Larsson's avatar
Alexander Larsson committed
550
551
552
  g_object_class_install_property (gobject_class,
				   PROP_NAME,
				   g_param_spec_string ("name",
553
554
 							P_("Widget name"),
							P_("The name of the widget"),
Alexander Larsson's avatar
Alexander Larsson committed
555
							NULL,
556
							GTK_PARAM_READWRITE));
Alexander Larsson's avatar
Alexander Larsson committed
557
558
559
  g_object_class_install_property (gobject_class,
				   PROP_PARENT,
				   g_param_spec_object ("parent",
560
561
							P_("Parent widget"), 
							P_("The parent widget of this widget. Must be a Container widget"),
Alexander Larsson's avatar
Alexander Larsson committed
562
							GTK_TYPE_CONTAINER,
563
							GTK_PARAM_READWRITE));
Havoc Pennington's avatar
Havoc Pennington committed
564

Alexander Larsson's avatar
Alexander Larsson committed
565
  g_object_class_install_property (gobject_class,
Havoc Pennington's avatar
Havoc Pennington committed
566
				   PROP_WIDTH_REQUEST,
Matthias Clasen's avatar
x    
Matthias Clasen committed
567
				   g_param_spec_int ("width-request",
568
569
 						     P_("Width request"),
 						     P_("Override for width request of the widget, or -1 if natural request should be used"),
Alexander Larsson's avatar
Alexander Larsson committed
570
571
572
 						     -1,
 						     G_MAXINT,
 						     -1,
573
 						     GTK_PARAM_READWRITE));
Alexander Larsson's avatar
Alexander Larsson committed
574
  g_object_class_install_property (gobject_class,
Havoc Pennington's avatar
Havoc Pennington committed
575
				   PROP_HEIGHT_REQUEST,
Matthias Clasen's avatar
x    
Matthias Clasen committed
576
				   g_param_spec_int ("height-request",
577
578
 						     P_("Height request"),
 						     P_("Override for height request of the widget, or -1 if natural request should be used"),
Alexander Larsson's avatar
Alexander Larsson committed
579
580
581
 						     -1,
 						     G_MAXINT,
 						     -1,
582
 						     GTK_PARAM_READWRITE));
Alexander Larsson's avatar
Alexander Larsson committed
583
584
585
  g_object_class_install_property (gobject_class,
				   PROP_VISIBLE,
				   g_param_spec_boolean ("visible",
586
587
 							 P_("Visible"),
 							 P_("Whether the widget is visible"),
Alexander Larsson's avatar
Alexander Larsson committed
588
 							 FALSE,
589
 							 GTK_PARAM_READWRITE));
Alexander Larsson's avatar
Alexander Larsson committed
590
591
592
  g_object_class_install_property (gobject_class,
				   PROP_SENSITIVE,
				   g_param_spec_boolean ("sensitive",
593
594
 							 P_("Sensitive"),
 							 P_("Whether the widget responds to input"),
Alexander Larsson's avatar
Alexander Larsson committed
595
 							 TRUE,
596
 							 GTK_PARAM_READWRITE));
Alexander Larsson's avatar
Alexander Larsson committed
597
598
  g_object_class_install_property (gobject_class,
				   PROP_APP_PAINTABLE,
Matthias Clasen's avatar
x    
Matthias Clasen committed
599
				   g_param_spec_boolean ("app-paintable",
600
601
 							 P_("Application paintable"),
 							 P_("Whether the application will paint directly on the widget"),
Alexander Larsson's avatar
Alexander Larsson committed
602
 							 FALSE,
603
 							 GTK_PARAM_READWRITE));
Alexander Larsson's avatar
Alexander Larsson committed
604
605
  g_object_class_install_property (gobject_class,
				   PROP_CAN_FOCUS,
Matthias Clasen's avatar
x    
Matthias Clasen committed
606
				   g_param_spec_boolean ("can-focus",
607
608
 							 P_("Can focus"),
 							 P_("Whether the widget can accept the input focus"),
Alexander Larsson's avatar
Alexander Larsson committed
609
 							 FALSE,
610
 							 GTK_PARAM_READWRITE));
Alexander Larsson's avatar
Alexander Larsson committed
611
612
  g_object_class_install_property (gobject_class,
				   PROP_HAS_FOCUS,
Matthias Clasen's avatar
x    
Matthias Clasen committed
613
				   g_param_spec_boolean ("has-focus",
614
615
 							 P_("Has focus"),
 							 P_("Whether the widget has the input focus"),
Alexander Larsson's avatar
Alexander Larsson committed
616
 							 FALSE,
617
 							 GTK_PARAM_READWRITE));
618
  g_object_class_install_property (gobject_class,
619
				   PROP_IS_FOCUS,
Matthias Clasen's avatar
x    
Matthias Clasen committed
620
				   g_param_spec_boolean ("is-focus",
621
622
 							 P_("Is focus"),
 							 P_("Whether the widget is the focus widget within the toplevel"),
623
 							 FALSE,
624
 							 GTK_PARAM_READWRITE));
Alexander Larsson's avatar
Alexander Larsson committed
625
626
  g_object_class_install_property (gobject_class,
				   PROP_CAN_DEFAULT,
Matthias Clasen's avatar
x    
Matthias Clasen committed
627
				   g_param_spec_boolean ("can-default",
628
629
 							 P_("Can default"),
 							 P_("Whether the widget can be the default widget"),
Alexander Larsson's avatar
Alexander Larsson committed
630
 							 FALSE,
631
 							 GTK_PARAM_READWRITE));
Alexander Larsson's avatar
Alexander Larsson committed
632
633
  g_object_class_install_property (gobject_class,
				   PROP_HAS_DEFAULT,
Matthias Clasen's avatar
x    
Matthias Clasen committed
634
				   g_param_spec_boolean ("has-default",
635
636
 							 P_("Has default"),
 							 P_("Whether the widget is the default widget"),
Alexander Larsson's avatar
Alexander Larsson committed
637
 							 FALSE,
638
 							 GTK_PARAM_READWRITE));
Alexander Larsson's avatar
Alexander Larsson committed
639
640
  g_object_class_install_property (gobject_class,
				   PROP_RECEIVES_DEFAULT,
Matthias Clasen's avatar
x    
Matthias Clasen committed
641
				   g_param_spec_boolean ("receives-default",
642
643
 							 P_("Receives default"),
 							 P_("If TRUE, the widget will receive the default action when it is focused"),
Alexander Larsson's avatar
Alexander Larsson committed
644
 							 FALSE,
645
 							 GTK_PARAM_READWRITE));
Alexander Larsson's avatar
Alexander Larsson committed
646
647
  g_object_class_install_property (gobject_class,
				   PROP_COMPOSITE_CHILD,
Matthias Clasen's avatar
x    
Matthias Clasen committed
648
				   g_param_spec_boolean ("composite-child",
649
650
 							 P_("Composite child"),
 							 P_("Whether the widget is part of a composite widget"),
Alexander Larsson's avatar
Alexander Larsson committed
651
 							 FALSE,
652
 							 GTK_PARAM_READABLE));
Alexander Larsson's avatar
Alexander Larsson committed
653
654
655
  g_object_class_install_property (gobject_class,
				   PROP_STYLE,
				   g_param_spec_object ("style",
656
657
 							P_("Style"),
 							P_("The style of the widget, which contains information about how it will look (colors etc)"),
Alexander Larsson's avatar
Alexander Larsson committed
658
 							GTK_TYPE_STYLE,
659
 							GTK_PARAM_READWRITE));
Alexander Larsson's avatar
Alexander Larsson committed
660
661
662
  g_object_class_install_property (gobject_class,
				   PROP_EVENTS,
				   g_param_spec_flags ("events",
663
664
 						       P_("Events"),
 						       P_("The event mask that decides what kind of GdkEvents this widget gets"),
665
 						       GDK_TYPE_EVENT_MASK,
Alexander Larsson's avatar
Alexander Larsson committed
666
 						       GDK_STRUCTURE_MASK,
667
 						       GTK_PARAM_READWRITE));
Alexander Larsson's avatar
Alexander Larsson committed
668
669
  g_object_class_install_property (gobject_class,
				   PROP_EXTENSION_EVENTS,
Matthias Clasen's avatar
x    
Matthias Clasen committed
670
				   g_param_spec_enum ("extension-events",
671
672
 						      P_("Extension events"),
 						      P_("The mask that decides what kind of extension events this widget gets"),
673
 						      GDK_TYPE_EXTENSION_MODE,
Alexander Larsson's avatar
Alexander Larsson committed
674
 						      GDK_EXTENSION_EVENTS_NONE,
675
 						      GTK_PARAM_READWRITE));
676
677
  g_object_class_install_property (gobject_class,
				   PROP_NO_SHOW_ALL,
Matthias Clasen's avatar
x    
Matthias Clasen committed
678
				   g_param_spec_boolean ("no-show-all",
679
680
 							 P_("No show all"),
 							 P_("Whether gtk_widget_show_all() should not affect this widget"),
681
 							 FALSE,
682
 							 GTK_PARAM_READWRITE));
Kristian Rietveld's avatar
Kristian Rietveld committed
683
684
685
686

/**
 * GtkWidget:has-tooltip:
 *
687
688
689
 * Enables or disables the emission of #GtkWidget::query-tooltip on @widget.  
 * A value of %TRUE indicates that @widget can have a tooltip, in this case
 * the widget will be queried using #GtkWidget::query-tooltip to determine
Kristian Rietveld's avatar
Kristian Rietveld committed
690
691
 * whether it will provide a tooltip or not.
 *
692
693
694
695
696
 * Note that setting this property to %TRUE for the first time will change
 * the event masks of the GdkWindows of this widget to include leave-notify
 * and motion-notify events.  This cannot and will not be undone when the
 * property is set to %FALSE again.
 *
Kristian Rietveld's avatar
Kristian Rietveld committed
697
698
699
700
701
702
703
704
705
 * Since: 2.12
 */
  g_object_class_install_property (gobject_class,
				   PROP_HAS_TOOLTIP,
				   g_param_spec_boolean ("has-tooltip",
 							 P_("Has tooltip"),
 							 P_("Whether this widget has a tooltip"),
 							 FALSE,
 							 GTK_PARAM_READWRITE));
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
  /**
   * GtkWidget:tooltip-text:
   *
   * Sets the text of tooltip to be the given string.
   *
   * Also see gtk_tooltip_set_text().
   *
   * This is a convenience property which will take care of getting the
   * tooltip shown if the given string is not %NULL: #GtkWidget:has-tooltip
   * will automatically be set to %TRUE and there will be taken care of
   * #GtkWidget::query-tooltip in the default signal handler.
   *
   * Since: 2.12
   */
  g_object_class_install_property (gobject_class,
                                   PROP_TOOLTIP_TEXT,
                                   g_param_spec_string ("tooltip-text",
                                                        P_("Tooltip Text"),
                                                        P_("The contents of the tooltip for this widget"),
                                                        NULL,
                                                        GTK_PARAM_READWRITE));
  /**
   * GtkWidget:tooltip-markup:
   *
   * Sets the text of tooltip to be the given string, which is marked up
   * with the <link linkend="PangoMarkupFormat">Pango text markup language</link>.
   * Also see gtk_tooltip_set_markup().
   *
   * This is a convenience property which will take care of getting the
   * tooltip shown if the given string is not %NULL: #GtkWidget:has-tooltip
   * will automatically be set to %TRUE and there will be taken care of
   * #GtkWidget::query-tooltip in the default signal handler.
   *
   * Since: 2.12
   */
Kristian Rietveld's avatar
Kristian Rietveld committed
741
742
743
744
745
746
747
748
  g_object_class_install_property (gobject_class,
				   PROP_TOOLTIP_MARKUP,
				   g_param_spec_string ("tooltip-markup",
 							P_("Tooltip markup"),
							P_("The contents of the tooltip for this widget"),
							NULL,
							GTK_PARAM_READWRITE));

Tim Janik's avatar
Tim Janik committed
749
750
751
  /**
   * GtkWidget:window:
   *
752
   * The widget's window if it is realized, %NULL otherwise.
Tim Janik's avatar
Tim Janik committed
753
   *
754
   * Since: 2.14
Tim Janik's avatar
Tim Janik committed
755
756
757
758
759
   */
  g_object_class_install_property (gobject_class,
				   PROP_WINDOW,
				   g_param_spec_object ("window",
 							P_("Window"),
760
							P_("The widget's window if it is realized"),
Tim Janik's avatar
Tim Janik committed
761
762
763
							GDK_TYPE_WINDOW,
							GTK_PARAM_READABLE));

764
  /**
765
   * GtkWidget:double-buffered
766
767
768
769
770
771
772
773
774
775
776
777
778
   *
   * Whether or not the widget is double buffered.
   *
   * Since: 2.18
   */
  g_object_class_install_property (gobject_class,
                                   PROP_DOUBLE_BUFFERED,
                                   g_param_spec_boolean ("double-buffered",
                                                         P_("Double Buffered"),
                                                         P_("Whether or not the widget is double buffered"),
                                                         TRUE,
                                                         GTK_PARAM_READWRITE));

779
780
781
782
  /**
   * GtkWidget::show:
   * @widget: the object which received the signal.
   */
Elliot Lee's avatar
Elliot Lee committed
783
  widget_signals[SHOW] =
Matthias Clasen's avatar
Matthias Clasen committed
784
    g_signal_new (I_("show"),
Manish Singh's avatar
Manish Singh committed
785
786
787
788
789
790
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_FIRST,
		  G_STRUCT_OFFSET (GtkWidgetClass, show),
		  NULL, NULL,
		  _gtk_marshal_VOID__VOID,
		  G_TYPE_NONE, 0);
791
792
793
794
795

  /**
   * GtkWidget::hide:
   * @widget: the object which received the signal.
   */
Elliot Lee's avatar
Elliot Lee committed
796
  widget_signals[HIDE] =
Matthias Clasen's avatar
Matthias Clasen committed
797
    g_signal_new (I_("hide"),
Manish Singh's avatar
Manish Singh committed
798
799
800
801
802
803
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_FIRST,
		  G_STRUCT_OFFSET (GtkWidgetClass, hide),
		  NULL, NULL,
		  _gtk_marshal_VOID__VOID,
		  G_TYPE_NONE, 0);
804
805
806
807
808

  /**
   * GtkWidget::map:
   * @widget: the object which received the signal.
   */
Elliot Lee's avatar
Elliot Lee committed
809
  widget_signals[MAP] =
Matthias Clasen's avatar
Matthias Clasen committed
810
    g_signal_new (I_("map"),
Manish Singh's avatar
Manish Singh committed
811
812
813
814
815
816
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_FIRST,
		  G_STRUCT_OFFSET (GtkWidgetClass, map),
		  NULL, NULL,
		  _gtk_marshal_VOID__VOID,
		  G_TYPE_NONE, 0);
817
818
819
820
821

  /**
   * GtkWidget::unmap:
   * @widget: the object which received the signal.
   */
Elliot Lee's avatar
Elliot Lee committed
822
  widget_signals[UNMAP] =
Matthias Clasen's avatar
Matthias Clasen committed
823
    g_signal_new (I_("unmap"),
Manish Singh's avatar
Manish Singh committed
824
825
826
827
828
829
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_FIRST,
		  G_STRUCT_OFFSET (GtkWidgetClass, unmap),
		  NULL, NULL,
		  _gtk_marshal_VOID__VOID,
		  G_TYPE_NONE, 0);
830
831
832
833
834

  /**
   * GtkWidget::realize:
   * @widget: the object which received the signal.
   */
Elliot Lee's avatar
Elliot Lee committed
835
  widget_signals[REALIZE] =
Matthias Clasen's avatar
Matthias Clasen committed
836
    g_signal_new (I_("realize"),
Manish Singh's avatar
Manish Singh committed
837
838
839
840
841
842
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_FIRST,
		  G_STRUCT_OFFSET (GtkWidgetClass, realize),
		  NULL, NULL,
		  _gtk_marshal_VOID__VOID,
		  G_TYPE_NONE, 0);
843
844
845
846
847

  /**
   * GtkWidget::unrealize:
   * @widget: the object which received the signal.
   */
Elliot Lee's avatar
Elliot Lee committed
848
  widget_signals[UNREALIZE] =
Matthias Clasen's avatar
Matthias Clasen committed
849
    g_signal_new (I_("unrealize"),
Manish Singh's avatar
Manish Singh committed
850
851
852
853
854
855
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkWidgetClass, unrealize),
		  NULL, NULL,
		  _gtk_marshal_VOID__VOID,
		  G_TYPE_NONE, 0);
856
857
858
859
860
861

  /**
   * GtkWidget::size-request:
   * @widget: the object which received the signal.
   * @requisition:
   */
Elliot Lee's avatar
Elliot Lee committed
862
  widget_signals[SIZE_REQUEST] =
Sven Neumann's avatar
Sven Neumann committed
863
    g_signal_new (I_("size-request"),
Manish Singh's avatar
Manish Singh committed
864
865
866
867
868
869
870
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_FIRST,
		  G_STRUCT_OFFSET (GtkWidgetClass, size_request),
		  NULL, NULL,
		  _gtk_marshal_VOID__BOXED,
		  G_TYPE_NONE, 1,
		  GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE);
871
872
873
874
875
876

  /**
   * GtkWidget::size-allocate:
   * @widget: the object which received the signal.
   * @allocation:
   */
877
  widget_signals[SIZE_ALLOCATE] = 
Sven Neumann's avatar
Sven Neumann committed
878
    g_signal_new (I_("size-allocate"),
Manish Singh's avatar
Manish Singh committed
879
880
881
882
883
884
885
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_FIRST,
		  G_STRUCT_OFFSET (GtkWidgetClass, size_allocate),
		  NULL, NULL,
		  _gtk_marshal_VOID__BOXED,
		  G_TYPE_NONE, 1,
		  GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
Matthias Clasen's avatar
Matthias Clasen committed
886

887
888
889
  /**
   * GtkWidget::state-changed:
   * @widget: the object which received the signal.
890
891
892
893
   * @state: the previous state
   *
   * The ::state-changed signal is emitted when the widget state changes.
   * See gtk_widget_get_state().
894
   */
Elliot Lee's avatar
Elliot Lee committed
895
  widget_signals[STATE_CHANGED] =
Sven Neumann's avatar
Sven Neumann committed
896
    g_signal_new (I_("state-changed"),
Manish Singh's avatar
Manish Singh committed
897
898
899
900
901
902
903
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_FIRST,
		  G_STRUCT_OFFSET (GtkWidgetClass, state_changed),
		  NULL, NULL,
		  _gtk_marshal_VOID__ENUM,
		  G_TYPE_NONE, 1,
		  GTK_TYPE_STATE_TYPE);
904
905
906
907
908
909
910

  /**
   * GtkWidget::parent-set:
   * @widget: the object on which the signal is emitted
   * @old_parent: the previous parent, or %NULL if the widget 
   *   just got its initial parent.
   *
911
912
   * The ::parent-set signal is emitted when a new parent 
   * has been set on a widget. 
913
   */
914
  widget_signals[PARENT_SET] =
Sven Neumann's avatar
Sven Neumann committed
915
    g_signal_new (I_("parent-set"),
Manish Singh's avatar
Manish Singh committed
916
917
918
919
920
921
922
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_FIRST,
		  G_STRUCT_OFFSET (GtkWidgetClass, parent_set),
		  NULL, NULL,
		  _gtk_marshal_VOID__OBJECT,
		  G_TYPE_NONE, 1,
		  GTK_TYPE_WIDGET);
Matthias Clasen's avatar
Matthias Clasen committed
923
924
925
926
927
928
929
930

  /**
   * GtkWidget::hierarchy-changed:
   * @widget: the object on which the signal is emitted
   * @previous_toplevel: the previous toplevel ancestor, or %NULL
   *   if the widget was previously unanchored
   *
   * The ::hierarchy-changed signal is emitted when the
931
932
933
934
   * anchored state of a widget changes. A widget is
   * <firstterm>anchored</firstterm> when its toplevel
   * ancestor is a #GtkWindow. This signal is emitted when
   * a widget changes from un-anchored to anchored or vice-versa.
Matthias Clasen's avatar
Matthias Clasen committed
935
   */
Owen Taylor's avatar
Owen Taylor committed
936
  widget_signals[HIERARCHY_CHANGED] =
Sven Neumann's avatar
Sven Neumann committed
937
    g_signal_new (I_("hierarchy-changed"),
Manish Singh's avatar
Manish Singh committed
938
939
940
941
942
943
944
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkWidgetClass, hierarchy_changed),
		  NULL, NULL,
		  _gtk_marshal_VOID__OBJECT,
		  G_TYPE_NONE, 1,
		  GTK_TYPE_WIDGET);
Matthias Clasen's avatar
Matthias Clasen committed
945

946
947
948
949
950
951
  /**
   * 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 
   *
952
   * The ::style-set signal is emitted when a new style has been set 
953
954
955
   * on a widget. Note that style-modifying functions like 
   * gtk_widget_modify_base() also cause this signal to be emitted.
   */
956
  widget_signals[STYLE_SET] =
Sven Neumann's avatar
Sven Neumann committed
957
    g_signal_new (I_("style-set"),
Manish Singh's avatar
Manish Singh committed
958
959
960
961
962
963
964
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_FIRST,
		  G_STRUCT_OFFSET (GtkWidgetClass, style_set),
		  NULL, NULL,
		  _gtk_marshal_VOID__OBJECT,
		  G_TYPE_NONE, 1,
		  GTK_TYPE_STYLE);
Matthias Clasen's avatar
Matthias Clasen committed
965
966
967
968
969
970
971
972
/**
 * GtkWidget::direction-changed:
 * @widget: the object on which the signal is emitted
 * @previous_direction: the previous text direction of @widget
 *
 * The ::direction-changed signal is emitted when the text direction
 * of a widget changes.
 */
973
  widget_signals[DIRECTION_CHANGED] =
Sven Neumann's avatar
Sven Neumann committed
974
    g_signal_new (I_("direction-changed"),
Manish Singh's avatar
Manish Singh committed
975
976
977
978
979
980
981
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_FIRST,
		  G_STRUCT_OFFSET (GtkWidgetClass, direction_changed),
		  NULL, NULL,
		  _gtk_marshal_VOID__ENUM,
		  G_TYPE_NONE, 1,
		  GTK_TYPE_TEXT_DIRECTION);
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997

  /**
   * 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.
   */
998
  widget_signals[GRAB_NOTIFY] =
Sven Neumann's avatar
Sven Neumann committed
999
    g_signal_new (I_("grab-notify"),
Manish Singh's avatar
Manish Singh committed
1000
1001
1002
1003
1004
1005
1006
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_FIRST,
                  G_STRUCT_OFFSET (GtkWidgetClass, grab_notify),
		  NULL, NULL,
		  _gtk_marshal_VOID__BOOLEAN,
		  G_TYPE_NONE, 1,
		  G_TYPE_BOOLEAN);
1007
1008
1009

/**
 * GtkWidget::child-notify:
1010
1011
 * @widget: the object which received the signal
 * @pspec: the #GParamSpec of the changed child property
1012
 *
1013
1014
 * The ::child-notify signal is emitted for each 
 * <link linkend="child-properties">child property</link>  that has
1015
1016
 * changed on an object. The signal's detail holds the property name. 
 */
Tim Janik's avatar
Tim Janik committed
1017
  widget_signals[CHILD_NOTIFY] =
Sven Neumann's avatar
Sven Neumann committed
1018
    g_signal_new (I_("child-notify"),
Manish Singh's avatar
Manish Singh committed
1019
		   G_TYPE_FROM_CLASS (gobject_class),
Tim Janik's avatar
Tim Janik committed
1020
1021
1022
1023
		   G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS,
		   G_STRUCT_OFFSET (GtkWidgetClass, child_notify),
		   NULL, NULL,
		   g_cclosure_marshal_VOID__PARAM,
Manish Singh's avatar
Manish Singh committed
1024
1025
		   G_TYPE_NONE, 1,
		   G_TYPE_PARAM);
1026
1027
1028
1029
1030
1031

  /**
   * GtkWidget::mnemonic-activate:
   * @widget: the object which received the signal.
   * @arg1:
   */
1032
  widget_signals[MNEMONIC_ACTIVATE] =
Sven Neumann's avatar
Sven Neumann committed
1033
    g_signal_new (I_("mnemonic-activate"),
Manish Singh's avatar
Manish Singh committed
1034
1035
1036
1037
1038
1039
1040
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkWidgetClass, mnemonic_activate),
		  _gtk_boolean_handled_accumulator, NULL,
		  _gtk_marshal_BOOLEAN__BOOLEAN,
		  G_TYPE_BOOLEAN, 1,
		  G_TYPE_BOOLEAN);
1041
1042
1043
1044
1045

  /**
   * GtkWidget::grab-focus:
   * @widget: the object which received the signal.
   */
1046
  widget_signals[GRAB_FOCUS] =
Sven Neumann's avatar
Sven Neumann committed
1047
    g_signal_new (I_("grab-focus"),
Manish Singh's avatar
Manish Singh committed
1048
1049
1050
1051
1052
1053
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
		  G_STRUCT_OFFSET (GtkWidgetClass, grab_focus),
		  NULL, NULL,
		  _gtk_marshal_VOID__VOID,
		  G_TYPE_NONE, 0);
1054
1055
1056
1057
1058
1059
1060
1061

  /**
   * GtkWidget::focus:
   * @widget: the object which received the signal.
   * @direction:
   *
   * Returns: %TRUE to stop other handlers from being invoked for the event. %FALSE to propagate the event further.
   */
1062
  widget_signals[FOCUS] =
Matthias Clasen's avatar
Matthias Clasen committed
1063
    g_signal_new (I_("focus"),
Manish Singh's avatar
Manish Singh committed
1064
1065
1066
1067
1068
1069
1070
		  G_TYPE_FROM_CLASS (object_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkWidgetClass, focus),
		  _gtk_boolean_handled_accumulator, NULL,
		  _gtk_marshal_BOOLEAN__ENUM,
		  G_TYPE_BOOLEAN, 1,
		  GTK_TYPE_DIRECTION_TYPE);
1071
1072
1073
1074
1075
1076

  /**
   * GtkWidget::move-focus:
   * @widget: the object which received the signal.
   * @direction:
   */
1077
  widget_signals[MOVE_FOCUS] =
Sven Neumann's avatar
Sven Neumann committed
1078
    g_signal_new_class_handler (I_("move-focus"),
1079
1080
1081
1082
1083
1084
1085
1086
                                G_TYPE_FROM_CLASS (object_class),
                                G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                                G_CALLBACK (gtk_widget_real_move_focus),
                                NULL, NULL,
                                _gtk_marshal_VOID__ENUM,
                                G_TYPE_NONE,
                                1,
                                GTK_TYPE_DIRECTION_TYPE);
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
  /**
   * GtkWidget::event:
   * @widget: the object which received the signal.
   * @event: the #GdkEvent which triggered this signal
   *
   * The GTK+ main loop will emit three signals for each GDK event delivered
   * to a widget: one generic ::event signal, another, more specific,
   * signal that matches the type of event delivered (e.g. 
   * #GtkWidget::key-press-event) and finally a generic 
   * #GtkWidget::event-after signal.
   *
   * Returns: %TRUE to stop other handlers from being invoked for the event 
   * and to cancel the emission of the second specific ::event signal.
   *   %FALSE to propagate the event further and to allow the emission of 
   *   the second signal. The ::event-after signal is emitted regardless of
   *   the return value.
   */
Elliot Lee's avatar
Elliot Lee committed
1104
  widget_signals[EVENT] =
Matthias Clasen's avatar
Matthias Clasen committed
1105
    g_signal_new (I_("event"),
Manish Singh's avatar
Manish Singh committed
1106
1107
1108
1109
1110
1111
1112
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkWidgetClass, event),
		  _gtk_boolean_handled_accumulator, NULL,
		  _gtk_marshal_BOOLEAN__BOXED,
		  G_TYPE_BOOLEAN, 1,
		  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123

  /**
   * GtkWidget::event-after:
   * @widget: the object which received the signal.
   * @event: the #GdkEvent which triggered this signal
   *
   * After the emission of the #GtkWidget::event signal and (optionally) 
   * the second more specific signal, ::event-after will be emitted 
   * regardless of the previous two signals handlers return values.
   *
   */
1124
  widget_signals[EVENT_AFTER] =
Sven Neumann's avatar
Sven Neumann committed
1125
    g_signal_new (I_("event-after"),
Manish Singh's avatar
Manish Singh committed
1126
1127
1128
1129
1130
1131
1132
		  G_TYPE_FROM_CLASS (gobject_class),
		  0,
		  0,
		  NULL, NULL,
		  _gtk_marshal_VOID__BOXED,
		  G_TYPE_NONE, 1,
		  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149

  /**
   * GtkWidget::button-press-event:
   * @widget: the object which received the signal.
   * @event: the #GdkEventButton which triggered this signal
   *
   * The ::button-press-event signal will be emitted when a button
   * (typically from a mouse) is pressed.
   *
   * To receive this signal, the #GdkWindow associated to the 
   * widget needs to enable the #GDK_BUTTON_PRESS_MASK mask.
   *
   * This signal will be sent to the grab widget if there is one.
   *
   * Returns: %TRUE to stop other handlers from being invoked for the event. 
   *   %FALSE to propagate the event further.
   */
Elliot Lee's avatar
Elliot Lee committed
1150
  widget_signals[BUTTON_PRESS_EVENT] =
Sven Neumann's avatar
Sven Neumann committed
1151
    g_signal_new (I_("button-press-event"),
Manish Singh's avatar
Manish Singh committed
1152
1153
1154
1155
1156
1157
1158
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkWidgetClass, button_press_event),
		  _gtk_boolean_handled_accumulator, NULL,
		  _gtk_marshal_BOOLEAN__BOXED,
		  G_TYPE_BOOLEAN, 1,
		  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175

  /**
   * GtkWidget::button-release-event:
   * @widget: the object which received the signal.
   * @event: the #GdkEventButton which triggered this signal
   *
   * The ::button-release-event signal will be emitted when a button
   * (typically from a mouse) is released.
   *
   * To receive this signal, the #GdkWindow associated to the 
   * widget needs to enable the #GDK_BUTTON_RELEASE_MASK mask.
   *
   * This signal will be sent to the grab widget if there is one.
   *
   * Returns: %TRUE to stop other handlers from being invoked for the event. 
   *   %FALSE to propagate the event further.
   */
Elliot Lee's avatar
Elliot Lee committed
1176
  widget_signals[BUTTON_RELEASE_EVENT] =
Sven Neumann's avatar
Sven Neumann committed
1177
    g_signal_new (I_("button-release-event"),
Manish Singh's avatar
Manish Singh committed
1178
1179
1180
1181
1182
1183
1184
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkWidgetClass, button_release_event),
		  _gtk_boolean_handled_accumulator, NULL,
		  _gtk_marshal_BOOLEAN__BOXED,
		  G_TYPE_BOOLEAN, 1,
		  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202

  /**
   * GtkWidget::scroll-event:
   * @widget: the object which received the signal.
   * @event: 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 
   * button press events for buttons 4 and 5 when the wheel is turned.
   *
   * To receive this signal, the #GdkWindow associated to the widget needs
   * to enable the #GDK_BUTTON_PRESS_MASK mask.
   *
   * This signal will be sent to the grab widget if there is one.
   *
   * Returns: %TRUE to stop other handlers from being invoked for the event. 
   *   %FALSE to propagate the event further.
   */
1203
  widget_signals[SCROLL_EVENT] =
Sven Neumann's avatar
Sven Neumann committed
1204
    g_signal_new (I_("scroll-event"),
Manish Singh's avatar
Manish Singh committed
1205
1206
1207
1208
1209
1210
1211
		  G_TYPE_FROM_CLASS (gobject_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET (GtkWidgetClass, scroll_event),
		  _gtk_boolean_handled_accumulator, NULL,
		  _gtk_marshal_BOOLEAN__BOXED,
		  G_TYPE_BOOLEAN, 1,
		  GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
  /**
   * GtkWidget::motion-notify-event:
   * @widget: the object which received the signal.
   * @event: the #GdkEventMotion which triggered this signal
   *
   * The ::motion-notify-event signal is emitted when the pointer moves 
   * over the widget's #GdkWindow.
   *
   * To receive this signal, the #GdkWindow associated to the widget 
   * needs to enable the #GDK_POINTER_MOTION_MASK mask.
   *
   * This signal will be sent to the grab widget if there is one.
   *
   * Returns: %TRUE to stop other handlers from being invoked for the event. 
   *   %FALSE to propagate the event further.
   */
Elliot Lee's avatar
Elliot Lee committed