Skip to content

Commit 81a8ed1

Browse files
authored
NotificationEntry: replace Deck with Carousel (#301)
1 parent 4016a11 commit 81a8ed1

2 files changed

Lines changed: 33 additions & 36 deletions

File tree

data/NotificationEntry.css

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,31 @@ notification .card {
33
padding: 6px;
44
/* Box shadow is clipped to the margin area */
55
margin: 0.75em 1em;
6+
/*Make sure notification always fills width*/
7+
min-width: calc(360px - 1em);
68
}
79

810
notification .title {
911
font-weight: bold;
1012
}
1113

12-
.delete-affordance {
14+
delete-affordance {
1315
background-color: mix(@theme_bg_color, @STRAWBERRY_500, 0.3);
1416
padding: 12px;
1517
}
1618

17-
.delete-affordance.left {
19+
delete-affordance.left {
1820
border-top-right-radius: 6px;
1921
border-bottom-right-radius: 6px;
2022
}
2123

22-
.delete-affordance.right {
24+
delete-affordance.right {
2325
border-top-left-radius: 6px;
2426
border-bottom-left-radius: 6px;
2527
}
2628

27-
.delete-affordance image,
28-
.delete-affordance label {
29+
delete-affordance image,
30+
delete-affordance label {
2931
color: mix(@theme_fg_color, @error_color, 0.6);
3032
font-weight: 600;
3133
}
@@ -41,12 +43,12 @@ notification .close {
4143
@BLACK_500
4244
);
4345
box-shadow:
44-
inset 0 0 0 1px alpha (#fff, 0.02),
45-
inset 0 1px 0 0 alpha (#fff, 0.07),
46-
inset 0 -1px 0 0 alpha (#fff, 0.01),
47-
0 0 0 1px alpha (#000, 0.7),
48-
0 1px 2px alpha (#000, 0.16),
49-
0 2px 3px alpha (#000, 0.23);
46+
inset 0 0 0 1px alpha(#fff, 0.02),
47+
inset 0 1px 0 0 alpha(#fff, 0.07),
48+
inset 0 -1px 0 0 alpha(#fff, 0.01),
49+
0 0 0 1px alpha(#000, 0.7),
50+
0 1px 2px alpha(#000, 0.16),
51+
0 2px 3px alpha(#000, 0.23);
5052
margin: 3px;
5153
}
5254

src/Widgets/NotificationEntry.vala

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -208,18 +208,18 @@ public class Notifications.NotificationEntry : Gtk.ListBoxRow {
208208
};
209209
overlay.add_overlay (delete_revealer);
210210

211-
var deck = new Hdy.Deck () {
212-
can_swipe_back = true,
213-
can_swipe_forward = true,
214-
transition_type = Hdy.DeckTransitionType.SLIDE
211+
var carousel = new Hdy.Carousel () {
212+
allow_scroll_wheel = false,
213+
// Eliminate race between packing widgets and page_changed
214+
reveal_duration = 0
215215
};
216-
deck.add (delete_left);
217-
deck.add (overlay);
218-
deck.add (delete_right);
219-
deck.visible_child = overlay;
216+
carousel.add (delete_left);
217+
carousel.add (overlay);
218+
carousel.add (delete_right);
219+
carousel.scroll_to (overlay);
220220

221221
revealer = new Gtk.Revealer () {
222-
child = deck,
222+
child = carousel,
223223
reveal_child = true,
224224
transition_duration = 200,
225225
transition_type = SLIDE_UP
@@ -252,14 +252,8 @@ public class Notifications.NotificationEntry : Gtk.ListBoxRow {
252252
return GLib.Source.CONTINUE;
253253
});
254254

255-
deck.notify["visible-child"].connect (() => {
256-
if (deck.transition_running == false && deck.visible_child != overlay) {
257-
clear ();
258-
}
259-
});
260-
261-
deck.notify["transition-running"].connect (() => {
262-
if (deck.transition_running == false && deck.visible_child != overlay) {
255+
carousel.page_changed.connect (() => {
256+
if (carousel.position != 1) {
263257
clear ();
264258
}
265259
});
@@ -285,32 +279,33 @@ public class Notifications.NotificationEntry : Gtk.ListBoxRow {
285279
}
286280
}
287281

288-
private class DeleteAffordance : Gtk.Bin {
282+
private class DeleteAffordance : Gtk.Box {
289283
public Gtk.Align alignment { get; construct; }
290284

291285
public DeleteAffordance (Gtk.Align alignment) {
292286
Object (alignment: alignment);
293287
}
294288

289+
class construct {
290+
set_css_name ("delete-affordance");
291+
}
292+
295293
construct {
296294
var image = new Gtk.Image.from_icon_name ("edit-delete-symbolic", Gtk.IconSize.MENU);
297295

298296
var label = new Gtk.Label (_("Delete"));
299297
label.get_style_context ().add_class (Granite.STYLE_CLASS_SMALL_LABEL);
300298

301-
var delete_internal_grid = new Gtk.Grid () {
299+
var box = new Gtk.Box (VERTICAL, 3) {
302300
halign = alignment,
303301
hexpand = true,
304-
row_spacing = 3,
305302
valign = CENTER,
306303
vexpand = true
307304
};
308-
delete_internal_grid.attach (image, 0, 0);
309-
delete_internal_grid.attach (label, 0, 1);
310-
311-
child = delete_internal_grid;
305+
box.add (image);
306+
box.add (label);
312307

313-
get_style_context ().add_class ("delete-affordance");
308+
add (box);
314309
}
315310
}
316311

0 commit comments

Comments
 (0)