Skip to content

Commit

Permalink
fix lists
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukinaha committed Jul 19, 2024
1 parent 96397f1 commit b57dc4b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,19 +556,18 @@ impl EmbyClient {
("ImageTypeLimit", "1"),
("StartIndex", start),
("Recursive", "true"),
("IncludeItemTypes", "Movie,Series,Video,Game,MusicAlbum"),
("IncludeItemTypes", "Movie,Series,MusicAlbum"),
("SortBy", sortby),
("SortOrder", sort_order),
("EnableImageTypes", "Primary,Backdrop,Thumb"),
if listtype == "Genres" {
if listtype == "Genre" {
("GenreIds", parentid)
} else if listtype == "Studios" {
("StudioIds", parentid)
} else {
("TagIds", parentid)
},
];

let id_clone;
if let Some(id) = id {
id_clone = id.clone();
Expand Down
12 changes: 11 additions & 1 deletion src/client/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ impl SGTitem {
}

impl SimpleListItem {
pub fn activate<T>(&self, widget: &T)
pub fn activate<T>(&self, widget: &T, parentid: Option<String>)
where
T: gtk::prelude::WidgetExt + glib::clone::Downgrade,
{
Expand Down Expand Up @@ -602,6 +602,16 @@ impl SimpleListItem {
);
push_page_with_tag(window, page, self.name.clone());
}
"Tag" | "Genre" => {
let page = SingleListPage::new(
self.id.clone(),
"".to_string(),
&self.latest_type,
parentid,
true,
);
push_page_with_tag(window, page, self.name.clone());
}
_ => toast!(window, gettext("Not Supported Type")),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl HomePage {
fn carousel_pressed_cb(&self) {
let position = self.imp().carousel.position();
if let Some(item) = self.imp().carouset_items.borrow().get(position as usize) {
item.activate(self);
item.activate(self, None);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/hortu_scrolled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ mod imp {
.and_downcast::<glib::BoxedAnyObject>()
.unwrap();
let result: std::cell::Ref<SimpleListItem> = item.borrow();
result.activate(listview);
result.activate(listview, None);
});
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/ui/widgets/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl ListPage {

pub async fn set_pages(&self) {
let imp = self.imp();
let id = imp.id.get().unwrap();
let id = self.id();
let collection_type = imp.collectiontype.get().unwrap();
let stack = imp.stack.get();

Expand All @@ -105,9 +105,10 @@ impl ListPage {
("genres", "Genres"),
("liked", "Liked"),
];


for (name, title) in pages {
let page = SingleListPage::new(id.clone(), collection_type.clone(), name, None, false);
let page = SingleListPage::new(id.clone(), collection_type.clone(), name, Some(id.clone()), false);
stack.add_titled(&page, Some(name), &gettext(title));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/widgets/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl SearchPage {
#[weak(rename_to = obj)]
self,
move |_| {
item.activate(&obj);
item.activate(&obj, None);
}
));
recommendbox.append(&button);
Expand All @@ -168,7 +168,7 @@ impl SearchPage {
.and_downcast::<glib::BoxedAnyObject>()
.unwrap();
let result: std::cell::Ref<SimpleListItem> = item.borrow();
result.activate(listview);
result.activate(listview, None);
}));
}

Expand Down
9 changes: 7 additions & 2 deletions src/ui/widgets/singlelist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,20 @@ impl SingleListPage {
imp.listgrid.set_min_columns(1);
imp.listgrid.set_max_columns(13);

let parentid = self.parentid();

imp.listgrid
.connect_activate(glib::clone!(move |listview, position| {
.connect_activate(glib::clone!(
#[strong]
parentid,
move |listview, position| {
let model = listview.model().unwrap();
let item = model
.item(position)
.and_downcast::<glib::BoxedAnyObject>()
.unwrap();
let result: std::cell::Ref<SimpleListItem> = item.borrow();
result.activate(listview);
result.activate(listview, parentid.clone());
}));
}

Expand Down

0 comments on commit b57dc4b

Please sign in to comment.