Permalink
Browse files

Take the label into account for child properties

  • Loading branch information...
antoyo committed Jan 2, 2018
1 parent 7a5ece1 commit 35c0f28a7647c4637fe33763f0f0a00aec3d54e0
@@ -7,7 +7,7 @@ license = "MIT"
name = "relm"
readme = "README.adoc"
repository = "https://github.com/antoyo/relm"
version = "0.11.0"
version = "0.12.0"
[badges.appveyor]
branch = "master"
repository = "antoyo/relm"
@@ -27,11 +27,11 @@ libc = "^0.2.22"
[dependencies.relm-core]
path = "relm-core"
version = "^0.11.0"
version = "^0.12.0"
[dependencies.relm-state]
path = "relm-state"
version = "^0.11.0"
version = "^0.12.0"
[dev-dependencies]
chrono = "^0.3.0"
@@ -42,15 +42,15 @@ version = "^0.3.0"
[dev-dependencies.relm-attributes]
path = "relm-attributes"
version = "^0.11.0"
version = "^0.12.0"
[dev-dependencies.relm-derive]
path = "relm-derive"
version = "^0.11.0"
version = "^0.12.0"
[dev-dependencies.relm-test]
path = "relm-test"
version = "^0.11.0"
version = "^0.12.0"
[features]
nightly = []
@@ -83,7 +83,7 @@ impl Widget for Win {
label: "-",
},
gtk::Button {
packing: {
child: {
expand: false,
fill: true,
pack_type: PackType::Start,
@@ -57,7 +57,7 @@ impl Widget for Button {
view! {
gtk::Button {
packing: {
child: {
expand: false,
fill: true,
pack_type: PackType::Start,
@@ -112,7 +112,7 @@ impl Widget for Win {
gtk::Window {
VBox {
gtk::Button {
packing: {
child: {
padding: 20,
},
clicked => Increment,
@@ -0,0 +1,154 @@
/*
* Copyright (c) 2017 Boucher, Antoni <bouanto@zoho.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#![feature(proc_macro)]
extern crate gtk;
#[macro_use]
extern crate relm;
extern crate relm_attributes;
#[macro_use]
extern crate relm_derive;
use gtk::{
ButtonExt,
GridExt,
Inhibit,
LabelExt,
WidgetExt,
};
use relm::Widget;
use relm_attributes::widget;
use self::Msg::*;
#[derive(Msg)]
pub enum Msg {
Quit,
}
#[widget]
impl Widget for Win {
fn model() -> () {
}
fn update(&mut self, event: Msg) {
match event {
Quit => gtk::main_quit(),
}
}
view! {
gtk::Window {
gtk::Grid {
gtk::Button {
label: "7",
cell: {
left_attach: 0,
top_attach: 0,
},
},
gtk::Button {
label: "8",
cell: {
left_attach: 1,
top_attach: 0,
},
},
gtk::Button {
label: "9",
cell: {
left_attach: 2,
top_attach: 0,
},
},
gtk::Button {
label: "4",
cell: {
left_attach: 0,
top_attach: 1,
},
},
gtk::Button {
label: "5",
cell: {
left_attach: 1,
top_attach: 1,
},
},
gtk::Button {
label: "6",
cell: {
left_attach: 2,
top_attach: 1,
},
},
gtk::Button {
label: "1",
cell: {
left_attach: 0,
top_attach: 2,
},
},
gtk::Button {
label: "2",
cell: {
left_attach: 1,
top_attach: 2,
},
},
gtk::Button {
label: "3",
cell: {
left_attach: 2,
top_attach: 2,
},
},
gtk::Button {
label: "+/-",
cell: {
left_attach: 0,
top_attach: 3,
},
},
gtk::Button {
label: "0",
cell: {
left_attach: 1,
top_attach: 3,
},
},
gtk::Button {
label: ".",
cell: {
left_attach: 2,
top_attach: 3,
},
}
},
delete_event(_, _) => (Quit, Inhibit(false))
}
}
}
fn main() {
Win::run(()).unwrap();
}
@@ -113,7 +113,7 @@ impl Widget for SplitBox {
},
#[container="right"]
MyFrame {
packing: {
child: {
padding: 10,
},
}
@@ -61,7 +61,7 @@ impl Widget for Win {
gtk::Window {
gtk::Notebook {
gtk::Button {
tab: {
child: {
tab_label: Some("First Button"),
},
label: "+",
@@ -5,7 +5,7 @@ documentation = "https://docs.rs/relm-attributes/"
license = "MIT"
name = "relm-attributes"
repository = "https://github.com/antoyo/relm"
version = "0.11.0"
version = "0.12.0"
[dependencies]
env_logger = "^0.4.2"
@@ -15,7 +15,7 @@ syn = "^0.11.9"
[dependencies.relm-gen-widget]
path = "../relm-gen-widget"
version = "^0.11.0"
version = "^0.12.0"
[lib]
proc-macro = true
@@ -6,7 +6,7 @@ documentation = "https://docs.rs/relm-core/"
license = "MIT"
name = "relm-core"
repository = "https://github.com/antoyo/relm"
version = "0.11.0"
version = "0.12.0"
[dependencies]
futures = "^0.1.14"
@@ -4,12 +4,12 @@ description = "Common derive implementation internally used by relm crates"
license = "MIT"
name = "relm-derive-common"
repository = "https://github.com/antoyo/relm"
version = "0.11.0"
version = "0.12.0"
[dependencies]
quote = "^0.3.15"
syn = "^0.11.11"
[dependencies.relm-gen-widget]
path = "../relm-gen-widget"
version = "^0.11.0"
version = "^0.12.0"
@@ -3,7 +3,7 @@ authors = ["Antoni Boucher <bouanto@zoho.com>"]
description = "Custom derive required by the relm-state crate."
license = "MIT"
name = "relm-derive-state"
version = "0.11.0"
version = "0.12.0"
repository = "https://github.com/antoyo/relm"
[lib]
@@ -14,4 +14,4 @@ syn = "^0.11.8"
[dependencies.relm-derive-common]
path = "../relm-derive-common"
version = "^0.11.0"
version = "^0.12.0"
@@ -5,7 +5,7 @@ documentation = "https://docs.rs/relm-derive/"
license = "MIT"
name = "relm-derive"
repository = "https://github.com/antoyo/relm"
version = "0.11.0"
version = "0.12.0"
[lib]
proc-macro = true
@@ -16,8 +16,8 @@ syn = "^0.11.8"
[dependencies.relm-derive-common]
path = "../relm-derive-common"
version = "^0.11.0"
version = "^0.12.0"
[dependencies.relm-gen-widget]
path = "../relm-gen-widget"
version = "^0.11.0"
version = "^0.12.0"
@@ -5,7 +5,7 @@ documentation = "https://docs.rs/relm-gen-widget/"
license = "MIT"
name = "relm-gen-widget"
repository = "https://github.com/antoyo/relm"
version = "0.11.0"
version = "0.12.0"
[dependencies]
lazy_static = "^0.2.4"
@@ -724,8 +724,8 @@ fn gen_set_child_prop_calls(widget: &Widget, parent: Option<&Ident>, parent_widg
let widget_name = &widget.name;
let mut child_properties = vec![];
if let Some(parent) = parent {
for (key, value) in &widget.child_properties {
let property_func = Ident::new(format!("set_child_{}", key));
for (&(ref ident, ref key), value) in &widget.child_properties {
let property_func = Ident::new(format!("set_{}_{}", ident, key));
let parent =
if parent_widget_type == IsGtk {
quote! {
@@ -537,8 +537,8 @@ fn get_second_param_type(sig: &MethodSig) -> Ty {
fn gen_set_child_prop_calls(widget: &Widget) -> Option<ImplItem> {
let mut tokens = Tokens::new();
let widget_name = &widget.name;
for (key, value) in &widget.child_properties {
let property_func = Ident::new(format!("set_child_{}", key));
for (&(ref ident, ref key), value) in &widget.child_properties {
let property_func = Ident::new(format!("set_{}_{}", ident, key));
tokens.append(quote! {
parent.#property_func(&self.#widget_name, #value);
});
Oops, something went wrong.

0 comments on commit 35c0f28

Please sign in to comment.