DataSourceTypes.vala 3.13 KB
Newer Older
1
/* Copyright 2016 Software Freedom Conservancy Inc.
2 3
 *
 * This software is licensed under the GNU Lesser General Public License
4
 * (version 2.1 or later).  See the COPYING file in this distribution.
5 6 7 8 9 10 11 12 13 14
 */

//
// Media sources
//

public abstract class ThumbnailSource : DataSource {
    public virtual signal void thumbnail_altered() {
    }
    
15
    protected ThumbnailSource(int64 object_id = INVALID_OBJECT_ID) {
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
        base (object_id);
    }
    
    public virtual void notify_thumbnail_altered() {
        // fire signal on self
        thumbnail_altered();
        
        // signal reflection to DataViews
        contact_subscribers(subscriber_thumbnail_altered);
    }
    
    private void subscriber_thumbnail_altered(DataView view) {
        ((ThumbnailView) view).notify_thumbnail_altered();
    }

    public abstract Gdk.Pixbuf? get_thumbnail(int scale) throws Error;
    
    // get_thumbnail( ) may return a cached pixbuf; create_thumbnail( ) is guaranteed to create
    // a new pixbuf (e.g., by the source loading, decoding, and scaling image data)
    public abstract Gdk.Pixbuf? create_thumbnail(int scale) throws Error;
    
    // A ThumbnailSource may use another ThumbnailSource as its representative.  It's up to the
    // subclass to forward on the appropriate methods to this ThumbnailSource.  But, since multiple
    // ThumbnailSources may be referring to a single ThumbnailSource, this allows for that to be
    // detected and optimized (in caching).
    //
    // Note that it's the responsibility of this ThumbnailSource to fire "thumbnail-altered" if its
    // representative does the same.
    //
    // Default behavior is to return the ID of this.
    public virtual string get_representative_id() {
        return get_source_id();
    }
    
    public abstract PhotoFileFormat get_preferred_thumbnail_format();
}

public abstract class PhotoSource : MediaSource {
54
    protected PhotoSource(int64 object_id = INVALID_OBJECT_ID) {
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
        base (object_id);
    }

    public abstract PhotoMetadata? get_metadata();
    
    public abstract Gdk.Pixbuf get_pixbuf(Scaling scaling) throws Error;
}

public abstract class VideoSource : MediaSource {
}

//
// EventSource
//

public abstract class EventSource : ThumbnailSource {
71
    protected EventSource(int64 object_id = INVALID_OBJECT_ID) {
72 73 74 75
        base (object_id);
    }
    
    public abstract time_t get_start_time();
76
    
77
    public abstract time_t get_end_time();
78
    
79 80 81 82 83
    public abstract uint64 get_total_filesize();
    
    public abstract int get_media_count();
    
    public abstract Gee.Collection<MediaSource> get_media();
84 85 86 87
    
    public abstract string? get_comment();
    
    public abstract bool set_comment(string? comment);
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
}

//
// ContainerSource
//

public interface ContainerSource : DataSource {
    public abstract bool has_links();
    
    public abstract SourceBacklink get_backlink();
    
    public abstract void break_link(DataSource source);
    
    public abstract void break_link_many(Gee.Collection<DataSource> sources);
    
    public abstract void establish_link(DataSource source);
    
    public abstract void establish_link_many(Gee.Collection<DataSource> sources);
}