-
-
Notifications
You must be signed in to change notification settings - Fork 82
Implement StyleContext::{get_color, lookup_color} #462
Conversation
Comment about closing must go to first comment to work. |
src/color_chooser.rs
Outdated
@@ -55,9 +50,11 @@ impl<O: IsA<ColorChooser>> ColorChooserExt for O { | |||
} | |||
} | |||
|
|||
fn add_palette(&self, orientation: Orientation, colors_per_line: i32, colors: Vec<GdkRGBA>) { | |||
fn add_palette(&self, orientation: Orientation, colors_per_line: i32, colors: Vec<RGBA>) { |
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.
colors: &[RGBA]
and as_mut_ptr
IMHO won't 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.
Need something like to_glib_none().0
, but its work also need "tested"
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.
Or collecting to Vec<ffi::GdkRGBA>
and pass pointer to it.
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 quite follow, are you saying that the colors
argument should not be Vec<RGBA>
or are you saying my conversion from Vec<RGBA>
to *mut gdk_ffi::GdkRGBA
is wrong?
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 need colors: &[RGBA]
and body changed back
I add few comments to reminder, it mainly for case when gtk-rs/gdk#140 selected to merge. |
src/color_chooser.rs
Outdated
unsafe { ffi::gtk_color_chooser_get_rgba(self.to_glib_none().0, &mut color) }; | ||
fn get_rgba(&self) -> RGBA { | ||
let mut color = unsafe { RGBA::uninitialized() }; | ||
unsafe { ffi::gtk_color_chooser_get_rgba(self.to_glib_none().0, color.to_glib_none_mut().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.
Single unsafe
block
src/color_chooser.rs
Outdated
color | ||
} | ||
|
||
fn set_rgba(&self, color: GdkRGBA) { | ||
unsafe { ffi::gtk_color_chooser_set_rgba(self.to_glib_none().0, &color) }; | ||
fn set_rgba(&self, color: RGBA) { |
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.
Change to color: &RGBA
to complement with record usage
src/style_context.rs
Outdated
} | ||
} | ||
|
||
pub fn lookup_color(&self, color_name: &str) -> Option<gdk::RGBA> { |
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.
See gtk-rs/gdk#140 (comment) with changing local variable name to color
to be equivalent generated version.
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.
color_name is actually what's used in the GTK docs which is why I used it: https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-context-lookup-color
@EPashkin Just pushed new commits that should resolve all your comments. |
src/color_chooser.rs
Outdated
@@ -55,9 +52,13 @@ impl<O: IsA<ColorChooser>> ColorChooserExt for O { | |||
} | |||
} | |||
|
|||
fn add_palette(&self, orientation: Orientation, colors_per_line: i32, colors: Vec<GdkRGBA>) { | |||
fn add_palette(&self, orientation: Orientation, colors_per_line: i32, colors: &mut [RGBA]) { |
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 &mut
just &
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 needs to be mut for the as_mut_ptr
call.
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.
Whoops, looks like that should have been an as_ptr()
call, in which case you're correct.
@Susurrus Sorry, but after |
@EPashkin Yeah, that makes more sense! Cool, that enables a bunch more functions too, including one that was already manually implemented, so that's nice. Hopefully this is now correct. |
src/color_button.rs
Outdated
unsafe { | ||
let mut rgba = mem::uninitialized(); | ||
ffi::gtk_color_button_get_rgba(self.to_glib_none().0, &mut rgba); | ||
unsafe { |
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 function and set_rgba
also not needed as it implemented by ColorChooserExt
I don't know why rust now don't nags about multiple cases even on use.
I've removed the Also, with the addition of the RGBA type, the auto-generated code now includes |
Thanks. |
Okay, so I don't need to do anything about those two functions then? |
Yes, this functions stays as is, deprecation will noted on docs as for http://gtk-rs.org/docs/gtk/prelude/trait.WidgetExt.html#tymethod.drag_source_set_icon_stock |
@GuillaumeGomez Maybe merge this before PR's related to gtk-rs/examples#112 ? |
Awesome, thanks for helping through implementing this @GuillaumeGomez and @EPashkin! |
Add property doc generation
This is done manually because the RGBA struct isn't generally usable by
gir
yet.Closes #454.