Skip to content
This repository has been archived by the owner on Mar 1, 2019. It is now read-only.

generate gio actionmap #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

generate gio actionmap #14

wants to merge 1 commit into from

Conversation

vhdirk
Copy link
Collaborator

@vhdirk vhdirk commented Jul 6, 2018

Again, no modifications needed here.
I'll create some tests later once I refactor my application for using these.

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));
Copy link
Member

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)?

Copy link
Collaborator Author

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),
Copy link
Member

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

Copy link
Collaborator Author

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...

Copy link
Collaborator Author

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?

Copy link
Member

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 :)

Copy link
Collaborator Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

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.

Copy link
Member

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

Copy link
Collaborator Author

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)

Copy link
Member

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants