Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2006-11-01 18:43:59 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2006-11-01 18:43:59 (GMT)
commit23565cfd483e38d3a64cd5980deea47cccb28581 (patch)
treef56a4a4d15308a3b20276edae8e93bff30c1d314 /services
parentcf508c1d229df5f4f645b7a66d568c1959bc6f62 (diff)
First version of the ClipboardService. Added support for showing the progress of a pdf download in the clipboard.
Diffstat (limited to 'services')
-rw-r--r--services/Makefile.am2
-rw-r--r--services/clipboard/ClipboardService.py76
-rw-r--r--services/clipboard/Makefile.am15
-rw-r--r--services/clipboard/__init__.py0
-rw-r--r--services/clipboard/org.laptop.Clipboard.service.in4
-rwxr-xr-xservices/clipboard/sugar-clipboard44
6 files changed, 140 insertions, 1 deletions
diff --git a/services/Makefile.am b/services/Makefile.am
index 1bae7e7..2a0fe5a 100644
--- a/services/Makefile.am
+++ b/services/Makefile.am
@@ -1 +1 @@
-SUBDIRS = presence nm
+SUBDIRS = presence nm clipboard
diff --git a/services/clipboard/ClipboardService.py b/services/clipboard/ClipboardService.py
new file mode 100644
index 0000000..35ac3a2
--- /dev/null
+++ b/services/clipboard/ClipboardService.py
@@ -0,0 +1,76 @@
+# vi: ts=4 ai noet
+#
+# Copyright (C) 2006, Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import logging
+import gobject
+import dbus
+import dbus.service
+from sugar import env
+
+_CLIPBOARD_SERVICE = "org.laptop.Clipboard"
+_CLIPBOARD_DBUS_INTERFACE = "org.laptop.Clipboard"
+_CLIPBOARD_OBJECT_PATH = "/org/laptop/Clipboard"
+
+class ClipboardDBusServiceHelper(dbus.service.Object):
+ def __init__(self, parent):
+ self._parent = parent
+
+ bus = dbus.SessionBus()
+ bus_name = dbus.service.BusName(_CLIPBOARD_DBUS_INTERFACE, bus=bus)
+ dbus.service.Object.__init__(self, bus_name, _CLIPBOARD_OBJECT_PATH)
+
+ @dbus.service.method(_CLIPBOARD_DBUS_INTERFACE,
+ in_signature="ss", out_signature="")
+ def add_object(self, mimeType, fileName):
+ logging.debug('Added object of type ' + mimeType + ' with path at ' + fileName)
+ self.object_added(mimeType, fileName)
+
+ @dbus.service.method(_CLIPBOARD_DBUS_INTERFACE,
+ in_signature="s", out_signature="")
+ def delete_object(self, fileName):
+ logging.debug('Deleted object with path at ' + fileName)
+ self.object_deleted(fileName)
+
+ @dbus.service.method(_CLIPBOARD_DBUS_INTERFACE,
+ in_signature="si", out_signature="")
+ def update_object_state(self, fileName, percent):
+ logging.debug('Updated object with path at ' + fileName + ' with percent ' + str(percent))
+ self.object_state_updated(fileName, percent)
+
+ @dbus.service.signal(_CLIPBOARD_DBUS_INTERFACE, signature="ss")
+ def object_added(self, mimeType, fileName):
+ pass
+
+ @dbus.service.signal(_CLIPBOARD_DBUS_INTERFACE, signature="s")
+ def object_deleted(self, fileName):
+ pass
+
+ @dbus.service.signal(_CLIPBOARD_DBUS_INTERFACE, signature="si")
+ def object_state_updated(self, fileName, percent):
+ pass
+
+class ClipboardService(object):
+ def __init__(self):
+ self._dbus_helper = ClipboardDBusServiceHelper(self)
+
+ def run(self):
+ loop = gobject.MainLoop()
+ try:
+ loop.run()
+ except KeyboardInterrupt:
+ print 'Ctrl+C pressed, exiting...'
diff --git a/services/clipboard/Makefile.am b/services/clipboard/Makefile.am
new file mode 100644
index 0000000..ccc54f2
--- /dev/null
+++ b/services/clipboard/Makefile.am
@@ -0,0 +1,15 @@
+servicedir = $(datadir)/sugar/services
+service_in_files = org.laptop.Clipboard.service.in
+service_DATA = $(service_in_files:.service.in=.service)
+
+$(service_DATA): $(service_in_files) Makefile
+ @sed -e "s|\@bindir\@|$(bindir)|" $< > $@
+
+sugardir = $(pkgdatadir)/services/clipboard
+sugar_PYTHON = \
+ __init__.py \
+ ClipboardService.py
+
+bin_SCRIPTS = sugar-clipboard
+
+EXTRA_DIST = $(service_in_files) $(bin_SCRIPTS)
diff --git a/services/clipboard/__init__.py b/services/clipboard/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/services/clipboard/__init__.py
diff --git a/services/clipboard/org.laptop.Clipboard.service.in b/services/clipboard/org.laptop.Clipboard.service.in
new file mode 100644
index 0000000..b38bf2b
--- /dev/null
+++ b/services/clipboard/org.laptop.Clipboard.service.in
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name = org.laptop.Clipboard
+Exec = @bindir@/sugar-clipboard
+
diff --git a/services/clipboard/sugar-clipboard b/services/clipboard/sugar-clipboard
new file mode 100755
index 0000000..bcbd280
--- /dev/null
+++ b/services/clipboard/sugar-clipboard
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+# vi: ts=4 ai noet
+#
+# Copyright (C) 2006, Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import sys
+import logging
+
+from sugar import logger
+logger.start('clipboard')
+
+import gobject
+import pygtk
+pygtk.require('2.0')
+
+import dbus.glib
+
+from sugar import env
+
+sys.path.insert(0, env.get_services_dir())
+
+from clipboard.ClipboardService import ClipboardService
+
+logging.info('Starting clipboard service.')
+
+gobject.threads_init()
+dbus.glib.threads_init()
+
+app = ClipboardService()
+app.run()