Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Fix #131 and #102 #132

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Fix #131 and #102 #132

wants to merge 15 commits into from

Conversation

john01dav
Copy link

This is my fix for #131, and, to test it, I added some examples to the repository, thus also fixing #102. Presently, it doesn't have any easy-mode interface, but I think that that's acceptable because one of the examples that I provided gives copy/pasteable code that accomplishes the same thing, and the set of functions that GTK's C api exposes is more complete than what I would do for that part.

@john01dav
Copy link
Author

john01dav commented May 28, 2020

It looks like Travis caught some sort of problem, but I can't find any message that explains what that problem is.
EDIT: I think that I figured it out. It seemed like I forgot a cargo fmt call after a recent fix.

@@ -0,0 +1,335 @@
use crate::CompletionActivation;
Copy link
Member

Choose a reason for hiding this comment

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

This file should be in src/subclass like in the other crates

};

let old_ptr = gobject_sys::g_object_get_qdata(
completion_provider as *mut _,
Copy link
Member

Choose a reason for hiding this comment

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

As we discussed this widget can be different for each proposal. So forbidding this seems like a problem, and the lifetime should probably be bound (via the qdata here) to the proposal and not to the provider.

gobject_sys::g_object_set_qdata_full(
completion_provider as *mut _,
COMPLETION_PROVIDER_INFO_WIDGET.to_glib(),
ret_ptr as *mut libc::c_void,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ret_ptr as *mut libc::c_void,
ret.to_glib_full() as *mut libc::c_void,

);
}

gobject_sys::g_object_set_qdata_full(
Copy link
Member

Choose a reason for hiding this comment

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

This only has to be done if ret is Some

Copy link
Author

Choose a reason for hiding this comment

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

If when ret is None the qdata isn't set, won't the user's implementation function be able to first return None then return Some? This seems like a violation of returning the same object with each call. I'm committing the correction without fully understanding it yet in the pursuit of finishing this soon, but I may be misunderstanding the correction.

gobject_sys::g_object_set_qdata_full(
completion_provider as *mut _,
COMPLETION_PROVIDER_GICON_QUARK.to_glib(),
ret_ptr as *mut libc::c_void,
Copy link
Member

Choose a reason for hiding this comment

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

Also here and elsewhere

Suggested change
ret_ptr as *mut libc::c_void,
ret.to_glib_full() as *mut libc::c_void,

And the whole thing only if ptr is Some

Copy link
Member

Choose a reason for hiding this comment

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

See also gtk-rs/gio#299

Copy link
Member

@sdroege sdroege left a comment

Choose a reason for hiding this comment

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

Mostly looks good to me, for the subclassing part. I don't really know the sourceview API so the examples are something for @GuillaumeGomez

@john01dav john01dav requested a review from sdroege May 29, 2020 17:55
@john01dav
Copy link
Author

With regard to the examples, I can't guarantee that they're free of error, but I'm a lot more confident with the main API than I am with subclassing (and the examples work), so I don't think that a detailed review of that part is vital to merge this PR, in case no one wants to do it. Of course, it is better to have one if someone is willing to.

@john01dav
Copy link
Author

Somehow rustc didn't catch that error when I was working on my code, and it kept building, but once I cleaned and rebuilt from scratch it did on my computer. I'm not sure how to fix it though.

@sdroege
Copy link
Member

sdroege commented May 29, 2020

I'm not sure how to fix it though.

See gtk-rs/gio#299

@john01dav
Copy link
Author

It's fixed... sorry about that.

@sdroege
Copy link
Member

sdroege commented May 30, 2020

No worries. Looks good to me now, the subclassing part. @GuillaumeGomez what do you think about the example?

@GuillaumeGomez
Copy link
Member

I'd prefer if the example was added into the examples repository (in the pending branch!).

@john01dav
Copy link
Author

@GuillaumeGomez My only concern with having it there and only there is that there's no test coverage in this repository then. With the examples where I put them, this repository has all that it needs to test (albeit manually, but that is how things are for GUIs in most cases that I've seen). If you really want, I'll move them from this PR and PR them there, but I think that it's important to address why I put them here in the first place.

@sdroege
Copy link
Member

sdroege commented Jun 1, 2020

@GuillaumeGomez I think having the examples here is ok. As this is not a core GNOME library, it probably shouldn't have the example in the examples repository, especially considering that you were planning to merge all the core libraries into the same repository (which then should also put the examples into the same repository).

@GuillaumeGomez
Copy link
Member

This is a good point.

@john01dav: Then please add a check for your newly added examples folder (in .travis.yml file). Also, please add comments explaining what your example do.

@sdroege
Copy link
Member

sdroege commented Jun 1, 2020

Then please add a check for your newly added examples folder (in .travis.yml file).

They're build automatically by cargo if you add --examples

@GuillaumeGomez
Copy link
Member

It still remains something to be added, no? Or did I miss something?

@sdroege
Copy link
Member

sdroege commented Jun 1, 2020

Yes, just explaining what has to be done :)

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.

3 participants