Skip to content
Merged
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
30 changes: 25 additions & 5 deletions src/Indicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
public class Notifications.Indicator : Wingpanel.Indicator {
private const string CHILD_SCHEMA_ID = "io.elementary.notifications.applications";
private const string CHILD_PATH = "/io/elementary/notifications/applications/%s/";
private const string KEYBINDING_SCHEMA = "io.elementary.panel.keybindings";
private const string REMEMBER_KEY = "remember";

private static GLib.Settings? keybinding_settings;
private Gee.HashMap<string, Settings> app_settings_cache;
private GLib.Settings notify_settings;

Expand All @@ -24,6 +26,12 @@ public class Notifications.Indicator : Wingpanel.Indicator {
);
}

static construct {
if (SettingsSchemaSource.get_default ().lookup (KEYBINDING_SCHEMA, true) != null) {
keybinding_settings = new GLib.Settings (KEYBINDING_SCHEMA);
}
}

construct {
GLib.Intl.bindtextdomain (Notifications.GETTEXT_PACKAGE, Notifications.LOCALEDIR);
GLib.Intl.bind_textdomain_codeset (Notifications.GETTEXT_PACKAGE, "UTF-8");
Expand Down Expand Up @@ -54,6 +62,10 @@ public class Notifications.Indicator : Wingpanel.Indicator {
}
});

if (keybinding_settings != null) {
keybinding_settings.changed["panel-notifications-menu"].connect (update_tooltip);
}

notify_settings.changed["do-not-disturb"].connect (() => {
set_display_icon_name ();
});
Expand Down Expand Up @@ -196,16 +208,24 @@ public class Notifications.Indicator : Wingpanel.Indicator {

private void update_tooltip () {
var number_of_notifications = nlist.notification_items.get_n_items ();
string[] accels = {};
string description;
string accel_label;
string middle_click_label = "";

if (keybinding_settings != null) {
var raw_accels = keybinding_settings.get_strv ("open-menu-notifications");
foreach (unowned string raw_accel in raw_accels) {
if (raw_accel != "") accels += raw_accel;
}
}

if (notify_settings.get_boolean ("do-not-disturb")) {
accel_label = _("Middle-click to disable Do Not Disturb");
middle_click_label += _("Middle-click to disable Do Not Disturb");
} else {
accel_label = _("Middle-click to enable Do Not Disturb");
middle_click_label += _("Middle-click to enable Do Not Disturb");
}

accel_label = Granite.TOOLTIP_SECONDARY_TEXT_MARKUP.printf (accel_label);
middle_click_label = Granite.TOOLTIP_SECONDARY_TEXT_MARKUP.printf (middle_click_label);

switch (number_of_notifications) {
case 0:
Expand All @@ -225,7 +245,7 @@ public class Notifications.Indicator : Wingpanel.Indicator {
break;
}

dynamic_icon.tooltip_markup = "%s\n%s".printf (description, accel_label);
dynamic_icon.tooltip_markup = "%s\n%s".printf (Granite.markup_accel_tooltip (accels, description), middle_click_label);
}
}

Expand Down
Loading