Skip to content

Commit f4eb0e6

Browse files
authored
library: Remove Usage of PreferencesPage and Group (#958)
1 parent 2b13cf3 commit f4eb0e6

File tree

2 files changed

+214
-77
lines changed

2 files changed

+214
-77
lines changed

src/Library/Library.blp

Lines changed: 211 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -16,82 +16,217 @@ Adw.Window window {
1616
};
1717
}
1818

19-
content: Adw.PreferencesPage {
20-
Adw.PreferencesGroup {
21-
Box {
22-
halign: center;
23-
vexpand: false;
24-
25-
Picture picture_illustration {
26-
can-shrink: false;
27-
margin-bottom: 32;
28-
}
29-
}
30-
31-
Label {
32-
label: _("Learn, Test, Remix");
33-
34-
styles [
35-
"title-1"
36-
]
37-
}
38-
39-
SearchEntry search_entry {
40-
search-delay: 100;
41-
placeholder-text: _("Search demos");
42-
activates-default: true;
43-
width-request: 400;
44-
margin-top: 32;
45-
}
46-
}
47-
48-
Adw.PreferencesGroup library_uncategorized {}
49-
50-
Adw.PreferencesGroup library_tools {
51-
title: _("Tools");
52-
}
53-
54-
Adw.PreferencesGroup library_network {
55-
title: _("Network");
56-
}
57-
58-
Adw.PreferencesGroup library_controls {
59-
title: _("Controls");
60-
}
61-
62-
Adw.PreferencesGroup library_layout {
63-
title: _("Layout");
64-
}
65-
66-
Adw.PreferencesGroup library_feedback {
67-
title: _("Feedback");
68-
}
69-
70-
Adw.PreferencesGroup library_navigation {
71-
title: _("Navigation");
72-
}
73-
74-
Adw.PreferencesGroup library_user_interface {
75-
title: _("User Interface");
76-
}
77-
78-
Adw.PreferencesGroup library_platform {
79-
title: _("Platform APIs");
80-
}
81-
82-
Adw.PreferencesGroup {
83-
vexpand: true;
84-
valign: end;
85-
86-
Label {
87-
label: _("All examples are dedicated to the public domain\nand <b>can be used freely</b> under the terms of <a href=\"https://creativecommons.org/publicdomain/zero/1.0/\">CC0 1.0</a>");
88-
use-markup: true;
89-
90-
styles [
91-
"caption"
92-
]
93-
}
94-
}
19+
content: ScrolledWindow {
20+
hscrollbar-policy: never;
21+
22+
child: Adw.Clamp {
23+
maximum-size: 576;
24+
margin-end: 12;
25+
margin-start: 12;
26+
27+
child: Box {
28+
orientation: vertical;
29+
spacing: 12;
30+
31+
Box {
32+
orientation: vertical;
33+
34+
Box {
35+
halign: center;
36+
vexpand: false;
37+
38+
Picture picture_illustration {
39+
can-shrink: false;
40+
margin-bottom: 32;
41+
margin-top: 24;
42+
}
43+
}
44+
45+
Label {
46+
label: _("Learn, Test, Remix");
47+
48+
styles [
49+
"title-1"
50+
]
51+
}
52+
53+
SearchEntry search_entry {
54+
search-delay: 100;
55+
placeholder-text: _("Search demos");
56+
activates-default: true;
57+
width-request: 400;
58+
margin-top: 32;
59+
}
60+
}
61+
62+
ListBox library_uncategorized {
63+
selection-mode: none;
64+
65+
styles [
66+
"boxed-list"
67+
]
68+
}
69+
70+
Label label_tools {
71+
label: _("Tools");
72+
halign: start;
73+
margin-top: 12;
74+
75+
styles [
76+
"title-4"
77+
]
78+
}
79+
80+
ListBox library_tools {
81+
selection-mode: none;
82+
83+
styles [
84+
"boxed-list"
85+
]
86+
}
87+
88+
Label label_network {
89+
label: _("Network");
90+
halign: start;
91+
margin-top: 12;
92+
93+
styles [
94+
"title-4"
95+
]
96+
}
97+
98+
ListBox library_network {
99+
selection-mode: none;
100+
101+
styles [
102+
"boxed-list"
103+
]
104+
}
105+
106+
Label label_controls {
107+
label: _("Controls");
108+
halign: start;
109+
margin-top: 12;
110+
111+
styles [
112+
"title-4"
113+
]
114+
}
115+
116+
ListBox library_controls {
117+
selection-mode: none;
118+
119+
styles [
120+
"boxed-list"
121+
]
122+
}
123+
124+
Label label_layout {
125+
label: _("Layout");
126+
halign: start;
127+
margin-top: 12;
128+
129+
styles [
130+
"title-4"
131+
]
132+
}
133+
134+
ListBox library_layout {
135+
selection-mode: none;
136+
137+
styles [
138+
"boxed-list"
139+
]
140+
}
141+
142+
Label label_feedback {
143+
label: _("Feedback");
144+
halign: start;
145+
margin-top: 12;
146+
147+
styles [
148+
"title-4"
149+
]
150+
}
151+
152+
ListBox library_feedback {
153+
selection-mode: none;
154+
155+
styles [
156+
"boxed-list"
157+
]
158+
}
159+
160+
Label label_navigation {
161+
label: _("Navigation");
162+
halign: start;
163+
margin-top: 12;
164+
165+
styles [
166+
"title-4"
167+
]
168+
}
169+
170+
ListBox library_navigation {
171+
selection-mode: none;
172+
173+
styles [
174+
"boxed-list"
175+
]
176+
}
177+
178+
Label label_user_interface {
179+
label: _("User Interface");
180+
halign: start;
181+
margin-top: 12;
182+
183+
styles [
184+
"title-4"
185+
]
186+
}
187+
188+
ListBox library_user_interface {
189+
selection-mode: none;
190+
191+
styles [
192+
"boxed-list"
193+
]
194+
}
195+
196+
Label label_platform {
197+
label: _("Platform APIs");
198+
halign: start;
199+
margin-top: 12;
200+
201+
styles [
202+
"title-4"
203+
]
204+
}
205+
206+
ListBox library_platform {
207+
selection-mode: none;
208+
209+
styles [
210+
"boxed-list"
211+
]
212+
}
213+
214+
Box {
215+
halign: center;
216+
margin-bottom: 24;
217+
margin-top: 12;
218+
219+
Label {
220+
label: _("All examples are dedicated to the public domain\nand <b>can be used freely</b> under the terms of <a href=\"https://creativecommons.org/publicdomain/zero/1.0/\">CC0 1.0</a>");
221+
use-markup: true;
222+
223+
styles [
224+
"caption"
225+
]
226+
}
227+
}
228+
};
229+
};
95230
};
96231
}
97232
}

src/Library/Library.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default function Library({ application }) {
5050
if (!category_map.has(demo.category)) {
5151
category_map.set(demo.category, objects[`library_${demo.category}`]);
5252
}
53-
objects[`library_${demo.category}`].add(entry_row);
53+
objects[`library_${demo.category}`].append(entry_row);
5454
widgets_map.set(demo.name, { entry_row, category: demo.category });
5555
});
5656

@@ -65,6 +65,8 @@ export default function Library({ application }) {
6565
});
6666

6767
category_map.forEach((category_widget, category_name) => {
68+
const label = objects[`label_${category_name}`];
69+
if (label) label.visible = search_term === "";
6870
category_widget.visible = visible_categories.has(category_name);
6971
});
7072
});

0 commit comments

Comments
 (0)