mirror of
https://github.com/elementary/gala.git
synced 2024-11-23 20:07:21 +03:00
Notification backend updated
This commit is contained in:
parent
5b3c056410
commit
36ab48433a
@ -231,18 +231,21 @@
|
|||||||
<default>false</default>
|
<default>false</default>
|
||||||
<_summary>Disable all notifications</_summary>
|
<_summary>Disable all notifications</_summary>
|
||||||
</key>
|
</key>
|
||||||
<key type="b" name="default-bubbles">
|
<child name="applications" schema="org.pantheon.desktop.gala.notifications.application" />
|
||||||
|
</schema>
|
||||||
|
|
||||||
|
<schema id="org.pantheon.desktop.gala.notifications.application" gettext-domain="@GETTEXT_PACKAGE@">
|
||||||
|
<key type="b" name="bubbles">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
<_summary>The default setting for the bubbles that would be used for new apps</_summary>
|
<_summary>Enable bubbles</_summary>
|
||||||
</key>
|
</key>
|
||||||
<key type="b" name="default-sounds">
|
<key type="b" name="sounds">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
<_summary>The default setting for the sounds that would be used for new apps</_summary>
|
<_summary>Enable sounds</_summary>
|
||||||
</key>
|
</key>
|
||||||
<key type="as" name="apps">
|
<key type="b" name="remember">
|
||||||
<default>[]</default>
|
<default>true</default>
|
||||||
<_summary>List of apps and their notification-permissions. Example: ['noise:show,on', 'pantheon-terminal:show,off']</_summary>
|
<_summary>Show missed notifications in notification center</_summary>
|
||||||
<_description>Structure: ['{APP-NAME}:{PRIORITY (show/hide)},{SOUNDS on/off}', ...]</_description>
|
|
||||||
</key>
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
|
|
||||||
|
@ -19,11 +19,6 @@ using Meta;
|
|||||||
|
|
||||||
namespace Gala.Plugins.Notify
|
namespace Gala.Plugins.Notify
|
||||||
{
|
{
|
||||||
const string APP_BUBBLES_SHOW = "show";
|
|
||||||
const string APP_BUBBLES_HIDE = "hide";
|
|
||||||
const string APP_SOUNDS_ON = "on";
|
|
||||||
const string APP_SOUNDS_OFF = "off";
|
|
||||||
|
|
||||||
const string X_CANONICAL_PRIVATE_SYNCHRONOUS = "x-canonical-private-synchronous";
|
const string X_CANONICAL_PRIVATE_SYNCHRONOUS = "x-canonical-private-synchronous";
|
||||||
const string X_CANONICAL_PRIVATE_ICON_ONLY = "x-canonical-private-icon-only";
|
const string X_CANONICAL_PRIVATE_ICON_ONLY = "x-canonical-private-icon-only";
|
||||||
|
|
||||||
@ -68,6 +63,7 @@ namespace Gala.Plugins.Notify
|
|||||||
|
|
||||||
DBus? bus_proxy = null;
|
DBus? bus_proxy = null;
|
||||||
unowned Canberra.Context? ca_context = null;
|
unowned Canberra.Context? ca_context = null;
|
||||||
|
Gee.HashMap<string, Settings> app_settings_cache;
|
||||||
|
|
||||||
public NotifyServer (NotificationStack stack)
|
public NotifyServer (NotificationStack stack)
|
||||||
{
|
{
|
||||||
@ -91,6 +87,8 @@ namespace Gala.Plugins.Notify
|
|||||||
Canberra.PROP_APPLICATION_LANGUAGE, locale,
|
Canberra.PROP_APPLICATION_LANGUAGE, locale,
|
||||||
null);
|
null);
|
||||||
ca_context.open ();
|
ca_context.open ();
|
||||||
|
|
||||||
|
app_settings_cache = new Gee.HashMap<string, Settings> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string [] get_capabilities ()
|
public string [] get_capabilities ()
|
||||||
@ -159,46 +157,31 @@ namespace Gala.Plugins.Notify
|
|||||||
var confirmation = hints.contains (X_CANONICAL_PRIVATE_SYNCHRONOUS);
|
var confirmation = hints.contains (X_CANONICAL_PRIVATE_SYNCHRONOUS);
|
||||||
var progress = confirmation && hints.contains ("value");
|
var progress = confirmation && hints.contains ("value");
|
||||||
|
|
||||||
unowned NotifySettings options = NotifySettings.get_default ();
|
unowned NotifySettings notify_settings = NotifySettings.get_default ();
|
||||||
|
|
||||||
// Default values for confirmations
|
// Default values for confirmations
|
||||||
var allow_bubble = true;
|
var allow_bubble = true;
|
||||||
var allow_sound = true;
|
var allow_sound = true;
|
||||||
|
|
||||||
if (!confirmation) {
|
if (!confirmation) {
|
||||||
var app_found = false;
|
if (notify_settings.do_not_disturb) {
|
||||||
var app_key = app_name.replace (":", "_").down ();
|
allow_bubble = allow_sound = false;
|
||||||
|
} else {
|
||||||
|
Settings? app_settings = app_settings_cache.get (app_name);
|
||||||
|
|
||||||
string[] parameters;
|
if (app_settings == null) {
|
||||||
unowned string param_bubbles = (options.default_bubbles ? APP_BUBBLES_SHOW : APP_BUBBLES_HIDE);
|
var schema = SettingsSchemaSource.get_default ().lookup ("org.pantheon.desktop.gala.notifications.application", false);
|
||||||
unowned string param_sounds = (options.default_sounds ? APP_SOUNDS_ON : APP_SOUNDS_OFF);
|
if (schema != null) {
|
||||||
|
app_settings = new Settings.full (schema, null, "/org/pantheon/desktop/gala/notifications/applications/%s/".printf (app_name));
|
||||||
foreach (unowned string app in options.apps) {
|
app_settings_cache.set (app_name, app_settings);
|
||||||
var properties = app.split (":");
|
|
||||||
|
|
||||||
if (properties.length == 2 && properties[0].down () == app_key) {
|
|
||||||
parameters = properties[1].split (",");
|
|
||||||
|
|
||||||
if (parameters.length == 2) {
|
|
||||||
param_bubbles = parameters[0];
|
|
||||||
param_sounds = parameters[1];
|
|
||||||
|
|
||||||
app_found = true;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// if no matching app was found, add the default values to the list
|
if (app_settings != null) {
|
||||||
if (!app_found) {
|
allow_bubble = app_settings.get_boolean ("bubbles");
|
||||||
var apps_new = options.apps;
|
allow_sound = app_settings.get_boolean ("sounds");
|
||||||
apps_new += "%s:%s,%s".printf (app_key, param_bubbles, param_sounds);
|
}
|
||||||
options.apps = apps_new;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allow_bubble = (!options.do_not_disturb && param_bubbles == APP_BUBBLES_SHOW);
|
|
||||||
allow_sound = (allow_bubble && param_sounds == APP_SOUNDS_ON);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 // enable to debug notifications
|
#if 0 // enable to debug notifications
|
||||||
|
@ -23,9 +23,6 @@ namespace Gala.Plugins.Notify
|
|||||||
public class NotifySettings : Granite.Services.Settings
|
public class NotifySettings : Granite.Services.Settings
|
||||||
{
|
{
|
||||||
public bool do_not_disturb { get; set; }
|
public bool do_not_disturb { get; set; }
|
||||||
public bool default_bubbles { get; set; }
|
|
||||||
public bool default_sounds { get; set; }
|
|
||||||
public string[] apps { get; set; }
|
|
||||||
|
|
||||||
static NotifySettings? instance = null;
|
static NotifySettings? instance = null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user