Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-03-14 04:50:06 (GMT)
committer Dan Williams <dcbw@redhat.com>2007-03-14 04:50:06 (GMT)
commit8b4ccf3eb10d0563344e123f7f2c773bba120a2f (patch)
tree7941f4122ecbda4ace3299b147b898b41aafd758 /shell
parentbfe04c2073f696fd6dd7c6edb12f34d17433dfbe (diff)
Cleanup clipboard D-Bus API
- The clipboard now determines each objects unique id and returns it from add_object() - The ID is opaque to the client and should not be used/accessed other than with the clipboard service - Add object type hints for dbus-python - Sugar clipboard bindings for get_object() now return a dict rather than a tuple - ClipboardIcon now retrieves the real file path and uses that to open the file - Adapt sugar bits to clipboard changes
Diffstat (limited to 'shell')
-rw-r--r--shell/view/clipboardicon.py12
-rw-r--r--shell/view/frame/clipboardbox.py30
-rw-r--r--shell/view/frame/clipboardpanelwindow.py4
3 files changed, 27 insertions, 19 deletions
diff --git a/shell/view/clipboardicon.py b/shell/view/clipboardicon.py
index 89d55ba..7167bce 100644
--- a/shell/view/clipboardicon.py
+++ b/shell/view/clipboardicon.py
@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import logging
+import os
from sugar.graphics.canvasicon import CanvasIcon
from view.clipboardmenu import ClipboardMenu
@@ -71,7 +72,16 @@ class ClipboardIcon(CanvasIcon):
logging.debug("_icon_activated_cb: " + self._object_id)
- activityfactory.create_with_uri(self._activity, self._object_id)
+ # Get the file path
+ cb_service = clipboardservice.get_instance()
+ obj = cb_service.get_object(self._object_id)
+ formats = obj['FORMATS']
+ if len(formats) > 0:
+ path = cb_service.get_object_data(self._object_id, formats[0])
+ if os.path.exists(path):
+ activityfactory.create_with_uri(self._activity, path)
+ else:
+ logging.debug("Clipboard item file path %s didn't exist" % path)
def _icon_activated_cb(self, icon):
self._open_file()
diff --git a/shell/view/frame/clipboardbox.py b/shell/view/frame/clipboardbox.py
index d5e435e..031854a 100644
--- a/shell/view/frame/clipboardbox.py
+++ b/shell/view/frame/clipboardbox.py
@@ -64,14 +64,16 @@ class ClipboardBox(hippo.CanvasBox):
return None
def _add_selection(self, object_id, selection):
- if selection.data:
- logging.debug('ClipboardBox: adding type ' + selection.type + '.')
-
- cb_service = clipboardservice.get_instance()
- cb_service.add_object_format(object_id,
- selection.type,
- selection.data,
- on_disk = False)
+ if not selection.data:
+ return
+
+ logging.debug('ClipboardBox: adding type ' + selection.type + '.')
+
+ cb_service = clipboardservice.get_instance()
+ cb_service.add_object_format(object_id,
+ selection.type,
+ selection.data,
+ on_disk = False)
def _object_added_cb(self, cb_service, object_id, name):
icon = ClipboardIcon(self._popup_context, object_id, name)
@@ -90,7 +92,6 @@ class ClipboardBox(hippo.CanvasBox):
icon_name, preview, activity):
icon = self._icons[object_id]
icon.set_state(name, percent, icon_name, preview, activity)
- logging.debug('ClipboardBox: ' + object_id + ' state was changed.')
def drag_motion_cb(self, widget, context, x, y, time):
logging.debug('ClipboardBox._drag_motion_cb')
@@ -99,12 +100,11 @@ class ClipboardBox(hippo.CanvasBox):
def drag_drop_cb(self, widget, context, x, y, time):
logging.debug('ClipboardBox._drag_drop_cb')
- object_id = util.unique_id()
- self._context_map.add_context(context, object_id, len(context.targets))
-
cb_service = clipboardservice.get_instance()
- cb_service.add_object(object_id, name="")
+ object_id = cb_service.add_object(name="")
+ self._context_map.add_context(context, object_id, len(context.targets))
+
for target in context.targets:
if str(target) not in ('TIMESTAMP', 'TARGETS', 'MULTIPLE'):
widget.drag_get_data(context, target, time)
@@ -186,8 +186,8 @@ class ClipboardBox(hippo.CanvasBox):
def _get_targets_for_dnd(self, object_id):
cb_service = clipboardservice.get_instance()
- (name, percent, icon, preview, activity, format_types) = \
- cb_service.get_object(object_id)
+ attrs = cb_service.get_object(object_id)
+ format_types = attrs[clipboardservice.FORMATS_KEY]
targets = []
for format_type in format_types:
diff --git a/shell/view/frame/clipboardpanelwindow.py b/shell/view/frame/clipboardpanelwindow.py
index cfdb4d5..6ee7ab8 100644
--- a/shell/view/frame/clipboardpanelwindow.py
+++ b/shell/view/frame/clipboardpanelwindow.py
@@ -43,10 +43,8 @@ class ClipboardPanelWindow(PanelWindow):
def _owner_change_cb(self, clipboard, event):
logging.debug("owner_change_cb")
- key = util.unique_id()
-
cb_service = clipboardservice.get_instance()
- cb_service.add_object(key, name="")
+ key = cb_service.add_object(name="")
cb_service.set_object_percent(key, percent = 100)
targets = clipboard.wait_for_targets()