FriendlyCaps: add sort func
Some checks failed
PostmarketOS Build / Prepare (push) Successful in 8s
PostmarketOS Build / Build for aarch64 (push) Failing after 30s
PostmarketOS Build / Build for x86_64 (push) Failing after 10s

Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
Vasiliy Doylov 2025-06-21 19:15:58 +03:00
parent de67da42ea
commit ab22bb8210
Signed by: NekoCWD
GPG key ID: B7BE22D44474A582
2 changed files with 10 additions and 5 deletions

View file

@ -133,11 +133,7 @@ public class EyeNeko.Gstreamer : Object {
}
construct {
var srt = new Gtk.SortListModel (available_caps, new Gtk.CustomSorter ((_a, _b) => {
var a = (FriendlyCaps) _a;
var b = (FriendlyCaps) _b;
return a.is_res_better (b) ? -1 : a.is_res_same (b) ? 0 : 1;
}));
var srt = new Gtk.SortListModel (available_caps, new Gtk.CustomSorter ((a,b)=>FriendlyCaps.sort_func((FriendlyCaps)a, (FriendlyCaps)b));
caps_selecton_model.set_model (srt);
caps_selecton_model.notify["selected-item"].connect (() => start_stream_from (current_camera));
}

View file

@ -70,6 +70,15 @@ namespace EyeNeko {
return (width * height == cap.width * cap.height);
}
public static int sort_func (FriendlyCaps a, FriendlyCaps b) {
if (a.width > b.width)
return -1;
else if (a.width == b.width)
return a.height > b.height ? -1 : a.height == b.height ? 0 : 1;
else
return 1;
}
public Gst.Caps to_caps () {
var res = new Gst.Caps.empty ();
res.append_structure (struct.copy ());