@@ -116,6 +116,26 @@ vo_gather_required( PElement *item, Vo *vo )
116
116
return ( NULL );
117
117
}
118
118
119
+ static int
120
+ vo_set_property ( Vo * vo ,
121
+ const char * name , GParamSpec * pspec , GValue * value )
122
+ {
123
+ /* If we're setting an enum from a string, look up the enum nickname.
124
+ */
125
+ if ( G_IS_PARAM_SPEC_ENUM ( pspec ) &&
126
+ G_VALUE_TYPE ( value ) == VIPS_TYPE_REF_STRING ) {
127
+ const char * str = vips_value_get_ref_string ( value , NULL );
128
+
129
+ if ( vips_object_set_argument_from_string ( vo -> object ,
130
+ name , str ) )
131
+ return ( -1 );
132
+ }
133
+ else
134
+ g_object_set_property ( G_OBJECT ( vo -> object ), name , value );
135
+
136
+ return ( 0 );
137
+ }
138
+
119
139
static void *
120
140
vo_set_required_input ( VipsObject * object , GParamSpec * pspec ,
121
141
VipsArgumentClass * argument_class ,
@@ -132,12 +152,15 @@ vo_set_required_input( VipsObject *object, GParamSpec *pspec,
132
152
const char * name = g_param_spec_get_name ( pspec );
133
153
int i = vo -> nargs_required ;
134
154
135
- GValue value = { 0 };
155
+ GValue gvalue = { 0 };
136
156
137
- if ( !heap_ip_to_gvalue ( & vo -> args [i ], & value ) )
157
+ if ( !heap_ip_to_gvalue ( & vo -> args [i ], & gvalue ) )
138
158
return ( object );
139
- g_object_set_property ( G_OBJECT ( object ), name , & value );
140
- g_value_unset ( & value );
159
+ if ( vo_set_property ( vo , name , pspec , & gvalue ) ) {
160
+ g_value_unset ( & gvalue );
161
+ return ( object );
162
+ }
163
+ g_value_unset ( & gvalue );
141
164
142
165
vo -> nargs_required += 1 ;
143
166
}
@@ -173,7 +196,10 @@ vo_set_optional_arg( const char *name, PElement *value, Vo *vo )
173
196
g_value_unset ( & gvalue );
174
197
return ( value );
175
198
}
176
- g_object_set_property ( G_OBJECT ( vo -> object ), name , & gvalue );
199
+ if ( vo_set_property ( vo , name , pspec , & gvalue ) ) {
200
+ g_value_unset ( & gvalue );
201
+ return ( value );
202
+ }
177
203
g_value_unset ( & gvalue );
178
204
}
179
205
0 commit comments