diff --git a/data/application.css b/data/application.css index 37a6d38..f3b86b3 100644 --- a/data/application.css +++ b/data/application.css @@ -60,7 +60,7 @@ window, margin-top: 12px; } -.notification .buttonbox button { +.notification .buttonbox.text-buttons button { min-width: 65px; } diff --git a/src/Bubble.vala b/src/Bubble.vala index 4570f6b..650d598 100644 --- a/src/Bubble.vala +++ b/src/Bubble.vala @@ -145,10 +145,27 @@ public class Notifications.Bubble : AbstractBubble { }; action_area.add_css_class ("buttonbox"); - foreach (var button in notification.buttons) { - action_area.append (new Gtk.Button.with_label (button.label) { - action_name = button.action_name - }); + if (!notification.action_icons) { + action_area.add_css_class ("text-buttons"); + } + + foreach (var action in notification.buttons) { + var button = new Gtk.Button () { + action_name = action.action_name + }; + + if (notification.action_icons) { + var action_name_split = action.action_name.split ("."); + + button.child = new Gtk.Image.from_icon_name (action_name_split[action_name_split.length - 1]) { + icon_size = LARGE + }; + button.add_css_class (Granite.CssClass.CIRCULAR); + } else { + button.child = new Gtk.Label (action.label); + } + + action_area.append (button); } attach (action_area, 0, 2, 2); diff --git a/src/DBus.vala b/src/DBus.vala index e0d0a54..b5e3d5e 100644 --- a/src/DBus.vala +++ b/src/DBus.vala @@ -71,6 +71,7 @@ public class Notifications.Server : Object { public string [] get_capabilities () throws DBusError, IOError { return { + "action-icons", "actions", "body", "body-markup", @@ -120,8 +121,13 @@ public class Notifications.Server : Object { if (hints.contains (X_CANONICAL_PRIVATE_SYNCHRONOUS)) { send_confirmation (app_icon, hints); } else { - var notification = new Notification (app_name, app_icon, summary, body, hints); - notification.buttons = new GenericArray (actions.length / 2); + var notification = new Notification (app_name, app_icon, summary, body, hints) { + buttons = new GenericArray (actions.length / 2) + }; + + if ("action-icons" in hints && hints["action-icons"].is_of_type (VariantType.BOOLEAN)) { + notification.action_icons = hints["action-icons"].get_boolean (); + } // validate actions for (var i = 0; i < actions.length; i += 2) { diff --git a/src/Notification.vala b/src/Notification.vala index a0ebafe..23d8e49 100644 --- a/src/Notification.vala +++ b/src/Notification.vala @@ -38,6 +38,7 @@ public class Notifications.Notification : GLib.Object { public Variant default_action_target { get; set; } public GenericArray buttons { get; set; } + public bool action_icons { get; set; default = false; } private static Regex entity_regex; private static Regex tag_regex;