diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 09:06:59 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 09:06:59 +0200 |
commit | 4ea2cc3bd4a7d9b1c54a9d33e6a1cf82e7c8c21d (patch) | |
tree | d2e54377d14d604356c86862a326f64ae64dadd6 /src/direct/DirectView.vala |
Imported Upstream version 0.18.1upstream/0.18.1
Diffstat (limited to 'src/direct/DirectView.vala')
-rw-r--r-- | src/direct/DirectView.vala | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/direct/DirectView.vala b/src/direct/DirectView.vala new file mode 100644 index 0000000..a36ec68 --- /dev/null +++ b/src/direct/DirectView.vala @@ -0,0 +1,50 @@ +/* Copyright 2011-2014 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +public class DirectView : DataView { + private File file; + private string? collate_key = null; + + public DirectView(DirectPhoto source) { + base ((DataSource) source); + + this.file = ((Photo) source).get_file(); + } + + public File get_file() { + return file; + } + + public string get_collate_key() { + if (collate_key == null) + collate_key = file.get_basename().collate_key_for_filename(); + + return collate_key; + } +} + +private class DirectViewCollection : ViewCollection { + private class DirectViewManager : ViewManager { + public override DataView create_view(DataSource source) { + return new DirectView((DirectPhoto) source); + } + } + + public DirectViewCollection() { + base ("DirectViewCollection"); + + set_comparator(filename_comparator, null); + monitor_source_collection(DirectPhoto.global, new DirectViewManager(), null); + } + + private static int64 filename_comparator(void *a, void *b) { + DirectView *aview = (DirectView *) a; + DirectView *bview = (DirectView *) b; + + return strcmp(aview->get_collate_key(), bview->get_collate_key()); + } +} + |