Implement Clippy suggestions
They were actually sensible for once???
This commit is contained in:
parent
2c2afb4b33
commit
4c2ad03a0e
16 changed files with 31 additions and 33 deletions
|
|
@ -35,12 +35,11 @@ pub struct DataManager {}
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
pub async fn init() -> Result<(), DataManagerError> {
|
pub async fn init() -> Result<(), DataManagerError> {
|
||||||
let data_dir = match var_os("XDG_DATA_HOME") {
|
let data_dir = if let Some(xdg_home_data_dir) = var_os("XDG_DATA_HOME") {
|
||||||
Some(xdg_home_data_dir) => concat_os_str!(xdg_home_data_dir, "/zoodex"),
|
concat_os_str!(xdg_home_data_dir, "/zoodex")
|
||||||
None => {
|
} else {
|
||||||
let home_dir = var_os("HOME").ok_or(DataManagerError::NoHomeDir)?;
|
let home_dir = var_os("HOME").ok_or(DataManagerError::NoHomeDir)?;
|
||||||
concat_os_str!(home_dir, "/.local/share/zoodex")
|
concat_os_str!(home_dir, "/.local/share/zoodex")
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let sqlite_manager = SqliteManager::new(data_dir.as_os_str()).await?;
|
let sqlite_manager = SqliteManager::new(data_dir.as_os_str()).await?;
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ async fn create_client(data_dir: &OsStr) -> Result<Client, DataManagerError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.map(|_| client)
|
.map(|()| client)
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ impl Component for App {
|
||||||
fn init(_init: (), root: ApplicationWindow, sender: ComponentSender<App>) -> ComponentParts<App> {
|
fn init(_init: (), root: ApplicationWindow, sender: ComponentSender<App>) -> ComponentParts<App> {
|
||||||
sender.oneshot_command(async {
|
sender.oneshot_command(async {
|
||||||
match DataManager::init().await {
|
match DataManager::init().await {
|
||||||
Ok(_) => AppCmdOutput::DataManagerReady,
|
Ok(()) => AppCmdOutput::DataManagerReady,
|
||||||
Err(error) => AppCmdOutput::DataManagerFailed(error),
|
Err(error) => AppCmdOutput::DataManagerFailed(error),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -64,7 +64,7 @@ impl Component for App {
|
||||||
}
|
}
|
||||||
AppCmdOutput::DataManagerFailed(error) => {
|
AppCmdOutput::DataManagerFailed(error) => {
|
||||||
// TODO: Show error in GUI.
|
// TODO: Show error in GUI.
|
||||||
println!("Error occurred in data manager initialization: {:?}", error);
|
println!("Error occurred in data manager initialization: {error:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ impl SimpleComponent for CollatableFilmGrid {
|
||||||
|
|
||||||
fn init(
|
fn init(
|
||||||
_init: (),
|
_init: (),
|
||||||
_root: gtk4::Box,
|
root: gtk4::Box,
|
||||||
_sender: ComponentSender<CollatableFilmGrid>,
|
_sender: ComponentSender<CollatableFilmGrid>,
|
||||||
) -> ComponentParts<CollatableFilmGrid> {
|
) -> ComponentParts<CollatableFilmGrid> {
|
||||||
let film_grid = FilmGrid::builder().launch(()).detach();
|
let film_grid = FilmGrid::builder().launch(()).detach();
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ impl SimpleComponent for CollatableSeriesGrid {
|
||||||
|
|
||||||
fn init(
|
fn init(
|
||||||
_init: (),
|
_init: (),
|
||||||
_root: gtk4::Box,
|
root: gtk4::Box,
|
||||||
_sender: ComponentSender<CollatableSeriesGrid>,
|
_sender: ComponentSender<CollatableSeriesGrid>,
|
||||||
) -> ComponentParts<CollatableSeriesGrid> {
|
) -> ComponentParts<CollatableSeriesGrid> {
|
||||||
let series_grid = SeriesGrid::builder().launch(()).detach();
|
let series_grid = SeriesGrid::builder().launch(()).detach();
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ impl SimpleComponent for FilmCollationMenu {
|
||||||
|
|
||||||
fn init(
|
fn init(
|
||||||
_init: (),
|
_init: (),
|
||||||
_root: gtk4::Box,
|
root: gtk4::Box,
|
||||||
sender: ComponentSender<FilmCollationMenu>,
|
sender: ComponentSender<FilmCollationMenu>,
|
||||||
) -> ComponentParts<FilmCollationMenu> {
|
) -> ComponentParts<FilmCollationMenu> {
|
||||||
let model = FilmCollationMenu {
|
let model = FilmCollationMenu {
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ impl SimpleComponent for SeriesCollationMenu {
|
||||||
|
|
||||||
fn init(
|
fn init(
|
||||||
_init: (),
|
_init: (),
|
||||||
_root: gtk4::Box,
|
root: gtk4::Box,
|
||||||
sender: ComponentSender<SeriesCollationMenu>,
|
sender: ComponentSender<SeriesCollationMenu>,
|
||||||
) -> ComponentParts<SeriesCollationMenu> {
|
) -> ComponentParts<SeriesCollationMenu> {
|
||||||
let model = SeriesCollationMenu {
|
let model = SeriesCollationMenu {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ impl SimpleComponent for FilmDetails {
|
||||||
|
|
||||||
fn init(
|
fn init(
|
||||||
film_overview: FilmOverview,
|
film_overview: FilmOverview,
|
||||||
_root: gtk4::Box,
|
root: gtk4::Box,
|
||||||
_sender: ComponentSender<FilmDetails>,
|
_sender: ComponentSender<FilmDetails>,
|
||||||
) -> ComponentParts<FilmDetails> {
|
) -> ComponentParts<FilmDetails> {
|
||||||
let model = FilmDetails { film_overview };
|
let model = FilmDetails { film_overview };
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ impl SimpleComponent for SeriesDetails {
|
||||||
|
|
||||||
fn init(
|
fn init(
|
||||||
series_overview: SeriesOverview,
|
series_overview: SeriesOverview,
|
||||||
_root: gtk4::Box,
|
root: gtk4::Box,
|
||||||
_sender: ComponentSender<SeriesDetails>,
|
_sender: ComponentSender<SeriesDetails>,
|
||||||
) -> ComponentParts<SeriesDetails> {
|
) -> ComponentParts<SeriesDetails> {
|
||||||
let model = SeriesDetails { series_overview };
|
let model = SeriesDetails { series_overview };
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ impl Component for FilmGrid {
|
||||||
|
|
||||||
fn init(
|
fn init(
|
||||||
_init: (),
|
_init: (),
|
||||||
_root: ScrolledWindow,
|
root: ScrolledWindow,
|
||||||
sender: ComponentSender<FilmGrid>,
|
sender: ComponentSender<FilmGrid>,
|
||||||
) -> ComponentParts<FilmGrid> {
|
) -> ComponentParts<FilmGrid> {
|
||||||
let widgets = view_output!();
|
let widgets = view_output!();
|
||||||
|
|
@ -119,7 +119,7 @@ impl Component for FilmGrid {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
FilmGridCmdOutput::OverviewDataFailed(error) => {
|
FilmGridCmdOutput::OverviewDataFailed(error) => {
|
||||||
println!("Error occurred in loading films overview: {:?}", error);
|
println!("Error occurred in loading films overview: {error:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ impl Component for SeriesGrid {
|
||||||
|
|
||||||
fn init(
|
fn init(
|
||||||
_init: (),
|
_init: (),
|
||||||
_root: ScrolledWindow,
|
root: ScrolledWindow,
|
||||||
sender: ComponentSender<SeriesGrid>,
|
sender: ComponentSender<SeriesGrid>,
|
||||||
) -> ComponentParts<SeriesGrid> {
|
) -> ComponentParts<SeriesGrid> {
|
||||||
let widgets = view_output!();
|
let widgets = view_output!();
|
||||||
|
|
@ -119,7 +119,7 @@ impl Component for SeriesGrid {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
SeriesGridCmdOutput::OverviewDataFailed(error) => {
|
SeriesGridCmdOutput::OverviewDataFailed(error) => {
|
||||||
println!("Error occurred in loading series overview: {:?}", error);
|
println!("Error occurred in loading series overview: {error:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ impl FactoryComponent for FilmGridItem {
|
||||||
#[name="original_name"]
|
#[name="original_name"]
|
||||||
Label {
|
Label {
|
||||||
set_visible: self.film.original_name.is_some(),
|
set_visible: self.film.original_name.is_some(),
|
||||||
set_cond_label: self.film.original_name.as_ref().map(String::as_str),
|
set_cond_label: self.film.original_name.as_deref(),
|
||||||
},
|
},
|
||||||
|
|
||||||
gtk4::Box {
|
gtk4::Box {
|
||||||
|
|
@ -121,7 +121,7 @@ impl FactoryComponent for FilmGridItem {
|
||||||
root.toplevel_window().expect("root widget of FilmGridItem should be ancestor of a window")
|
root.toplevel_window().expect("root widget of FilmGridItem should be ancestor of a window")
|
||||||
}),
|
}),
|
||||||
#[watch]
|
#[watch]
|
||||||
set_child: self.details.as_ref().map(|details| details.widget()),
|
set_child: self.details.as_ref().map(ComponentController::widget),
|
||||||
connect_closed => FilmGridItemInput::DetailsClosed,
|
connect_closed => FilmGridItemInput::DetailsClosed,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -172,7 +172,7 @@ impl FactoryComponent for FilmGridItem {
|
||||||
// If no poster is present we don't need to do anything.
|
// If no poster is present we don't need to do anything.
|
||||||
FilmGridItemCmdOutput::NoPosterFound => {}
|
FilmGridItemCmdOutput::NoPosterFound => {}
|
||||||
FilmGridItemCmdOutput::PosterFailed(error) => {
|
FilmGridItemCmdOutput::PosterFailed(error) => {
|
||||||
println!("Error occurred in loading film poster: {:?}", error);
|
println!("Error occurred in loading film poster: {error:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ impl FactoryComponent for SeriesGridItem {
|
||||||
#[name="original_name"]
|
#[name="original_name"]
|
||||||
Label {
|
Label {
|
||||||
set_visible: self.series.original_name.is_some(),
|
set_visible: self.series.original_name.is_some(),
|
||||||
set_cond_label: self.series.original_name.as_ref().map(String::as_str),
|
set_cond_label: self.series.original_name.as_deref(),
|
||||||
},
|
},
|
||||||
|
|
||||||
#[name="release_date"]
|
#[name="release_date"]
|
||||||
|
|
@ -109,7 +109,7 @@ impl FactoryComponent for SeriesGridItem {
|
||||||
root.toplevel_window().expect("root widget of FilmGridItem should be ancestor of a window")
|
root.toplevel_window().expect("root widget of FilmGridItem should be ancestor of a window")
|
||||||
}),
|
}),
|
||||||
#[watch]
|
#[watch]
|
||||||
set_child: self.details.as_ref().map(|details| details.widget()),
|
set_child: self.details.as_ref().map(ComponentController::widget),
|
||||||
connect_closed => SeriesGridItemInput::DetailsClosed,
|
connect_closed => SeriesGridItemInput::DetailsClosed,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -166,7 +166,7 @@ impl FactoryComponent for SeriesGridItem {
|
||||||
// If no poster is present we don't need to do anything.
|
// If no poster is present we don't need to do anything.
|
||||||
SeriesGridItemCmdOutput::NoPosterFound => {}
|
SeriesGridItemCmdOutput::NoPosterFound => {}
|
||||||
SeriesGridItemCmdOutput::PosterFailed(error) => {
|
SeriesGridItemCmdOutput::PosterFailed(error) => {
|
||||||
println!("Error occurred in loading series poster: {:?}", error);
|
println!("Error occurred in loading series poster: {error:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ impl SimpleComponent for MediaTypeSwitcher {
|
||||||
|
|
||||||
fn init(
|
fn init(
|
||||||
_init: (),
|
_init: (),
|
||||||
_root: ToolbarView,
|
root: ToolbarView,
|
||||||
_sender: ComponentSender<MediaTypeSwitcher>,
|
_sender: ComponentSender<MediaTypeSwitcher>,
|
||||||
) -> ComponentParts<MediaTypeSwitcher> {
|
) -> ComponentParts<MediaTypeSwitcher> {
|
||||||
let films_grid = CollatableFilmGrid::builder().launch(()).detach();
|
let films_grid = CollatableFilmGrid::builder().launch(()).detach();
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,10 @@ where
|
||||||
F: Fn(&I, &I) -> Ordering,
|
F: Fn(&I, &I) -> Ordering,
|
||||||
I: FactoryComponent<Index = DynamicIndex>,
|
I: FactoryComponent<Index = DynamicIndex>,
|
||||||
{
|
{
|
||||||
_sort_factory_vec(factory_vec, 0, factory_vec.len(), &compare);
|
sort_factory_vec_inner(factory_vec, 0, factory_vec.len(), &compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _sort_factory_vec<F, I>(
|
fn sort_factory_vec_inner<F, I>(
|
||||||
factory_vec: &mut FactoryVecDequeGuard<I>,
|
factory_vec: &mut FactoryVecDequeGuard<I>,
|
||||||
start_index: usize,
|
start_index: usize,
|
||||||
end_index: usize,
|
end_index: usize,
|
||||||
|
|
@ -26,8 +26,8 @@ fn _sort_factory_vec<F, I>(
|
||||||
{
|
{
|
||||||
if end_index - start_index > 1 {
|
if end_index - start_index > 1 {
|
||||||
let pivot = lomuto_partition(factory_vec, start_index, end_index, compare);
|
let pivot = lomuto_partition(factory_vec, start_index, end_index, compare);
|
||||||
_sort_factory_vec(factory_vec, start_index, pivot, compare);
|
sort_factory_vec_inner(factory_vec, start_index, pivot, compare);
|
||||||
_sort_factory_vec(factory_vec, pivot + 1, end_index, compare);
|
sort_factory_vec_inner(factory_vec, pivot + 1, end_index, compare);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,8 @@ pub trait CondDialogExt: IsA<Dialog> {
|
||||||
// Unlike AdwDialogExt::present the parent is not a reference, so that using it
|
// Unlike AdwDialogExt::present the parent is not a reference, so that using it
|
||||||
// with Option::map is more ergonomic.
|
// with Option::map is more ergonomic.
|
||||||
fn cond_present<W: IsA<Widget>>(&self, parent: Option<W>) {
|
fn cond_present<W: IsA<Widget>>(&self, parent: Option<W>) {
|
||||||
match parent {
|
if let Some(parent) = parent {
|
||||||
Some(parent) => self.present(Some(&parent)),
|
self.present(Some(&parent));
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue