18
18
* Authored by: Corentin Noël <corentin@elementary.io>
21
const string CATEGORIES_STYLE_CSS = """
23
background-image: linear-gradient(to bottom,
27
background-position: center center;
28
background-repeat: no-repeat;
29
border: 1px solid alpha (#000, 0.15);
32
box-shadow: inset 0 0 0 1px alpha (#fff, 0.05),
33
inset 0 1px 0 0 alpha (#fff, 0.45),
34
inset 0 -1px 0 0 alpha (#fff, 0.15),
35
0 3px 2px -1px alpha (#000, 0.15),
36
0 3px 5px alpha (#000, 0.10);
42
background-image: -gtk-scaled(url("resource:///org/pantheon/appcenter/backgrounds/audio.svg"), url("resource:///org/pantheon/appcenter/backgrounds/audio@2x.svg")),
43
linear-gradient(to bottom,
47
border-color: alpha (#a25812, 0.8);
49
icon-shadow: 0 1px 1px alpha (#6c1900, 0.5),
50
0 2px 3px alpha (#6c1900, 0.5);
51
text-shadow: 0 1px 1px alpha (#6c1900, 0.5),
52
0 2px 3px alpha (#6c1900, 0.5);
54
.category.development {
55
background-image: linear-gradient(to bottom,
59
border-color: alpha (#352d48, 0.8);
61
text-shadow: 0 2px 0 alpha (#000, 0.3);
64
.category.accessories {
66
box-shadow: inset 0 0 0 1px alpha (#fff, 0.10),
67
inset 0 1px 0 0 alpha (#fff, 0.90),
68
inset 0 -1px 0 0 alpha (#fff, 0.30),
69
0 0 0 1px alpha (#000, 0.15),
70
0 3px 2px -1px alpha (#000, 0.15),
71
0 3px 5px alpha (#000, 0.10);
76
box-shadow: inset 0 0 0 1px alpha (#fff, 0.10),
77
inset 0 1px 0 0 alpha (#fff, 0.90),
78
inset 0 -1px 0 0 alpha (#fff, 0.30),
79
0 0 0 1px alpha (#000, 0.15),
80
0 3px 2px -1px alpha (#000, 0.15),
81
0 3px 5px alpha (#000, 0.10);
85
background-image: linear-gradient(to bottom,
89
border-color: alpha (#454951, 0.8);
90
box-shadow: inset 0 0 0 1px alpha (#fff, 0.05),
91
inset 0 1px 0 0 alpha (#fff, 0.25),
92
inset 0 -1px 0 0 alpha (#fff, 0.10),
93
0 3px 2px -1px alpha (#000, 0.15),
94
0 3px 5px alpha (#000, 0.10);
96
text-shadow: 0 1px 1px alpha (#000, 0.3),
97
0 2px 3px alpha (#000, 0.3);
100
background-image: -gtk-gradient(radial, center center, 0.42, center center, 0.47, from(transparent), to(alpha(#000,0.3))),
101
linear-gradient(to bottom,
105
background-size: auto 150%;
106
border-color: alpha (#8c201d, 0.8);
107
box-shadow: inset 0 0 0 1px alpha (#fff, 0.05),
108
inset 0 1px 0 0 alpha (#fff, 0.25),
109
inset 0 -1px 0 0 alpha (#fff, 0.10),
110
0 3px 2px -1px alpha (#000, 0.15),
111
0 3px 5px alpha (#000, 0.10);
112
text-shadow: 0 1px 2px alpha (#000, 0.3);
113
icon-shadow: 0 1px 2px alpha (#000, 0.3);
118
box-shadow: inset 0 0 0 1px alpha (#fff, 0.10),
119
inset 0 1px 0 0 alpha (#fff, 0.90),
120
inset 0 -1px 0 0 alpha (#fff, 0.30),
121
0 0 0 1px alpha (#000, 0.15),
122
0 3px 2px -1px alpha (#000, 0.15),
123
0 3px 5px alpha (#000, 0.10);
126
.category.graphics .label {
127
border-image: -gtk-scaled(url("resource:///org/pantheon/appcenter/backgrounds/graphics.svg"),url("resource:///org/pantheon/appcenter/backgrounds/graphics@2x.svg")) 10 10 10 10 / 10px 10px 10px 10px repeat;
130
.category.graphics .label:dir(rtl) {
131
border-image: -gtk-scaled(url("resource:///org/pantheon/appcenter/backgrounds/graphics-rtl.svg"),url("resource:///org/pantheon/appcenter/backgrounds/graphics-rtl@2x.svg")) 10 10 10 10 / 10px 10px 10px 10px repeat;
134
background-image: linear-gradient(to bottom,
138
border-color: alpha (#1B2022, 0.8);
139
box-shadow: inset 0 0 0 1px alpha (#fff, 0.02),
140
inset 0 1px 0 0 alpha (#fff, 0.23),
141
inset 0 -1px 0 0 alpha (#fff, 0.07),
142
0 3px 2px -1px alpha (#000, 0.15),
143
0 3px 5px alpha (#000, 0.10);
144
text-shadow: 0 1px 2px alpha (#000, 0.3);
145
icon-shadow: 0 1px 2px alpha (#000, 0.3);
150
.category.education {
151
background-image: linear-gradient(to bottom,
155
border-color: alpha (#213D30, 0.8);
156
box-shadow: inset 0 0 0 1px alpha (#fff, 0.05),
157
inset 0 1px 0 0 alpha (#fff, 0.25),
158
inset 0 -1px 0 0 alpha (#fff, 0.10),
159
0 3px 2px -1px alpha (#000, 0.15),
160
0 3px 5px alpha (#000, 0.10);
161
text-shadow: 0 1px 2px alpha (#000, 0.3);
162
icon-shadow: 0 1px 2px alpha (#000, 0.3);
163
font-family: Operating Instructions;
168
background-image: linear-gradient(to bottom,
172
border-color: alpha (#2980D1, 0.8);
173
box-shadow: inset 0 0 0 1px alpha (#fff, 0.05),
174
inset 0 1px 0 0 alpha (#fff, 0.25),
175
inset 0 -1px 0 0 alpha (#fff, 0.10),
176
0 3px 2px -1px alpha (#000, 0.15),
177
0 3px 5px alpha (#000, 0.10);
178
text-shadow: 0 1px 1px alpha (#000, 0.3),
179
0 2px 3px alpha (#000, 0.3);
183
background-image: url("resource:///org/pantheon/appcenter/backgrounds/science.svg"),
184
linear-gradient(to bottom,
188
border-color: alpha (#1B2022, 0.8);
189
box-shadow: inset 0 0 0 1px alpha (#fff, 0.02),
190
inset 0 1px 0 0 alpha (#fff, 0.23),
191
inset 0 -1px 0 0 alpha (#fff, 0.07),
192
0 3px 2px -1px alpha (#000, 0.15),
193
0 3px 5px alpha (#000, 0.10);
194
text-shadow: 0 1px 2px alpha (#000, 0.3);
195
icon-shadow: 0 1px 2px alpha (#000, 0.3);
196
font-family: Limelight;
200
.category.accessibility {
201
background-image: linear-gradient(to bottom,
205
border-color: alpha (#2980D1, 0.8);
209
icon-shadow: 0 1px 0 alpha (#000, 0.3);
210
text-shadow: 0 1px 0 alpha (#000, 0.3);
21
214
public class AppCenter.Widgets.CategoryItem : Gtk.FlowBoxChild {
22
215
public AppStream.Category app_category;
23
216
private Gtk.Grid grid;
24
217
private Gtk.Image display_image;
25
218
private Gtk.Label name_label;
26
private Gtk.Label desc_label;
219
private Gtk.Grid themed_grid;
28
221
public CategoryItem (AppStream.Category app_category) {
29
222
this.app_category = app_category;
30
name_label.label = GLib.Markup.escape_text (app_category.name ?? "");
31
desc_label.label = GLib.Markup.escape_text (app_category.summary ?? "");
32
display_image.icon_name = app_category.icon;
223
name_label.label = app_category.name;
224
tooltip_text = app_category.summary ?? "";
225
if (app_category.icon != null) {
226
display_image.icon_name = app_category.icon;
227
((Gtk.Misc) name_label).xalign = 0;
228
name_label.halign = Gtk.Align.START;
230
display_image.destroy ();
231
name_label.justify = Gtk.Justification.CENTER;
238
var provider = new Gtk.CssProvider ();
240
provider.load_from_data (CATEGORIES_STYLE_CSS, CATEGORIES_STYLE_CSS.length);
241
Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
243
critical (e.message);
37
get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
39
248
grid = new Gtk.Grid ();
41
grid.column_spacing = 12;
249
grid.orientation = Gtk.Orientation.HORIZONTAL;
250
grid.column_spacing = 6;
251
grid.halign = Gtk.Align.CENTER;
42
252
grid.valign = Gtk.Align.CENTER;
253
grid.margin_top = 32;
254
grid.margin_end = 16;
255
grid.margin_bottom = 32;
256
grid.margin_start = 16;
44
258
display_image = new Gtk.Image ();
45
259
display_image.icon_size = Gtk.IconSize.DIALOG;
46
grid.attach (display_image, 0, 0, 1, 2);
260
display_image.valign = Gtk.Align.CENTER;
261
display_image.halign = Gtk.Align.END;
262
grid.add (display_image);
48
264
name_label = new Gtk.Label (null);
49
name_label.get_style_context ().add_class ("h3");
50
name_label.use_markup = true;
51
((Gtk.Misc) name_label).xalign = 0;
52
name_label.hexpand = true;
53
grid.attach (name_label, 1, 0, 1, 1);
55
desc_label = new Gtk.Label (null);
56
((Gtk.Misc) desc_label).xalign = 0;
57
desc_label.wrap = true;
58
desc_label.hexpand = true;
59
grid.attach (desc_label, 1, 1, 1, 1);
265
name_label.wrap = true;
266
grid.add (name_label);
268
var expanded_grid = new Gtk.Grid ();
269
expanded_grid.expand = true;
270
expanded_grid.margin = 12;
272
themed_grid = new Gtk.Grid ();
273
themed_grid.get_style_context ().add_class ("category");
274
themed_grid.attach (grid, 0, 0, 1, 1);
275
themed_grid.attach (expanded_grid, 0, 0, 1, 1);
276
themed_grid.margin = 12;
281
public void add_category_class (string theme_name) {
282
themed_grid.get_style_context ().add_class (theme_name);