Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gtk: more manual stuff 4 #229

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

bilelmoussaoui
Copy link
Member

@bilelmoussaoui bilelmoussaoui commented Mar 24, 2021

Pretty small one

  • FileChooser::add_choice
  • PrintSettings::set_page_ranges
  • EntryBuffer::inserted-text
  • EntryBuffer::deleted-text

gtk4/src/file_chooser.rs Outdated Show resolved Hide resolved
&EntryBuffer::from_glib_borrow(this).unsafe_cast_ref(),
to_u16!(position),
&glib::GString::from_glib_borrow(chars),
to_u16!(n_chars),
Copy link
Member

Choose a reason for hiding this comment

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

Should chars be limited to n_chars?

Copy link
Member Author

Choose a reason for hiding this comment

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

As this needs a bit of testing, I added an example and i will try to use some of those APIs and see how that goes

@bilelmoussaoui bilelmoussaoui added this to the 0.1.0 milestone Mar 25, 2021
the API takes a list of option ids that can be None for boolean case (a checkbox)
along with a list for the corresponding labels that can be Null as well.
The change merges them to a single list to ensure both have the same size.
@bilelmoussaoui bilelmoussaoui force-pushed the bilelmoussaoui/more-manual-stuff-4 branch from 5e3326f to 1098c1f Compare May 9, 2021 00:33

impl EntryBufferImpl for CustomEntryBuffer {
fn text(&self, _entry_buffer: &Self::Type) -> glib::GString {
self.text.borrow().clone().into()
Copy link
Member Author

Choose a reason for hiding this comment

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

This is all not really great to use, is there a better way to handle this than having to clone the string? or is it fine to do so as the string can't be that huge due to the EntryBuffer limitation of being at max of a u16::MAX length?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know. You could in theory just return a reference here if it isn't required to be NUL-terminated.

self.text.borrow().chars().count() as u16
}

fn insert_text(&self, entry_buffer: &Self::Type, _position: u16, chars: &str) -> u16 {
Copy link
Member Author

Choose a reason for hiding this comment

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

Both the current insert_text & delete_text methods are wrong due to their complexity on figuring out the bytes position back from the chars position where to insert/delete the string. I was wondering if there might some kind of API/external crate that helps for such situations?

Copy link
Member

Choose a reason for hiding this comment

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

The std API is not enough? How do actual implementors of this in C handle it?

@bilelmoussaoui bilelmoussaoui linked an issue May 9, 2021 that may be closed by this pull request
@bilelmoussaoui
Copy link
Member Author

As much as i would like to get this one in before the release. I will definitely not have the time to finish it. So worth moving it to the next milestone

@bilelmoussaoui bilelmoussaoui removed this from the 0.1.0 milestone Jun 2, 2021
@sdroege
Copy link
Member

sdroege commented Jun 2, 2021

You could also get it into 0.1.1 or so :) It's new API, not something requiring API changes.

@bilelmoussaoui bilelmoussaoui added this to the 0.3 milestone Jul 12, 2021
@sdroege sdroege linked an issue Sep 13, 2021 that may be closed by this pull request
bilelmoussaoui added a commit that referenced this pull request Oct 12, 2021
bilelmoussaoui added a commit that referenced this pull request Oct 12, 2021
bilelmoussaoui added a commit that referenced this pull request Oct 25, 2021
@bilelmoussaoui bilelmoussaoui removed this from the 0.3 milestone Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update EntryBuffer subclass to use u16 [FEATURE REQUEST] gtk_file_chooser_add_choice() binding is missing
2 participants