From 15f712c7ddf1098bee12e936e7f815eb302537ce Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Sat, 8 May 2021 15:49:57 -0400 Subject: [PATCH] gather crates into workspace --- .github/workflows/CI.yml | 19 +-- .gitignore | 2 +- Cargo.toml | 6 + relm-examples/Cargo.toml | 5 + .../examples/{async/src/main.rs => async.rs} | 0 relm-examples/examples/async/Cargo.toml | 19 --- .../examples/buttons-attribute/Cargo.toml | 18 --- .../examples/buttons-attribute/src/main.rs | 122 ------------------ .../examples/{http/src/main.rs => http.rs} | 0 relm-examples/examples/http/Cargo.toml | 22 ---- relm-examples/tests/include.rs | 2 +- src/lib.rs | 4 + 12 files changed, 20 insertions(+), 199 deletions(-) rename relm-examples/examples/{async/src/main.rs => async.rs} (100%) delete mode 100644 relm-examples/examples/async/Cargo.toml delete mode 100644 relm-examples/examples/buttons-attribute/Cargo.toml delete mode 100644 relm-examples/examples/buttons-attribute/src/main.rs rename relm-examples/examples/{http/src/main.rs => http.rs} (100%) delete mode 100644 relm-examples/examples/http/Cargo.toml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b5218f88..ba55b195 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -47,33 +47,20 @@ jobs: Xvfb :99 & sleep 3 openbox & - cargo test --manifest-path relm-examples/Cargo.toml -- --nocapture + cargo test -- --nocapture - name: "relm-derive: tests" run: | cargo test --manifest-path relm-derive/Cargo.toml -- --nocapture - - name: "relm: test examples" + - name: "relm-examples: tests" run: | Xvfb :99 & sleep 3 openbox & cargo test --manifest-path relm-examples/Cargo.toml --examples - - name: "relm: test buttons-attribute example" - run: | - Xvfb :99 & - sleep 3 - openbox & - cargo test --manifest-path relm-examples/examples/buttons-attribute/Cargo.toml - - - name: "relm: build http example" - run: cargo build --manifest-path relm-examples/examples/http/Cargo.toml - - - name: "relm: build async example" - run: cargo build --manifest-path relm-examples/examples/async/Cargo.toml - - - name: "relm: build webkit-test example" + - name: "relm-examples: build webkit-test example" run: cargo build --manifest-path relm-examples/examples/webkit-test/Cargo.toml - uses: bcomnes/cleanup-xvfb@v1.0.6 diff --git a/.gitignore b/.gitignore index d96c183e..0f3ff491 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -target +/target Cargo.lock release.sh diff --git a/Cargo.toml b/Cargo.toml index 3cef9b8d..4d3e2dc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,5 +21,11 @@ gtk = "^0.9.0" libc = "^0.2.54" log = "^0.4.6" +[dev-dependencies] +relm-derive = { path = "relm-derive" } + [features] hidpi = ["cairo-rs/v1_14"] + +[workspace] +members = ["relm-derive", "relm-examples", "relm-examples/examples/webkit-test", "relm-test"] diff --git a/relm-examples/Cargo.toml b/relm-examples/Cargo.toml index d791279c..20659b89 100644 --- a/relm-examples/Cargo.toml +++ b/relm-examples/Cargo.toml @@ -10,13 +10,18 @@ edition = "2018" [dev-dependencies] chrono = "0.4" gdk = "^0.13.0" +gdk-pixbuf = "^0.9.0" glib = "^0.10.0" gtk = "^0.9.0" gtk-test = "^0.6" +json = "^0.11.5" rand = "^0.5.1" +simplelog = "^0.5.3" +uhttp_uri = "^0.5.1" [dev-dependencies.gio] version = "^0.9.0" +features = ["v2_50"] [dev-dependencies.relm] path = ".." diff --git a/relm-examples/examples/async/src/main.rs b/relm-examples/examples/async.rs similarity index 100% rename from relm-examples/examples/async/src/main.rs rename to relm-examples/examples/async.rs diff --git a/relm-examples/examples/async/Cargo.toml b/relm-examples/examples/async/Cargo.toml deleted file mode 100644 index 9c0f7a68..00000000 --- a/relm-examples/examples/async/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -authors = ["Antoni Boucher "] -name = "async" -version = "0.1.0" -edition = "2018" - -[dependencies] -glib = "0.10.0" -gtk = "^0.9.0" - -[dependencies.gio] -features = ["v2_50"] -version = "^0.9.0" - -[dependencies.relm] -path = "../../.." - -[dependencies.relm-derive] -path = "../../../relm-derive" diff --git a/relm-examples/examples/buttons-attribute/Cargo.toml b/relm-examples/examples/buttons-attribute/Cargo.toml deleted file mode 100644 index 40906ae6..00000000 --- a/relm-examples/examples/buttons-attribute/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "buttons-attribute" -version = "0.1.0" -authors = ["Antoni Boucher "] -edition = "2018" - -[dependencies] -gtk = "^0.9.0" -gtk-test = "^0.6" - -[dependencies.relm] -path = "../../.." - -[dependencies.relm-derive] -path = "../../../relm-derive" - -[dependencies.relm-test] -path = "../../../relm-test" diff --git a/relm-examples/examples/buttons-attribute/src/main.rs b/relm-examples/examples/buttons-attribute/src/main.rs deleted file mode 100644 index 72904d4c..00000000 --- a/relm-examples/examples/buttons-attribute/src/main.rs +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2018-2020 Boucher, Antoni - * - * 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. - */ - -use gtk::{ - ButtonExt, - Inhibit, - LabelExt, - OrientableExt, - WidgetExt, -}; -use gtk::Orientation::Vertical; -use relm::{Relm, Widget, timeout}; -use relm_derive::{Msg, widget}; - -use self::Msg::*; - -// Define the structure of the model. -pub struct Model { - counter: i32, -} - -// The messages that can be sent to the update function. -#[derive(Msg)] -pub enum Msg { - Decrement, - Increment, - Quit, - Show, -} - -#[widget] -impl Widget for Win { - // The initial model. - fn model(relm: &Relm, _: ()) -> Model { - timeout(relm.stream(), 1000, || Show); - Model { - counter: 0, - } - } - - // Update the model according to the message received. - fn update(&mut self, event: Msg) { - match event { - Decrement => self.model.counter -= 1, - Increment => self.model.counter += 1, - Quit => gtk::main_quit(), - Show => self.widgets.dec_button.set_visible(true), - } - } - - view! { - gtk::Window { - gtk::Box { - // Set the orientation property of the Box. - orientation: Vertical, - // Create a Button inside the Box. - gtk::Button { - // Send the message Increment when the button is clicked. - clicked => Increment, - // TODO: check if using two events of the same name work. - label: "+", - }, - #[name="label"] - gtk::Label { - // Bind the text property of the label to the counter attribute of the model. - text: &self.model.counter.to_string(), - }, - #[name="dec_button"] - gtk::Button { - clicked => Decrement, - label: "-", - visible: false, - }, - }, - delete_event(_, _) => (Quit, Inhibit(false)), - } - } -} - -fn main() { - Win::run(()).expect("Win::run failed"); -} - -#[cfg(test)] -mod tests { - use gtk::LabelExt; - - use gtk_test::assert_text; - use relm_test::click; - - use crate::Win; - - #[test] - fn label_change() { - let (_component, _, widgets) = relm::init_test::(()).expect("init_test failed"); - let dec_button = &widgets.dec_button; - let label = &widgets.label; - - click(dec_button); - assert_text!(label, -1); - click(dec_button); - assert_text!(label, -2); - } -} diff --git a/relm-examples/examples/http/src/main.rs b/relm-examples/examples/http.rs similarity index 100% rename from relm-examples/examples/http/src/main.rs rename to relm-examples/examples/http.rs diff --git a/relm-examples/examples/http/Cargo.toml b/relm-examples/examples/http/Cargo.toml deleted file mode 100644 index 9b4eaf93..00000000 --- a/relm-examples/examples/http/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -authors = ["Antoni Boucher "] -name = "http" -version = "0.1.0" -edition = "2018" - -[dependencies] -gdk = "^0.13.0" -gdk-pixbuf = "^0.9.0" -gio = "^0.9.0" -glib = "^0.10.0" -glib-sys = "^0.10.0" -gtk = "^0.9.0" -json = "^0.11.5" -simplelog = "^0.5.3" -uhttp_uri = "^0.5.1" - -[dependencies.relm] -path = "../../.." - -[dependencies.relm-derive] -path = "../../../relm-derive" diff --git a/relm-examples/tests/include.rs b/relm-examples/tests/include.rs index d6f8066f..2453ccc4 100644 --- a/relm-examples/tests/include.rs +++ b/relm-examples/tests/include.rs @@ -64,7 +64,7 @@ impl Widget for Win { } // Specify a view written in another file. - view!("tests/buttons.relm"); + view!("relm-examples/tests/buttons.relm"); } fn main() { diff --git a/src/lib.rs b/src/lib.rs index 507ebf83..b07246ed 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -238,6 +238,10 @@ type InitTestComponents = (Component, ::St /// # } /// # /// # impl WidgetTest for Win { +/// # type Streams = (); +/// # +/// # fn get_streams(&self) -> Self::Streams {} +/// # /// # type Widgets = Win; /// # /// # fn get_widgets(&self) -> Self::Widgets {