gtkwidget.c 168 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1 2 3 4
/* GTK - The GIMP Toolkit
 * 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/. 
 */

Elliot Lee's avatar
Elliot Lee committed
27 28
#include <stdarg.h>
#include <string.h>
29
#include <locale.h>
Elliot Lee's avatar
Elliot Lee committed
30
#include "gtkcontainer.h"
31
#include "gtkiconfactory.h"
32
#include "gtkintl.h"
Elliot Lee's avatar
Elliot Lee committed
33 34 35
#include "gtkmain.h"
#include "gtkrc.h"
#include "gtkselection.h"
36
#include "gtksettings.h"
37
#include "gtksizegroup.h"
Elliot Lee's avatar
Elliot Lee committed
38 39 40
#include "gtksignal.h"
#include "gtkwidget.h"
#include "gtkwindow.h"
Tim Janik's avatar
Tim Janik committed
41
#include "gtkbindings.h"
42
#include "gtkprivate.h"
Elliot Lee's avatar
Elliot Lee committed
43
#include "gdk/gdk.h"
44
#include "gdk/gdkprivate.h" /* Used in gtk_reset_shapes_recurse to avoid copy */
Tim Janik's avatar
Tim Janik committed
45 46
#include <gobject/gvaluecollector.h>
#include <gobject/gobjectnotifyqueue.c>
Owen Taylor's avatar
Owen Taylor committed
47
#include "gdk/gdkkeysyms.h"
Alexander Larsson's avatar
Alexander Larsson committed
48
#include "gtkintl.h"
49
#include "gtkaccessible.h"
Elliot Lee's avatar
Elliot Lee committed
50

51
#define WIDGET_CLASS(w)	 GTK_WIDGET_GET_CLASS (w)
Tim Janik's avatar
Tim Janik committed
52
#define	INIT_PATH_SIZE	(512)
Elliot Lee's avatar
Elliot Lee committed
53 54 55 56 57 58 59 60 61 62 63 64


enum {
  SHOW,
  HIDE,
  MAP,
  UNMAP,
  REALIZE,
  UNREALIZE,
  SIZE_REQUEST,
  SIZE_ALLOCATE,
  STATE_CHANGED,
65
  PARENT_SET,
Owen Taylor's avatar
Owen Taylor committed
66
  HIERARCHY_CHANGED,
67
  STYLE_SET,
68
  DIRECTION_CHANGED,
69
  GRAB_NOTIFY,
Tim Janik's avatar
Tim Janik committed
70
  CHILD_NOTIFY,
Tim Janik's avatar
Tim Janik committed
71
  ADD_ACCELERATOR,
Elliot Lee's avatar
Elliot Lee committed
72
  REMOVE_ACCELERATOR,
73
  ACTIVATE_MNEMONIC,
74
  GRAB_FOCUS,
75
  FOCUS,
Elliot Lee's avatar
Elliot Lee committed
76 77 78
  EVENT,
  BUTTON_PRESS_EVENT,
  BUTTON_RELEASE_EVENT,
79
  SCROLL_EVENT,
Elliot Lee's avatar
Elliot Lee committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
  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,
97
  SELECTION_GET,
Elliot Lee's avatar
Elliot Lee committed
98 99 100
  SELECTION_RECEIVED,
  PROXIMITY_IN_EVENT,
  PROXIMITY_OUT_EVENT,
101 102 103 104 105 106 107 108
  DRAG_BEGIN,
  DRAG_END,
  DRAG_DATA_DELETE,
  DRAG_LEAVE,
  DRAG_MOTION,
  DRAG_DROP,
  DRAG_DATA_GET,
  DRAG_DATA_RECEIVED,
109
  CLIENT_EVENT,
110
  NO_EXPOSE_EVENT,
111
  VISIBILITY_NOTIFY_EVENT,
Havoc Pennington's avatar
Havoc Pennington committed
112
  WINDOW_STATE_EVENT,
Owen Taylor's avatar
Owen Taylor committed
113
  POPUP_MENU,
Elliot Lee's avatar
Elliot Lee committed
114 115 116
  LAST_SIGNAL
};

117
enum {
Alexander Larsson's avatar
Alexander Larsson committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
  PROP_0,
  PROP_NAME,
  PROP_PARENT,
  PROP_X,
  PROP_Y,
  PROP_WIDTH,
  PROP_HEIGHT,
  PROP_VISIBLE,
  PROP_SENSITIVE,
  PROP_APP_PAINTABLE,
  PROP_CAN_FOCUS,
  PROP_HAS_FOCUS,
  PROP_CAN_DEFAULT,
  PROP_HAS_DEFAULT,
  PROP_RECEIVES_DEFAULT,
  PROP_COMPOSITE_CHILD,
  PROP_STYLE,
  PROP_EVENTS,
  PROP_EXTENSION_EVENTS
137 138
};

139 140 141 142 143
typedef	struct	_GtkStateData	 GtkStateData;

struct _GtkStateData
{
  GtkStateType  state;
144
  guint		state_restoration : 1;
145
  guint         parent_sensitive : 1;
146
  guint		use_forall : 1;
147
};
Elliot Lee's avatar
Elliot Lee committed
148

Tim Janik's avatar
Tim Janik committed
149 150 151 152 153

/* --- prototypes --- */
static void	gtk_widget_class_init		 (GtkWidgetClass    *klass);
static void	gtk_widget_init			 (GtkWidget	    *widget);
static void	gtk_widget_set_property		 (GObject           *object,
Alexander Larsson's avatar
Alexander Larsson committed
154 155 156
						  guint              prop_id,
						  const GValue      *value,
						  GParamSpec        *pspec);
Tim Janik's avatar
Tim Janik committed
157
static void	gtk_widget_get_property		 (GObject           *object,
Alexander Larsson's avatar
Alexander Larsson committed
158 159 160
						  guint              prop_id,
						  GValue            *value,
						  GParamSpec        *pspec);
Tim Janik's avatar
Tim Janik committed
161 162 163 164 165 166 167 168 169 170
static void	gtk_widget_shutdown		 (GObject	    *object);
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,
171
						  GtkRequisition    *requisition);
Tim Janik's avatar
Tim Janik committed
172
static void	gtk_widget_real_size_allocate	 (GtkWidget	    *widget,
173
						  GtkAllocation	    *allocation);
Tim Janik's avatar
Tim Janik committed
174
static void	gtk_widget_style_set		 (GtkWidget	    *widget,
175
						  GtkStyle          *previous_style);
Tim Janik's avatar
Tim Janik committed
176
static void	gtk_widget_direction_changed	 (GtkWidget	    *widget,
177
						  GtkTextDirection   previous_direction);
Tim Janik's avatar
Tim Janik committed
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
static void	gtk_widget_real_grab_focus	 (GtkWidget         *focus_widget);
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);
static GdkColormap*	gtk_widget_peek_colormap		(void);
static GtkStyle*	gtk_widget_peek_style			(void);
static PangoContext*	gtk_widget_peek_pango_context		(GtkWidget	  *widget);
static void		gtk_widget_reparent_container_child	(GtkWidget	  *widget,
								 gpointer          client_data);
static void		gtk_widget_propagate_state		(GtkWidget	  *widget,
								 GtkStateData 	  *data);
static void		gtk_widget_set_style_internal		(GtkWidget	  *widget,
								 GtkStyle	  *style,
								 gboolean	   initial_emission);
static void		gtk_widget_set_style_recurse		(GtkWidget	  *widget,
								 gpointer	   client_data);
static gint		gtk_widget_event_internal		(GtkWidget	  *widget,
								 GdkEvent	  *event);
static void		gtk_widget_propagate_hierarchy_changed	(GtkWidget	  *widget,
								 gpointer	   client_data);
static gboolean		gtk_widget_real_mnemonic_activate	(GtkWidget	  *widget,
								 gboolean	   group_cycling);
static void		gtk_widget_aux_info_destroy		(GtkWidgetAuxInfo *aux_info);
static void		gtk_widget_do_uposition			(GtkWidget	  *widget);
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);


/* --- variables --- */
218 219 220 221 222 223 224 225 226 227
static gpointer         parent_class = NULL;
static guint            widget_signals[LAST_SIGNAL] = { 0 };
static GMemChunk       *aux_info_mem_chunk = NULL;
static GdkColormap     *default_colormap = NULL;
static GtkStyle        *gtk_default_style = NULL;
static GSList          *colormap_stack = NULL;
static GSList          *style_stack = NULL;
static guint            composite_child_stack = 0;
static GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR;
static GParamSpecPool  *style_property_spec_pool = NULL;
Tim Janik's avatar
Tim Janik committed
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
static GQuark		quark_property_parser = 0;
static GQuark		quark_aux_info = 0;
static GQuark		quark_event_mask = 0;
static GQuark		quark_extension_event_mode = 0;
static GQuark		quark_parent_window = 0;
static GQuark		quark_saved_default_style = 0;
static GQuark		quark_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;
GParamSpecPool         *_gtk_widget_child_property_pool = NULL;
GObjectNotifyContext   *_gtk_widget_child_property_notify_context = NULL;


/* --- functions --- */
244
GtkType
245
gtk_widget_get_type (void)
Elliot Lee's avatar
Elliot Lee committed
246
{
247
  static GtkType widget_type = 0;
248
  
Elliot Lee's avatar
Elliot Lee committed
249 250
  if (!widget_type)
    {
251
      static const GtkTypeInfo widget_info =
Elliot Lee's avatar
Elliot Lee committed
252 253 254 255 256 257
      {
	"GtkWidget",
	sizeof (GtkWidget),
	sizeof (GtkWidgetClass),
	(GtkClassInitFunc) gtk_widget_class_init,
	(GtkObjectInitFunc) gtk_widget_init,
258 259
        /* reserved_1 */ NULL,
	/* reserved_2 */ NULL,
260
	(GtkClassInitFunc) NULL,
Elliot Lee's avatar
Elliot Lee committed
261
      };
262
      
263 264 265 266 267 268 269 270
      static const GInterfaceInfo accessibility_info =
      {
        (GInterfaceInitFunc) gtk_widget_accessible_interface_init,
        (GInterfaceFinalizeFunc) NULL,
        NULL /* interface data */
      };

 
271
      widget_type = gtk_type_unique (GTK_TYPE_OBJECT, &widget_info);
272 273 274 275

      g_type_add_interface_static (widget_type, ATK_TYPE_IMPLEMENTOR,
                                   &accessibility_info) ;

Elliot Lee's avatar
Elliot Lee committed
276
    }
277
  
Elliot Lee's avatar
Elliot Lee committed
278 279 280
  return widget_type;
}

Tim Janik's avatar
Tim Janik committed
281 282 283 284 285 286 287 288
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
289 290 291
static void
gtk_widget_class_init (GtkWidgetClass *klass)
{
Tim Janik's avatar
Tim Janik committed
292
  static GObjectNotifyContext cpn_context = { 0, NULL, NULL };
293 294
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
  GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
Owen Taylor's avatar
Owen Taylor committed
295
  GtkBindingSet *binding_set;
296
  
Tim Janik's avatar
Tim Janik committed
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
  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_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");
  quark_saved_default_style = g_quark_from_static_string ("gtk-saved-default-style");
  quark_shape_info = g_quark_from_static_string ("gtk-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");

  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;
316 317 318

  gobject_class->shutdown = gtk_widget_shutdown;
  gobject_class->finalize = gtk_widget_finalize;
Alexander Larsson's avatar
Alexander Larsson committed
319 320
  gobject_class->set_property = gtk_widget_set_property;
  gobject_class->get_property = gtk_widget_get_property;
321 322

  object_class->destroy = gtk_widget_real_destroy;
323
  
324 325
  klass->activate_signal = 0;
  klass->set_scroll_adjustments_signal = 0;
Tim Janik's avatar
Tim Janik committed
326
  klass->dispatch_child_properties_changed = gtk_widget_dispatch_child_properties_changed;
327 328 329 330 331 332 333 334 335 336 337 338
  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
339
  klass->hierarchy_changed = NULL;
340
  klass->style_set = gtk_widget_style_set;
341
  klass->direction_changed = gtk_widget_direction_changed;
Tim Janik's avatar
Tim Janik committed
342 343
  klass->grab_notify = NULL;
  klass->child_notify = NULL;
344 345
  klass->add_accelerator = (void*) gtk_accel_group_handle_add;
  klass->remove_accelerator = (void*) gtk_accel_group_handle_remove;
346
  klass->mnemonic_activate = gtk_widget_real_mnemonic_activate;
347
  klass->grab_focus = gtk_widget_real_grab_focus;
348
  klass->focus = gtk_widget_real_focus;
349 350 351 352 353 354 355 356 357 358 359 360
  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;
361 362
  klass->focus_in_event = gtk_widget_real_focus_in_event;
  klass->focus_out_event = gtk_widget_real_focus_out_event;
363 364
  klass->map_event = NULL;
  klass->unmap_event = NULL;
Havoc Pennington's avatar
Havoc Pennington committed
365
  klass->window_state_event = NULL;
366 367 368 369 370 371 372 373 374 375 376 377 378 379
  klass->property_notify_event = gtk_selection_property_notify;
  klass->selection_clear_event = gtk_selection_clear;
  klass->selection_request_event = gtk_selection_request;
  klass->selection_notify_event = gtk_selection_notify;
  klass->selection_received = NULL;
  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;
Tim Janik's avatar
Tim Janik committed
380
  klass->get_accessible = gtk_widget_real_get_accessible;	/* Accessibility support */
381 382
  klass->no_expose_event = NULL;

Alexander Larsson's avatar
Alexander Larsson committed
383 384 385 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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
  g_object_class_install_property (gobject_class,
				   PROP_NAME,
				   g_param_spec_string ("name",
 							_("Widget name"),
							_("The name of the widget"),
							NULL,
							G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_PARENT,
				   g_param_spec_object ("parent",
							_("Parent widget"),
							_("The parent widget of this widget. Must be a Container widget."),
							GTK_TYPE_CONTAINER,
							G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_X,
				   g_param_spec_int ("x",
 						     _("x coordinate"),
 						     _("The x coordinate of the top-left corner of the widget, or -1 if not set"),
 						     -G_MAXINT,
 						     G_MAXINT,
 						     -1,
 						     G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_Y,
				   g_param_spec_int ("y",
 						     _("y coordinate"),
 						     _("The y coordinate of the top-left corner of the widget, or -1 if not set"),
 						     -G_MAXINT,
 						     G_MAXINT,
 						     -1,
 						     G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_WIDTH,
				   g_param_spec_int ("width",
 						     _("Width"),
 						     _("The width of the widget, or -1 if unset."),
 						     -1,
 						     G_MAXINT,
 						     -1,
 						     G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_HEIGHT,
				   g_param_spec_int ("height",
 						     _("Height"),
 						     _("The height of the widget, or -1 if unset."),
 						     -1,
 						     G_MAXINT,
 						     -1,
 						     G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_VISIBLE,
				   g_param_spec_boolean ("visible",
 							 _("Visible"),
 							 _("Whether the widget is visible"),
 							 FALSE,
 							 G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_SENSITIVE,
				   g_param_spec_boolean ("sensitive",
 							 _("Sensitive"),
 							 _("Whether the widget responds to input"),
 							 TRUE,
 							 G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_APP_PAINTABLE,
				   g_param_spec_boolean ("app_paintable",
 							 _("Application paintable"),
 							 _("Whether the application will paint directly on the widget"),
 							 FALSE,
 							 G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_CAN_FOCUS,
				   g_param_spec_boolean ("can_focus",
 							 _("Can focus"),
 							 _("Whether the widget can accept the input focus"),
 							 FALSE,
 							 G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_HAS_FOCUS,
				   g_param_spec_boolean ("has_focus",
 							 _("Has focus"),
 							 _("Whether the widget has the input focus"),
 							 FALSE,
 							 G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_CAN_DEFAULT,
				   g_param_spec_boolean ("can_default",
 							 _("Can default"),
 							 _("Whether the widget can be the default widget"),
 							 FALSE,
 							 G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_HAS_DEFAULT,
				   g_param_spec_boolean ("has_default",
 							 _("Has default"),
 							 _("Whether the widget is the default widget"),
 							 FALSE,
 							 G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_RECEIVES_DEFAULT,
				   g_param_spec_boolean ("receives_default",
 							 _("Receives default"),
 							 _("If TRUE, the widget will receive the default action when it is focused."),
 							 FALSE,
 							 G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_COMPOSITE_CHILD,
				   g_param_spec_boolean ("composite_child",
 							 _("Composite child"),
 							 _("Whether the widget is composed of other widgets"),
 							 FALSE,
495
 							 G_PARAM_READABLE));
Alexander Larsson's avatar
Alexander Larsson committed
496 497 498 499 500 501 502 503 504 505 506 507
  g_object_class_install_property (gobject_class,
				   PROP_STYLE,
				   g_param_spec_object ("style",
 							_("Style"),
 							_("The style of the widget, which contains information about how it will look (colors etc)."),
 							GTK_TYPE_STYLE,
 							G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_EVENTS,
				   g_param_spec_flags ("events",
 						       _("Events"),
 						       _("The event mask that decides what kind of GdkEvents this widget gets."),
508
 						       GDK_TYPE_EVENT_MASK,
Alexander Larsson's avatar
Alexander Larsson committed
509 510 511 512 513 514 515
 						       GDK_STRUCTURE_MASK,
 						       G_PARAM_READWRITE));
  g_object_class_install_property (gobject_class,
				   PROP_EXTENSION_EVENTS,
				   g_param_spec_enum ("extension_events",
 						      _("Extension events"),
 						      _("The mask that decides what kind of extension events this widget gets."),
516
 						      GDK_TYPE_EXTENSION_MODE,
Alexander Larsson's avatar
Alexander Larsson committed
517 518
 						      GDK_EXTENSION_EVENTS_NONE,
 						      G_PARAM_READWRITE));
Elliot Lee's avatar
Elliot Lee committed
519 520 521
  widget_signals[SHOW] =
    gtk_signal_new ("show",
		    GTK_RUN_FIRST,
522
		    GTK_CLASS_TYPE (object_class),
Elliot Lee's avatar
Elliot Lee committed
523
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, show),
524
		    gtk_marshal_VOID__VOID,
Elliot Lee's avatar
Elliot Lee committed
525 526 527 528
		    GTK_TYPE_NONE, 0);
  widget_signals[HIDE] =
    gtk_signal_new ("hide",
		    GTK_RUN_FIRST,
529
		    GTK_CLASS_TYPE (object_class),
Elliot Lee's avatar
Elliot Lee committed
530
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, hide),
531
		    gtk_marshal_VOID__VOID,
Elliot Lee's avatar
Elliot Lee committed
532 533 534 535
		    GTK_TYPE_NONE, 0);
  widget_signals[MAP] =
    gtk_signal_new ("map",
		    GTK_RUN_FIRST,
536
		    GTK_CLASS_TYPE (object_class),
Elliot Lee's avatar
Elliot Lee committed
537
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, map),
538
		    gtk_marshal_VOID__VOID,
Elliot Lee's avatar
Elliot Lee committed
539 540 541 542
		    GTK_TYPE_NONE, 0);
  widget_signals[UNMAP] =
    gtk_signal_new ("unmap",
		    GTK_RUN_FIRST,
543
		    GTK_CLASS_TYPE (object_class),
Elliot Lee's avatar
Elliot Lee committed
544
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, unmap),
545
		    gtk_marshal_VOID__VOID,
Elliot Lee's avatar
Elliot Lee committed
546 547 548 549
		    GTK_TYPE_NONE, 0);
  widget_signals[REALIZE] =
    gtk_signal_new ("realize",
		    GTK_RUN_FIRST,
550
		    GTK_CLASS_TYPE (object_class),
Elliot Lee's avatar
Elliot Lee committed
551
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, realize),
552
		    gtk_marshal_VOID__VOID,
Elliot Lee's avatar
Elliot Lee committed
553 554 555 556
		    GTK_TYPE_NONE, 0);
  widget_signals[UNREALIZE] =
    gtk_signal_new ("unrealize",
		    GTK_RUN_FIRST,
557
		    GTK_CLASS_TYPE (object_class),
Elliot Lee's avatar
Elliot Lee committed
558
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, unrealize),
559
		    gtk_marshal_VOID__VOID,
Elliot Lee's avatar
Elliot Lee committed
560 561
		    GTK_TYPE_NONE, 0);
  widget_signals[SIZE_REQUEST] =
562 563 564 565 566 567 568 569
    g_signal_newc ("size_request",
		   G_OBJECT_CLASS_TYPE (object_class),
		   G_SIGNAL_RUN_FIRST,
		   G_STRUCT_OFFSET (GtkWidgetClass, size_request),
		   NULL, NULL,
		   gtk_marshal_VOID__BOXED,
		   GTK_TYPE_NONE, 1,
		   GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE);
570
  widget_signals[SIZE_ALLOCATE] = 
Elliot Lee's avatar
Elliot Lee committed
571 572
    gtk_signal_new ("size_allocate",
		    GTK_RUN_FIRST,
573
		    GTK_CLASS_TYPE (object_class),
Elliot Lee's avatar
Elliot Lee committed
574
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, size_allocate),
Owen Taylor's avatar
Owen Taylor committed
575
		    gtk_marshal_VOID__BOXED,
Elliot Lee's avatar
Elliot Lee committed
576
		    GTK_TYPE_NONE, 1,
Owen Taylor's avatar
Owen Taylor committed
577
		    GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
Elliot Lee's avatar
Elliot Lee committed
578 579 580
  widget_signals[STATE_CHANGED] =
    gtk_signal_new ("state_changed",
		    GTK_RUN_FIRST,
581
		    GTK_CLASS_TYPE (object_class),
Elliot Lee's avatar
Elliot Lee committed
582
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, state_changed),
583
		    gtk_marshal_VOID__ENUM,
584
		    GTK_TYPE_NONE, 1,
585
		    GTK_TYPE_STATE_TYPE);
586 587
  widget_signals[PARENT_SET] =
    gtk_signal_new ("parent_set",
588
		    GTK_RUN_FIRST,
589
		    GTK_CLASS_TYPE (object_class),
590
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, parent_set),
Tim Janik's avatar
Tim Janik committed
591
		    gtk_marshal_VOID__OBJECT,
592 593
		    GTK_TYPE_NONE, 1,
		    GTK_TYPE_OBJECT);
Owen Taylor's avatar
Owen Taylor committed
594 595 596 597 598 599 600
  widget_signals[HIERARCHY_CHANGED] =
    gtk_signal_new ("hierarchy_changed",
		    GTK_RUN_LAST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, hierarchy_changed),
		    gtk_marshal_NONE__NONE,
		    GTK_TYPE_NONE, 0);
601 602 603
  widget_signals[STYLE_SET] =
    gtk_signal_new ("style_set",
		    GTK_RUN_FIRST,
604
		    GTK_CLASS_TYPE (object_class),
605
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, style_set),
Tim Janik's avatar
Tim Janik committed
606
		    gtk_marshal_VOID__OBJECT,
607
		    GTK_TYPE_NONE, 1,
608
		    GTK_TYPE_STYLE);
609 610 611 612 613
  widget_signals[DIRECTION_CHANGED] =
    gtk_signal_new ("direction_changed",
		    GTK_RUN_FIRST,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, direction_changed),
614
		    gtk_marshal_VOID__ENUM,
615 616
		    GTK_TYPE_NONE, 1,
		    GTK_TYPE_TEXT_DIRECTION);
617 618 619 620 621 622 623 624
  widget_signals[GRAB_NOTIFY] =
    gtk_signal_new ("grab_notify",
		    GTK_RUN_FIRST,
		    GTK_CLASS_TYPE (object_class),
                    GTK_SIGNAL_OFFSET (GtkWidgetClass, grab_notify),
		    gtk_marshal_VOID__BOOLEAN,
		    GTK_TYPE_NONE, 1,
		    GTK_TYPE_BOOL);
Tim Janik's avatar
Tim Janik committed
625 626 627 628 629 630 631 632 633
  widget_signals[CHILD_NOTIFY] =
    g_signal_newc ("child_notify",
		   G_TYPE_FROM_CLASS (klass),
		   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,
		   G_TYPE_NONE,
		   1, G_TYPE_PARAM);
Tim Janik's avatar
Tim Janik committed
634
  widget_signals[ADD_ACCELERATOR] =
635
    gtk_accel_group_create_add (GTK_CLASS_TYPE (object_class), GTK_RUN_LAST,
Tim Janik's avatar
Tim Janik committed
636
				GTK_SIGNAL_OFFSET (GtkWidgetClass, add_accelerator));
Elliot Lee's avatar
Elliot Lee committed
637
  widget_signals[REMOVE_ACCELERATOR] =
638
    gtk_accel_group_create_remove (GTK_CLASS_TYPE (object_class), GTK_RUN_LAST,
Tim Janik's avatar
Tim Janik committed
639
				   GTK_SIGNAL_OFFSET (GtkWidgetClass, remove_accelerator));
640
  widget_signals[ACTIVATE_MNEMONIC] =
641
    g_signal_newc ("mnemonic_activate",
642 643
		   GTK_CLASS_TYPE (object_class),
		   GTK_RUN_LAST,
644
		   GTK_SIGNAL_OFFSET (GtkWidgetClass, mnemonic_activate),
645
		   _gtk_boolean_handled_accumulator, NULL,
646 647 648
		   gtk_marshal_BOOLEAN__BOOLEAN,
		   GTK_TYPE_BOOL, 1,
		   GTK_TYPE_BOOL);
649 650
  widget_signals[GRAB_FOCUS] =
    gtk_signal_new ("grab_focus",
651
		    GTK_RUN_LAST | GTK_RUN_ACTION,
652
		    GTK_CLASS_TYPE (object_class),
653
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, grab_focus),
654
		    gtk_marshal_VOID__VOID,
655
		    GTK_TYPE_NONE, 0);
656 657 658 659 660 661 662 663 664
  widget_signals[FOCUS] =
    g_signal_newc ("focus",
                   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);
Elliot Lee's avatar
Elliot Lee committed
665
  widget_signals[EVENT] =
666 667 668 669 670 671 672 673
    g_signal_newc ("event",
		   G_TYPE_FROM_CLASS(object_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);
Elliot Lee's avatar
Elliot Lee committed
674
  widget_signals[BUTTON_PRESS_EVENT] =
675 676 677 678 679 680 681 682
    g_signal_newc ("button_press_event",
		   G_TYPE_FROM_CLASS(object_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);
Elliot Lee's avatar
Elliot Lee committed
683
  widget_signals[BUTTON_RELEASE_EVENT] =
684 685 686 687 688 689 690 691
    g_signal_newc ("button_release_event",
		   G_TYPE_FROM_CLASS(object_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);
692
  widget_signals[SCROLL_EVENT] =
693 694 695 696 697 698 699 700
    g_signal_newc ("scroll_event",
		   G_TYPE_FROM_CLASS(object_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);
Elliot Lee's avatar
Elliot Lee committed
701
  widget_signals[MOTION_NOTIFY_EVENT] =
702 703 704 705 706 707 708 709
    g_signal_newc ("motion_notify_event",
		   G_TYPE_FROM_CLASS(object_class),
		   G_SIGNAL_RUN_LAST,
		   G_STRUCT_OFFSET(GtkWidgetClass, motion_notify_event),
		   _gtk_boolean_handled_accumulator, NULL,
		   gtk_marshal_BOOLEAN__BOXED,
		   G_TYPE_BOOLEAN, 1,
		   GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
710
  widget_signals[DELETE_EVENT] =
711 712 713 714 715 716 717 718
    g_signal_newc ("delete_event",
		   G_TYPE_FROM_CLASS(object_class),
		   G_SIGNAL_RUN_LAST,
		   G_STRUCT_OFFSET(GtkWidgetClass, delete_event),
		   _gtk_boolean_handled_accumulator, NULL,
		   gtk_marshal_BOOLEAN__BOXED,
		   G_TYPE_BOOLEAN, 1,
		   GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
719
  widget_signals[DESTROY_EVENT] =
720 721 722 723 724 725 726 727
    g_signal_newc ("destroy_event",
		   G_TYPE_FROM_CLASS(object_class),
		   G_SIGNAL_RUN_LAST,
		   G_STRUCT_OFFSET(GtkWidgetClass, destroy_event),
		   _gtk_boolean_handled_accumulator, NULL,
		   gtk_marshal_BOOLEAN__BOXED,
		   G_TYPE_BOOLEAN, 1,
		   GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
728
  widget_signals[EXPOSE_EVENT] =
729 730 731 732 733 734 735 736
    g_signal_newc ("expose_event",
		   G_TYPE_FROM_CLASS(object_class),
		   G_SIGNAL_RUN_LAST,
		   G_STRUCT_OFFSET(GtkWidgetClass, expose_event),
		   _gtk_boolean_handled_accumulator, NULL,
		   gtk_marshal_BOOLEAN__BOXED,
		   G_TYPE_BOOLEAN, 1,
		   GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
737
  widget_signals[KEY_PRESS_EVENT] =
738 739 740 741 742 743 744 745
    g_signal_newc ("key_press_event",
		   G_TYPE_FROM_CLASS(object_class),
		   G_SIGNAL_RUN_LAST,
		   G_STRUCT_OFFSET(GtkWidgetClass, key_press_event),
		   _gtk_boolean_handled_accumulator, NULL,
		   gtk_marshal_BOOLEAN__BOXED,
		   G_TYPE_BOOLEAN, 1,
		   GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
746
  widget_signals[KEY_RELEASE_EVENT] =
747 748 749 750 751 752 753 754
    g_signal_newc ("key_release_event",
		   G_TYPE_FROM_CLASS(object_class),
		   G_SIGNAL_RUN_LAST,
		   G_STRUCT_OFFSET(GtkWidgetClass, key_release_event),
		   _gtk_boolean_handled_accumulator, NULL,
		   gtk_marshal_BOOLEAN__BOXED,
		   G_TYPE_BOOLEAN, 1,
		   GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
755
  widget_signals[ENTER_NOTIFY_EVENT] =
756 757 758 759 760 761 762 763
    g_signal_newc ("enter_notify_event",
		   G_TYPE_FROM_CLASS(object_class),
		   G_SIGNAL_RUN_LAST,
		   G_STRUCT_OFFSET(GtkWidgetClass, enter_notify_event),
		   _gtk_boolean_handled_accumulator, NULL,
		   gtk_marshal_BOOLEAN__BOXED,
		   G_TYPE_BOOLEAN, 1,
		   GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
764
  widget_signals[LEAVE_NOTIFY_EVENT] =
765 766 767 768 769 770 771 772
    g_signal_newc ("leave_notify_event",
		   G_TYPE_FROM_CLASS(object_class),
		   G_SIGNAL_RUN_LAST,
		   G_STRUCT_OFFSET(GtkWidgetClass, leave_notify_event),
		   _gtk_boolean_handled_accumulator, NULL,
		   gtk_marshal_BOOLEAN__BOXED,
		   G_TYPE_BOOLEAN, 1,
		   GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
773
  widget_signals[CONFIGURE_EVENT] =
774 775 776 777 778 779 780 781
    g_signal_newc ("configure_event",
		   G_TYPE_FROM_CLASS(object_class),
		   G_SIGNAL_RUN_LAST,
		   G_STRUCT_OFFSET(GtkWidgetClass, configure_event),
		   _gtk_boolean_handled_accumulator, NULL,
		   gtk_marshal_BOOLEAN__BOXED,
		   G_TYPE_BOOLEAN, 1,
		   GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
782
  widget_signals[FOCUS_IN_EVENT] =
783
    g_signal_newc ("focus_in_event",
784 785 786 787 788 789
                  G_TYPE_FROM_CLASS(object_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET(GtkWidgetClass, focus_in_event),
                  _gtk_boolean_handled_accumulator, NULL,
                  gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
790
                  GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
791
  widget_signals[FOCUS_OUT_EVENT] =
792
    g_signal_newc ("focus_out_event",
793 794 795 796 797 798
                  G_TYPE_FROM_CLASS(object_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET(GtkWidgetClass, focus_out_event),
                  _gtk_boolean_handled_accumulator, NULL,
                  gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
799
                  GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
800
  widget_signals[MAP_EVENT] =
801
    g_signal_newc ("map_event",
802 803 804 805 806 807
                  G_TYPE_FROM_CLASS(object_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET(GtkWidgetClass, map_event),
                  _gtk_boolean_handled_accumulator, NULL,
                  gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
808
                  GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
809
  widget_signals[UNMAP_EVENT] =
810
    g_signal_newc ("unmap_event",
811 812 813 814 815 816
                  G_TYPE_FROM_CLASS(object_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET(GtkWidgetClass, unmap_event),
                  _gtk_boolean_handled_accumulator, NULL,
                  gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
817
                  GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
818
  widget_signals[PROPERTY_NOTIFY_EVENT] =
819
    g_signal_newc ("property_notify_event",
820 821 822 823 824 825
                  G_TYPE_FROM_CLASS(object_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET(GtkWidgetClass, property_notify_event),
                  _gtk_boolean_handled_accumulator, NULL,
                  gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
826
                  GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
827
  widget_signals[SELECTION_CLEAR_EVENT] =
828
    g_signal_newc ("selection_clear_event",
829 830 831 832 833 834
                  G_TYPE_FROM_CLASS(object_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET(GtkWidgetClass, selection_clear_event),
                  _gtk_boolean_handled_accumulator, NULL,
                  gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
835
                  GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
836
  widget_signals[SELECTION_REQUEST_EVENT] =
837
    g_signal_newc ("selection_request_event",
838 839 840 841 842 843
                  G_TYPE_FROM_CLASS(object_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET(GtkWidgetClass, selection_request_event),
                  _gtk_boolean_handled_accumulator, NULL,
                  gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
844
                  GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
845
  widget_signals[SELECTION_NOTIFY_EVENT] =
846
    g_signal_newc ("selection_notify_event",
847 848 849 850 851 852
                  G_TYPE_FROM_CLASS(object_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET(GtkWidgetClass, selection_notify_event),
                  _gtk_boolean_handled_accumulator, NULL,
                  gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
853
                  GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
854 855 856
  widget_signals[SELECTION_RECEIVED] =
    gtk_signal_new ("selection_received",
		    GTK_RUN_LAST,
857
		    GTK_CLASS_TYPE (object_class),
Elliot Lee's avatar
Elliot Lee committed
858
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, selection_received),
Tim Janik's avatar
Tim Janik committed
859
		    gtk_marshal_VOID__BOXED_UINT,
860 861 862 863 864 865
		    GTK_TYPE_NONE, 2,
		    GTK_TYPE_SELECTION_DATA,
		    GTK_TYPE_UINT);
  widget_signals[SELECTION_GET] =
    gtk_signal_new ("selection_get",
		    GTK_RUN_LAST,
866
		    GTK_CLASS_TYPE (object_class),
867
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, selection_get),
Tim Janik's avatar
Tim Janik committed
868
		    gtk_marshal_VOID__BOXED_UINT_UINT,
869
		    GTK_TYPE_NONE, 3,
870 871 872
		    GTK_TYPE_SELECTION_DATA,
		    GTK_TYPE_UINT,
		    GTK_TYPE_UINT);
Elliot Lee's avatar
Elliot Lee committed
873
  widget_signals[PROXIMITY_IN_EVENT] =
874
    g_signal_newc ("proximity_in_event",
875 876 877 878 879 880
                  G_TYPE_FROM_CLASS(object_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET(GtkWidgetClass, proximity_in_event),
                  _gtk_boolean_handled_accumulator, NULL,
                  gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
881
                  GDK_TYPE_EVENT);
Elliot Lee's avatar
Elliot Lee committed
882
  widget_signals[PROXIMITY_OUT_EVENT] =
883
    g_signal_newc ("proximity_out_event",
884 885 886 887 888 889
                  G_TYPE_FROM_CLASS(object_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET(GtkWidgetClass, proximity_out_event),
                  _gtk_boolean_handled_accumulator, NULL,
                  gtk_marshal_BOOLEAN__BOXED,
                  G_TYPE_BOOLEAN, 1,
890
                  GDK_TYPE_EVENT);
891 892
  widget_signals[DRAG_LEAVE] =
    gtk_signal_new ("drag_leave",
Elliot Lee's avatar
Elliot Lee committed
893
		    GTK_RUN_LAST,
894
		    GTK_CLASS_TYPE (object_class),
895
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_leave),
896
		    gtk_marshal_VOID__OBJECT_UINT,
897
		    GTK_TYPE_NONE, 2,
898
		    GDK_TYPE_DRAG_CONTEXT,
899 900 901
		    GTK_TYPE_UINT);
  widget_signals[DRAG_BEGIN] =
    gtk_signal_new ("drag_begin",
Elliot Lee's avatar
Elliot Lee committed
902
		    GTK_RUN_LAST,
903
		    GTK_CLASS_TYPE (object_class),
904
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_begin),
905
		    gtk_marshal_VOID__OBJECT,
906
		    GTK_TYPE_NONE, 1,
907
		    GDK_TYPE_DRAG_CONTEXT);
908 909
  widget_signals[DRAG_END] =
    gtk_signal_new ("drag_end",
910
		    GTK_RUN_LAST,
911
		    GTK_CLASS_TYPE (object_class),
912
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_end),
913
		    gtk_marshal_VOID__OBJECT,
914
		    GTK_TYPE_NONE, 1,
915
		    GDK_TYPE_DRAG_CONTEXT);
916 917
  widget_signals[DRAG_DATA_DELETE] =
    gtk_signal_new ("drag_data_delete",
918
		    GTK_RUN_LAST,
919
		    GTK_CLASS_TYPE (object_class),
920
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_data_delete),
921
		    gtk_marshal_VOID__OBJECT,
922
		    GTK_TYPE_NONE, 1,
923
		    GDK_TYPE_DRAG_CONTEXT);
924
  widget_signals[DRAG_MOTION] =
925
    g_signal_newc ("drag_motion",
926 927 928 929 930 931 932 933 934 935
                  G_TYPE_FROM_CLASS(object_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET(GtkWidgetClass, drag_motion),
                  _gtk_boolean_handled_accumulator, NULL,
		  gtk_marshal_BOOLEAN__OBJECT_INT_INT_UINT,
		  G_TYPE_BOOLEAN, 4,
		  GDK_TYPE_DRAG_CONTEXT,
		  G_TYPE_INT,
		  G_TYPE_INT,
		  G_TYPE_UINT);
936
  widget_signals[DRAG_DROP] =
937
    g_signal_newc ("drag_drop",
938 939 940 941 942 943 944 945 946 947
                  G_TYPE_FROM_CLASS(object_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET(GtkWidgetClass, drag_drop),
                  _gtk_boolean_handled_accumulator, NULL,
		  gtk_marshal_BOOLEAN__OBJECT_INT_INT_UINT,
		  G_TYPE_BOOLEAN, 4,
		  GDK_TYPE_DRAG_CONTEXT,
		  G_TYPE_INT,
		  G_TYPE_INT,
		  G_TYPE_UINT);
948 949 950
  widget_signals[DRAG_DATA_GET] =
    gtk_signal_new ("drag_data_get",
		    GTK_RUN_LAST,
951
		    GTK_CLASS_TYPE (object_class),
952
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_data_get),
953
		    gtk_marshal_VOID__OBJECT_BOXED_UINT_UINT,
954
		    GTK_TYPE_NONE, 4,
955
		    GDK_TYPE_DRAG_CONTEXT,
956 957 958 959 960 961
		    GTK_TYPE_SELECTION_DATA,
		    GTK_TYPE_UINT,
		    GTK_TYPE_UINT);
  widget_signals[DRAG_DATA_RECEIVED] =
    gtk_signal_new ("drag_data_received",
		    GTK_RUN_LAST,
962
		    GTK_CLASS_TYPE (object_class),
963
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_data_received),
964
		    gtk_marshal_VOID__OBJECT_INT_INT_BOXED_UINT_UINT,
965
		    GTK_TYPE_NONE, 6,
966
		    GDK_TYPE_DRAG_CONTEXT,
967 968
		    GTK_TYPE_INT,
		    GTK_TYPE_INT,
969 970 971
		    GTK_TYPE_SELECTION_DATA,
		    GTK_TYPE_UINT,
		    GTK_TYPE_UINT);
Tim Janik's avatar
Tim Janik committed
972
  widget_signals[VISIBILITY_NOTIFY_EVENT] =
973
    g_signal_newc ("visibility_notify_event",
974 975 976 977 978 979
		  G_TYPE_FROM_CLASS(object_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET(GtkWidgetClass, visibility_notify_event),
                  _gtk_boolean_handled_accumulator, NULL,
		  gtk_marshal_BOOLEAN__BOXED,
		  G_TYPE_BOOLEAN, 1,
980
                  GDK_TYPE_EVENT);
981
  widget_signals[CLIENT_EVENT] =
982
    g_signal_newc ("client_event",
983 984 985 986 987 988
		  G_TYPE_FROM_CLASS(object_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET(GtkWidgetClass, client_event),
		  _gtk_boolean_handled_accumulator, NULL,
		  gtk_marshal_BOOLEAN__BOXED,
		  G_TYPE_BOOLEAN, 1,
989
		  GDK_TYPE_EVENT);
990
  widget_signals[NO_EXPOSE_EVENT] =
991
    g_signal_newc ("no_expose_event",
992 993 994 995 996 997
		  G_TYPE_FROM_CLASS(object_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET(GtkWidgetClass, no_expose_event),
		  _gtk_boolean_handled_accumulator, NULL,
		  gtk_marshal_BOOLEAN__BOXED,
		  G_TYPE_BOOLEAN, 1,
998
		  GDK_TYPE_EVENT);
Havoc Pennington's avatar
Havoc Pennington committed
999
  widget_signals[WINDOW_STATE_EVENT] =
1000
    g_signal_newc ("window_state_event",
1001 1002 1003 1004 1005 1006
		  G_TYPE_FROM_CLASS(object_class),
		  G_SIGNAL_RUN_LAST,
		  G_STRUCT_OFFSET(GtkWidgetClass, window_state_event),
		  _gtk_boolean_handled_accumulator, NULL,
		  gtk_marshal_BOOLEAN__BOXED,
		  G_TYPE_BOOLEAN, 1,
1007
		  GDK_TYPE_EVENT);
Owen Taylor's avatar
Owen Taylor committed
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020
  widget_signals[POPUP_MENU] =
    gtk_signal_new ("popup_menu",
		    GTK_RUN_LAST | GTK_RUN_ACTION,
		    GTK_CLASS_TYPE (object_class),
		    GTK_SIGNAL_OFFSET (GtkWidgetClass, popup_menu),
                    gtk_marshal_NONE__NONE,
		    GTK_TYPE_NONE, 0);
  
  binding_set = gtk_binding_set_by_class (klass);
  gtk_binding_entry_add_signal (binding_set, GDK_F10, GDK_SHIFT_MASK,
                                "popup_menu", 0);
  gtk_binding_entry_add_signal (binding_set, GDK_Menu, 0,
                                "popup_menu", 0);  
1021 1022 1023 1024 1025

  gtk_widget_class_install_style_property (klass,
					   g_param_spec_boolean ("interior_focus",
								 _("Interior Focus"),
								 _("Whether to draw the focus indicator inside widgets."),
1026
								 TRUE,
1027
								 G_PARAM_READABLE));
Elliot Lee's avatar
Elliot Lee committed
1028 1029 1030
}

static void
Alexander Larsson's avatar
Alexander Larsson committed
1031 1032 1033 1034
gtk_widget_set_property (GObject         *object,
			 guint            prop_id,
			 const GValue    *value,
			 GParamSpec      *pspec)
Elliot Lee's avatar
Elliot Lee committed
1035
{
1036
  GtkWidget *widget;
1037
  GtkWidgetAuxInfo *aux_info;
1038 1039

  widget = GTK_WIDGET (object);
1040

Alexander Larsson's avatar
Alexander Larsson committed
1041
  switch (prop_id)
Elliot Lee's avatar
Elliot Lee committed
1042
    {
1043 1044
      guint32 saved_flags;
      
Alexander Larsson's avatar
Alexander Larsson committed
1045 1046
    case PROP_NAME:
      gtk_widget_set_name (widget, g_value_get_string (value));
1047
      break;
Alexander Larsson's avatar
Alexander Larsson committed
1048 1049
    case PROP_PARENT:
      gtk_container_add (GTK_CONTAINER (g_value_get_object (value)), widget);
1050
      break;
Alexander Larsson's avatar
Alexander Larsson committed
1051
    case PROP_X:
1052
      aux_info = _gtk_widget_get_aux_info (widget, TRUE);
Alexander Larsson's avatar
Alexander Larsson committed
1053
      if (g_value_get_int (value) == -1)
1054 1055 1056 1057
	aux_info->x_set = FALSE;
      else
	{
	  aux_info->x_set = TRUE;
Alexander Larsson's avatar
Alexander Larsson committed
1058
	  aux_info->x = g_value_get_int (value);
1059 1060
	}
      gtk_widget_do_uposition (widget);
1061
      break;
Alexander Larsson's avatar
Alexander Larsson committed
1062
    case PROP_Y:
1063
      aux_info = _gtk_widget_get_aux_info (widget, TRUE);
Alexander Larsson's avatar
Alexander Larsson committed
1064
      if (g_value_get_int (value) == -1)
1065 1066 1067 1068
	aux_info->y_set = FALSE;
      else
	{
	  aux_info->y_set = TRUE;
Alexander Larsson's avatar
Alexander Larsson committed
1069
	  aux_info->y = g_value_get_int (value);
1070 1071
	}
      gtk_widget_do_uposition (widget);
1072
      break;
Alexander Larsson's avatar
Alexander Larsson committed
1073 1074
    case PROP_WIDTH:
      gtk_widget_set_usize (widget, g_value_get_int (value), -2);
1075
      break;
Alexander Larsson's avatar
Alexander Larsson committed
1076 1077
    case PROP_HEIGHT:
      gtk_widget_set_usize (widget, -2, g_value_get_int (value));
1078
      break;
Alexander Larsson's avatar
Alexander Larsson committed
1079 1080
    case PROP_VISIBLE:
      if (g_value_get_boolean (value))
1081
	gtk_widget_show (widget);
Elliot Lee's avatar
Elliot Lee committed
1082
      else
1083
	gtk_widget_hide (widget);
1084
      break;
Alexander Larsson's avatar
Alexander Larsson committed
1085 1086
    case PROP_SENSITIVE:
      gtk_widget_set_sensitive (widget, g_value_get_boolean (value));
1087
      break;
Alexander Larsson's avatar
Alexander Larsson committed
1088 1089
    case PROP_APP_PAINTABLE:
      gtk_widget_set_app_paintable (widget, g_value_get_boolean (value));
1090
      break;
Alexander Larsson's avatar
Alexander Larsson committed
1091
    case PROP_CAN_FOCUS:
1092
      saved_flags = GTK_WIDGET_FLAGS (widget);
Alexander Larsson's avatar
Alexander Larsson committed
1093
      if (g_value_get_boolean (value))
1094 1095 1096
	GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
      else
	GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
1097 1098
      if (saved_flags != GTK_WIDGET_FLAGS (widget))
	gtk_widget_queue_resize (widget);
1099
      break;
Alexander Larsson's avatar
Alexander Larsson committed
1100 1101
    case PROP_HAS_FOCUS:
      if (g_value_get_boolean (value))
1102 1103
	gtk_widget_grab_focus (widget);
      break;
Alexander Larsson's avatar
Alexander Larsson committed
1104
    case PROP_CAN_DEFAULT: