Skip to content

Commit

Permalink
chore(platform): Updated dependency stack to GNOME 46
Browse files Browse the repository at this point in the history
  • Loading branch information
mfep committed May 11, 2024
1 parent 79b1742 commit 677f3f2
Show file tree
Hide file tree
Showing 11 changed files with 823 additions and 935 deletions.
637 changes: 286 additions & 351 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 5 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,19 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
relm4 = { version="0.6.2", features = ["gnome_44", "libadwaita"] }
relm4-components = "0.6.2"
relm4 = { version="0.8.1", features = ["gnome_46", "libadwaita"] }
relm4-components = "0.8.1"
relm4-macros = "0.8.1"
relm4-icons = { version = "0.6.0", features = [
"edit",
"entry-clear",
"pause",
"play",
"plus",
"refresh",
"weight2"
] }
libadwaita = { version="0.4.4", features = ["v1_4"] }
relm4-icons = { version = "0.8.2" }
libadwaita = { version="0.6.0", features = ["v1_5"] }
tokio = { version = "1.36", features = [
"rt",
"macros",
"time",
"rt-multi-thread",
] }
futures = "0.3.30"
rodio = { version="0.17.3", default-features=false, features = ["wav"] }
rodio = { version="0.18.0", default-features=false, features = ["wav"] }
json = "0.12.4"

[build-dependencies]
Expand Down
1,022 changes: 485 additions & 537 deletions cargo-sources.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions icons.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
icons = [
"edit",
"entry-clear",
"pause",
"play",
"plus",
"refresh",
"weight2"
]
28 changes: 19 additions & 9 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use relm4::{
prelude::*,
RelmObjectExt,
};
use relm4_icons::icon_names;

#[derive(Debug)]
pub enum AppModelInput {
Expand Down Expand Up @@ -74,7 +75,7 @@ impl Component for AppModel {
set_child = &adw::ToolbarView {
add_top_bar = &adw::HeaderBar {
pack_start = &gtk::Button {
set_icon_name: "plus",
set_icon_name: icon_names::PLUS,
connect_clicked => AppModelInput::PromptNewExercise,
},
pack_end = &gtk::MenuButton {
Expand All @@ -98,7 +99,7 @@ impl Component for AppModel {
},
#[name = "exercise_list_status"]
adw::StatusPage {
set_icon_name: Some("weight2"),
set_icon_name: Some(icon_names::WEIGHT2),
set_title: "No exercise is created yet",
gtk::Button {
set_css_classes: &["suggested-action", "pill"],
Expand Down Expand Up @@ -126,14 +127,23 @@ impl Component for AppModel {

fn init(
init: Self::Init,
root: &Self::Root,
root: Self::Root,
sender: ComponentSender<Self>,
) -> ComponentParts<Self> {
let list_exercises = relm4::factory::FactoryVecDeque::from_iter(
settings::load_exercise_list_from_gsettings().into_iter(),
gtk::Box::default(),
sender.input_sender(),
);
let mut list_exercises = relm4::factory::FactoryVecDeque::builder()
.launch(gtk::Box::default())
.forward(sender.input_sender(), |output| match output {
ExerciseSetupOutput::Remove(index) => AppModelInput::RemoveExerciseSetup(index),
ExerciseSetupOutput::Load(exercise_setup) => {
AppModelInput::LoadExercise(exercise_setup)
}
});
{
let mut guard = list_exercises.guard();
for exercise_setup in settings::load_exercise_list_from_gsettings().into_iter() {
guard.push_back(exercise_setup);
}
}
let model = AppModel {
exercise_timer: None,
list_exercises,
Expand Down Expand Up @@ -273,7 +283,7 @@ impl Component for AppModel {
}
}
}
update_status_visible(&widgets, &self);
update_status_visible(widgets, self);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/exercise_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl relm4::SimpleComponent for ExerciseEditor {

fn init(
init: Self::Init,
root: &Self::Root,
root: Self::Root,
sender: relm4::ComponentSender<Self>,
) -> relm4::ComponentParts<Self> {
let model = ExerciseEditor {
Expand Down
26 changes: 10 additions & 16 deletions src/exercise_setup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::app::*;
use crate::exercise_editor::*;
use crate::settings;
use futures::prelude::*;
Expand All @@ -7,6 +6,7 @@ use relm4::{
prelude::*,
RelmWidgetExt,
};
use relm4_icons::icon_names;
use std::time::Duration;

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -55,7 +55,6 @@ impl FactoryComponent for ExerciseSetup {
type Input = ExerciseSetupInput;
type Output = ExerciseSetupOutput;
type CommandOutput = ();
type ParentInput = AppModelInput;
type ParentWidget = gtk::Box;

view! {
Expand Down Expand Up @@ -106,7 +105,7 @@ impl FactoryComponent for ExerciseSetup {
attach[1, 1, 1, 1] = &gtk::Label {
set_halign: gtk::Align::Start,
#[watch]
set_label: &format!("{} s", self.exercise_s.to_string()),
set_label: &format!("{} s", self.exercise_s),
},
attach[0, 2, 1, 1] = &gtk::Label {
set_halign: gtk::Align::Start,
Expand All @@ -115,7 +114,7 @@ impl FactoryComponent for ExerciseSetup {
attach[1, 2, 1, 1] = &gtk::Label {
set_halign: gtk::Align::Start,
#[watch]
set_label: &format!("{} s", self.rest_s.to_string()),
set_label: &format!("{} s", self.rest_s),
},
},
#[wrap(Some)]
Expand All @@ -125,21 +124,21 @@ impl FactoryComponent for ExerciseSetup {
set_orientation: gtk::Orientation::Horizontal,
set_valign: gtk::Align::End,
gtk::Button {
set_icon_name: "edit",
set_icon_name: icon_names::EDIT,
connect_clicked[sender] => move |btn| {
sender.input(ExerciseSetupInput::Edit(btn.root().unwrap()));
},
},
gtk::Button {
set_class_active: ("destructive-action", true),
set_icon_name: "entry-clear",
set_icon_name: icon_names::ENTRY_CLEAR,
connect_clicked[sender, index] => move |_| {
sender.output(ExerciseSetupOutput::Remove(index.clone()))
sender.output(ExerciseSetupOutput::Remove(index.clone())).unwrap();
},
},
gtk::Button {
set_class_active: ("suggested-action", true),
set_icon_name: "play",
set_icon_name: icon_names::PLAY,
connect_clicked => ExerciseSetupInput::Load,
},
},
Expand All @@ -157,13 +156,6 @@ impl FactoryComponent for ExerciseSetup {
init
}

fn forward_to_parent(output: Self::Output) -> Option<Self::ParentInput> {
Some(match output {
ExerciseSetupOutput::Remove(index) => AppModelInput::RemoveExerciseSetup(index),
ExerciseSetupOutput::Load(setup) => AppModelInput::LoadExercise(setup),
})
}

fn update(&mut self, message: Self::Input, sender: relm4::FactorySender<Self>) {
match message {
ExerciseSetupInput::Edit(root) => {
Expand All @@ -182,7 +174,9 @@ impl FactoryComponent for ExerciseSetup {
*self = setup;
}
ExerciseSetupInput::Load => {
sender.output(ExerciseSetupOutput::Load(self.clone()));
sender
.output(ExerciseSetupOutput::Load(self.clone()))
.unwrap();
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/exercise_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use relm4::{
prelude::*,
RelmObjectExt, RelmWidgetExt,
};
use relm4_icons::icon_names;
use timer::{TimerModel, TimerOutput};

use crate::{exercise_setup::ExerciseSetup, settings::GlobalExerciseSetup};
Expand Down Expand Up @@ -200,7 +201,7 @@ impl Component for ExerciseTimer {
set_spacing: 12,
gtk::Button {
set_css_classes: &["circular", "large-button"],
set_icon_name: "refresh",
set_icon_name: icon_names::REFRESH,
set_valign: gtk::Align::Center,
connect_clicked => ExerciseTimerInput::Reset,
#[watch]
Expand All @@ -213,7 +214,7 @@ impl Component for ExerciseTimer {
connect_clicked => ExerciseTimerInput::StartStop,
gtk::Image {
#[watch]
set_icon_name: Some(if model.running { "pause" } else { "play" }),
set_icon_name: Some(if model.running { icon_names::PAUSE } else { icon_names::PLAY }),
},
},
#[name = "volume_button"]
Expand Down Expand Up @@ -241,7 +242,7 @@ impl Component for ExerciseTimer {

fn init(
init: Self::Init,
root: &Self::Root,
root: Self::Root,
sender: relm4::ComponentSender<Self>,
) -> ComponentParts<Self> {
let model = ExerciseTimer::new(init.setup, init.global_setup, init.output_handle, &sender);
Expand Down
1 change: 0 additions & 1 deletion src/settings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::exercise_setup::*;
use json;
use relm4::{
self,
binding::*,
Expand Down
2 changes: 1 addition & 1 deletion src/settings_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Component for SettingsDialogModel {

fn init(
init: Self::Init,
root: &Self::Root,
root: Self::Root,
_sender: ComponentSender<Self>,
) -> ComponentParts<Self> {
let widgets = view_output!();
Expand Down
6 changes: 3 additions & 3 deletions src/shortcuts_window.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use relm4::{
self,
gtk::{self, prelude::*},
gtk::{self, glib, prelude::*},
prelude::*,
};

Expand Down Expand Up @@ -34,14 +34,14 @@ impl SimpleComponent for ShortcutsWindowModel {
set_visible: model.visible,
connect_close_request[sender] => move |_| {
sender.input(ShortcutsWindowInput::Hide);
gtk::Inhibit(false)
glib::Propagation::Stop
}
}
}

fn init(
_init: Self::Init,
root: &Self::Root,
root: Self::Root,
sender: ComponentSender<Self>,
) -> ComponentParts<Self> {
let model = Self { visible: false };
Expand Down

0 comments on commit 677f3f2

Please sign in to comment.