[seed] Add ConsoleKit DBus example
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] Add ConsoleKit DBus example
- Date: Mon, 11 May 2009 18:29:35 -0400 (EDT)
commit 4d5fa622d9eb6c9dfd4296adff4c8018aae6a4f5
Author: Robert Carr <racarr svn gnome org>
Date: Mon May 11 18:29:14 2009 -0400
Add ConsoleKit DBus example
---
doc/index.html | 3 +-
examples/Makefile.am | 2 +
examples/dbus-consolekit.js | 57 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+), 1 deletions(-)
diff --git a/doc/index.html b/doc/index.html
index 396ecf9..12a523d 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -71,7 +71,8 @@ Seed has a wide variety of examples <a href="http://git.gnome.org/cgit/seed/tree
<li><a href="http://git.gnome.org/cgit/seed/tree/examples/clutter-pad.js">clutter-pad</a> - An example to prototype Clutter scripts using a GtkSourceView widget and a GtkClutter stage. Demonstrates usage of sandbox module.</li>
<li><a href="http://git.gnome.org/cgit/seed/tree/examples/pango-fontset.js">pango-fontset</a> - Demonstrates basic Pango usage (for querying font information) </li>
<li><a href="http://git.gnome.org/cgit/seed/tree/examples/pango.js">pango</a> - Demonstrates a bit more complicated Pango usage, and Clutter usage, to create a sort of font playground. </li>
-<li><a href="http://git.gnome.org/cgit/seed/tree/examples/banshee-dbus.js">banshee-dbus</a> - Demonstrates the use of DBus to control Banshee </li>
+<li><a href="http://git.gnome.org/cgit/seed/tree/examples/dbus-banshee.js">dbus-banshee</a> - Demonstrates the use of DBus to control Banshee </li>
+<li><a href="http://git.gnome.org/cgit/seed/tree/examples/dbus-consolekit.js">dbus-consolekit</a> - Demonstrates the use of DBus to query ConsoleKit </li>
</ul>
</p>
diff --git a/examples/Makefile.am b/examples/Makefile.am
index c5d2e3f..b3d2fd3 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -27,6 +27,7 @@ examples_DATA = \
Gnio-server.js \
clutter-cairo.js \
threaded-repl.js \
+ dbus-consolekit.js \
clutter-pad.js \
gtkplug.js \
calculator.js \
@@ -81,5 +82,6 @@ EXTRA_DIST = \
vte-test.js \
threaded-repl.js \
json-reddit.js \
+ dbus-consolekit.js \
HACKING
diff --git a/examples/dbus-consolekit.js b/examples/dbus-consolekit.js
new file mode 100755
index 0000000..2b08606
--- /dev/null
+++ b/examples/dbus-consolekit.js
@@ -0,0 +1,57 @@
+#!/usr/local/bin/seed
+DBus = imports.dbus;
+GLib = imports.gi.GLib;
+
+function ConsoleKitManager() {
+ this._init();
+}
+
+ConsoleKitManager.prototype = {
+ _init: function() {
+ DBus.system.proxifyObject (this, 'org.freedesktop.ConsoleKit','/org/freedesktop/ConsoleKit/Manager');
+ }
+};
+
+function ConsoleKitSession(path) {
+ this._init(path);
+}
+
+ConsoleKitSession.prototype = {
+ _init: function(path) {
+ DBus.system.proxifyObject (this, 'org.freedesktop.ConsoleKit', path);
+ }
+};
+
+var ManagerIface = {
+ name: 'org.freedesktop.ConsoleKit.Manager',
+ methods: [
+ { name: 'GetCurrentSession', inSignature: '', outSignature: 'o' },
+ ]
+};
+
+var SessionIFace = {
+ name: 'org.freedesktop.ConsoleKit.Session',
+ methods: [
+ { name: 'IsLocal', inSignature: '', outSignature: 'b'}
+ ]
+};
+
+
+DBus.proxifyPrototype (ConsoleKitManager.prototype, ManagerIface);
+DBus.proxifyPrototype (ConsoleKitSession.prototype, SessionIFace);
+
+manager = new ConsoleKitManager();
+manager.GetCurrentSessionRemote(
+ function(result, exception){
+ session = new ConsoleKitSession(result);
+ session.IsLocalRemote (function (result){
+ if (result)
+ Seed.print ("Session is local");
+ else
+ Seed.print ("Session is remote");
+ Seed.quit();
+ });
+ });
+
+mainloop = GLib.main_loop_new();
+GLib.main_loop_run(mainloop);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]