1
/* Copyright 2016 Software Freedom Conservancy Inc.
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.
8
* Aggregates multiple FolderProperties into one. This way a Geary.Folder can
9
* present one stable FolderProperties object that the client can register
10
* change listeners on, etc. despite most Geary.Folders having both a local
11
* and remote version of FolderProperties.
13
* The class relies on GObject bindings and the fact that FolderProperties
14
* contains only propertiess.
16
private class Geary.AggregatedFolderProperties : Geary.FolderProperties {
17
// Map of child FolderProperties to their bindings.
18
private Gee.Map<FolderProperties, Gee.List<Binding>> child_bindings
19
= new Gee.HashMap<FolderProperties, Gee.List<Binding>>();
22
* Creates an aggregate FolderProperties.
24
public AggregatedFolderProperties(bool is_local_only, bool is_virtual) {
26
base(0, 0, Trillian.UNKNOWN, Trillian.UNKNOWN, Trillian.UNKNOWN, is_local_only, is_virtual, false);
30
* Adds a child FolderProperties. The child's property values will overwrite
31
* this class's property values.
33
public void add(FolderProperties child) {
34
// Create a binding for all properties.
35
Gee.List<Binding>? bindings = Geary.ObjectUtils.mirror_properties(child, this);
36
assert(bindings != null);
37
child_bindings.set(child, bindings);
41
* Removes a child FolderProperties.
43
public bool remove(FolderProperties child) {
44
Gee.List<Binding> bindings;
45
if (child_bindings.unset(child, out bindings)) {
46
Geary.ObjectUtils.unmirror_properties(bindings);