-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Rename "Session" to "Test" (#107)
This terminology is more precise, and less prone to misunderstandings.
- Loading branch information
1 parent
fc6c58c
commit c13a973
Showing
10 changed files
with
150 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* discord_rpc.rs | ||
* | ||
* SPDX-FileCopyrightText: © 2024 Brage Fuglseth <[email protected]> | ||
* SPDX-FileCopyrightText: © 2024–2025 Brage Fuglseth <[email protected]> | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
|
@@ -17,7 +17,7 @@ | |
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use crate::session_enums::*; | ||
use crate::typing_test_utils::*; | ||
use discord_presence::models::rich_presence::Activity; | ||
use discord_presence::Client; | ||
use std::sync::mpsc; | ||
|
@@ -29,7 +29,7 @@ const DISCORD_CLIENT_ID: u64 = 1320106636743802923; | |
|
||
enum RpcMessage { | ||
SendStored, | ||
Change(SessionConfig, PresenceState), | ||
Change(TestConfig, PresenceState), | ||
UpdateStats(f64, f64), | ||
} | ||
|
||
|
@@ -67,14 +67,14 @@ impl Default for RpcWrapper { | |
for msg in receiver.iter() { | ||
if let RpcMessage::Change(session_config, state) = msg { | ||
let details_string = match session_config { | ||
SessionConfig::Finite => "Custom text".to_string(), | ||
SessionConfig::Generated { | ||
difficulty: GeneratedSessionDifficulty::Simple, | ||
TestConfig::Finite => "Custom text".to_string(), | ||
TestConfig::Generated { | ||
difficulty: GeneratedTestDifficulty::Simple, | ||
duration, | ||
.. | ||
} => format!("Simple, {}", duration.english_string()), | ||
SessionConfig::Generated { | ||
difficulty: GeneratedSessionDifficulty::Advanced, | ||
TestConfig::Generated { | ||
difficulty: GeneratedTestDifficulty::Advanced, | ||
duration, | ||
.. | ||
} => format!("Advanced, {}", duration.english_string()), | ||
|
@@ -121,7 +121,7 @@ impl Default for RpcWrapper { | |
} | ||
|
||
impl RpcWrapper { | ||
pub fn set_activity(&self, session_config: SessionConfig, state: PresenceState) { | ||
pub fn set_activity(&self, session_config: TestConfig, state: PresenceState) { | ||
self.sender | ||
.send(RpcMessage::Change(session_config, state)) | ||
.expect("channel exists until app shuts down"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* results_view.rs | ||
* | ||
* SPDX-FileCopyrightText: © 2024 Brage Fuglseth <[email protected]> | ||
* SPDX-FileCopyrightText: © 2024–2025 Brage Fuglseth <[email protected]> | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
|
@@ -17,7 +17,7 @@ | |
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use crate::session_enums::*; | ||
use crate::typing_test_utils::*; | ||
use adw::prelude::*; | ||
use adw::subclass::prelude::*; | ||
use gettextrs::gettext; | ||
|
@@ -41,9 +41,9 @@ mod imp { | |
#[template_child] | ||
pub accuracy_label: TemplateChild<gtk::Label>, | ||
#[template_child] | ||
pub session_info_box: TemplateChild<gtk::Box>, | ||
pub test_info_box: TemplateChild<gtk::Box>, | ||
#[template_child] | ||
pub session_type_label: TemplateChild<gtk::Label>, | ||
pub test_type_label: TemplateChild<gtk::Label>, | ||
#[template_child] | ||
pub duration_label: TemplateChild<gtk::Label>, | ||
#[template_child] | ||
|
@@ -80,8 +80,8 @@ mod imp { | |
wpm_accuracy_box: Default::default(), | ||
wpm_label: Default::default(), | ||
accuracy_label: Default::default(), | ||
session_info_box: Default::default(), | ||
session_type_label: Default::default(), | ||
test_info_box: Default::default(), | ||
test_type_label: Default::default(), | ||
duration_label: Default::default(), | ||
language_box: Default::default(), | ||
language_label: Default::default(), | ||
|
@@ -109,17 +109,17 @@ mod imp { | |
self.parent_constructed(); | ||
|
||
let wpm_accuracy_box = self.wpm_accuracy_box.get(); | ||
let session_info_box = self.session_info_box.get(); | ||
let test_info_box = self.test_info_box.get(); | ||
|
||
let obj = self.obj(); | ||
|
||
obj.bind_property("orientation", &wpm_accuracy_box, "orientation") | ||
.build(); | ||
|
||
obj.bind_property("orientation", &session_info_box, "orientation") | ||
obj.bind_property("orientation", &test_info_box, "orientation") | ||
.build(); | ||
|
||
obj.bind_property("orientation", &session_info_box, "spacing") | ||
obj.bind_property("orientation", &test_info_box, "spacing") | ||
.transform_to(|_, orientation| match orientation { | ||
gtk::Orientation::Horizontal => Some(30), | ||
gtk::Orientation::Vertical => Some(18), | ||
|
@@ -144,8 +144,8 @@ glib::wrapper! { | |
} | ||
|
||
impl KpResultsView { | ||
pub fn set_summary(&self, summary: SessionSummary) { | ||
let SessionSummary { | ||
pub fn set_summary(&self, summary: TestSummary) { | ||
let TestSummary { | ||
config, | ||
real_duration, | ||
wpm, | ||
|
@@ -167,19 +167,19 @@ impl KpResultsView { | |
imp.duration_label | ||
.set_label(&human_readable_duration(real_duration)); | ||
|
||
let session_type_string = match config { | ||
SessionConfig::Finite => gettext("Custom"), | ||
SessionConfig::Generated { difficulty, .. } => match difficulty { | ||
GeneratedSessionDifficulty::Simple => gettext("Simple"), | ||
GeneratedSessionDifficulty::Advanced => gettext("Advanced"), | ||
let test_type_string = match config { | ||
TestConfig::Finite => gettext("Custom"), | ||
TestConfig::Generated { difficulty, .. } => match difficulty { | ||
GeneratedTestDifficulty::Simple => gettext("Simple"), | ||
GeneratedTestDifficulty::Advanced => gettext("Advanced"), | ||
}, | ||
}; | ||
|
||
imp.session_type_label.set_label(&session_type_string); | ||
imp.test_type_label.set_label(&test_type_string); | ||
|
||
match config { | ||
SessionConfig::Finite => imp.language_box.set_visible(false), | ||
SessionConfig::Generated { language, .. } => { | ||
TestConfig::Finite => imp.language_box.set_visible(false), | ||
TestConfig::Generated { language, .. } => { | ||
imp.language_box.set_visible(true); | ||
imp.language_label | ||
.set_label(&language.get_message().unwrap()); | ||
|
Oops, something went wrong.