Conditionally use g_object_notify_by_pspec

This adds a wrapper macro to clutter-private that will use
g_object_notify_by_pspec if it's compiled against a version of GLib
that is sufficiently new. Otherwise it will notify by the property
name as before by extracting the name from the pspec. The objects can
then store a static array of GParamSpecs and notify using those as
suggested in the documentation for g_object_notify_by_pspec.

Note that the name of the variable used for storing the array of
GParamSpecs is obj_props instead of properties as used in the
documentation because some places in Clutter uses 'properties' as the
name of a local variable.

Mose of the classes in Clutter have been converted using the script in
the bug report. Some classes have not been modified even though the
script picked them up as described here:

json-generator:

 We probably don't want to modify the internal copy of JSON

behaviour-depth:
rectangle:
score:
stage-manager:

 These aren't using the separate GParamSpec* variable style.

blur-effect:
win32/device-manager:

 Don't actually define any properties even though it has the enum.

box-layout:
flow-layout:

  Have some per-child properties that don't work automatically with
  the script.

clutter-model:

  The script gets confused with ClutterModelIter

stage:

  Script gets confused because PROP_USER_RESIZE doesn't match
  "user-resizable"

test-layout:

  Don't really want to modify the tests

http://bugzilla.clutter-project.org/show_bug.cgi?id=2150
This commit is contained in:
Neil Roberts
2010-06-21 10:20:32 +01:00
parent bfa10f629f
commit 8d51617979
42 changed files with 608 additions and 242 deletions

View File

@ -46,9 +46,13 @@ enum
PROP_ID,
PROP_DEVICE_TYPE,
PROP_NAME
PROP_NAME,
PROP_LAST
};
static GParamSpec *obj_props[PROP_LAST];
G_DEFINE_TYPE (ClutterInputDevice, clutter_input_device, G_TYPE_OBJECT);
static void
@ -130,6 +134,7 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
0,
CLUTTER_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
obj_props[PROP_ID] = pspec;
g_object_class_install_property (gobject_class, PROP_ID, pspec);
/**
@ -145,6 +150,7 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
NULL,
CLUTTER_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
obj_props[PROP_NAME] = pspec;
g_object_class_install_property (gobject_class, PROP_NAME, pspec);
/**
@ -161,6 +167,7 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
CLUTTER_POINTER_DEVICE,
CLUTTER_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
obj_props[PROP_DEVICE_TYPE] = pspec;
g_object_class_install_property (gobject_class, PROP_DEVICE_TYPE, pspec);
}