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: Implementable implementation for AccessibleText #1789

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

Conversation

felinira
Copy link
Contributor

@felinira felinira commented Jul 4, 2024

No description provided.

Comment on lines +442 to +454
let mut c_ranges = glib::Slice::with_capacity(attrs.len());
let mut c_names = glib::StrV::with_capacity(attrs.len());
let mut c_values = glib::StrV::with_capacity(attrs.len());

for (range, name, value) in attrs {
c_ranges.push(range);
c_names.push(name);
c_values.push(value);
}

*ranges = c_ranges.to_glib_container().0;
*attribute_names = c_names.into_glib_ptr();
*attribute_values = c_values.into_glib_ptr();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like having to juggle the collections like that here, and in get_default_attributes, but having to return three Vec from this function would also be odd. Semantically these are triples, but they are supposed to be stored in three different arrays.

A wrapper type could solve the problem but I'm not sure we should introduce two of these just for this one-off.

@felinira felinira force-pushed the wip/fina/accessible-text-impl branch from dadc102 to d3daa8a Compare July 7, 2024 18:08
@felinira
Copy link
Contributor Author

felinira commented Jul 7, 2024

I am a little unsure if it's ever ok to return null in get_contents(_at) or not. Should I return an empty gbytes instead?

@bilelmoussaoui
Copy link
Member

I don't have the time to review this right now but two questions:

  • is it important for you to have this in the next release or waiting till a future .x would be okay?
  • do you think you could add an example of how it could be used?

@felinira
Copy link
Contributor Author

is it important for you to have this in the next release or waiting till a future .x would be okay?

We can postpone it for now.

do you think you could add an example of how it could be used?

Sure, that makes sense. It's quite an involved interface.

#[doc(alias = "GtkAccessibleTextRange")]
#[repr(transparent)]
pub struct AccessibleTextRange(crate::ffi::GtkAccessibleTextRange);
use glib::translate::UnsafeFrom;
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
use glib::translate::UnsafeFrom;
use glib::translate::*;

#[repr(transparent)]
pub struct AccessibleTextRange(crate::ffi::GtkAccessibleTextRange);
use glib::translate::UnsafeFrom;
use gtk4_sys::GtkAccessibleTextRange;
Copy link
Member

Choose a reason for hiding this comment

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

You import it, then only use it in certain places... Usually we do use crate::ffi; and call ffi types with ffi::$Type or functions as well.

glib::wrapper! {
#[doc(alias = "GtkAccessibleTextRange")]
pub struct AccessibleTextRange(BoxedInline<crate::ffi::GtkAccessibleTextRange>);
}
Copy link
Member

Choose a reason for hiding this comment

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

Should be moved to a separate commit.

Comment on lines +8 to +13
use crate::accessible_text_range::AccessibleTextRange;
use crate::subclass::prelude::*;
use crate::{ffi, AccessibleText, AccessibleTextGranularity};
use glib::object::Cast;
use glib::translate::*;
use glib::GString;
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
use crate::accessible_text_range::AccessibleTextRange;
use crate::subclass::prelude::*;
use crate::{ffi, AccessibleText, AccessibleTextGranularity};
use glib::object::Cast;
use glib::translate::*;
use glib::GString;
use crate::{ffi,subclass::prelude::*, AccessibleText,AccessibleTextRange, prelude::*, AccessibleTextGranularity};
use glib::{translate::*, GString};


let func = (*parent_iface)
.get_contents
.expect("no parent \"get_contents\" implementation");
Copy link
Member

Choose a reason for hiding this comment

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

Is this required? Usually we return None if there is no override/default implementation

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.

2 participants