Commit 77a810da authored by Wolfgang Steitz's avatar Wolfgang Steitz

Provide option to sort photos by filename, in addition to title, exporsure...

Provide option to sort photos by filename, in addition to title, exporsure date and rating (#717878)
parent ebe6722e
......@@ -122,7 +122,8 @@ public abstract class MediaPage : CheckerboardPage {
TITLE = 1,
EXPOSURE_DATE = 2,
RATING = 3,
MAX = 3
FILENAME = 4,
MAX = 4
}
protected class ZoomSliderAssembly : Gtk.ToolItem {
......@@ -498,6 +499,12 @@ public abstract class MediaPage : CheckerboardPage {
by_rating.tooltip = _("Sort photos by rating");
sort_crit_actions += by_rating;
Gtk.RadioActionEntry by_filename = { "SortByFilename", null, TRANSLATABLE, null,
TRANSLATABLE, SortBy.FILENAME };
by_filename.label = _("By _Filename");
by_filename.tooltip = _("Sort photos by filename");
sort_crit_actions += by_filename;
action_group.add_radio_actions(sort_crit_actions, sort_by, on_sort_changed);
// Sort order.
......@@ -1220,6 +1227,13 @@ public abstract class MediaPage : CheckerboardPage {
predicate = Thumbnail.rating_comparator_predicate;
break;
case SortBy.FILENAME:
if (ascending)
comparator = Thumbnail.filename_ascending_comparator;
else comparator = Thumbnail.filename_descending_comparator;
predicate = Thumbnail.filename_comparator_predicate;
break;
default:
debug("Unknown sort criteria: %s", get_menu_sort_by().to_string());
comparator = Thumbnail.title_descending_comparator;
......@@ -1240,6 +1254,9 @@ public abstract class MediaPage : CheckerboardPage {
case SortBy.RATING:
return "/MenuBar/ViewMenu/SortPhotos/SortByRating";
case SortBy.FILENAME:
return "/MenuBar/ViewMenu/SortPhotos/SortByFilename";
default:
debug("Unknown sort criteria: %d", sort_by);
......
......@@ -193,6 +193,10 @@ public class Thumbnail : MediaSourceItem {
return alteration.has_detail("metadata", "exposure-time");
}
public static bool filename_comparator_predicate(DataObject object, Alteration alteration) {
return alteration.has_detail("metadata", "filename");
}
public static int64 filename_ascending_comparator(void *a, void *b) {
string path_a = ((Thumbnail *) a)->media.get_file().get_basename().down();
string path_b = ((Thumbnail *) b)->media.get_file().get_basename().down();
......
......@@ -55,6 +55,7 @@
<separator />
<menu name="SortPhotos" action="SortPhotos">
<menuitem name="SortByTitle" action="SortByTitle" />
<menuitem name="SortByFilename" action="SortByFilename" />
<menuitem name="SortByExposureDate" action="SortByExposureDate" />
<menuitem name="SortByRating" action="SortByRating" />
<separator />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment