[kupfer] Implement PresentWithStartup D-Bus method to take timestamp



commit 82d9bfa084e1427ea0a04a5eaed16301b8620cb0
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Sun Mar 13 02:39:32 2011 +0100

    Implement PresentWithStartup D-Bus method to take timestamp
    
    When we start Kupfer from an desktop launcher, pass on the startup id
    with its timestamp to the running kupfer (if it exists).

 bin/kupfer.in       |    7 ++++---
 kupfer/ui/listen.py |   18 ++++++++++++++++--
 2 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/bin/kupfer.in b/bin/kupfer.in
index d76f7bc..0f8b7f5 100755
--- a/bin/kupfer.in
+++ b/bin/kupfer.in
@@ -35,7 +35,7 @@ IFACE="se.kaizer.kupfer.Listener"
 # We allow reading directly from stdin if we pipe text into Kupfer
 if ! tty --quiet
 then
-	echo "kupfer: Reading from stdin" > /dev/stderr
+	echo "kupfer: Reading from stdin" >&2
 	TEXT_INPUT=$(cat)
 fi
 
@@ -44,7 +44,8 @@ _hasprefix "$1" "--"
 KUPFER_HAS_OPTIONS=$?
 
 test $KUPFER_HAS_OPTIONS != 0 && dbus-send --type=method_call --print-reply \
-	--dest=$SERVICE $OBJ $IFACE.Present >/dev/null 2>&1
+	--dest=$SERVICE $OBJ $IFACE.PresentWithStartup \
+	"string:$DESKTOP_STARTUP_ID" >/dev/null 2>&1
 KUPFER_RUNNING=$?
 
 if test \( -n "$TEXT_INPUT" -a $KUPFER_HAS_OPTIONS != 0 \)
@@ -59,7 +60,7 @@ _realpaths () {
 	do
 		LINK=$(readlink -e -- "$1")
 		if test $? != 0 ; then
-			echo "Error: $1 does not exist" > /dev/stderr
+			echo "Error: $1 does not exist" >&2
 			shift
 			continue
 		fi
diff --git a/kupfer/ui/listen.py b/kupfer/ui/listen.py
index 021e68c..b560123 100644
--- a/kupfer/ui/listen.py
+++ b/kupfer/ui/listen.py
@@ -49,7 +49,20 @@ class Service (ExportedGObject):
 
 	@dbus.service.method(interface_name)
 	def Present(self):
-		self.emit("present")
+		self.emit("present", 0)
+
+	@dbus.service.method(interface_name, in_signature="ay",
+	                     byte_arrays=True)
+	def PresentWithStartup(self, startup_notification_id):
+		# Try to parse out the time from the startup id
+		time = 0
+		if "_TIME" in startup_notification_id:
+			_ign, bstime = startup_notification_id.split("_TIME", 1)
+			try:
+				time = int(bstime)
+			except ValueError:
+				pass
+		self.emit("present", time)
 
 	@dbus.service.method(interface_name)
 	def ShowHide(self):
@@ -75,7 +88,8 @@ class Service (ExportedGObject):
 		self.emit("quit")
 
 gobject.signal_new("present", Service, gobject.SIGNAL_RUN_LAST,
-		gobject.TYPE_BOOLEAN, ())
+		gobject.TYPE_BOOLEAN, (gobject.TYPE_UINT64, ))
+
 gobject.signal_new("show-hide", Service, gobject.SIGNAL_RUN_LAST,
 		gobject.TYPE_BOOLEAN, ())
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]