Patches to gtkwidget and gtkwindow for property support
- From: John Margaglione <jmargaglione yahoo com>
- To: gtk-devel-list gnome org
- Subject: Patches to gtkwidget and gtkwindow for property support
- Date: Sun, 18 Feb 2001 14:09:40 -0600
Here are my changes to GtkWidget and GtkWindow. I converted the args to
properties using g_type support. Let me know if they are ok, and I will
continue with the other files. The only open question I have is when to
use g_object_notify. Some of the files (gtktexttag.c) use it, and some
(gtkcellrenderer.c) don't.
John
42c42
<
---
> #include "gtkintl.h"
108,125c108,126
< 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
140,145c141,150
< 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);
269,270c274,275
< 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);
277,278c282,284
< 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;
>
336,353c342,498
< 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_READABLE | G_PARAM_WRITABLE));
>
> g_object_class_install_property (gobject_class,
> PROP_PARENT,
> g_param_spec_object ("parent",
> _("Parent Widget"),
> _("The parent widget"),
> GTK_TYPE_CONTAINER,
> G_PARAM_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> g_object_class_install_property (gobject_class,
> PROP_VISIBLE,
> g_param_spec_boolean ("visible",
> _("Visible"),
> _("If the widget is visible"),
> FALSE,
> G_PARAM_READABLE | G_PARAM_WRITABLE));
>
> g_object_class_install_property (gobject_class,
> PROP_SENSITIVE,
> g_param_spec_boolean ("sensitive",
> _("Sensitive"),
> _("If the widget responds to input"),
> FALSE,
> G_PARAM_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE));
>
>
> g_object_class_install_property (gobject_class,
> PROP_STYLE,
> g_param_spec_boxed ("style",
> _("Style"),
> _("Widget styles"),
> GTK_TYPE_STYLE,
> G_PARAM_READABLE | G_PARAM_WRITABLE));
>
> g_object_class_install_property (gobject_class,
> PROP_EVENTS,
> g_param_spec_int ("events",
> _("Events"),
> _("Widget events"),
> 0,
> GDK_ALL_EVENTS_MASK,
> 0,
> G_PARAM_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
789,791c934,938
< 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)
797c944
< switch (arg_id)
---
> switch (prop_id)
801,802c948,949
< case ARG_NAME:
< gtk_widget_set_name (widget, GTK_VALUE_STRING (*arg));
---
> case PROP_NAME:
> gtk_widget_set_name (widget, g_value_get_string (value));
804,805c951,952
< case ARG_PARENT:
< gtk_container_add (GTK_CONTAINER (GTK_VALUE_OBJECT (*arg)), widget);
---
> case PROP_PARENT:
> gtk_container_add (GTK_CONTAINER (g_value_get_object (value)), widget);
807,808c954,955
< case ARG_X:
< gtk_widget_set_uposition (widget, GTK_VALUE_INT (*arg), -2);
---
> case PROP_X:
> gtk_widget_set_uposition (widget, g_value_get_int (value), -2);
810,811c957,958
< case ARG_Y:
< gtk_widget_set_uposition (widget, -2, GTK_VALUE_INT (*arg));
---
> case PROP_Y:
> gtk_widget_set_uposition (widget, -2, g_value_get_int (value));
813,814c960,961
< case ARG_WIDTH:
< gtk_widget_set_usize (widget, GTK_VALUE_INT (*arg), -2);
---
> case PROP_WIDTH:
> gtk_widget_set_usize (widget, g_value_get_int (value), -2);
816,817c963,964
< case ARG_HEIGHT:
< gtk_widget_set_usize (widget, -2, GTK_VALUE_INT (*arg));
---
> case PROP_HEIGHT:
> gtk_widget_set_usize (widget, -2, g_value_get_int (value));
819,820c966,967
< case ARG_VISIBLE:
< if (GTK_VALUE_BOOL(*arg))
---
> case PROP_VISIBLE:
> if (g_value_get_boolean (value))
825,826c972,973
< 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));
828,829c975,976
< 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));
831c978
< case ARG_CAN_FOCUS:
---
> case PROP_CAN_FOCUS:
833c980
< if (GTK_VALUE_BOOL (*arg))
---
> if (g_value_get_boolean (value))
840,841c987,988
< case ARG_HAS_FOCUS:
< if (GTK_VALUE_BOOL (*arg))
---
> case PROP_HAS_FOCUS:
> if (g_value_get_boolean (value))
844c991
< case ARG_CAN_DEFAULT:
---
> case PROP_CAN_DEFAULT:
846c993
< if (GTK_VALUE_BOOL (*arg))
---
> if (g_value_get_boolean (value))
853,854c1000,1001
< case ARG_HAS_DEFAULT:
< if (GTK_VALUE_BOOL (*arg))
---
> case PROP_HAS_DEFAULT:
> if (g_value_get_boolean (value))
857,858c1004,1005
< case ARG_RECEIVES_DEFAULT:
< if (GTK_VALUE_BOOL (*arg))
---
> case PROP_RECEIVES_DEFAULT:
> if (g_value_get_boolean (value))
863,864c1010,1011
< case ARG_COMPOSITE_CHILD:
< if (GTK_VALUE_BOOL(*arg))
---
> case PROP_COMPOSITE_CHILD:
> if (g_value_get_boolean (value))
869,870c1016,1017
< case ARG_STYLE:
< gtk_widget_set_style (widget, (GtkStyle*) GTK_VALUE_BOXED (*arg));
---
> case PROP_STYLE:
> gtk_widget_set_style (widget, (GtkStyle*) g_value_get_as_pointer (value));
872c1019
< case ARG_EVENTS:
---
> case PROP_EVENTS:
874c1021
< gtk_widget_set_events (widget, GTK_VALUE_FLAGS (*arg));
---
> gtk_widget_set_events (widget, g_value_get_int (value));
876,877c1023,1025
< case ARG_EXTENSION_EVENTS:
< gtk_widget_set_extension_events (widget, GTK_VALUE_FLAGS (*arg));
---
> case PROP_EXTENSION_EVENTS:
> gtk_widget_set_extension_events (widget,
> (GdkExtensionMode) g_value_get_enum (value));
885c1033
< * gtk_widget_get_arg:
---
> * gtk_widget_get_property:
893,895c1041,1045
< 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)
901c1051
< switch (arg_id)
---
> switch (prop_id)
907c1057
< case ARG_NAME:
---
> case PROP_NAME:
909c1059
< GTK_VALUE_STRING (*arg) = g_strdup (widget->name);
---
> g_value_set_string (value, widget->name);
911c1061
< GTK_VALUE_STRING (*arg) = g_strdup ("");
---
> g_value_set_string (value, "" );
913,914c1063,1064
< case ARG_PARENT:
< GTK_VALUE_OBJECT (*arg) = (GtkObject*) widget->parent;
---
> case PROP_PARENT:
> g_value_set_object (value, G_OBJECT (widget->parent));
916c1066
< case ARG_X:
---
> case PROP_X:
919c1069
< GTK_VALUE_INT (*arg) = -1;
---
> g_value_set_int (value, -1);
921c1071
< GTK_VALUE_INT (*arg) = aux_info->x;
---
> g_value_set_int (value, aux_info->x);
923c1073
< case ARG_Y:
---
> case PROP_Y:
926c1076
< GTK_VALUE_INT (*arg) = -1;
---
> g_value_set_int (value, -1);
928c1078
< GTK_VALUE_INT (*arg) = aux_info->y;
---
> g_value_set_int (value, aux_info->y);
930c1080
< case ARG_WIDTH:
---
> case PROP_WIDTH:
933c1083
< GTK_VALUE_INT (*arg) = -1;
---
> g_value_set_int (value, -1);
935c1085
< GTK_VALUE_INT (*arg) = aux_info->width;
---
> g_value_set_int (value, aux_info->width);
937c1087
< case ARG_HEIGHT:
---
> case PROP_HEIGHT:
940c1090
< GTK_VALUE_INT (*arg) = -1;
---
> g_value_set_int (value, -1);
942c1092
< GTK_VALUE_INT (*arg) = aux_info->height;
---
> g_value_set_int (value, aux_info->height);
944,945c1094,1095
< 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));
947,948c1097,1098
< 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));
950,951c1100,1101
< 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));
953,954c1103,1104
< 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));
956,957c1106,1107
< 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));
959,960c1109,1110
< 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));
962,963c1112,1113
< 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));
965,966c1115,1116
< 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));
968,969c1118,1119
< 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));
971,972c1121,1122
< case ARG_STYLE:
< GTK_VALUE_BOXED (*arg) = (gpointer) gtk_widget_get_style (widget);
---
> case PROP_STYLE:
> g_value_set_boxed (value, (gpointer) gtk_widget_get_style (widget));
974c1124
< case ARG_EVENTS:
---
> case PROP_EVENTS:
977c1127
< GTK_VALUE_FLAGS (*arg) = 0;
---
> g_value_set_int (value, 0);
979c1129
< GTK_VALUE_FLAGS (*arg) = *eventp;
---
> g_value_set_int (value, *eventp);
981c1131
< case ARG_EXTENSION_EVENTS:
---
> case PROP_EXTENSION_EVENTS:
984c1134
< GTK_VALUE_FLAGS (*arg) = 0;
---
> g_value_set_enum (value, 0);
986c1136
< GTK_VALUE_FLAGS (*arg) = *modep;
---
> g_value_set_enum (value, (GdkExtensionMode) *modep);
989c1139
< arg->type = GTK_TYPE_INVALID;
---
> G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
49a50
> #include "gtkintl.h"
63,73c64,80
< 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
97,102d103
< 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);
187c188,197
<
---
> 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);
230,231c240,242
< 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;
>
259,269c270,351
< 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_READABLE | G_PARAM_WRITABLE | 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_READABLE | G_PARAM_WRITABLE));
>
> g_object_class_install_property (gobject_class,
> PROP_ALLOW_SHRINK,
> g_param_spec_boolean ("allow_shrink",
> _("Auto Shrink"),
> _("If the window can be resized to a smaller size by the user"),
> FALSE,
> G_PARAM_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> 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,
> -1,
> G_PARAM_READABLE | G_PARAM_WRITABLE));
>
> 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,
> -1,
> G_PARAM_READABLE | G_PARAM_WRITABLE));
>
> 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_READABLE | G_PARAM_WRITABLE));
>
> /* Style props are set or not */
>
332,334c414,418
< 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)
340c424
< switch (arg_id)
---
> switch (prop_id)
342,343c426,427
< case ARG_TYPE:
< window->type = GTK_VALUE_ENUM (*arg);
---
> case PROP_TYPE:
> window->type = g_value_get_enum (value);
345,346c429,430
< 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));
348,349c432,433
< case ARG_AUTO_SHRINK:
< window->auto_shrink = (GTK_VALUE_BOOL (*arg) != FALSE);
---
> case PROP_AUTO_SHRINK:
> window->auto_shrink = g_value_get_boolean (value);
352,353c436,437
< case ARG_ALLOW_SHRINK:
< window->allow_shrink = (GTK_VALUE_BOOL (*arg) != FALSE);
---
> case PROP_ALLOW_SHRINK:
> window->allow_shrink = g_value_get_boolean (value);
356,357c440,441
< case ARG_ALLOW_GROW:
< window->allow_grow = (GTK_VALUE_BOOL (*arg) != FALSE);
---
> case PROP_ALLOW_GROW:
> window->allow_grow = g_value_get_boolean (value);
360,361c444,445
< 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));
363,364c447,448
< 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));
366,367c450,451
< 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);
369,370c453,454
< 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));
372,373c456,457
< 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));
381,383c465,469
< 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)
389c475
< switch (arg_id)
---
> switch (prop_id)
392,393c478,479
< case ARG_TYPE:
< GTK_VALUE_ENUM (*arg) = window->type;
---
> case PROP_TYPE:
> g_value_set_enum (value, window->type);
395,396c481,482
< case ARG_TITLE:
< GTK_VALUE_STRING (*arg) = g_strdup (window->title);
---
> case PROP_TITLE:
> g_value_set_string (value, window->title);
398,399c484,485
< case ARG_AUTO_SHRINK:
< GTK_VALUE_BOOL (*arg) = window->auto_shrink;
---
> case PROP_AUTO_SHRINK:
> g_value_set_boolean (value, window->auto_shrink);
401,402c487,488
< case ARG_ALLOW_SHRINK:
< GTK_VALUE_BOOL (*arg) = window->allow_shrink;
---
> case PROP_ALLOW_SHRINK:
> g_value_set_boolean (value, window->allow_shrink);
404,405c490,491
< case ARG_ALLOW_GROW:
< GTK_VALUE_BOOL (*arg) = window->allow_grow;
---
> case PROP_ALLOW_GROW:
> g_value_set_boolean (value, window->allow_grow);
407,408c493,494
< case ARG_MODAL:
< GTK_VALUE_BOOL (*arg) = window->modal;
---
> case PROP_MODAL:
> g_value_set_boolean (value, window->modal);
410,411c496,497
< case ARG_WIN_POS:
< GTK_VALUE_ENUM (*arg) = window->position;
---
> case PROP_WIN_POS:
> g_value_set_enum (value, window->position);
413c499
< case ARG_DEFAULT_WIDTH:
---
> case PROP_DEFAULT_WIDTH:
416c502
< GTK_VALUE_INT (*arg) = -1;
---
> g_value_set_int (value, -1);
418c504
< GTK_VALUE_INT (*arg) = info->width;
---
> g_value_set_int (value, info->width);
420c506
< case ARG_DEFAULT_HEIGHT:
---
> case PROP_DEFAULT_HEIGHT:
423c509
< GTK_VALUE_INT (*arg) = -1;
---
> g_value_set_int (value, -1);
425c511
< GTK_VALUE_INT (*arg) = info->height;
---
> g_value_set_int (value, info->height);
427,428c513,514
< 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);
431c517
< arg->type = GTK_TYPE_INVALID;
---
> G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]