added color button, i am unsure what to do with it know... you figure that out (#32)
* Add GtkColorButton widget
This commit is contained in:
parent
a7328e458d
commit
d5fc9df94d
1 changed files with 33 additions and 0 deletions
|
@ -22,6 +22,8 @@ pub(super) fn widget_to_gtk_widget(bargs: &mut BuilderArgs) -> Result<Option<gtk
|
||||||
"literal" => build_gtk_literal(bargs)?.upcast(),
|
"literal" => build_gtk_literal(bargs)?.upcast(),
|
||||||
"input" => build_gtk_input(bargs)?.upcast(),
|
"input" => build_gtk_input(bargs)?.upcast(),
|
||||||
"calendar" => build_gtk_calendar(bargs)?.upcast(),
|
"calendar" => build_gtk_calendar(bargs)?.upcast(),
|
||||||
|
"colorButton" => build_gtk_color_button(bargs)?.upcast(),
|
||||||
|
"expander" => build_gtk_expander(bargs)?.upcast(),
|
||||||
_ => return Ok(None),
|
_ => return Ok(None),
|
||||||
};
|
};
|
||||||
Ok(Some(gtk_widget))
|
Ok(Some(gtk_widget))
|
||||||
|
@ -145,6 +147,37 @@ pub(super) fn resolve_orientable_attrs(bargs: &mut BuilderArgs, gtk_widget: >k
|
||||||
|
|
||||||
// concrete widgets
|
// concrete widgets
|
||||||
|
|
||||||
|
/// @widget expander widget
|
||||||
|
fn build_gtk_expander(bargs: &mut BuilderArgs) -> Result<gtk::Expander> {
|
||||||
|
let gtk_widget = gtk::Expander::new(Some("Placeholder text, don't forget to set the property 'name'"));
|
||||||
|
resolve_block!(bargs, gtk_widget, {
|
||||||
|
// @prop label - label of the expander
|
||||||
|
prop(label: as_string) {gtk_widget.set_label(Some(&label));}
|
||||||
|
});
|
||||||
|
Ok(gtk_widget)
|
||||||
|
}
|
||||||
|
/// @widget color button
|
||||||
|
fn build_gtk_color_button(bargs: &mut BuilderArgs) -> Result<gtk::ColorButton> {
|
||||||
|
let gtk_widget = gtk::ColorButtonBuilder::new().build();
|
||||||
|
let on_change_handler_id: Rc<RefCell<Option<glib::SignalHandlerId>>> = Rc::new(RefCell::new(None));
|
||||||
|
resolve_block!(bargs, gtk_widget, {
|
||||||
|
// @prop use-alpha - bool to wether or not use alpha
|
||||||
|
prop(use_alpha: as_bool) {gtk_widget.set_use_alpha(use_alpha);},
|
||||||
|
// @prop onchange - runs the code when the color was selected
|
||||||
|
prop(onchange: as_string) {
|
||||||
|
let old_id = on_change_handler_id.replace(Some(
|
||||||
|
gtk_widget.connect_color_set(move |gtk_widget| {
|
||||||
|
run_command(&onchange, gtk_widget.get_rgba());
|
||||||
|
})
|
||||||
|
));
|
||||||
|
old_id.map(|id| gtk_widget.disconnect(id));
|
||||||
|
}
|
||||||
|
prop(use_alpha: as_bool) {gtk_widget.set_use_alpha(use_alpha);}
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(gtk_widget)
|
||||||
|
}
|
||||||
|
|
||||||
/// @widget scale extends range
|
/// @widget scale extends range
|
||||||
/// @desc a slider.
|
/// @desc a slider.
|
||||||
fn build_gtk_scale(bargs: &mut BuilderArgs) -> Result<gtk::Scale> {
|
fn build_gtk_scale(bargs: &mut BuilderArgs) -> Result<gtk::Scale> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue