gtkwidget/window patches, part deux



Now in unified format :)

John
--- gtk+/gtk/gtkwidget.c	Fri Feb  2 19:09:40 2001
+++ gtk+-modified/gtk/gtkwidget.c	Sun Feb 18 18:17:40 2001
@@ -39,7 +39,7 @@
 #include "gtkprivate.h"
 #include "gdk/gdk.h"
 #include "gdk/gdkprivate.h" /* Used in gtk_reset_shapes_recurse to avoid copy */
-
+#include "gtkintl.h"
 
 #define WIDGET_CLASS(w)	 GTK_WIDGET_GET_CLASS (w)
 #define	INIT_PATH_SIZE	(512)
@@ -105,24 +105,25 @@
 
 enum {
   ARG_0,
-  ARG_NAME,
-  ARG_PARENT,
-  ARG_X,
-  ARG_Y,
-  ARG_WIDTH,
-  ARG_HEIGHT,
-  ARG_VISIBLE,
-  ARG_SENSITIVE,
-  ARG_APP_PAINTABLE,
-  ARG_CAN_FOCUS,
-  ARG_HAS_FOCUS,
-  ARG_CAN_DEFAULT,
-  ARG_HAS_DEFAULT,
-  ARG_RECEIVES_DEFAULT,
-  ARG_COMPOSITE_CHILD,
-  ARG_STYLE,
-  ARG_EVENTS,
-  ARG_EXTENSION_EVENTS
+
+  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
 };
 
 typedef	struct	_GtkStateData	 GtkStateData;
@@ -137,12 +138,16 @@
 
 static void gtk_widget_class_init		 (GtkWidgetClass    *klass);
 static void gtk_widget_init			 (GtkWidget	    *widget);
-static void gtk_widget_set_arg			 (GtkObject         *object,
-						  GtkArg	    *arg,
-						  guint		     arg_id);
-static void gtk_widget_get_arg			 (GtkObject         *object,
-						  GtkArg	    *arg,
-						  guint		     arg_id);
+static void gtk_widget_set_property		 (GObject         *object,
+						  guint            prop_id,
+						  const GValue    *value,
+						  GParamSpec      *pspec,
+						  const gchar     *trailer);
+static void gtk_widget_get_property		 (GObject         *object,
+						  guint            prop_id,
+						  GValue          *value,
+						  GParamSpec      *pspec,
+						  const gchar     *trailer);
 static void gtk_widget_shutdown			 (GObject	    *object);
 static void gtk_widget_real_destroy		 (GtkObject	    *object);
 static void gtk_widget_finalize			 (GObject	    *object);
@@ -266,16 +271,17 @@
 static void
 gtk_widget_class_init (GtkWidgetClass *klass)
 {
-  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-  GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
+  GObjectClass   *gobject_class = G_OBJECT_CLASS (klass);
+  GtkObjectClass *object_class  = GTK_OBJECT_CLASS (klass);
   
   parent_class = gtk_type_class (GTK_TYPE_OBJECT);
 
   gobject_class->shutdown = gtk_widget_shutdown;
   gobject_class->finalize = gtk_widget_finalize;
 
-  object_class->set_arg = gtk_widget_set_arg;
-  object_class->get_arg = gtk_widget_get_arg;
+  gobject_class->set_property = gtk_widget_set_property;
+  gobject_class->get_property = gtk_widget_get_property;
+  
   object_class->destroy = gtk_widget_real_destroy;
   
   klass->activate_signal = 0;
@@ -333,24 +339,162 @@
 
   klass->debug_msg = gtk_widget_debug_msg;
   
-  gtk_object_add_arg_type ("GtkWidget::name", GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_NAME);
-  gtk_object_add_arg_type ("GtkWidget::parent", GTK_TYPE_CONTAINER, GTK_ARG_READWRITE, ARG_PARENT);
-  gtk_object_add_arg_type ("GtkWidget::x", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_X);
-  gtk_object_add_arg_type ("GtkWidget::y", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_Y);
-  gtk_object_add_arg_type ("GtkWidget::width", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_WIDTH);
-  gtk_object_add_arg_type ("GtkWidget::height", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_HEIGHT);
-  gtk_object_add_arg_type ("GtkWidget::visible", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_VISIBLE);
-  gtk_object_add_arg_type ("GtkWidget::sensitive", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_SENSITIVE);
-  gtk_object_add_arg_type ("GtkWidget::app_paintable", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_APP_PAINTABLE);
-  gtk_object_add_arg_type ("GtkWidget::can_focus", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_CAN_FOCUS);
-  gtk_object_add_arg_type ("GtkWidget::has_focus", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HAS_FOCUS);
-  gtk_object_add_arg_type ("GtkWidget::can_default", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_CAN_DEFAULT);
-  gtk_object_add_arg_type ("GtkWidget::has_default", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HAS_DEFAULT);
-  gtk_object_add_arg_type ("GtkWidget::receives_default", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_RECEIVES_DEFAULT);
-  gtk_object_add_arg_type ("GtkWidget::composite_child", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_COMPOSITE_CHILD);
-  gtk_object_add_arg_type ("GtkWidget::style", GTK_TYPE_STYLE, GTK_ARG_READWRITE, ARG_STYLE);
-  gtk_object_add_arg_type ("GtkWidget::events", GTK_TYPE_GDK_EVENT_MASK, GTK_ARG_READWRITE, ARG_EVENTS);
-  gtk_object_add_arg_type ("GtkWidget::extension_events", GTK_TYPE_GDK_EVENT_MASK, GTK_ARG_READWRITE, ARG_EXTENSION_EVENTS);
+  
+  g_object_class_install_property (gobject_class,
+                                   PROP_NAME,
+                                   g_param_spec_string ("name",
+							_("Widget Name"),
+                                                        _("The name of the widget"),
+                                                        "",
+                                                        G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_PARENT,
+                                   g_param_spec_object ("parent",
+                                                        _("Parent Widget"),
+                                                        _("The parent widget"),
+                                                        GTK_TYPE_CONTAINER,
+                                                        G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_X,
+                                   g_param_spec_int ("x",
+						     _("X coordinate of window"),
+						     _("The X-axis coordinate of the top-left corner of the widget"),
+						     0,
+						     G_MAXINT,
+						     -1,
+						     G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_Y,
+                                   g_param_spec_int ("y",
+						     _("Y coordinate of window"),
+						     _("The Y-axis coordinate of the top-left corner of the widget"),
+						     0,
+						     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"),
+						     0,
+						     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"),
+						     0,
+						     G_MAXINT,
+						     -1,
+						     G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_VISIBLE,
+                                   g_param_spec_boolean ("visible",
+							 _("Visible"),
+							 _("If the widget is visible"),
+							 FALSE,
+							 G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_SENSITIVE,
+                                   g_param_spec_boolean ("sensitive",
+							 _("Sensitive"),
+							 _("If the widget responds to input"),
+							 FALSE,
+							 G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_APP_PAINTABLE,
+                                   g_param_spec_boolean ("app_paintable",
+							 _("Visible"),
+							 _("If the application can paint the widget"),
+							 FALSE,
+							 G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_CAN_FOCUS,
+                                   g_param_spec_boolean ("can_focus",
+							 _("Can Focus"),
+							 _("If 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"),
+							 _("If 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"),
+							 _("If 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"),
+							 _("If 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"),
+							 _("The widget when focused will receive the default action, period."),
+							 FALSE,
+							 G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_COMPOSITE_CHILD,
+                                   g_param_spec_boolean ("composite_child",
+							 _("Composite Child"),
+							 _("If the widget is composed of other widgets"),
+							 FALSE,
+							 G_PARAM_READWRITE));
+
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_STYLE,
+                                   g_param_spec_object ("style",
+							_("Style"),
+							_("Widget styles"),
+							GTK_TYPE_STYLE,
+							G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_EVENTS,
+                                   g_param_spec_enum ("events",
+						      _("Events"),
+						      _("Widget events"),
+						      GTK_TYPE_GDK_EVENT_MASK,
+						      0,
+						      G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_EXTENSION_EVENTS,
+                                   g_param_spec_enum ("extension_events",
+						      _("Extension Events"),
+						      _("Widget extension events"),
+						      GTK_TYPE_GDK_EXTENSION_MODE,
+						      GDK_EXTENSION_EVENTS_NONE,
+						      G_PARAM_READWRITE));
+
   
   widget_signals[SHOW] =
     gtk_signal_new ("show",
@@ -786,103 +930,123 @@
 }
 
 static void
-gtk_widget_set_arg (GtkObject   *object,
-		    GtkArg	*arg,
-		    guint	 arg_id)
+gtk_widget_set_property (GObject         *object,
+			 guint            prop_id,
+			 const GValue    *value,
+			 GParamSpec      *pspec,
+			 const gchar     *trailer)
 {
   GtkWidget *widget;
 
   widget = GTK_WIDGET (object);
 
-  switch (arg_id)
+  switch (prop_id)
     {
       guint32 saved_flags;
       
-    case ARG_NAME:
-      gtk_widget_set_name (widget, GTK_VALUE_STRING (*arg));
-      break;
-    case ARG_PARENT:
-      gtk_container_add (GTK_CONTAINER (GTK_VALUE_OBJECT (*arg)), widget);
-      break;
-    case ARG_X:
-      gtk_widget_set_uposition (widget, GTK_VALUE_INT (*arg), -2);
-      break;
-    case ARG_Y:
-      gtk_widget_set_uposition (widget, -2, GTK_VALUE_INT (*arg));
-      break;
-    case ARG_WIDTH:
-      gtk_widget_set_usize (widget, GTK_VALUE_INT (*arg), -2);
-      break;
-    case ARG_HEIGHT:
-      gtk_widget_set_usize (widget, -2, GTK_VALUE_INT (*arg));
+    case PROP_NAME:
+      gtk_widget_set_name (widget, g_value_get_string (value));
+      g_object_notify (G_OBJECT (widget), "name" );
+      break;
+    case PROP_PARENT:
+      gtk_container_add (GTK_CONTAINER (g_value_get_object (value)), widget);
+      g_object_notify (G_OBJECT (widget), "parent" );
+      break;
+    case PROP_X:
+      gtk_widget_set_uposition (widget, g_value_get_int (value), -2);
+      g_object_notify (G_OBJECT (widget), "x" );
+      break;
+    case PROP_Y:
+      gtk_widget_set_uposition (widget, -2, g_value_get_int (value));
+      g_object_notify (G_OBJECT (widget), "y" );
+      break;
+    case PROP_WIDTH:
+      gtk_widget_set_usize (widget, g_value_get_int (value), -2);
+      g_object_notify (G_OBJECT (widget), "width" );
+      break;
+    case PROP_HEIGHT:
+      gtk_widget_set_usize (widget, -2, g_value_get_int (value));
+      g_object_notify (G_OBJECT (widget), "height" );
       break;
-    case ARG_VISIBLE:
-      if (GTK_VALUE_BOOL(*arg))
+    case PROP_VISIBLE:
+      if (g_value_get_boolean (value))
 	gtk_widget_show (widget);
       else
 	gtk_widget_hide (widget);
+      g_object_notify (G_OBJECT (widget), "visible" );
       break;
-    case ARG_SENSITIVE:
-      gtk_widget_set_sensitive (widget, GTK_VALUE_BOOL (*arg));
+    case PROP_SENSITIVE:
+      gtk_widget_set_sensitive (widget, g_value_get_boolean (value));
+      g_object_notify (G_OBJECT (widget), "sensitive" );
       break;
-    case ARG_APP_PAINTABLE:
-      gtk_widget_set_app_paintable (widget, GTK_VALUE_BOOL (*arg));
+    case PROP_APP_PAINTABLE:
+      gtk_widget_set_app_paintable (widget, g_value_get_boolean (value));
+      g_object_notify (G_OBJECT (widget), "app_paintable" );
       break;
-    case ARG_CAN_FOCUS:
+    case PROP_CAN_FOCUS:
       saved_flags = GTK_WIDGET_FLAGS (widget);
-      if (GTK_VALUE_BOOL (*arg))
+      if (g_value_get_boolean (value))
 	GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
       else
 	GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
       if (saved_flags != GTK_WIDGET_FLAGS (widget))
 	gtk_widget_queue_resize (widget);
+      g_object_notify (G_OBJECT (widget), "can_focus" );
       break;
-    case ARG_HAS_FOCUS:
-      if (GTK_VALUE_BOOL (*arg))
+    case PROP_HAS_FOCUS:
+      if (g_value_get_boolean (value))
 	gtk_widget_grab_focus (widget);
+      g_object_notify (G_OBJECT (widget), "has_focus" );
       break;
-    case ARG_CAN_DEFAULT:
+    case PROP_CAN_DEFAULT:
       saved_flags = GTK_WIDGET_FLAGS (widget);
-      if (GTK_VALUE_BOOL (*arg))
+      if (g_value_get_boolean (value))
 	GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_DEFAULT);
       else
 	GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_DEFAULT);
       if (saved_flags != GTK_WIDGET_FLAGS (widget))
 	gtk_widget_queue_resize (widget);
+      g_object_notify (G_OBJECT (widget), "can_default" );
       break;
-    case ARG_HAS_DEFAULT:
-      if (GTK_VALUE_BOOL (*arg))
+    case PROP_HAS_DEFAULT:
+      if (g_value_get_boolean (value))
 	gtk_widget_grab_default (widget);
+      g_object_notify (G_OBJECT (widget), "has_default" );
       break;
-    case ARG_RECEIVES_DEFAULT:
-      if (GTK_VALUE_BOOL (*arg))
+    case PROP_RECEIVES_DEFAULT:
+      if (g_value_get_boolean (value))
 	GTK_WIDGET_SET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
       else
 	GTK_WIDGET_UNSET_FLAGS (widget, GTK_RECEIVES_DEFAULT);
+      g_object_notify (G_OBJECT (widget), "receives_default" );
       break;
-    case ARG_COMPOSITE_CHILD:
-      if (GTK_VALUE_BOOL(*arg))
+    case PROP_COMPOSITE_CHILD:
+      if (g_value_get_boolean (value))
 	GTK_WIDGET_SET_FLAGS (widget, GTK_COMPOSITE_CHILD);
       else
 	GTK_WIDGET_UNSET_FLAGS (widget, GTK_COMPOSITE_CHILD);
+      g_object_notify (G_OBJECT (widget), "composite_child" );
       break;
-    case ARG_STYLE:
-      gtk_widget_set_style (widget, (GtkStyle*) GTK_VALUE_BOXED (*arg));
+    case PROP_STYLE:
+      gtk_widget_set_style (widget, g_value_get_object (value));
+      g_object_notify (G_OBJECT (widget), "style" );
       break;
-    case ARG_EVENTS:
+    case PROP_EVENTS:
       if (!GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_NO_WINDOW (widget))
-	gtk_widget_set_events (widget, GTK_VALUE_FLAGS (*arg));
+	gtk_widget_set_events (widget, g_value_get_enum (value));
+      g_object_notify (G_OBJECT (widget), "events" );
       break;
-    case ARG_EXTENSION_EVENTS:
-      gtk_widget_set_extension_events (widget, GTK_VALUE_FLAGS (*arg));
+    case PROP_EXTENSION_EVENTS:
+      gtk_widget_set_extension_events (widget, g_value_get_enum (value));
       break;
+      g_object_notify (G_OBJECT (widget), "extension_events" );
     default:
       break;
     }
 }
 
 /*****************************************
- * gtk_widget_get_arg:
+ * gtk_widget_get_property:
  *
  *   arguments:
  *
@@ -890,103 +1054,105 @@
  *****************************************/
 
 static void
-gtk_widget_get_arg (GtkObject   *object,
-		    GtkArg	*arg,
-		    guint	 arg_id)
+gtk_widget_get_property (GObject         *object,
+			 guint            prop_id,
+			 GValue          *value,
+			 GParamSpec      *pspec,
+			 const gchar     *trailer)
 {
   GtkWidget *widget;
 
   widget = GTK_WIDGET (object);
   
-  switch (arg_id)
+  switch (prop_id)
     {
       GtkWidgetAuxInfo *aux_info;
       gint *eventp;
       GdkExtensionMode *modep;
 
-    case ARG_NAME:
+    case PROP_NAME:
       if (widget->name)
-	GTK_VALUE_STRING (*arg) = g_strdup (widget->name);
+	g_value_set_string (value, widget->name);
       else
-	GTK_VALUE_STRING (*arg) = g_strdup ("");
+	g_value_set_string (value, "" );
       break;
-    case ARG_PARENT:
-      GTK_VALUE_OBJECT (*arg) = (GtkObject*) widget->parent;
+    case PROP_PARENT:
+      g_value_set_object (value, G_OBJECT (widget->parent));
       break;
-    case ARG_X:
+    case PROP_X:
       aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id);
       if (!aux_info)
-	GTK_VALUE_INT (*arg) = -1;
+	g_value_set_int (value, -1);
       else
-	GTK_VALUE_INT (*arg) = aux_info->x;
+	g_value_set_int (value, aux_info->x);
       break;
-    case ARG_Y:
+    case PROP_Y:
       aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id);
       if (!aux_info)
-	GTK_VALUE_INT (*arg) = -1;
+	g_value_set_int (value, -1);
       else
-	GTK_VALUE_INT (*arg) = aux_info->y;
+	g_value_set_int (value, aux_info->y);
       break;
-    case ARG_WIDTH:
+    case PROP_WIDTH:
       aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id);
       if (!aux_info)
-	GTK_VALUE_INT (*arg) = -1;
+	g_value_set_int (value, -1);
       else
-	GTK_VALUE_INT (*arg) = aux_info->width;
+	g_value_set_int (value, aux_info->width);
       break;
-    case ARG_HEIGHT:
+    case PROP_HEIGHT:
       aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id);
       if (!aux_info)
-	GTK_VALUE_INT (*arg) = -1;
+	g_value_set_int (value, -1);
       else
-	GTK_VALUE_INT (*arg) = aux_info->height;
+	g_value_set_int (value, aux_info->height);
       break;
-    case ARG_VISIBLE:
-      GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_VISIBLE (widget) != FALSE);
+    case PROP_VISIBLE:
+      g_value_set_boolean (value, (GTK_WIDGET_VISIBLE (widget) != FALSE));
       break;
-    case ARG_SENSITIVE:
-      GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_SENSITIVE (widget) != FALSE);
+    case PROP_SENSITIVE:
+      g_value_set_boolean (value, (GTK_WIDGET_SENSITIVE (widget) != FALSE));
       break;
-    case ARG_APP_PAINTABLE:
-      GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_APP_PAINTABLE (widget) != FALSE);
+    case PROP_APP_PAINTABLE:
+      g_value_set_boolean (value, (GTK_WIDGET_APP_PAINTABLE (widget) != FALSE));
       break;
-    case ARG_CAN_FOCUS:
-      GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_CAN_FOCUS (widget) != FALSE);
+    case PROP_CAN_FOCUS:
+      g_value_set_boolean (value, (GTK_WIDGET_CAN_FOCUS (widget) != FALSE));
       break;
-    case ARG_HAS_FOCUS:
-      GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_HAS_FOCUS (widget) != FALSE);
+    case PROP_HAS_FOCUS:
+      g_value_set_boolean (value, (GTK_WIDGET_HAS_FOCUS (widget) != FALSE));
       break;
-    case ARG_CAN_DEFAULT:
-      GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_CAN_DEFAULT (widget) != FALSE);
+    case PROP_CAN_DEFAULT:
+      g_value_set_boolean (value, (GTK_WIDGET_CAN_DEFAULT (widget) != FALSE));
       break;
-    case ARG_HAS_DEFAULT:
-      GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_HAS_DEFAULT (widget) != FALSE);
+    case PROP_HAS_DEFAULT:
+      g_value_set_boolean (value, (GTK_WIDGET_HAS_DEFAULT (widget) != FALSE));
       break;
-    case ARG_RECEIVES_DEFAULT:
-      GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_RECEIVES_DEFAULT (widget) != FALSE);
+    case PROP_RECEIVES_DEFAULT:
+      g_value_set_boolean (value, (GTK_WIDGET_RECEIVES_DEFAULT (widget) != FALSE));
       break;
-    case ARG_COMPOSITE_CHILD:
-      GTK_VALUE_BOOL (*arg) = (GTK_WIDGET_COMPOSITE_CHILD (widget) != FALSE);
+    case PROP_COMPOSITE_CHILD:
+      g_value_set_boolean (value, (GTK_WIDGET_COMPOSITE_CHILD (widget) != FALSE));
       break;
-    case ARG_STYLE:
-      GTK_VALUE_BOXED (*arg) = (gpointer) gtk_widget_get_style (widget);
+    case PROP_STYLE:
+      g_value_set_object (value, G_OBJECT (gtk_widget_get_style (widget)));
       break;
-    case ARG_EVENTS:
+    case PROP_EVENTS:
       eventp = gtk_object_get_data_by_id (GTK_OBJECT (widget), event_key_id);
       if (!eventp)
-	GTK_VALUE_FLAGS (*arg) = 0;
+	g_value_set_int (value, 0);
       else
-	GTK_VALUE_FLAGS (*arg) = *eventp;
+	g_value_set_int (value, *eventp);
       break;
-    case ARG_EXTENSION_EVENTS:
+    case PROP_EXTENSION_EVENTS:
       modep = gtk_object_get_data_by_id (GTK_OBJECT (widget), extension_event_key_id);
       if (!modep)
-	GTK_VALUE_FLAGS (*arg) = 0;
+	g_value_set_enum (value, 0);
       else
-	GTK_VALUE_FLAGS (*arg) = *modep;
+	g_value_set_enum (value, (GdkExtensionMode) *modep);
       break;
     default:
-      arg->type = GTK_TYPE_INVALID;
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
     }
 }
--- gtk+/gtk/gtkwindow.c	Fri Feb  2 19:09:40 2001
+++ gtk+-modified/gtk/gtkwindow.c	Sun Feb 18 17:16:18 2001
@@ -47,6 +47,7 @@
 #include "gtkbindings.h"
 #include "gtkmain.h"
 #include "gtkiconfactory.h"
+#include "gtkintl.h"
 
 /* TODO: remove this define and assorted code in 1.3 and fix up the
  * real culprits.
@@ -60,17 +61,23 @@
 };
 
 enum {
-  ARG_0,
-  ARG_TYPE,
-  ARG_TITLE,
-  ARG_AUTO_SHRINK,
-  ARG_ALLOW_SHRINK,
-  ARG_ALLOW_GROW,
-  ARG_MODAL,
-  ARG_WIN_POS,
-  ARG_DEFAULT_WIDTH,
-  ARG_DEFAULT_HEIGHT,
-  ARG_DESTROY_WITH_PARENT
+  PROP_0,
+
+  /* Construct */
+  PROP_TYPE,
+
+  /* Style Props */
+  PROP_TITLE,
+  PROP_AUTO_SHRINK,
+  PROP_ALLOW_SHRINK,
+  PROP_ALLOW_GROW,
+  PROP_MODAL,
+  PROP_WIN_POS,
+  PROP_DEFAULT_WIDTH,
+  PROP_DEFAULT_HEIGHT,
+  PROP_DESTROY_WITH_PARENT,
+
+  LAST_ARG
 };
 
 typedef struct {
@@ -94,12 +101,6 @@
 
 static void gtk_window_class_init         (GtkWindowClass    *klass);
 static void gtk_window_init               (GtkWindow         *window);
-static void gtk_window_set_arg            (GtkObject         *object,
-					   GtkArg            *arg,
-					   guint	      arg_id);
-static void gtk_window_get_arg            (GtkObject         *object,
-					   GtkArg            *arg,
-					   guint	      arg_id);
 static void gtk_window_shutdown           (GObject           *object);
 static void gtk_window_destroy            (GtkObject         *object);
 static void gtk_window_finalize           (GObject           *object);
@@ -184,7 +185,16 @@
 static GtkBinClass *parent_class = NULL;
 static guint        window_signals[LAST_SIGNAL] = { 0 };
 
-
+static void gtk_window_set_property (GObject         *object,
+				     guint            prop_id,
+				     const GValue    *value,
+				     GParamSpec      *pspec,
+				     const gchar     *trailer);
+static void gtk_window_get_property (GObject         *object,
+				     guint            prop_id,
+				     GValue          *value,
+				     GParamSpec      *pspec,
+				     const gchar     *trailer);
 GtkType
 gtk_window_get_type (void)
 {
@@ -227,8 +237,9 @@
   gobject_class->shutdown = gtk_window_shutdown;
   gobject_class->finalize = gtk_window_finalize;
 
-  object_class->set_arg = gtk_window_set_arg;
-  object_class->get_arg = gtk_window_get_arg;
+  gobject_class->set_property = gtk_window_set_property;
+  gobject_class->get_property = gtk_window_get_property;
+  
   object_class->destroy = gtk_window_destroy;
 
   widget_class->show = gtk_window_show;
@@ -256,17 +267,96 @@
   klass->set_focus = gtk_window_real_set_focus;
   klass->frame_event = gtk_window_frame_event;
 
-  gtk_object_add_arg_type ("GtkWindow::type", GTK_TYPE_WINDOW_TYPE, GTK_ARG_READWRITE, ARG_TYPE);
-  gtk_object_add_arg_type ("GtkWindow::title", GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TITLE);
-  gtk_object_add_arg_type ("GtkWindow::auto_shrink", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_AUTO_SHRINK);
-  gtk_object_add_arg_type ("GtkWindow::allow_shrink", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ALLOW_SHRINK);
-  gtk_object_add_arg_type ("GtkWindow::allow_grow", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ALLOW_GROW);
-  gtk_object_add_arg_type ("GtkWindow::modal", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_MODAL);
-  gtk_object_add_arg_type ("GtkWindow::window_position", GTK_TYPE_WINDOW_POSITION, GTK_ARG_READWRITE, ARG_WIN_POS);
-  gtk_object_add_arg_type ("GtkWindow::default_width", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_DEFAULT_WIDTH);
-  gtk_object_add_arg_type ("GtkWindow::default_height", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_DEFAULT_HEIGHT);
-  gtk_object_add_arg_type ("GtkWindow::destroy_with_parent", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_DESTROY_WITH_PARENT);
-  
+  /* Construct */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TYPE,
+                                   g_param_spec_enum ("type",
+						      _("Window Type"),
+						      _("The type of the window"),
+						      GTK_TYPE_WINDOW_TYPE,
+						      GTK_WINDOW_TOPLEVEL,
+						      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+  /* Style Props */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TITLE,
+                                   g_param_spec_string ("title",
+                                                        _("Window Title"),
+                                                        _("The title of the window"),
+                                                        "",
+                                                        G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_AUTO_SHRINK,
+                                   g_param_spec_boolean ("auto_shrink",
+							 _("Auto Shrink"),
+							 _("If the window shrinks automatically when widgets within it shrink"),
+							 FALSE,
+							 G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ALLOW_SHRINK,
+                                   g_param_spec_boolean ("allow_shrink",
+							 _("Allow Shrink"),
+							 _("If the window can be resized to a smaller size by the user"),
+							 FALSE,
+							 G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ALLOW_GROW,
+                                   g_param_spec_boolean ("allow_grow",
+							 _("Allow Grow"),
+							 _("If the window can be resized to a larger size by the user"),
+							 TRUE,
+							 G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_MODAL,
+                                   g_param_spec_boolean ("modal",
+							 _("Modal"),
+							 _("If the window is modal, i.e. it grabs all GTK+ events"),
+							 FALSE,
+							 G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_WIN_POS,
+                                   g_param_spec_enum ("window_position",
+						      _("Window Position"),
+						      _("The position of the window"),
+						      GTK_TYPE_WINDOW_POSITION,
+						      GTK_WIN_POS_NONE,
+						      G_PARAM_READWRITE));
+ 
+  g_object_class_install_property (gobject_class,
+                                   PROP_DEFAULT_WIDTH,
+                                   g_param_spec_int ("default_width",
+						     _("Default Width"),
+						     _("The default width of the window"),
+						     0,
+						     G_MAXINT,
+						     0,
+						     G_PARAM_READWRITE));
+ 
+  g_object_class_install_property (gobject_class,
+                                   PROP_DEFAULT_HEIGHT,
+                                   g_param_spec_int ("default_height",
+						     _("Default Height"),
+						     _("The default height of the window"),
+						     0,
+						     G_MAXINT,
+						     0,
+						     G_PARAM_READWRITE));
+ 
+  g_object_class_install_property (gobject_class,
+                                   PROP_DESTROY_WITH_PARENT,
+                                   g_param_spec_boolean ("destroy_with_parent",
+							 _("Destroy with Parent"),
+							 _("If this window should be destroyed when the parent is destroyed"),
+							 TRUE,
+							 G_PARAM_READWRITE));
+
+  /* Style props are set or not */
+
   window_signals[SET_FOCUS] =
     gtk_signal_new ("set_focus",
                     GTK_RUN_LAST,
@@ -329,48 +419,50 @@
 }
 
 static void
-gtk_window_set_arg (GtkObject  *object,
-		    GtkArg     *arg,
-		    guint	arg_id)
+gtk_window_set_property (GObject      *object,
+			 guint         prop_id,
+			 const GValue *value,
+			 GParamSpec   *pspec,
+			 const gchar  *trailer)
 {
   GtkWindow  *window;
 
   window = GTK_WINDOW (object);
 
-  switch (arg_id)
+  switch (prop_id)
     {
-    case ARG_TYPE:
-      window->type = GTK_VALUE_ENUM (*arg);
+    case PROP_TYPE:
+      window->type = g_value_get_enum (value);
       break;
-    case ARG_TITLE:
-      gtk_window_set_title (window, GTK_VALUE_STRING (*arg));
+    case PROP_TITLE:
+      gtk_window_set_title (window, g_value_get_string (value));
       break;
-    case ARG_AUTO_SHRINK:
-      window->auto_shrink = (GTK_VALUE_BOOL (*arg) != FALSE);
+    case PROP_AUTO_SHRINK:
+      window->auto_shrink = g_value_get_boolean (value);
       gtk_widget_queue_resize (GTK_WIDGET (window));
       break;
-    case ARG_ALLOW_SHRINK:
-      window->allow_shrink = (GTK_VALUE_BOOL (*arg) != FALSE);
+    case PROP_ALLOW_SHRINK:
+      window->allow_shrink = g_value_get_boolean (value);
       gtk_widget_queue_resize (GTK_WIDGET (window));
       break;
-    case ARG_ALLOW_GROW:
-      window->allow_grow = (GTK_VALUE_BOOL (*arg) != FALSE);
+    case PROP_ALLOW_GROW:
+      window->allow_grow = g_value_get_boolean (value);
       gtk_widget_queue_resize (GTK_WIDGET (window));
       break;
-    case ARG_MODAL:
-      gtk_window_set_modal (window, GTK_VALUE_BOOL (*arg));
+    case PROP_MODAL:
+      gtk_window_set_modal (window, g_value_get_boolean (value));
       break;
-    case ARG_WIN_POS:
-      gtk_window_set_position (window, GTK_VALUE_ENUM (*arg));
+    case PROP_WIN_POS:
+      gtk_window_set_position (window, g_value_get_enum (value));
       break;
-    case ARG_DEFAULT_WIDTH:
-      gtk_window_set_default_size (window, GTK_VALUE_INT (*arg), -2);
+    case PROP_DEFAULT_WIDTH:
+      gtk_window_set_default_size (window, g_value_get_int (value), -2);
       break;
-    case ARG_DEFAULT_HEIGHT:
-      gtk_window_set_default_size (window, -2, GTK_VALUE_INT (*arg));
+    case PROP_DEFAULT_HEIGHT:
+      gtk_window_set_default_size (window, -2, g_value_get_int (value));
       break;
-    case ARG_DESTROY_WITH_PARENT:
-      gtk_window_set_destroy_with_parent (window, GTK_VALUE_BOOL (*arg));
+    case PROP_DESTROY_WITH_PARENT:
+      gtk_window_set_destroy_with_parent (window, g_value_get_boolean (value));
       break;
     default:
       break;
@@ -378,57 +470,69 @@
 }
 
 static void
-gtk_window_get_arg (GtkObject  *object,
-		    GtkArg     *arg,
-		    guint	arg_id)
+gtk_window_get_property (GObject      *object,
+			 guint         prop_id,
+			 GValue       *value,
+			 GParamSpec   *pspec,
+			 const gchar  *trailer)
 {
   GtkWindow  *window;
 
   window = GTK_WINDOW (object);
 
-  switch (arg_id)
+  switch (prop_id)
     {
       GtkWindowGeometryInfo *info;
-    case ARG_TYPE:
-      GTK_VALUE_ENUM (*arg) = window->type;
-      break;
-    case ARG_TITLE:
-      GTK_VALUE_STRING (*arg) = g_strdup (window->title);
-      break;
-    case ARG_AUTO_SHRINK:
-      GTK_VALUE_BOOL (*arg) = window->auto_shrink;
-      break;
-    case ARG_ALLOW_SHRINK:
-      GTK_VALUE_BOOL (*arg) = window->allow_shrink;
-      break;
-    case ARG_ALLOW_GROW:
-      GTK_VALUE_BOOL (*arg) = window->allow_grow;
-      break;
-    case ARG_MODAL:
-      GTK_VALUE_BOOL (*arg) = window->modal;
-      break;
-    case ARG_WIN_POS:
-      GTK_VALUE_ENUM (*arg) = window->position;
+    case PROP_TYPE:
+      g_value_set_enum (value, window->type);
+      g_object_notify (G_OBJECT (widget), "type" );
+      break;
+    case PROP_TITLE:
+      g_value_set_string (value, window->title);
+      g_object_notify (G_OBJECT (widget), "title" );
+      break;
+    case PROP_AUTO_SHRINK:
+      g_value_set_boolean (value, window->auto_shrink);
+      g_object_notify (G_OBJECT (widget), "auto_shrink" );
+      break;
+    case PROP_ALLOW_SHRINK:
+      g_value_set_boolean (value, window->allow_shrink);
+      g_object_notify (G_OBJECT (widget), "allow_shrink" );
+      break;
+    case PROP_ALLOW_GROW:
+      g_value_set_boolean (value, window->allow_grow);
+      g_object_notify (G_OBJECT (widget), "allow_grow" );
+      break;
+    case PROP_MODAL:
+      g_value_set_boolean (value, window->modal);
+      g_object_notify (G_OBJECT (widget), "modal" );
+      break;
+    case PROP_WIN_POS:
+      g_value_set_enum (value, window->position);
+      g_object_notify (G_OBJECT (widget), "window_position" );
       break;
-    case ARG_DEFAULT_WIDTH:
+    case PROP_DEFAULT_WIDTH:
       info = gtk_window_get_geometry_info (window, FALSE);
       if (!info)
-	GTK_VALUE_INT (*arg) = -1;
+	g_value_set_int (value, -1);
       else
-	GTK_VALUE_INT (*arg) = info->width;
+	g_value_set_int (value, info->width);
+      g_object_notify (G_OBJECT (widget), "default_width" );
       break;
-    case ARG_DEFAULT_HEIGHT:
+    case PROP_DEFAULT_HEIGHT:
       info = gtk_window_get_geometry_info (window, FALSE);
       if (!info)
-	GTK_VALUE_INT (*arg) = -1;
+	g_value_set_int (value, -1);
       else
-	GTK_VALUE_INT (*arg) = info->height;
+	g_value_set_int (value, info->height);
+      g_object_notify (G_OBJECT (widget), "default_height" );
       break;
-    case ARG_DESTROY_WITH_PARENT:
-      GTK_VALUE_BOOL (*arg) = window->destroy_with_parent;
+    case PROP_DESTROY_WITH_PARENT:
+      g_value_set_boolean (value, window->destroy_with_parent);
+      g_object_notify (G_OBJECT (widget), "destroy_with_parent" );
       break;
     default:
-      arg->type = GTK_TYPE_INVALID;
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]