-
Notifications
You must be signed in to change notification settings - Fork 81
add glib.Object.GetProperty and glib.Object.SetProperty #56
base: master
Are you sure you want to change the base?
Conversation
I think that Set should be fixed rather than just tacking on a workaround. Do you have an example that shows the failure? |
paramSpec := C.g_object_class_find_property(C._g_object_get_class(v.native()), (*C.gchar)(cstr)) | ||
if paramSpec == nil { | ||
return TYPE_INVALID, errors.New("couldn't find Property") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this whitespace.
In any case, I added a whole bunch of comments for some style mistakes. Please fix Set with the new implementation and fix these style issues and I'd be happy to merge the PR. |
First thank you for the comments. My problem was with setting 'uri' on a playbin in the example in my gst binding fork - here (it currently needs additional changes in my development branch of gotk3). |
Thinking about it - I would really prefer if GParamSpec gets a representation as a go type which would take GObjectClass representation too. That would make GetPropertyType unnecessary. |
Sorry for the slow response. I think it may be a good idea if it can be done without substantial complexity, but I'm not totally familiar with the internals of and API for using GParamSpec (and the glib doco is rather light in this area). If my understanding is correct, this should allow creating/retrieving the properties for any Object, like: paramSpec := obj.ParamSpec()
prop, err := paramSpec.GetPropery(propName)
// Assumming prop is an int
n, ok := prop.(int)
paramSpec.SetProperty(propName, n+1) What other advantages would adding ParamSpec wrappers have? The above is basically how I expect Get and Set must work, but without the ParamSpec plumbing in the middle. |
No worries, and I'm sorry for my slow response, too :). I more and more think that you are correct at least for the moment as the two things I can think of using GParamSpec implementation are : Both are not bad features to have, but will take a lot more work to implement either of them. On the other hand redoing the above code to use a possible future implementation of both GParamSpec and GObjectClass does not actually take a lot of code changes. I'm not all that familiar with glib, gtk or any of the other techonology/libraries that are being used. So all of the above was learned while reading the docs to bind what I need. |
I had problems using the Object.Set method so decided to implement the SetProperty and GetProperty (at which point my problem was resolved).
I might implement the property listing and wrap GParamSpec in the future