add notificationDaemon.js
currently supports summary+icon only, and requires you to manually kill the existing notification-daemon first
This commit is contained in:
parent
e823a3b554
commit
b48b21e578
@ -20,6 +20,7 @@ const Overview = imports.ui.overview;
|
|||||||
const Panel = imports.ui.panel;
|
const Panel = imports.ui.panel;
|
||||||
const RunDialog = imports.ui.runDialog;
|
const RunDialog = imports.ui.runDialog;
|
||||||
const LookingGlass = imports.ui.lookingGlass;
|
const LookingGlass = imports.ui.lookingGlass;
|
||||||
|
const NotificationDaemon = imports.ui.notificationDaemon;
|
||||||
const ShellDBus = imports.ui.shellDBus;
|
const ShellDBus = imports.ui.shellDBus;
|
||||||
const Sidebar = imports.ui.sidebar;
|
const Sidebar = imports.ui.sidebar;
|
||||||
const WindowManager = imports.ui.windowManager;
|
const WindowManager = imports.ui.windowManager;
|
||||||
@ -35,6 +36,7 @@ let runDialog = null;
|
|||||||
let lookingGlass = null;
|
let lookingGlass = null;
|
||||||
let wm = null;
|
let wm = null;
|
||||||
let messaging = null;
|
let messaging = null;
|
||||||
|
let notificationDaemon = null;
|
||||||
let notificationPopup = null;
|
let notificationPopup = null;
|
||||||
let recorder = null;
|
let recorder = null;
|
||||||
let shellDBusService = null;
|
let shellDBusService = null;
|
||||||
@ -106,6 +108,7 @@ function start() {
|
|||||||
sidebar = new Sidebar.Sidebar();
|
sidebar = new Sidebar.Sidebar();
|
||||||
wm = new WindowManager.WindowManager();
|
wm = new WindowManager.WindowManager();
|
||||||
messaging = new Messaging.Messaging();
|
messaging = new Messaging.Messaging();
|
||||||
|
notificationDaemon = new NotificationDaemon.NotificationDaemon();
|
||||||
notificationPopup = new MessageTray.Notification();
|
notificationPopup = new MessageTray.Notification();
|
||||||
|
|
||||||
global.screen.connect('toggle-recording', function() {
|
global.screen.connect('toggle-recording', function() {
|
||||||
|
92
js/ui/notificationDaemon.js
Normal file
92
js/ui/notificationDaemon.js
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
||||||
|
|
||||||
|
const DBus = imports.dbus;
|
||||||
|
const Lang = imports.lang;
|
||||||
|
const Shell = imports.gi.Shell;
|
||||||
|
const Mainloop = imports.mainloop;
|
||||||
|
|
||||||
|
const Main = imports.ui.main;
|
||||||
|
|
||||||
|
const NotificationDaemonIface = {
|
||||||
|
name: 'org.freedesktop.Notifications',
|
||||||
|
methods: [{ name: 'Notify',
|
||||||
|
inSignature: 'susssasa{sv}i',
|
||||||
|
outSignature: 'u'
|
||||||
|
},
|
||||||
|
{ name: 'CloseNotification',
|
||||||
|
inSignature: 'u',
|
||||||
|
outSignature: ''
|
||||||
|
},
|
||||||
|
{ name: 'GetCapabilities',
|
||||||
|
inSignature: '',
|
||||||
|
outSignature: 'as'
|
||||||
|
},
|
||||||
|
{ name: 'GetServerInformation',
|
||||||
|
inSignature: '',
|
||||||
|
outSignature: 'ssss'
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
function NotificationDaemon() {
|
||||||
|
this._init();
|
||||||
|
}
|
||||||
|
|
||||||
|
NotificationDaemon.prototype = {
|
||||||
|
_init: function() {
|
||||||
|
DBus.session.exportObject('/org/freedesktop/Notifications', this);
|
||||||
|
|
||||||
|
let acquiredName = false;
|
||||||
|
DBus.session.acquire_name('org.freedesktop.Notifications', DBus.SINGLE_INSTANCE,
|
||||||
|
function(name) {
|
||||||
|
log("Acquired name " + name);
|
||||||
|
acquiredName = true;
|
||||||
|
},
|
||||||
|
function(name) {
|
||||||
|
if (acquiredName)
|
||||||
|
log("Lost name " + name);
|
||||||
|
else
|
||||||
|
log("Could not get name " + name);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
Notify: function(appName, replacesId, icon, summary, body,
|
||||||
|
actions, hints, timeout) {
|
||||||
|
let iconActor = null;
|
||||||
|
|
||||||
|
if (icon != '')
|
||||||
|
iconActor = Shell.TextureCache.get_default().load_icon_name(icon, 24);
|
||||||
|
else {
|
||||||
|
// FIXME: load icon data from hints
|
||||||
|
}
|
||||||
|
|
||||||
|
Main.notificationPopup.show(iconActor, summary);
|
||||||
|
},
|
||||||
|
|
||||||
|
CloseNotification: function(id) {
|
||||||
|
},
|
||||||
|
|
||||||
|
GetCapabilities: function() {
|
||||||
|
return [
|
||||||
|
// 'actions',
|
||||||
|
'body',
|
||||||
|
// 'body-hyperlinks',
|
||||||
|
// 'body-images',
|
||||||
|
// 'body-markup',
|
||||||
|
// 'icon-multi',
|
||||||
|
'icon-static'
|
||||||
|
// 'sound',
|
||||||
|
];
|
||||||
|
},
|
||||||
|
|
||||||
|
GetServerInformation: function() {
|
||||||
|
return [
|
||||||
|
'GNOME Shell',
|
||||||
|
'GNOME',
|
||||||
|
'0.1', // FIXME, get this from somewhere
|
||||||
|
'1.0'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DBus.conformExport(NotificationDaemon.prototype, NotificationDaemonIface);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user