-
-
Notifications
You must be signed in to change notification settings - Fork 24
Allow to get Color from Analysis #168
base: master
Are you sure you want to change the base?
Conversation
src/attr_color.rs
Outdated
|
||
impl PartialEq for AttrColor { | ||
fn eq(&self, other: &AttrColor) -> bool { | ||
self.0 == other.0 |
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 should probably call pango_attr_equal()
And a Drop
impl that calls pango_attr_destroy()
should probably exist too, and a Clone
impl that calls pango_attr_copy()
I think the attrs should probably be implemented like the patterns in cairo
. The generic pango_attr
API works on all of them and then there are "subclasses" of the generic PangoAttr
type.
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.
@sdroege would you be able to provide me with some links to the code that I could use as references? Especially to the patterns in cairo
. Thanks.
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.
Take a look here: https://github.com/gtk-rs/cairo/blob/master/src/patterns.rs
There's a base Pattern
type and specific struct FooPattern(Pattern)
that provide specific API. Pattern
impls Drop
for memory management, and there are try_from()
and deref()
impls to get from one to another.
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 still applies to the PR and requires some more work
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.
@GuillaumeGomez See above, that's the main missing part here. Let's just defer that to a future release, it involves quite some work and figuring out a nice API. I wouldn't want to merge that just before a release but rather give people some time to try it first.
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.
More like a Widget
and not Button
. ;) From my point of view, we should merge this and implement what's left in the next release.
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.
It's useless as it is and will only cause bug reports from people trying to figure out how to use it and not understanding :) And worst case we introduce a new actual bug here that slipped through the review.
I would rather wait until after the release, there's no advantage in having this in this release already and only the risk of introducing a new bug.
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.
You mean except being able to create the attributes which we cannot currently? :p
It seems it's more of a "create and never modify" API from what I saw. So I guess it's mostly fine. Also, where could they get bugs? We don't access to anything...
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.
What do you think about this @EPashkin ?
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.
Waiting for his opinion then :) Maybe I'm just a bit too strict here.
Need a hand in here? |
3b6bc0f
to
385dcec
Compare
Ok, I updated the code. The |
385dcec
to
52886eb
Compare
use glib::translate::from_glib_full; | ||
use glib::translate::ToGlib; | ||
use glib::translate::ToGlibPtr; | ||
|
||
impl Attribute { | ||
#[cfg(any(feature = "v1_38", feature = "dox"))] | ||
pub fn new_background_alpha(alpha: u16) -> Option<Attribute> { |
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 (and all the others too) should probably return an AttributeBackgrondAlpha
?
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.
No, it's all casted as Attribute
in the source code. Also, it's not really supposed to be "used" so better not give access to the fields.
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.
Ack
src/attribute.rs
Outdated
|
||
pub fn new_weight(weight: Weight) -> Option<Attribute> { | ||
unsafe { from_glib_full(pango_sys::pango_attr_weight_new(weight.to_glib())) } | ||
} | ||
|
||
pub fn get_attr_class(&self) -> AttrClass { |
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.
Why remove this?
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.
Went too quickly I think... Putting it back!
} | ||
} | ||
|
||
pub fn get_end_index(&self) -> u32 { |
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.
These two getters at least seem useful, the setters maybe not
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.
Indeed. Don't remember why I removed them...
let stash = self.to_glib_none_mut(); | ||
(*stash.0).end_index = index; | ||
} | ||
} |
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 implement Clone
via pango_attribute_copy()
, Drop
via pango_attribute_destroy()
, PartialEq/Eq
via pango_attribute_equal()
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.
Look at the auto impl maybe?
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.
Ah I thought there's only the manual impl of it. Ok then
52886eb
to
6796ab7
Compare
Updated. |
6796ab7
to
82d96e9
Compare
I tried to look at code again after long time, |
You can't, that's the whole point. But at least you can now create all available attributes. |
Then maybe remove changes in analysis.rs and Gir.toml. This we have constructors and minimal get/set for Attribute (API really strange) |
That's a good point. The PR as it is now does not even implement what the title says :) |
The idea is to use it like this: