Skip to content
Open
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
2 changes: 1 addition & 1 deletion data/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ window,
margin-top: 12px;
}

.notification .buttonbox button {
.notification .buttonbox.text-buttons button {
min-width: 65px;
}

Expand Down
25 changes: 21 additions & 4 deletions src/Bubble.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 8 additions & 2 deletions src/DBus.vala
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class Notifications.Server : Object {

public string [] get_capabilities () throws DBusError, IOError {
return {
"action-icons",
"actions",
"body",
"body-markup",
Expand Down Expand Up @@ -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<Notification.Button?> (actions.length / 2);
var notification = new Notification (app_name, app_icon, summary, body, hints) {
buttons = new GenericArray<Notification.Button?> (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) {
Expand Down
1 change: 1 addition & 0 deletions src/Notification.vala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Notifications.Notification : GLib.Object {
public Variant default_action_target { get; set; }

public GenericArray<Button?> buttons { get; set; }
public bool action_icons { get; set; default = false; }

private static Regex entity_regex;
private static Regex tag_regex;
Expand Down