-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
base: main
Are you sure you want to change the base?
Conversation
&EntryBuffer::from_glib_borrow(this).unsafe_cast_ref(), | ||
to_u16!(position), | ||
&glib::GString::from_glib_borrow(chars), | ||
to_u16!(n_chars), |
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.
Should chars
be limited to n_chars
?
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.
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
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.
we need the conversion between u32 & u16
5e3326f
to
1098c1f
Compare
|
||
impl EntryBufferImpl for CustomEntryBuffer { | ||
fn text(&self, _entry_buffer: &Self::Type) -> glib::GString { | ||
self.text.borrow().clone().into() |
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.
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?
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 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 { |
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.
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?
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.
The std
API is not enough? How do actual implementors of this in C handle it?
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 |
You could also get it into 0.1.1 or so :) It's new API, not something requiring API changes. |
Pretty small one