Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2006-11-05 18:52:46 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2006-11-05 18:52:46 (GMT)
commita7e4092b0e4f3d30a21ee5a7982aecd5252a0822 (patch)
treedea15838e34861e902ebe991cbeabb1a72599bcd /sugar
parentb9f75c14727b30b9cd07b18c2c15f15d71201bb4 (diff)
Created SugarDownloadManager and ClipboardService's wrapper. Show and hide the frame when adding an object to the clipboard.
Diffstat (limited to 'sugar')
-rw-r--r--sugar/Makefile.am2
-rw-r--r--sugar/clipboard/ClipboardService.py73
-rw-r--r--sugar/clipboard/Makefile.am5
-rw-r--r--sugar/clipboard/__init__.py0
-rw-r--r--sugar/graphics/Makefile.am1
-rw-r--r--sugar/graphics/menu.py8
6 files changed, 86 insertions, 3 deletions
diff --git a/sugar/Makefile.am b/sugar/Makefile.am
index ae2e2ee..905555a 100644
--- a/sugar/Makefile.am
+++ b/sugar/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = activity chat graphics p2p presence
+SUBDIRS = activity chat clipboard graphics p2p presence
sugardir = $(pythondir)/sugar
sugar_PYTHON = \
diff --git a/sugar/clipboard/ClipboardService.py b/sugar/clipboard/ClipboardService.py
new file mode 100644
index 0000000..e189653
--- /dev/null
+++ b/sugar/clipboard/ClipboardService.py
@@ -0,0 +1,73 @@
+import dbus
+import gobject
+
+DBUS_SERVICE = "org.laptop.Clipboard"
+DBUS_INTERFACE = "org.laptop.Clipboard"
+DBUS_PATH = "/org/laptop/Clipboard"
+
+class ClipboardService(gobject.GObject):
+
+ __gsignals__ = {
+ 'object-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([str, str])),
+ 'object-deleted': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([str])),
+ 'object-state-updated': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([str, int])),
+ }
+
+ def __init__(self):
+ gobject.GObject.__init__(self)
+
+ self._dbus_service = None
+ bus = dbus.SessionBus()
+ bus.add_signal_receiver(self._name_owner_changed_cb,
+ signal_name="NameOwnerChanged",
+ dbus_interface="org.freedesktop.DBus")
+ # Try to register to ClipboardService, if we fail, we'll try later.
+ try:
+ self._connect_clipboard_signals()
+ except dbus.DBusException, exception:
+ pass
+
+ def _connect_clipboard_signals(self):
+ bus = dbus.SessionBus()
+ proxy_obj = bus.get_object(DBUS_SERVICE, DBUS_PATH)
+ self._dbus_service = dbus.Interface(proxy_obj, DBUS_SERVICE)
+ self._dbus_service.connect_to_signal('object_added', self._object_added_cb)
+ self._dbus_service.connect_to_signal('object_deleted', self._object_deleted_cb)
+ self._dbus_service.connect_to_signal('object_state_updated',
+ self._object_state_updated_cb)
+
+ def _name_owner_changed_cb(self, name, old, new):
+ if name != DBUS_SERVICE:
+ return
+
+ if (not old and not len(old)) and (new and len(new)):
+ # ClipboardService started up
+ self._connect_clipboard_signals()
+
+ def _object_added_cb(self, mimeType, fileName):
+ self.emit('object-added', mimeType, fileName)
+
+ def _object_deleted_cb(self, fileName):
+ self.emit('object-deleted', fileName)
+
+ def _object_state_updated_cb(self, fileName, percent):
+ self.emit('object-state-updated', fileName, percent)
+
+ def add_object(self, mimeType, fileName):
+ self._dbus_service.add_object(mimeType, fileName)
+
+ def delete_object(self, fileName):
+ self._dbus_service.delete_object(fileName)
+
+ def update_object_state(self, fileName, percent):
+ self._dbus_service.update_object_state(fileName, percent)
+
+_clipboard_service = None
+def get_instance():
+ global _clipboard_service
+ if not _clipboard_service:
+ _clipboard_service = ClipboardService()
+ return _clipboard_service
diff --git a/sugar/clipboard/Makefile.am b/sugar/clipboard/Makefile.am
new file mode 100644
index 0000000..dbfabe9
--- /dev/null
+++ b/sugar/clipboard/Makefile.am
@@ -0,0 +1,5 @@
+sugardir = $(pythondir)/sugar/clipboard
+sugar_PYTHON = \
+ __init__.py \
+ ClipboardService.py
+
diff --git a/sugar/clipboard/__init__.py b/sugar/clipboard/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/sugar/clipboard/__init__.py
diff --git a/sugar/graphics/Makefile.am b/sugar/graphics/Makefile.am
index 83b0920..9828c8c 100644
--- a/sugar/graphics/Makefile.am
+++ b/sugar/graphics/Makefile.am
@@ -4,6 +4,7 @@ sugar_PYTHON = \
bubble.py \
canvasicon.py \
colors.py \
+ ClipboardBubble.py \
grid.py \
iconcolor.py \
menu.py \
diff --git a/sugar/graphics/menu.py b/sugar/graphics/menu.py
index 5404cf5..9c031ba 100644
--- a/sugar/graphics/menu.py
+++ b/sugar/graphics/menu.py
@@ -49,6 +49,7 @@ class Menu(gtk.Window):
self._root.append(content_box)
self._action_box = None
+ self._action_box_separator = None
def _create_separator(self):
separator = hippo.CanvasBox()
@@ -56,8 +57,8 @@ class Menu(gtk.Window):
return separator
def _create_action_box(self):
- separator = self._create_separator()
- self._root.append(separator)
+ self._action_box_separator = self._create_separator()
+ self._root.append(self._action_box_separator)
self._action_box = hippo.CanvasBox(
orientation=hippo.ORIENTATION_HORIZONTAL)
@@ -71,5 +72,8 @@ class Menu(gtk.Window):
icon.connect('activated', self._action_clicked_cb, action_id)
self._action_box.append(icon)
+ def remove_action(self, icon):
+ self._action_box.remove(icon)
+
def _action_clicked_cb(self, icon, action):
self.emit('action', action)