mirror of
https://github.com/13hannes11/toolbx-tuner.git
synced 2024-09-03 23:21:00 +02:00
change icon based on container status
This commit is contained in:
17
src/app.rs
17
src/app.rs
@@ -13,17 +13,18 @@ use std::collections::HashSet;
|
|||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use crate::config::{APP_ID, PROFILE};
|
||||||
|
use crate::factories::container_list::Container;
|
||||||
|
use crate::factories::container_list::ContainerStatus;
|
||||||
|
use crate::modals::about::AboutDialog;
|
||||||
|
use crate::modals::unsupported::UnsupportedDialog;
|
||||||
|
use crate::modals::unsupported::UnsupportedDialogOutput;
|
||||||
|
use crate::util::toolbox::ToolbxStatus;
|
||||||
use gtk::prelude::{
|
use gtk::prelude::{
|
||||||
ApplicationExt, ApplicationWindowExt, GtkWindowExt, OrientableExt, SettingsExt, WidgetExt,
|
ApplicationExt, ApplicationWindowExt, GtkWindowExt, OrientableExt, SettingsExt, WidgetExt,
|
||||||
};
|
};
|
||||||
use gtk::{gio, glib};
|
use gtk::{gio, glib};
|
||||||
|
|
||||||
use crate::config::{APP_ID, PROFILE};
|
|
||||||
use crate::factories::container_list::Container;
|
|
||||||
use crate::modals::about::AboutDialog;
|
|
||||||
use crate::modals::unsupported::UnsupportedDialog;
|
|
||||||
use crate::modals::unsupported::UnsupportedDialogOutput;
|
|
||||||
|
|
||||||
pub(super) struct App {
|
pub(super) struct App {
|
||||||
unsupported_dialog: Controller<UnsupportedDialog>,
|
unsupported_dialog: Controller<UnsupportedDialog>,
|
||||||
about_dialog: Controller<AboutDialog>,
|
about_dialog: Controller<AboutDialog>,
|
||||||
@@ -223,6 +224,10 @@ impl Component for App {
|
|||||||
toolbox.id.clone(),
|
toolbox.id.clone(),
|
||||||
ContainerInit {
|
ContainerInit {
|
||||||
name: toolbox.name.clone(),
|
name: toolbox.name.clone(),
|
||||||
|
status: match toolbox.status {
|
||||||
|
ToolbxStatus::Running => ContainerStatus::Running,
|
||||||
|
_ => ContainerStatus::NotRunning,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
updated_containers.insert(toolbox.id.clone());
|
updated_containers.insert(toolbox.id.clone());
|
||||||
|
|||||||
@@ -7,10 +7,17 @@ use relm4::gtk;
|
|||||||
use relm4::gtk::prelude::WidgetExt;
|
use relm4::gtk::prelude::WidgetExt;
|
||||||
use relm4_icons::icon_names;
|
use relm4_icons::icon_names;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum ContainerStatus {
|
||||||
|
Running,
|
||||||
|
NotRunning,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Container {
|
pub struct Container {
|
||||||
hash: String,
|
hash: String,
|
||||||
value: String,
|
value: String,
|
||||||
|
status: ContainerStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -22,6 +29,7 @@ pub enum ContainerMsg {
|
|||||||
|
|
||||||
pub struct ContainerInit {
|
pub struct ContainerInit {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub status: ContainerStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[relm4::factory(pub)]
|
#[relm4::factory(pub)]
|
||||||
@@ -38,6 +46,7 @@ impl FactoryComponent for Container {
|
|||||||
root = adw::ActionRow {
|
root = adw::ActionRow {
|
||||||
#[watch]
|
#[watch]
|
||||||
set_title: &self.value,
|
set_title: &self.value,
|
||||||
|
#[watch]
|
||||||
set_subtitle: &self.hash,
|
set_subtitle: &self.hash,
|
||||||
|
|
||||||
add_prefix = >k::Box{
|
add_prefix = >k::Box{
|
||||||
@@ -45,8 +54,11 @@ impl FactoryComponent for Container {
|
|||||||
set_ratio: 1.0,
|
set_ratio: 1.0,
|
||||||
#[name(play_button)]
|
#[name(play_button)]
|
||||||
gtk::Button {
|
gtk::Button {
|
||||||
// TODO: make component with state that either is waiting, play or pause
|
#[watch]
|
||||||
set_icon_name: icon_names::PLAY,
|
set_icon_name: match &self.status {
|
||||||
|
ContainerStatus::NotRunning => icon_names::PLAY,
|
||||||
|
ContainerStatus::Running => icon_names::PAUSE,
|
||||||
|
},
|
||||||
set_margin_top: 10,
|
set_margin_top: 10,
|
||||||
set_margin_bottom: 10,
|
set_margin_bottom: 10,
|
||||||
set_css_classes: &["circular"],
|
set_css_classes: &["circular"],
|
||||||
@@ -76,6 +88,7 @@ impl FactoryComponent for Container {
|
|||||||
Self {
|
Self {
|
||||||
hash: index.clone(),
|
hash: index.clone(),
|
||||||
value: value.name.clone(),
|
value: value.name.clone(),
|
||||||
|
status: value.status,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user