#51726 - Param spec for gunichar
- From: Owen Taylor <otaylor redhat com>
- To: timj gtk org
- Cc: gtk-devel-list gtk org
- Subject: #51726 - Param spec for gunichar
- Date: 26 Mar 2001 18:06:37 -0500
Does this look reasonable?
Regards,
Owen
Index: gparamspecs.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gparamspecs.c,v
retrieving revision 1.14
diff -u -r1.14 gparamspecs.c
--- gparamspecs.c 2001/03/14 15:33:45 1.14
+++ gparamspecs.c 2001/03/26 23:04:18
@@ -279,6 +279,48 @@
}
static void
+param_unichar_init (GParamSpec *pspec)
+{
+ GParamSpecUnichar *uspec = G_PARAM_SPEC_UNICHAR (pspec);
+
+ uspec->default_value = 0;
+}
+
+static void
+param_unichar_set_default (GParamSpec *pspec,
+ GValue *value)
+{
+ value->data[0].v_uint = G_PARAM_SPEC_UNICHAR (pspec)->default_value;
+}
+
+static gboolean
+param_unichar_validate (GParamSpec *pspec,
+ GValue *value)
+{
+ gunichar oval = value->data[0].v_uint;
+ gboolean changed = FALSE;
+
+ if (!g_unichar_validate (oval))
+ {
+ value->data[0].v_uint = 0;
+ changed = TRUE;
+ }
+
+ return changed;
+}
+
+static gint
+param_unichar_values_cmp (GParamSpec *pspec,
+ const GValue *value1,
+ const GValue *value2)
+{
+ if (value1->data[0].v_uint < value2->data[0].v_uint)
+ return -1;
+ else
+ return value1->data[0].v_uint > value2->data[0].v_uint;
+}
+
+static void
param_enum_init (GParamSpec *pspec)
{
GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
@@ -999,11 +1041,28 @@
type = g_param_type_register_static ("GParamULong", &pspec_info);
g_assert (type == G_TYPE_PARAM_ULONG);
}
-
- /* G_TYPE_PARAM_ENUM
+
+ /* G_TYPE_PARAM_UNICHAR
*/
{
static const GParamSpecTypeInfo pspec_info = {
+ sizeof (GParamSpecUnichar), /* instance_size */
+ 16, /* n_preallocs */
+ param_unichar_init, /* instance_init */
+ G_TYPE_UINT, /* value_type */
+ NULL, /* finalize */
+ param_unichar_set_default, /* value_set_default */
+ param_unichar_validate, /* value_validate */
+ param_unichar_values_cmp, /* values_cmp */
+ };
+ type = g_param_type_register_static ("GParamUnichar", &pspec_info);
+ g_assert (type == G_TYPE_PARAM_UNICHAR);
+ }
+
+ /* G_TYPE_PARAM_ENUM
+ */
+ {
+ static const GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecEnum), /* instance_size */
16, /* n_preallocs */
param_enum_init, /* instance_init */
@@ -1363,6 +1422,26 @@
uspec->minimum = minimum;
uspec->maximum = maximum;
+ uspec->default_value = default_value;
+
+ return G_PARAM_SPEC (uspec);
+}
+
+GParamSpec*
+g_param_spec_unichar (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ gunichar default_value,
+ GParamFlags flags)
+{
+ GParamSpecUnichar *uspec;
+
+ uspec = g_param_spec_internal (G_TYPE_PARAM_UNICHAR,
+ name,
+ nick,
+ blurb,
+ flags);
+
uspec->default_value = default_value;
return G_PARAM_SPEC (uspec);
Index: gparamspecs.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gparamspecs.h,v
retrieving revision 1.9
diff -u -r1.9 gparamspecs.h
--- gparamspecs.h 2001/03/09 21:39:50 1.9
+++ gparamspecs.h 2001/03/26 23:04:18
@@ -43,6 +43,8 @@
#define G_IS_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_LONG))
#define G_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_LONG, GParamSpecLong))
#define G_IS_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ULONG))
+#define G_PARAM_SPEC_UNICHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UNICHAR, GParamSpecUnichar))
+#define G_IS_PARAM_SPEC_UNICHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UNICHAR))
#define G_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ULONG, GParamSpecULong))
#define G_IS_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ENUM))
#define G_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ENUM, GParamSpecEnum))
@@ -76,6 +78,7 @@
typedef struct _GParamSpecUInt GParamSpecUInt;
typedef struct _GParamSpecLong GParamSpecLong;
typedef struct _GParamSpecULong GParamSpecULong;
+typedef struct _GParamSpecUnichar GParamSpecUnichar;
typedef struct _GParamSpecEnum GParamSpecEnum;
typedef struct _GParamSpecFlags GParamSpecFlags;
typedef struct _GParamSpecFloat GParamSpecFloat;
@@ -141,6 +144,12 @@
gulong maximum;
gulong default_value;
};
+struct _GParamSpecUnichar
+{
+ GParamSpec parent_instance;
+
+ gunichar default_value;
+};
struct _GParamSpecEnum
{
GParamSpec parent_instance;
@@ -260,6 +269,11 @@
gulong maximum,
gulong default_value,
GParamFlags flags);
+GParamSpec* g_param_spec_unichar (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ gunichar default_value,
+ GParamFlags flags);
GParamSpec* g_param_spec_enum (const gchar *name,
const gchar *nick,
const gchar *blurb,
Index: gtype.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gtype.h,v
retrieving revision 1.24
diff -u -r1.24 gtype.h
--- gtype.h 2001/03/18 04:44:37 1.24
+++ gtype.h 2001/03/26 23:04:18
@@ -89,7 +89,8 @@
G_TYPE_PARAM_POINTER = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 15),
G_TYPE_PARAM_VALUE_ARRAY = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 16),
G_TYPE_PARAM_CLOSURE = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 17),
- G_TYPE_PARAM_OBJECT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 18)
+ G_TYPE_PARAM_OBJECT = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 18),
+ G_TYPE_PARAM_UNICHAR = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 19)
} GTypeFundamentals;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]