Make example runnable as example

Trying to run examples as usual (and as described in the README) fails:

    > cargo run --release --example cosmic
    error: no example target named `cosmic`.

The examples themselves are written as separate crates, and are
therefore not usable as examples (they also won't build via `cargo build
--examples`).

This commit makes the example fit the style that cargo can understand.
That is:

- Don't declare the example as a separate crate.
- Remove the nested `src` inside the example directory.
- Put example-only dependencies in dev-dependencies

No rust code was modified, files were only moved.
This commit is contained in:
Hugo Osvaldo Barrera 2023-03-12 11:24:49 +01:00
parent e3ec7e3b7d
commit 6ce9f4fc7a
12 changed files with 3 additions and 14 deletions

View file

@ -1,94 +0,0 @@
use cosmic::{
iced::widget::{horizontal_space, row, text},
iced::Length,
widget::{icon, list_column, settings},
Element,
};
use super::{Message, Page, SubPage, Window};
#[derive(Default)]
pub struct State {}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum SystemAndAccountsPage {
Users,
About,
Firmware,
}
impl SubPage for SystemAndAccountsPage {
//TODO: translate
fn title(&self) -> &'static str {
use SystemAndAccountsPage::*;
match self {
Users => "Users",
About => "About",
Firmware => "Firmware",
}
}
//TODO: translate
fn description(&self) -> &'static str {
use SystemAndAccountsPage::*;
match self {
Users => "Authentication and login, lock screen.",
About => "Device name, hardware information, operating system defaults.",
Firmware => "Firmware details.",
}
}
fn icon_name(&self) -> &'static str {
use SystemAndAccountsPage::*;
match self {
Users => "system-users-symbolic",
About => "help-about-symbolic",
Firmware => "firmware-manager-symbolic",
}
}
fn parent_page(&self) -> Page {
Page::SystemAndAccounts(None)
}
fn into_page(self) -> Page {
Page::SystemAndAccounts(Some(self))
}
}
impl State {
pub(super) fn view<'a>(&'a self, window: &'a Window) -> Element<'a, Message> {
settings::view_column(vec![
window.parent_page_button(SystemAndAccountsPage::About),
row!(
horizontal_space(Length::Fill),
icon("distributor-logo", 78),
horizontal_space(Length::Fill),
)
.into(),
list_column()
.add(settings::item("Device name", text("TODO")))
.into(),
settings::view_section("Hardware")
.add(settings::item("Hardware model", text("TODO")))
.add(settings::item("Memory", text("TODO")))
.add(settings::item("Processor", text("TODO")))
.add(settings::item("Graphics", text("TODO")))
.add(settings::item("Disk Capacity", text("TODO")))
.into(),
settings::view_section("Operating System")
.add(settings::item("Operating system", text("TODO")))
.add(settings::item(
"Operating system architecture",
text("TODO"),
))
.add(settings::item("Desktop environment", text("TODO")))
.add(settings::item("Windowing system", text("TODO")))
.into(),
settings::view_section("Related settings")
.add(settings::item("Get support", text("TODO")))
.into(),
])
.into()
}
}