3 (defstruct g-class-property-definition
4 "Structure describing property of a GObject class.
6 See accessor functions:
8 @item{@fun{g-class-property-definition-name}}
9 @item{@fun{g-class-property-definition-type}}
10 @item{@fun{g-class-property-definition-readable}}
11 @item{@fun{g-class-property-definition-writable}}
12 @item{@fun{g-class-property-definition-constructor}}
13 @item{@fun{g-class-property-definition-constructor-only}}
14 @item{@fun{g-class-property-definition-owner-type}}
25 (setf (documentation 'g-class-property-definition-name 'function)
26 "Name of GObject class property. See @class{g-class-property-definition}.
29 (setf (documentation 'g-class-property-definition-type 'function)
30 "Type of GObject class property. See @class{g-class-property-definition}.
31 @return{a GType (integer)}")
33 (setf (documentation 'g-class-property-definition-readable 'function)
34 "Whether the GObject class property is readable. See @class{g-class-property-definition}.
37 (setf (documentation 'g-class-property-definition-writable 'function)
38 "Whether the GObject class property is writable. See @class{g-class-property-definition}.
41 (setf (documentation 'g-class-property-definition-constructor 'function)
42 "Whether the GObject class property can be set at object construction time. See @class{g-class-property-definition}.
45 (setf (documentation 'g-class-property-definition-constructor-only 'function)
46 "Whether the GObject class property can only be set at object construction time. See @class{g-class-property-definition}.
49 (setf (documentation 'g-class-property-definition-owner-type 'function)
50 "The GType on which this GObject class property was defined. See @class{g-class-property-definition}.
51 @return{a GType (integer)}")
53 (defun parse-g-param-spec (param)
54 (let ((flags (foreign-slot-value param 'g-param-spec 'flags)))
55 (make-g-class-property-definition
56 :name (foreign-slot-value param 'g-param-spec
58 :type (foreign-slot-value param 'g-param-spec
60 :readable (not (null (member :readable flags)))
61 :writable (not (null (member :writable flags)))
62 :constructor (not (null (member :construct flags)))
63 :constructor-only (not (null (member :construct-only flags)))
64 :owner-type (foreign-slot-value param 'g-param-spec
67 (defun class-properties (g-type)
68 "@return{list of properties of GObject class @code{g-type}. Each property is described by an object of type @class{g-class-property-definition}.}
69 @arg[g-type]{an integer or a string specifying the GType}"
70 (setf g-type (ensure-g-type g-type))
71 (let ((g-class (g-type-class-ref g-type)))
73 (with-foreign-object (n-properties :uint)
74 (let ((params (g-object-class-list-properties g-class n-properties)))
77 for i from 0 below (mem-ref n-properties :uint)
78 for param = (mem-aref params :pointer i)
79 collect (parse-g-param-spec param))
81 (g-type-class-unref g-class))))
83 (defun class-parent (type)
84 (g-type-parent (ensure-g-type type)))
86 (defun interface-properties (g-type)
87 "@return{list of properties of GObject interface @code{g-type}. Each property is described by an object of type @class{g-class-property-definition}.}
88 @arg[g-type]{an integer or a string specifying the GType}"
89 (setf g-type (ensure-g-type g-type))
90 (let ((g-iface (g-type-default-interface-ref g-type)))
92 (with-foreign-object (n-properties :uint)
93 (let ((params (g-object-interface-list-properties g-iface n-properties)))
96 for i from 0 below (mem-ref n-properties :uint)
97 for param = (mem-aref params :pointer i)
98 for flags = (foreign-slot-value param 'g-param-spec 'flags)
99 collect (make-g-class-property-definition
100 :name (foreign-slot-value param 'g-param-spec
102 :type (foreign-slot-value param 'g-param-spec
104 :readable (not (null (member :readable flags)))
105 :writable (not (null (member :writable flags)))
106 :constructor (not (null (member :construct flags)))
107 :constructor-only (not (null (member :construct-only flags)))
108 :owner-type (foreign-slot-value param 'g-param-spec
111 (g-type-default-interface-unref g-iface))))
114 "A structure describing a single enumeration item.
116 See accessor functions:
118 @item{@fun{enum-item-name}}
119 @item{@fun{enum-item-value}}
120 @item{@fun{enum-item-nick}}
124 (setf (documentation 'enum-item-name 'function)
125 "The C name of enum item, e.g. \"GTK_WINDOW_TOPLEVEL\".
128 (setf (documentation 'enum-item-value 'function)
129 "The numeric value of enum item.
130 @return{an integer}")
132 (setf (documentation 'enum-item-nick 'function)
133 "The \"nickname\" of enum item. Nickname is a short name of enum item. E.g., \"toplevel\".
136 (defun get-enum-items (type)
137 "Gets the list of enum items that belong to GEnum type @code{type}
138 @arg[type]{a string or an integer specifying GEnum type}
139 @return{a list of @class{enum-item} objects}"
140 (let ((g-class (g-type-class-ref (ensure-g-type type))))
143 with n = (foreign-slot-value g-class 'g-enum-class 'n-values)
144 with values = (foreign-slot-value g-class 'g-enum-class 'values)
146 for enum-value = (mem-aref values 'g-enum-value i)
147 collect (make-enum-item
148 :name (foreign-slot-value enum-value 'g-enum-value
150 :value (foreign-slot-value enum-value 'g-enum-value
152 :nick (foreign-slot-value enum-value 'g-enum-value
154 (g-type-class-unref g-class))))
156 (defstruct flags-item
157 "A structure describing a single flags item.
159 See accessor functions:
161 @item{@fun{flags-item-name}}
162 @item{@fun{flags-item-value}}
163 @item{@fun{flags-item-nick}}
167 (setf (documentation 'flags-item-name 'function)
168 "The C name of flags item, e.g. \"GDK_PROPERTY_CHANGE_MASK\".
171 (setf (documentation 'flags-item-value 'function)
172 "The numeric value of flags item.
173 @return{an integer}")
175 (setf (documentation 'flags-item-nick 'function)
176 "The \"nickname\" of flags item. Nickname is a short name of flags item. E.g., \"property-change-mask\".
179 (defun get-flags-items (type)
180 "Gets the list of flags items that belong to GFlags type @code{type}
181 @arg[type]{a string or an integer specifying GFlags type}
182 @return{a list of @class{flags-item} objects}"
183 (let ((g-class (g-type-class-ref (ensure-g-type type))))
186 with n = (foreign-slot-value g-class 'g-flags-class 'n-values)
187 with values = (foreign-slot-value g-class 'g-flags-class 'values)
189 for flags-value = (mem-aref values 'g-flags-value i)
190 collect (make-flags-item
191 :name (foreign-slot-value flags-value 'g-flags-value
193 :value (foreign-slot-value flags-value 'g-flags-value
195 :nick (foreign-slot-value flags-value 'g-flags-value
197 (g-type-class-unref g-class))))