FriendlyCaps: add sort func
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
de67da42ea
commit
ab22bb8210
2 changed files with 10 additions and 5 deletions
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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 ());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue