1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
/* Copyright 2016 Software Freedom Conservancy Inc.
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
namespace Plugins {
[GtkTemplate (ui = "/org/gnome/Shotwell/ui/manifest_widget.ui")]
public class ManifestWidgetMediator : Gtk.Box {
[GtkChild]
private unowned Gtk.ScrolledWindow list_bin;
private ManifestListView list = new ManifestListView();
public ManifestWidgetMediator() {
Object();
list_bin.add(list);
}
}
private class CollectionModel<G> : GLib.ListModel, Object {
private Gee.Collection<G> target;
private unowned Gee.List<G>? as_list = null;
public CollectionModel(Gee.Collection<G> target) {
Object();
this.target = target.read_only_view;
if (this.target is Gee.List) {
this.as_list = (Gee.List<G>)this.target;
}
}
GLib.Object? get_item(uint position) {
if (position >= this.target.size) {
return null;
}
if (this.as_list != null) {
return (GLib.Object) this.as_list.@get((int) position);
}
var count = 0U;
foreach (var g in this.target) {
if (count == position) {
return (GLib.Object)g;
}
count++;
}
return null;
}
GLib.Type get_item_type() {
return typeof(G);
}
uint get_n_items() {
return this.target.size;
}
}
private class Selection : Object {
public signal void changed();
}
private class PluggableRow : Gtk.Box {
public Spit.Pluggable pluggable { get; construct; }
public bool enabled {get; construct; }
public PluggableRow(Spit.Pluggable pluggable_, bool enable_) {
Object(orientation: Gtk.Orientation.VERTICAL, pluggable: pluggable_,
enabled: enable_, margin_top: 6, margin_bottom:6, margin_start:6, margin_end:6);
}
public override void constructed() {
base.constructed();
var content = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
pack_start(content, true);
var revealer = new Gtk.Revealer();
revealer.margin_top = 6;
pack_end(revealer, true);
var info = pluggable.get_info();
var image = new Gtk.Image.from_icon_name(info.icon_name, Gtk.IconSize.BUTTON);
content.pack_start(image, false, false, 6);
image.hexpand = false;
var label = new Gtk.Label(pluggable.get_pluggable_name());
label.halign = Gtk.Align.START;
content.pack_start(label, true, true, 6);
var button = new Gtk.ToggleButton();
button.get_style_context().add_class("flat");
content.pack_end(button, false, false, 6);
button.bind_property("active", revealer, "reveal-child", BindingFlags.DEFAULT);
image = new Gtk.Image.from_icon_name("go-down-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
button.add(image);
var plugin_enabled = new Gtk.Switch();
plugin_enabled.hexpand = false;
plugin_enabled.vexpand = false;
plugin_enabled.valign = Gtk.Align.CENTER;
plugin_enabled.set_active(enabled);
content.pack_end(plugin_enabled, false, false, 6);
plugin_enabled.notify["active"].connect(() => {
var id = pluggable.get_id();
set_pluggable_enabled(id, plugin_enabled.active);
});
if (pluggable is Spit.Publishing.Service) {
#if 0
var manage = new Gtk.Button.from_icon_name("avatar-default-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
manage.get_style_context().add_class("flat");
// TRANSLATORS: %s is the name of an online service such as YouTube, Mastodon, ...
manage.set_tooltip_text(_("Manage accounts for %s").printf(pluggable.get_pluggable_name()));
content.pack_start(manage, false, false, 6);
#endif
}
var grid = new Gtk.Grid();
grid.get_style_context().add_class("content");
grid.set_row_spacing(12);
grid.set_column_spacing(6);
revealer.add(grid);
label = new Gtk.Label(info.copyright);
label.hexpand = true;
label.halign = Gtk.Align.START;
grid.attach(label, 0, 0, 2, 1);
label = new Gtk.Label(_("Authors"));
label.get_style_context().add_class("dim-label");
label.halign = Gtk.Align.END;
label.margin_start = 12;
grid.attach(label, 0, 1, 1, 1);
label = new Gtk.Label(info.authors);
label.halign = Gtk.Align.START;
label.hexpand = true;
grid.attach(label, 1, 1, 1, 1);
label = new Gtk.Label(_("Version"));
label.get_style_context().add_class("dim-label");
label.halign = Gtk.Align.END;
label.margin_start = 12;
grid.attach(label, 0, 2, 1, 1);
label = new Gtk.Label(info.version);
label.halign = Gtk.Align.START;
label.hexpand = true;
grid.attach(label, 1, 2, 1, 1);
label = new Gtk.Label(_("License"));
label.get_style_context().add_class("dim-label");
label.halign = Gtk.Align.END;
label.margin_start = 12;
grid.attach(label, 0, 3, 1, 1);
var link = new Gtk.LinkButton.with_label(info.license_url, info.license_blurp);
link.halign = Gtk.Align.START;
// remove the annoying padding around the link
link.get_style_context().remove_class("text-button");
link.get_style_context().add_class("shotwell-plain-link");
grid.attach(link, 1, 3, 1, 1);
label = new Gtk.Label(_("Website"));
label.get_style_context().add_class("dim-label");
label.halign = Gtk.Align.END;
label.margin_start = 12;
grid.attach(label, 0, 4, 1, 1);
link = new Gtk.LinkButton.with_label(info.website_url, info.website_name);
link.halign = Gtk.Align.START;
// remove the annoying padding around the link
link.get_style_context().remove_class("text-button");
link.get_style_context().add_class("shotwell-plain-link");
grid.attach(link, 1, 4, 1, 1);
}
}
private class ManifestListView : Gtk.Box {
public ManifestListView() {
Object(orientation: Gtk.Orientation.VERTICAL, spacing: 6);
}
public signal void row_selected(Spit.Pluggable? pluggable);
public override void constructed() {
base.constructed();
foreach (var extension_point in get_extension_points(compare_extension_point_names)) {
var label = new Gtk.Label(null);
label.set_markup("<span weight=\"bold\">%s</span>".printf(extension_point.name));
label.halign = Gtk.Align.START;
label.hexpand = true;
add(label);
var pluggables = get_pluggables_for_type(extension_point.pluggable_type, compare_pluggable_names, true);
var box = new Gtk.ListBox();
box.set_selection_mode(Gtk.SelectionMode.NONE);
box.hexpand = true;
box.margin_start = 12;
box.margin_end = 12;
var added = 0;
foreach (var pluggable in pluggables) {
bool enabled;
if (!get_pluggable_enabled(pluggable.get_id(), out enabled))
continue;
var pluggable_row = new PluggableRow(pluggable, enabled);
added++;
box.insert(pluggable_row, -1);
}
if (added > 0) {
add(box);
}
}
show_all();
}
}
}
|