[gnome-shell/message-tray: 53/54] add notificationDaemon.js
- From: Dan Winship <danw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-shell/message-tray: 53/54] add notificationDaemon.js
- Date: Wed, 18 Nov 2009 18:44:46 +0000 (UTC)
commit b48b21e578ed96e8c68b10f540d58db29eddaad0
Author: Dan Winship <danw gnome org>
Date: Wed Nov 18 13:42:38 2009 -0500
add notificationDaemon.js
currently supports summary+icon only, and requires you to manually
kill the existing notification-daemon first
js/ui/main.js | 3 +
js/ui/notificationDaemon.js | 92 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 95 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index ec59928..f0dae68 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -20,6 +20,7 @@ const Overview = imports.ui.overview;
const Panel = imports.ui.panel;
const RunDialog = imports.ui.runDialog;
const LookingGlass = imports.ui.lookingGlass;
+const NotificationDaemon = imports.ui.notificationDaemon;
const ShellDBus = imports.ui.shellDBus;
const Sidebar = imports.ui.sidebar;
const WindowManager = imports.ui.windowManager;
@@ -35,6 +36,7 @@ let runDialog = null;
let lookingGlass = null;
let wm = null;
let messaging = null;
+let notificationDaemon = null;
let notificationPopup = null;
let recorder = null;
let shellDBusService = null;
@@ -106,6 +108,7 @@ function start() {
sidebar = new Sidebar.Sidebar();
wm = new WindowManager.WindowManager();
messaging = new Messaging.Messaging();
+ notificationDaemon = new NotificationDaemon.NotificationDaemon();
notificationPopup = new MessageTray.Notification();
global.screen.connect('toggle-recording', function() {
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
new file mode 100644
index 0000000..8ae0157
--- /dev/null
+++ b/js/ui/notificationDaemon.js
@@ -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);
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]