mirror of
https://github.com/13hannes11/toolbx-tuner.git
synced 2024-09-03 23:21:00 +02:00
change to use multiple buttons to make state handling easier
This commit is contained in:
@@ -7,7 +7,7 @@ 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)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum ContainerStatus {
|
pub enum ContainerStatus {
|
||||||
Running,
|
Running,
|
||||||
NotRunning,
|
NotRunning,
|
||||||
@@ -52,25 +52,38 @@ impl FactoryComponent for Container {
|
|||||||
add_prefix = >k::Box{
|
add_prefix = >k::Box{
|
||||||
gtk::AspectFrame{
|
gtk::AspectFrame{
|
||||||
set_ratio: 1.0,
|
set_ratio: 1.0,
|
||||||
#[name(play_button)]
|
gtk::Box{
|
||||||
gtk::Button {
|
gtk::Button {
|
||||||
#[watch]
|
#[watch]
|
||||||
set_icon_name: match &self.status {
|
set_visible: self.status == ContainerStatus::NotRunning,
|
||||||
ContainerStatus::NotRunning => icon_names::PLAY,
|
set_icon_name: 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"],
|
||||||
connect_clicked => ContainerMsg::Start,
|
connect_clicked => ContainerMsg::Start,
|
||||||
},
|
},
|
||||||
|
gtk::Button {
|
||||||
|
#[watch]
|
||||||
|
set_visible: self.status == ContainerStatus::Running,
|
||||||
|
set_icon_name: icon_names::PAUSE,
|
||||||
|
set_margin_top: 10,
|
||||||
|
set_margin_bottom: 10,
|
||||||
|
set_css_classes: &["circular"],
|
||||||
|
connect_clicked => ContainerMsg::Stop,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
add_prefix = >k::Box{
|
||||||
|
gtk::AspectFrame{
|
||||||
|
set_ratio: 1.0,
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
add_suffix = >k::Box{
|
add_suffix = >k::Box{
|
||||||
gtk::AspectFrame{
|
gtk::AspectFrame{
|
||||||
set_ratio: 1.0,
|
set_ratio: 1.0,
|
||||||
#[name(add_button)]
|
|
||||||
gtk::Button {
|
gtk::Button {
|
||||||
set_icon_name: icon_names::TERMINAL,
|
set_icon_name: icon_names::TERMINAL,
|
||||||
set_margin_start: 10,
|
set_margin_start: 10,
|
||||||
|
|||||||
Reference in New Issue
Block a user