First version of the ClipboardService. Added support for showing the progress of a pdf download in the clipboard.

This commit is contained in:
Tomeu Vizoso
2006-11-01 19:43:59 +01:00
parent cf508c1d22
commit 23565cfd48
21 changed files with 593 additions and 37 deletions
+61
View File
@@ -0,0 +1,61 @@
import logging
import dbus
import hippo
from sugar.graphics import style
from view.ClipboardIcon import ClipboardIcon
class ClipboardBox(hippo.CanvasBox):
_CLIPBOARD_SERVICE = "org.laptop.Clipboard"
_CLIPBOARD_OBJECT_PATH = "/org/laptop/Clipboard"
def __init__(self, shell, menu_shell):
hippo.CanvasBox.__init__(self)
self._shell = shell
self._menu_shell = menu_shell
self._icons = {}
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(self._CLIPBOARD_SERVICE, self._CLIPBOARD_OBJECT_PATH)
iface = dbus.Interface(proxy_obj, self._CLIPBOARD_SERVICE)
iface.connect_to_signal('object_added', self.object_added_callback)
iface.connect_to_signal('object_deleted', self.object_deleted_callback)
iface.connect_to_signal('object_state_updated', self.object_state_updated_callback)
def name_owner_changed_cb(self, name, old, new):
if name != self._CLIPBOARD_SERVICE:
return
if (not old and not len(old)) and (new and len(new)):
# ClipboardService started up
self._connect_clipboard_signals()
def object_added_callback(self, mimeType, fileName):
icon = ClipboardIcon(self._menu_shell, fileName)
style.apply_stylesheet(icon, 'frame.BuddyIcon')
self.append(icon)
self._icons[fileName] = icon
logging.debug('ClipboardBox: ' + fileName + ' was added.')
def object_deleted_callback(self, fileName):
icon = self._icons[fileName]
self.remove(icon)
self._icons.remove(icon)
logging.debug('ClipboardBox: ' + fileName + ' was deleted.')
def object_state_updated_callback(self, fileName, percent):
icon = self._icons[fileName]
icon.set_percent(percent)
logging.debug('ClipboardBox: ' + fileName + ' state was updated.')
+5 -1
View File
@@ -23,6 +23,7 @@ from view.frame.ActivitiesBox import ActivitiesBox
from view.frame.ZoomBox import ZoomBox
from view.frame.overlaybox import OverlayBox
from view.frame.FriendsBox import FriendsBox
from view.frame.ClipboardBox import ClipboardBox
from view.frame.PanelWindow import PanelWindow
from view.frame.notificationtray import NotificationTray
from sugar.graphics.timeline import Timeline
@@ -198,7 +199,10 @@ class Frame:
root.append(box)
# Left panel
self._create_panel(grid, 0, 1, 1, 10)
[menu_shell, root] = self._create_panel(grid, 0, 1, 1, 10)
box = ClipboardBox(self._shell, menu_shell)
root.append(box)
def _create_panel(self, grid, x, y, width, height):
panel = PanelWindow()
+1
View File
@@ -2,6 +2,7 @@ sugardir = $(pkgdatadir)/shell/view/frame
sugar_PYTHON = \
__init__.py \
ActivitiesBox.py \
ClipboardBox.py \
FriendsBox.py \
PanelWindow.py \
Frame.py \