mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2025-02-16 15:22:01 +03:00
feat(ui): reworked entry rows in the settings
Removed huge pill buttons, added small "+" icons
This commit is contained in:
parent
bdd45471ca
commit
3d036e6a97
3 changed files with 78 additions and 56 deletions
|
@ -110,6 +110,20 @@ impl SimpleAsyncComponent for EnvironmentApp {
|
|||
add = &adw::PreferencesGroup {
|
||||
set_title: &tr("new-variable"),
|
||||
|
||||
#[wrap(Some)]
|
||||
set_header_suffix = >k::Button {
|
||||
add_css_class: "flat",
|
||||
|
||||
set_valign: gtk::Align::Center,
|
||||
|
||||
adw::ButtonContent {
|
||||
set_icon_name: "list-add-symbolic",
|
||||
set_label: &tr("add")
|
||||
},
|
||||
|
||||
connect_clicked => EnvironmentAppMsg::Add
|
||||
},
|
||||
|
||||
#[local_ref]
|
||||
name_entry -> adw::EntryRow {
|
||||
set_title: &tr("name")
|
||||
|
@ -118,16 +132,6 @@ impl SimpleAsyncComponent for EnvironmentApp {
|
|||
#[local_ref]
|
||||
value_entry -> adw::EntryRow {
|
||||
set_title: &tr("value")
|
||||
},
|
||||
|
||||
gtk::Button {
|
||||
set_label: &tr("add"),
|
||||
add_css_class: "pill",
|
||||
|
||||
set_margin_top: 8,
|
||||
set_halign: gtk::Align::Start,
|
||||
|
||||
connect_clicked => EnvironmentAppMsg::Add
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ impl AsyncFactoryComponent for GameSession {
|
|||
pub struct GameApp {
|
||||
sessions: AsyncFactoryVecDeque<GameSession>,
|
||||
|
||||
active_sessions: gtk::StringList,
|
||||
session_name_entry: adw::EntryRow
|
||||
}
|
||||
|
||||
|
@ -82,24 +83,32 @@ impl SimpleAsyncComponent for GameApp {
|
|||
view! {
|
||||
adw::PreferencesPage {
|
||||
set_title: "Game",
|
||||
set_icon_name: Some("document-properties-symbolic"),
|
||||
set_icon_name: Some("applications-games-symbolic"),
|
||||
|
||||
add = &adw::PreferencesGroup {
|
||||
set_title: "Saved sessions",
|
||||
set_title: "Game sessions",
|
||||
|
||||
adw::ComboRow {
|
||||
set_title: "Active session",
|
||||
set_subtitle: "Currently selected game session",
|
||||
|
||||
set_model = Some(&model.active_sessions),
|
||||
}
|
||||
},
|
||||
|
||||
add = &adw::PreferencesGroup {
|
||||
#[local_ref]
|
||||
session_name_entry -> adw::EntryRow {
|
||||
set_title: &tr("name")
|
||||
},
|
||||
set_title: &tr("name"),
|
||||
|
||||
gtk::Button {
|
||||
set_label: &tr("add"),
|
||||
add_css_class: "pill",
|
||||
add_suffix = >k::Button {
|
||||
set_icon_name: "list-add-symbolic",
|
||||
add_css_class: "flat",
|
||||
|
||||
set_margin_top: 8,
|
||||
set_halign: gtk::Align::Start,
|
||||
|
||||
connect_clicked => GameAppMsg::AddSession
|
||||
set_valign: gtk::Align::Center,
|
||||
|
||||
connect_clicked => GameAppMsg::AddSession
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -113,11 +122,12 @@ impl SimpleAsyncComponent for GameApp {
|
|||
root: Self::Root,
|
||||
sender: AsyncComponentSender<Self>,
|
||||
) -> AsyncComponentParts<Self> {
|
||||
tracing::info!("Initializing environment settings");
|
||||
tracing::info!("Initializing game settings");
|
||||
|
||||
let mut model = Self {
|
||||
sessions: AsyncFactoryVecDeque::new(adw::PreferencesGroup::new(), sender.input_sender()),
|
||||
|
||||
active_sessions: gtk::StringList::new(&[]),
|
||||
session_name_entry: adw::EntryRow::new()
|
||||
};
|
||||
|
||||
|
@ -142,6 +152,8 @@ impl SimpleAsyncComponent for GameApp {
|
|||
if !name.is_empty() {
|
||||
self.session_name_entry.set_text("");
|
||||
|
||||
self.active_sessions.append(&name);
|
||||
|
||||
self.sessions.guard().push_back(GameSession {
|
||||
title: name,
|
||||
description: None,
|
||||
|
@ -151,10 +163,7 @@ impl SimpleAsyncComponent for GameApp {
|
|||
}
|
||||
|
||||
GameAppMsg::RemoveSession(index) => {
|
||||
if let Some(var) = self.sessions.guard().get(index.current_index()) {
|
||||
// ..
|
||||
}
|
||||
|
||||
self.active_sessions.remove(index.current_index() as u32);
|
||||
self.sessions.guard().remove(index.current_index());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,8 +197,10 @@ impl SimpleAsyncComponent for SandboxApp {
|
|||
},
|
||||
|
||||
add_suffix = >k::Button {
|
||||
set_valign: gtk::Align::Center,
|
||||
set_icon_name: "dialog-information-symbolic",
|
||||
add_css_class: "flat",
|
||||
|
||||
set_valign: gtk::Align::Center,
|
||||
|
||||
connect_clicked[sender] => move |_| {
|
||||
if let Err(err) = open::that("https://man.archlinux.org/man/bwrap.1") {
|
||||
|
@ -218,17 +220,16 @@ impl SimpleAsyncComponent for SandboxApp {
|
|||
|
||||
#[local_ref]
|
||||
private_path_entry -> adw::EntryRow {
|
||||
set_title: &tr("path")
|
||||
},
|
||||
set_title: &tr("path"),
|
||||
|
||||
gtk::Button {
|
||||
set_label: &tr("add"),
|
||||
add_css_class: "pill",
|
||||
add_suffix = >k::Button {
|
||||
set_icon_name: "list-add-symbolic",
|
||||
add_css_class: "flat",
|
||||
|
||||
set_margin_top: 8,
|
||||
set_halign: gtk::Align::Start,
|
||||
|
||||
connect_clicked => SandboxAppMsg::AddPrivate
|
||||
set_valign: gtk::Align::Center,
|
||||
|
||||
connect_clicked => SandboxAppMsg::AddPrivate
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -239,6 +240,20 @@ impl SimpleAsyncComponent for SandboxApp {
|
|||
set_title: &tr("shared-directories"),
|
||||
set_description: Some(&tr("shared-directories-description")),
|
||||
|
||||
#[wrap(Some)]
|
||||
set_header_suffix = >k::Button {
|
||||
add_css_class: "flat",
|
||||
|
||||
set_valign: gtk::Align::Center,
|
||||
|
||||
adw::ButtonContent {
|
||||
set_icon_name: "list-add-symbolic",
|
||||
set_label: &tr("add")
|
||||
},
|
||||
|
||||
connect_clicked => SandboxAppMsg::AddShared
|
||||
},
|
||||
|
||||
#[local_ref]
|
||||
shared_path_from_entry -> adw::EntryRow {
|
||||
set_title: &tr("original-path")
|
||||
|
@ -257,16 +272,6 @@ impl SimpleAsyncComponent for SandboxApp {
|
|||
add_suffix = read_only_switch -> gtk::Switch {
|
||||
set_valign: gtk::Align::Center
|
||||
}
|
||||
},
|
||||
|
||||
gtk::Button {
|
||||
set_label: &tr("add"),
|
||||
add_css_class: "pill",
|
||||
|
||||
set_margin_top: 8,
|
||||
set_halign: gtk::Align::Start,
|
||||
|
||||
connect_clicked => SandboxAppMsg::AddShared
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -277,6 +282,20 @@ impl SimpleAsyncComponent for SandboxApp {
|
|||
set_title: &tr("symlinks"),
|
||||
set_description: Some(&tr("symlinks-description")),
|
||||
|
||||
#[wrap(Some)]
|
||||
set_header_suffix = >k::Button {
|
||||
add_css_class: "flat",
|
||||
|
||||
set_valign: gtk::Align::Center,
|
||||
|
||||
adw::ButtonContent {
|
||||
set_icon_name: "list-add-symbolic",
|
||||
set_label: &tr("add")
|
||||
},
|
||||
|
||||
connect_clicked => SandboxAppMsg::AddSymlink
|
||||
},
|
||||
|
||||
#[local_ref]
|
||||
symlink_path_from_entry -> adw::EntryRow {
|
||||
set_title: &tr("original-path")
|
||||
|
@ -285,16 +304,6 @@ impl SimpleAsyncComponent for SandboxApp {
|
|||
#[local_ref]
|
||||
symlink_path_to_entry -> adw::EntryRow {
|
||||
set_title: &tr("new-path")
|
||||
},
|
||||
|
||||
gtk::Button {
|
||||
set_label: &tr("add"),
|
||||
add_css_class: "pill",
|
||||
|
||||
set_margin_top: 8,
|
||||
set_halign: gtk::Align::Start,
|
||||
|
||||
connect_clicked => SandboxAppMsg::AddSymlink
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue