Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sweep animation #283

Merged
merged 5 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions data/AppEntry.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* SPDX-License-Identifier: GPL-2.0-or-later
* SPDX-FileCopyrightText: 2017-2023 elementary, Inc. (https://elementary.io)
*/

.expander:checked {
background: transparent;
}

.expander:checked:focus {
background: @selected_bg_color;
}

.expander image {
transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.expander:checked image {
transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
-gtk-icon-transform: rotate(90deg);
}

.expander label {
font-weight: inherit;
}

@keyframes sweep {
0% { -gtk-icon-transform: rotate(0deg) translatex(0); }
20% { -gtk-icon-transform: rotate(40deg) translatex(-5px); }
60% { -gtk-icon-transform: rotate(0deg) translatex(0); }
80% { -gtk-icon-transform: rotate(-30deg) translatex(3px); }
100% { -gtk-icon-transform: rotate(0deg) translatex(0); }
}

.sweep-animation {
transition: all 175ms ease-in-out;
}

.sweep-animation.active {
animation: sweep 600ms ease-in-out;
}
25 changes: 0 additions & 25 deletions data/AppEntryExpander.css

This file was deleted.

2 changes: 1 addition & 1 deletion data/gresource.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/io/elementary/wingpanel/notifications">
<file compressed="true">AppEntryExpander.css</file>
<file compressed="true">AppEntry.css</file>
<file compressed="true">indicator.css</file>
<file compressed="true">NotificationEntry.css</file>
</gresource>
Expand Down
22 changes: 15 additions & 7 deletions src/Widgets/AppEntry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class Notifications.AppEntry : Gtk.ListBoxRow {

static construct {
provider = new Gtk.CssProvider ();
provider.load_from_resource ("/io/elementary/wingpanel/notifications/AppEntryExpander.css");
provider.load_from_resource ("/io/elementary/wingpanel/notifications/AppEntry.css");
Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

settings = new Settings ("io.elementary.wingpanel.notifications");
headers = (HashTable<string, bool>) settings.get_value ("headers");
Expand All @@ -53,14 +54,12 @@ public class Notifications.AppEntry : Gtk.ListBoxRow {
}

var image = new Gtk.Image.from_icon_name ("pan-end-symbolic", SMALL_TOOLBAR);
image.get_style_context ().add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

var label = new Gtk.Label (name) {
hexpand = true,
xalign = 0
};
label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);
label.get_style_context ().add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

var expander_content = new Gtk.Box (HORIZONTAL, 3);
expander_content.add (label);
Expand All @@ -71,11 +70,15 @@ public class Notifications.AppEntry : Gtk.ListBoxRow {
active = true
};
unowned var expander_style_context = expander.get_style_context ();
expander_style_context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
expander_style_context.add_class ("image-button");
alainm23 marked this conversation as resolved.
Show resolved Hide resolved
expander_style_context.add_class ("expander");

var clear_btn_entry = new Gtk.Button.from_icon_name ("edit-clear-all-symbolic", Gtk.IconSize.SMALL_TOOLBAR) {
tooltip_text = _("Clear all %s notifications").printf (name)
var clear_btn_image = new Gtk.Image.from_icon_name ("edit-clear-all-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
clear_btn_image.get_style_context ().add_class ("sweep-animation");

var clear_btn_entry = new Gtk.Button () {
tooltip_text = _("Clear all %s notifications").printf (name),
child = clear_btn_image
};
clear_btn_entry.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);

Expand All @@ -101,7 +104,12 @@ public class Notifications.AppEntry : Gtk.ListBoxRow {
});

clear_btn_entry.clicked.connect (() => {
clear (); // Causes notification list to destroy this app entry after clearing its notification entries
clear_btn_image.get_style_context ().add_class ("active");
clear_all_notification_entries ();
GLib.Timeout.add (600, () => {
clear (); // Causes notification list to destroy this app entry after clearing its notification entries
return GLib.Source.REMOVE;
});
});

expander.bind_property ("active", image, "tooltip-text", SYNC_CREATE, (binding, srcval, ref targetval) => {
Expand Down