mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2024-11-26 14:54:16 +03:00
feat(ui): added backgrounds to main window buttons
Before they were transparent and e.g. settings button was nearly invisible
This commit is contained in:
parent
6ab0423579
commit
9d98f2890d
2 changed files with 144 additions and 128 deletions
|
@ -148,6 +148,10 @@ fn main() {
|
||||||
transition-duration: 0.5s;
|
transition-duration: 0.5s;
|
||||||
transition-timing-function: linear;
|
transition-timing-function: linear;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
.round-bin {{
|
||||||
|
border-radius: 8px;
|
||||||
|
}}
|
||||||
", BACKGROUND_FILE.to_string_lossy()));
|
", BACKGROUND_FILE.to_string_lossy()));
|
||||||
|
|
||||||
// Set UI language
|
// Set UI language
|
||||||
|
|
268
src/ui/main.rs
268
src/ui/main.rs
|
@ -259,175 +259,187 @@ impl SimpleComponent for App {
|
||||||
|
|
||||||
// TODO: add tooltips
|
// TODO: add tooltips
|
||||||
|
|
||||||
gtk::Button {
|
adw::Bin {
|
||||||
#[watch]
|
set_css_classes: &["background", "round-bin"],
|
||||||
set_width_request: match model.style {
|
|
||||||
LauncherStyle::Modern => -1,
|
|
||||||
LauncherStyle::Classic => 40
|
|
||||||
},
|
|
||||||
|
|
||||||
// TODO: update tooltip for predownloaded update
|
gtk::Button {
|
||||||
|
#[watch]
|
||||||
|
set_width_request: match model.style {
|
||||||
|
LauncherStyle::Modern => -1,
|
||||||
|
LauncherStyle::Classic => 40
|
||||||
|
},
|
||||||
|
|
||||||
#[watch]
|
// TODO: update tooltip for predownloaded update
|
||||||
set_tooltip_text: Some(&tr_args("predownload-update", [
|
|
||||||
("version", match model.state.as_ref() {
|
|
||||||
Some(LauncherState::PredownloadAvailable { game, .. }) => game.latest().to_string(),
|
|
||||||
_ => String::from("?")
|
|
||||||
}.into()),
|
|
||||||
|
|
||||||
("size", match model.state.as_ref() {
|
#[watch]
|
||||||
Some(LauncherState::PredownloadAvailable { game, voices }) => {
|
set_tooltip_text: Some(&tr_args("predownload-update", [
|
||||||
let mut size = game.size().unwrap_or((0, 0)).0;
|
("version", match model.state.as_ref() {
|
||||||
|
Some(LauncherState::PredownloadAvailable { game, .. }) => game.latest().to_string(),
|
||||||
|
_ => String::from("?")
|
||||||
|
}.into()),
|
||||||
|
|
||||||
for voice in voices {
|
("size", match model.state.as_ref() {
|
||||||
size += voice.size().unwrap_or((0, 0)).0;
|
Some(LauncherState::PredownloadAvailable { game, voices }) => {
|
||||||
|
let mut size = game.size().unwrap_or((0, 0)).0;
|
||||||
|
|
||||||
|
for voice in voices {
|
||||||
|
size += voice.size().unwrap_or((0, 0)).0;
|
||||||
|
}
|
||||||
|
|
||||||
|
prettify_bytes(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
prettify_bytes(size)
|
_ => String::from("?")
|
||||||
|
}.into())
|
||||||
|
])),
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: matches!(model.state.as_ref(), Some(LauncherState::PredownloadAvailable { .. })),
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_sensitive: match model.state.as_ref() {
|
||||||
|
Some(LauncherState::PredownloadAvailable { game, voices }) => {
|
||||||
|
let config = config::get().unwrap();
|
||||||
|
let temp = config.launcher.temp.unwrap_or_else(|| PathBuf::from("/tmp"));
|
||||||
|
|
||||||
|
let downloaded = temp.join(game.file_name().unwrap()).exists() &&
|
||||||
|
voices.iter().all(|voice| temp.join(voice.file_name().unwrap()).exists());
|
||||||
|
|
||||||
|
!downloaded
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => String::from("?")
|
_ => false
|
||||||
}.into())
|
},
|
||||||
])),
|
|
||||||
|
|
||||||
#[watch]
|
#[watch]
|
||||||
set_visible: matches!(model.state.as_ref(), Some(LauncherState::PredownloadAvailable { .. })),
|
set_css_classes: match model.state.as_ref() {
|
||||||
|
Some(LauncherState::PredownloadAvailable { game, voices }) => {
|
||||||
|
let config = config::get().unwrap();
|
||||||
|
let temp = config.launcher.temp.unwrap_or_else(|| PathBuf::from("/tmp"));
|
||||||
|
|
||||||
#[watch]
|
let downloaded = temp.join(game.file_name().unwrap()).exists() &&
|
||||||
set_sensitive: match model.state.as_ref() {
|
voices.iter().all(|voice| temp.join(voice.file_name().unwrap()).exists());
|
||||||
Some(LauncherState::PredownloadAvailable { game, voices }) => {
|
|
||||||
let config = config::get().unwrap();
|
|
||||||
let temp = config.launcher.temp.unwrap_or_else(|| PathBuf::from("/tmp"));
|
|
||||||
|
|
||||||
let downloaded = temp.join(game.file_name().unwrap()).exists() &&
|
if downloaded {
|
||||||
voices.iter().all(|voice| temp.join(voice.file_name().unwrap()).exists());
|
&["success"]
|
||||||
|
} else {
|
||||||
!downloaded
|
&["warning"]
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => false
|
|
||||||
},
|
|
||||||
|
|
||||||
#[watch]
|
|
||||||
set_css_classes: match model.state.as_ref() {
|
|
||||||
Some(LauncherState::PredownloadAvailable { game, voices }) => {
|
|
||||||
let config = config::get().unwrap();
|
|
||||||
let temp = config.launcher.temp.unwrap_or_else(|| PathBuf::from("/tmp"));
|
|
||||||
|
|
||||||
let downloaded = temp.join(game.file_name().unwrap()).exists() &&
|
|
||||||
voices.iter().all(|voice| temp.join(voice.file_name().unwrap()).exists());
|
|
||||||
|
|
||||||
if downloaded {
|
|
||||||
&["success"]
|
|
||||||
} else {
|
|
||||||
&["warning"]
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_ => &["warning"]
|
_ => &["warning"]
|
||||||
},
|
},
|
||||||
|
|
||||||
set_icon_name: "document-save-symbolic",
|
set_icon_name: "document-save-symbolic",
|
||||||
set_hexpand: false,
|
set_hexpand: false,
|
||||||
|
|
||||||
connect_clicked => AppMsg::PredownloadUpdate
|
connect_clicked => AppMsg::PredownloadUpdate
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
gtk::Button {
|
adw::Bin {
|
||||||
#[watch]
|
set_css_classes: &["background", "round-bin"],
|
||||||
set_label: &match model.state {
|
|
||||||
Some(LauncherState::Launch) => tr("launch"),
|
|
||||||
Some(LauncherState::PredownloadAvailable { .. }) => tr("launch"),
|
|
||||||
Some(LauncherState::PatchAvailable(_)) => tr("apply-patch"),
|
|
||||||
Some(LauncherState::WineNotInstalled) => tr("download-wine"),
|
|
||||||
Some(LauncherState::PrefixNotExists) => tr("create-prefix"),
|
|
||||||
Some(LauncherState::VoiceUpdateAvailable(_)) => tr("update"),
|
|
||||||
Some(LauncherState::VoiceOutdated(_)) => tr("update"),
|
|
||||||
Some(LauncherState::VoiceNotInstalled(_)) => tr("download"),
|
|
||||||
Some(LauncherState::GameUpdateAvailable(_)) => tr("update"),
|
|
||||||
Some(LauncherState::GameOutdated(_)) => tr("update"),
|
|
||||||
Some(LauncherState::GameNotInstalled(_)) => tr("download"),
|
|
||||||
|
|
||||||
None => String::from("...")
|
gtk::Button {
|
||||||
},
|
#[watch]
|
||||||
|
set_label: &match model.state {
|
||||||
|
Some(LauncherState::Launch) => tr("launch"),
|
||||||
|
Some(LauncherState::PredownloadAvailable { .. }) => tr("launch"),
|
||||||
|
Some(LauncherState::PatchAvailable(_)) => tr("apply-patch"),
|
||||||
|
Some(LauncherState::WineNotInstalled) => tr("download-wine"),
|
||||||
|
Some(LauncherState::PrefixNotExists) => tr("create-prefix"),
|
||||||
|
Some(LauncherState::VoiceUpdateAvailable(_)) => tr("update"),
|
||||||
|
Some(LauncherState::VoiceOutdated(_)) => tr("update"),
|
||||||
|
Some(LauncherState::VoiceNotInstalled(_)) => tr("download"),
|
||||||
|
Some(LauncherState::GameUpdateAvailable(_)) => tr("update"),
|
||||||
|
Some(LauncherState::GameOutdated(_)) => tr("update"),
|
||||||
|
Some(LauncherState::GameNotInstalled(_)) => tr("download"),
|
||||||
|
|
||||||
#[watch]
|
None => String::from("...")
|
||||||
set_sensitive: match model.state.as_ref() {
|
|
||||||
Some(LauncherState::GameOutdated { .. }) |
|
|
||||||
Some(LauncherState::VoiceOutdated(_)) => false,
|
|
||||||
|
|
||||||
Some(LauncherState::PatchAvailable(patch)) => match patch {
|
|
||||||
Patch::NotAvailable |
|
|
||||||
Patch::Outdated { .. } |
|
|
||||||
Patch::Preparation { .. } => false,
|
|
||||||
|
|
||||||
Patch::Testing { .. } |
|
|
||||||
Patch::Available { .. } => true
|
|
||||||
},
|
},
|
||||||
|
|
||||||
Some(_) => true,
|
#[watch]
|
||||||
|
set_sensitive: match model.state.as_ref() {
|
||||||
|
Some(LauncherState::GameOutdated { .. }) |
|
||||||
|
Some(LauncherState::VoiceOutdated(_)) => false,
|
||||||
|
|
||||||
None => false
|
Some(LauncherState::PatchAvailable(patch)) => match patch {
|
||||||
},
|
Patch::NotAvailable |
|
||||||
|
Patch::Outdated { .. } |
|
||||||
|
Patch::Preparation { .. } => false,
|
||||||
|
|
||||||
#[watch]
|
Patch::Testing { .. } |
|
||||||
set_css_classes: match model.state.as_ref() {
|
Patch::Available { .. } => true
|
||||||
Some(LauncherState::GameOutdated { .. }) |
|
},
|
||||||
Some(LauncherState::VoiceOutdated(_)) => &["warning"],
|
|
||||||
|
|
||||||
Some(LauncherState::PatchAvailable(patch)) => match patch {
|
Some(_) => true,
|
||||||
Patch::NotAvailable |
|
|
||||||
Patch::Outdated { .. } |
|
|
||||||
Patch::Preparation { .. } => &["error"],
|
|
||||||
|
|
||||||
Patch::Testing { .. } => &["warning"],
|
None => false
|
||||||
Patch::Available { .. } => &["suggested-action"]
|
|
||||||
},
|
},
|
||||||
|
|
||||||
Some(_) => &["suggested-action"],
|
#[watch]
|
||||||
|
set_css_classes: match model.state.as_ref() {
|
||||||
|
Some(LauncherState::GameOutdated { .. }) |
|
||||||
|
Some(LauncherState::VoiceOutdated(_)) => &["warning"],
|
||||||
|
|
||||||
None => &[]
|
Some(LauncherState::PatchAvailable(patch)) => match patch {
|
||||||
},
|
Patch::NotAvailable |
|
||||||
|
Patch::Outdated { .. } |
|
||||||
|
Patch::Preparation { .. } => &["error"],
|
||||||
|
|
||||||
#[watch]
|
Patch::Testing { .. } => &["warning"],
|
||||||
set_tooltip_text: Some(&match model.state.as_ref() {
|
Patch::Available { .. } => &["suggested-action"]
|
||||||
Some(LauncherState::GameOutdated { .. }) |
|
},
|
||||||
Some(LauncherState::VoiceOutdated(_)) => tr("main-window--version-outdated-tooltip"),
|
|
||||||
|
|
||||||
Some(LauncherState::PatchAvailable(patch)) => match patch {
|
Some(_) => &["suggested-action"],
|
||||||
Patch::NotAvailable => tr("main-window--patch-unavailable-tooltip"),
|
|
||||||
|
|
||||||
Patch::Outdated { .. } |
|
None => &[]
|
||||||
Patch::Preparation { .. } => tr("main-window--patch-outdated-tooltip"),
|
},
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_tooltip_text: Some(&match model.state.as_ref() {
|
||||||
|
Some(LauncherState::GameOutdated { .. }) |
|
||||||
|
Some(LauncherState::VoiceOutdated(_)) => tr("main-window--version-outdated-tooltip"),
|
||||||
|
|
||||||
|
Some(LauncherState::PatchAvailable(patch)) => match patch {
|
||||||
|
Patch::NotAvailable => tr("main-window--patch-unavailable-tooltip"),
|
||||||
|
|
||||||
|
Patch::Outdated { .. } |
|
||||||
|
Patch::Preparation { .. } => tr("main-window--patch-outdated-tooltip"),
|
||||||
|
|
||||||
|
_ => String::new()
|
||||||
|
},
|
||||||
|
|
||||||
_ => String::new()
|
_ => String::new()
|
||||||
},
|
}),
|
||||||
|
|
||||||
_ => String::new()
|
#[watch]
|
||||||
}),
|
set_sensitive: !model.disabled_buttons,
|
||||||
|
|
||||||
#[watch]
|
set_hexpand: false,
|
||||||
set_sensitive: !model.disabled_buttons,
|
set_width_request: 200,
|
||||||
|
|
||||||
set_hexpand: false,
|
connect_clicked => AppMsg::PerformAction
|
||||||
set_width_request: 200,
|
}
|
||||||
|
|
||||||
connect_clicked => AppMsg::PerformAction
|
|
||||||
},
|
},
|
||||||
|
|
||||||
gtk::Button {
|
adw::Bin {
|
||||||
#[watch]
|
set_css_classes: &["background", "round-bin"],
|
||||||
set_width_request: match model.style {
|
|
||||||
LauncherStyle::Modern => -1,
|
|
||||||
LauncherStyle::Classic => 40
|
|
||||||
},
|
|
||||||
|
|
||||||
#[watch]
|
gtk::Button {
|
||||||
set_sensitive: !model.disabled_buttons,
|
#[watch]
|
||||||
|
set_width_request: match model.style {
|
||||||
|
LauncherStyle::Modern => -1,
|
||||||
|
LauncherStyle::Classic => 40
|
||||||
|
},
|
||||||
|
|
||||||
set_icon_name: "emblem-system-symbolic",
|
#[watch]
|
||||||
|
set_sensitive: !model.disabled_buttons,
|
||||||
|
|
||||||
connect_clicked => AppMsg::OpenPreferences
|
set_icon_name: "emblem-system-symbolic",
|
||||||
|
|
||||||
|
connect_clicked => AppMsg::OpenPreferences
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue