-
Notifications
You must be signed in to change notification settings - Fork 4
generate gio actionmap #14
base: master
Are you sure you want to change the base?
Conversation
let imp = instance.get_impl(); | ||
let imp = (*(*interface_static).imp_static).get_impl(imp); | ||
let wrap = from_glib_borrow(gptr); | ||
imp.add_action(&wrap, &from_glib_none(action)); |
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.
Why not &from_glib_borrow(action)
?
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.
Not sure, I'll look into that. Either this is a bug in the gir definitions or in the generator.
let _: gio::Action = gio::Action::from_glib_full(p as *mut gio_ffi::GAction); | ||
}; | ||
gobject_ffi::g_object_set_qdata_full(gptr as *mut gobject_ffi::GObject, | ||
glib_ffi::g_quark_from_string("rs_action_map_lookup_action_ret".to_glib_none().0), |
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.
I think this is not correct here. The caller should be able to grab all actions from the object (different names), but with your code now the action would potentially become invalid at the next call for a differently named action.
let action1 = map.lookup_action("action1");
let action2 = map.lookup_action("action2");
// at this point action1 is invalid but shouldn't
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.
Indeed. Any ideas how this can be solved within the generator? For the return value I could marshall the input value(s), but that's never going to be the silver bullet anyway...
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.
Do you have any idea how this is solved in the python bindings? I would assume they would've run into a similar situation at some point?
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.
Indeed. Any ideas how this can be solved within the generator? For the return value I could marshall the input value(s), but that's never going to be the silver bullet anyway...
As this is a map, the actions should be valid until they are removed.
Do you have any idea how this is solved in the python bindings? I would assume they would've run into a similar situation at some point?
Good question, I don't know. That's definitely worth checking :)
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.
Just for clarity; would this work with my current implementation? In any language, not just Rust.
let action1a = map.lookup_action("action1");
let action1b = map.lookup_action("action1");
// is action1a still valid here?
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.
@vhdirk ?
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.
Oh, I totally missed your reply there. I've been busy with other stuff. Marking this as unsafe indeed seems like to only plausible thing to do. I'll see how fast I can get that done.
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.
No worries :)
I also noticed something else we probably want. Default vfunc implementations for interfaces, not sure if this is already relevant for any interfaces that you added.
See e.g. sdroege/gst-plugin-rs@d1f90d0#diff-e19d43e6ae8224d1a5d7c511c1fcef33R21
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.
Seems useful. The priority of this has shifted back a bit. I've been working om my application, taking inspiration from Hammond and Fractal. Currently, using gtk-subclass still adds so much boilerplate that it still a hassle to actually use it... (aside from cellrenderer, that is)
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.
Yes, I agree. It only really makes sense where there is no other option currently
Again, no modifications needed here.
I'll create some tests later once I refactor my application for using these.