1
/* Copyright 2011-2014 Yorba Foundation
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.
7
public class MetadataView : Gtk.ScrolledWindow {
8
private List<Properties> properties_collection = new List<Properties> ();
9
private Gtk.Notebook notebook = new Gtk.Notebook ();
10
private Gtk.Grid grid = new Gtk.Grid ();
11
private int line_count = 0;
12
private BasicProperties colletion_page_properties = new BasicProperties ();
13
private Gtk.Label no_items_label = new Gtk.Label ("No items selected");
14
public const int SIDEBAR_PADDING = 12;
15
public MetadataView () {
16
set_policy (Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
17
get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR);
18
properties_collection.append (new LibraryProperties ());
19
properties_collection.append (new BasicProperties ());
20
properties_collection.append (new ExtendedProperties ());
22
foreach (var properties in properties_collection)
23
add_expander (properties);
25
grid.set_row_spacing (16);
26
grid.margin = SIDEBAR_PADDING;
27
colletion_page_properties.margin = SIDEBAR_PADDING;
29
notebook.append_page (grid);
30
notebook.append_page (colletion_page_properties);
31
notebook.append_page (no_items_label);
32
notebook.set_show_tabs (false);
37
private void add_expander (Properties properties) {
38
var expander = new Gtk.Expander ("<b>" + properties.get_header_title () + "</b>");
39
expander.use_markup = true;
40
expander.add (properties);
41
expander.set_spacing (10);
42
grid.attach (expander, 0, line_count, 1, 1);
44
expander.set_expanded (true);
47
public void update_properties (Page page) {
48
/* figure out if we have a single image selected */
49
ViewCollection view = page.get_view ();
50
bool display_single = false;
53
notebook.set_current_page ( notebook.page_num (no_items_label));
58
int count = view.get_selected_count ();
59
Gee.Iterable<DataView> iter = null;
61
iter = view.get_selected ();
63
count = view.get_count ();
64
iter = (Gee.Iterable<DataView>) view.get_all ();
67
if (iter == null || count == 0) {
68
notebook.set_current_page (notebook.page_num (no_items_label));
74
foreach (DataView item in iter) {
75
var source = item.get_source () as MediaSource;
77
display_single = true;
81
display_single = true;
87
colletion_page_properties.update_properties (page);
88
page_num = notebook.page_num (colletion_page_properties);
90
foreach (var properties in properties_collection)
91
properties.update_properties (page);
92
page_num = notebook.page_num (grid);
94
notebook.set_current_page (page_num);
97
public void save_changes () {
98
foreach (var properties in properties_collection)
99
properties.save_changes_to_source ();