mirror of
https://github.com/13hannes11/toolbx-tuner.git
synced 2024-09-03 23:21:00 +02:00
load real toolbx information on startup
This commit is contained in:
@@ -8,22 +8,21 @@ use relm4::{
|
||||
gtk, send, view, Sender,
|
||||
};
|
||||
|
||||
use crate::ui::{
|
||||
app::model::ToolboxStatus,
|
||||
use crate::{ui::{
|
||||
ui_strings::{
|
||||
APP_ICON, APP_TOOLTIP, SETTINGS_ICON, SETTINGS_TOOLTIP, SHUTDOWN_ICON, SHUTDOWN_TOOLTIP,
|
||||
START_ICON, START_TOOLTIP, TERMINAL_ICON, TERMINAL_TOOLTIP, UPDATE_ICON, UPDATE_TOOLTIP,
|
||||
},
|
||||
};
|
||||
}, toolbx::ToolbxContainer};
|
||||
|
||||
use super::{messages::AppMsg, model::ToolboxContainer};
|
||||
use super::{messages::AppMsg};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FactoryWidgets {
|
||||
pub action_row: adw::ActionRow,
|
||||
}
|
||||
|
||||
impl FactoryPrototype for ToolboxContainer {
|
||||
impl FactoryPrototype for ToolbxContainer {
|
||||
type Factory = FactoryVec<Self>;
|
||||
type Widgets = FactoryWidgets;
|
||||
type Root = adw::ActionRow;
|
||||
@@ -37,79 +36,97 @@ impl FactoryPrototype for ToolboxContainer {
|
||||
) -> Self::Widgets {
|
||||
view! {
|
||||
suffix_box = >k::Box{
|
||||
append = >k::Button::from_icon_name(APP_ICON) {
|
||||
set_margin_start: 10,
|
||||
set_margin_top: 10,
|
||||
set_margin_bottom: 10,
|
||||
set_tooltip_text: Some(APP_TOOLTIP),
|
||||
set_css_classes: &["flat"],
|
||||
connect_clicked(sender) => move |btn| {
|
||||
send!(sender, AppMsg::ShowToolboxAppsRequest);
|
||||
append = >k::AspectFrame{
|
||||
set_ratio: 1.0,
|
||||
set_child = Some(>k::Button::from_icon_name(APP_ICON)) {
|
||||
set_margin_start: 10,
|
||||
set_margin_top: 10,
|
||||
set_margin_bottom: 10,
|
||||
set_tooltip_text: Some(APP_TOOLTIP),
|
||||
set_css_classes: &["flat"],
|
||||
connect_clicked(sender) => move |btn| {
|
||||
send!(sender, AppMsg::ShowToolboxAppsRequest);
|
||||
},
|
||||
}
|
||||
},
|
||||
append = >k::AspectFrame{
|
||||
set_ratio: 1.0,
|
||||
set_child = Some(>k::Button::from_icon_name(TERMINAL_ICON)) {
|
||||
set_margin_start: 10,
|
||||
set_margin_top: 10,
|
||||
set_margin_bottom: 10,
|
||||
set_tooltip_text: Some(TERMINAL_TOOLTIP),
|
||||
set_css_classes: &["flat"],
|
||||
}
|
||||
},
|
||||
append = >k::AspectFrame{
|
||||
set_ratio: 1.0,
|
||||
set_child = Some(>k::Button::from_icon_name(SETTINGS_ICON)) {
|
||||
set_margin_start: 10,set_margin_start: 10,
|
||||
set_margin_top: 10,
|
||||
set_margin_bottom: 10,
|
||||
set_tooltip_text: Some(SETTINGS_TOOLTIP),
|
||||
set_css_classes: &["circular"],
|
||||
connect_clicked(sender) => move |btn| {
|
||||
send!(sender, AppMsg::ShowToolboxSettingsRequest);
|
||||
},
|
||||
},
|
||||
},
|
||||
append = >k::Button::from_icon_name(TERMINAL_ICON) {
|
||||
set_margin_start: 10,
|
||||
set_margin_top: 10,
|
||||
set_margin_bottom: 10,
|
||||
set_tooltip_text: Some(TERMINAL_TOOLTIP),
|
||||
set_css_classes: &["flat"],
|
||||
},
|
||||
append = >k::Button::from_icon_name(SETTINGS_ICON) {
|
||||
set_margin_start: 10,set_margin_start: 10,
|
||||
set_margin_top: 10,
|
||||
set_margin_bottom: 10,
|
||||
set_tooltip_text: Some(SETTINGS_TOOLTIP),
|
||||
set_css_classes: &["circular"],
|
||||
connect_clicked(sender) => move |btn| {
|
||||
send!(sender, AppMsg::ShowToolboxSettingsRequest);
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
if self.update_available {
|
||||
view! {
|
||||
update_button = >k::Button::from_icon_name(UPDATE_ICON) {
|
||||
set_margin_top: 10,
|
||||
set_margin_bottom: 10,
|
||||
set_margin_end: 10,
|
||||
set_tooltip_text: Some(UPDATE_TOOLTIP),
|
||||
set_css_classes: &["suggested-action"],
|
||||
update_button = >k::AspectFrame{
|
||||
set_ratio: 1.0,
|
||||
set_child = Some(>k::Button::from_icon_name(UPDATE_ICON)) {
|
||||
set_margin_top: 10,
|
||||
set_margin_bottom: 10,
|
||||
set_margin_end: 10,
|
||||
set_tooltip_text: Some(UPDATE_TOOLTIP),
|
||||
set_css_classes: &["suggested-action"],
|
||||
}
|
||||
}
|
||||
};
|
||||
suffix_box.prepend(&update_button);
|
||||
}
|
||||
|
||||
let is_on = true;
|
||||
*/
|
||||
|
||||
let mut status_button_tooltip = START_TOOLTIP;
|
||||
let mut status_button_icon = START_ICON;
|
||||
|
||||
match &self.status {
|
||||
&ToolboxStatus::Running => {
|
||||
match self.status.as_str() {
|
||||
"running" => {
|
||||
status_button_tooltip = SHUTDOWN_TOOLTIP;
|
||||
status_button_icon = SHUTDOWN_ICON;
|
||||
}
|
||||
&ToolboxStatus::Stopped => {
|
||||
_ => {
|
||||
status_button_tooltip = START_TOOLTIP;
|
||||
status_button_icon = START_ICON;
|
||||
}
|
||||
}
|
||||
|
||||
let subtitle = format!("created {}\n{}", self.created, self.image);
|
||||
|
||||
view! {
|
||||
action_row = &adw::ActionRow {
|
||||
set_title: &self.name,
|
||||
set_subtitle: "additional information",
|
||||
set_subtitle: subtitle.as_str(),
|
||||
add_prefix = >k::Box {
|
||||
append = >k::Button::from_icon_name(status_button_icon) {
|
||||
set_margin_top: 10,
|
||||
set_margin_bottom: 10,
|
||||
set_tooltip_text: Some(status_button_tooltip),
|
||||
set_css_classes: &["circular"],
|
||||
append = >k::AspectFrame{
|
||||
set_ratio: 1.0,
|
||||
set_child = Some(>k::Button::from_icon_name(status_button_icon)) {
|
||||
set_margin_top: 10,
|
||||
set_margin_bottom: 10,
|
||||
set_tooltip_text: Some(status_button_tooltip),
|
||||
set_css_classes: &["circular"],
|
||||
},
|
||||
},
|
||||
},
|
||||
add_suffix: &suffix_box,
|
||||
}
|
||||
|
||||
};
|
||||
FactoryWidgets { action_row }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user