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::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::{
|
||||
ApplicationExt, ApplicationWindowExt, GtkWindowExt, OrientableExt, SettingsExt, WidgetExt,
|
||||
};
|
||||
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 {
|
||||
unsupported_dialog: Controller<UnsupportedDialog>,
|
||||
about_dialog: Controller<AboutDialog>,
|
||||
@@ -223,6 +224,10 @@ impl Component for App {
|
||||
toolbox.id.clone(),
|
||||
ContainerInit {
|
||||
name: toolbox.name.clone(),
|
||||
status: match toolbox.status {
|
||||
ToolbxStatus::Running => ContainerStatus::Running,
|
||||
_ => ContainerStatus::NotRunning,
|
||||
},
|
||||
},
|
||||
);
|
||||
updated_containers.insert(toolbox.id.clone());
|
||||
|
||||
@@ -7,10 +7,17 @@ use relm4::gtk;
|
||||
use relm4::gtk::prelude::WidgetExt;
|
||||
use relm4_icons::icon_names;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ContainerStatus {
|
||||
Running,
|
||||
NotRunning,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Container {
|
||||
hash: String,
|
||||
value: String,
|
||||
status: ContainerStatus,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -22,6 +29,7 @@ pub enum ContainerMsg {
|
||||
|
||||
pub struct ContainerInit {
|
||||
pub name: String,
|
||||
pub status: ContainerStatus,
|
||||
}
|
||||
|
||||
#[relm4::factory(pub)]
|
||||
@@ -38,6 +46,7 @@ impl FactoryComponent for Container {
|
||||
root = adw::ActionRow {
|
||||
#[watch]
|
||||
set_title: &self.value,
|
||||
#[watch]
|
||||
set_subtitle: &self.hash,
|
||||
|
||||
add_prefix = >k::Box{
|
||||
@@ -45,8 +54,11 @@ impl FactoryComponent for Container {
|
||||
set_ratio: 1.0,
|
||||
#[name(play_button)]
|
||||
gtk::Button {
|
||||
// TODO: make component with state that either is waiting, play or pause
|
||||
set_icon_name: icon_names::PLAY,
|
||||
#[watch]
|
||||
set_icon_name: match &self.status {
|
||||
ContainerStatus::NotRunning => icon_names::PLAY,
|
||||
ContainerStatus::Running => icon_names::PAUSE,
|
||||
},
|
||||
set_margin_top: 10,
|
||||
set_margin_bottom: 10,
|
||||
set_css_classes: &["circular"],
|
||||
@@ -76,6 +88,7 @@ impl FactoryComponent for Container {
|
||||
Self {
|
||||
hash: index.clone(),
|
||||
value: value.name.clone(),
|
||||
status: value.status,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user