Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar

This commit is contained in:
Marco Pesenti Gritti 2007-02-24 16:39:28 +01:00
commit db7830b86c
10 changed files with 57 additions and 19 deletions

View File

@ -60,7 +60,12 @@ class PresenceService(dbus.service.Object):
self._registry = ManagerRegistry()
self._registry.LoadManagers()
self._server_client = self._connect_to_server()
account = {
'account': 'olpc@collabora.co.uk',
'password': 'learn',
'server': 'light.bluelinux.co.uk'
}
self._server_client = self._connect_to_connection_manager("jabber", account)
self._handles[self._server_client] = {}
# Telepathy link local connection
@ -72,15 +77,13 @@ class PresenceService(dbus.service.Object):
dbus.service.Object.__init__(self, self._bus_name, _PRESENCE_PATH)
def _connect_to_server(self):
protocol = 'jabber'
account = {
'account': 'olpc@collabora.co.uk',
'password': 'learn',
'server': 'light.bluelinux.co.uk'
}
def _connect_to_connection_manager(self, protocol, account):
if protocol == "jabber":
cm = "gabble"
else:
return
mgr = self._registry.GetManager('gabble')
mgr = self._registry.GetManager(cm)
conn = None
# Search existing connections, if any, that we might be able to use
@ -88,7 +91,7 @@ class PresenceService(dbus.service.Object):
for item in connections:
if item[CONN_INTERFACE].GetProtocol() != protocol:
continue
if not item.object_path.startswith("/org/freedesktop/Telepathy/Connection/gabble/jabber/"):
if not item.object_path.startswith("/org/freedesktop/Telepathy/Connection/%s/%s/" % (cm, protocol)):
continue
if item[CONN_INTERFACE].GetStatus() == CONNECTION_STATUS_CONNECTED:
self_name = account['account']

View File

@ -35,6 +35,8 @@ class BuddyMenu(Menu):
self._shell = shell
Menu.__init__(self, buddy.get_name())
self.props.border = 0
self.props.padding = units.points_to_pixels(5)
pixbuf = self._get_buddy_icon_pixbuf()
if pixbuf:
icon_item = hippo.CanvasImage()

View File

@ -4,6 +4,7 @@ from sugar.graphics.canvasicon import CanvasIcon
from view.clipboardmenu import ClipboardMenu
from sugar.graphics.xocolor import XoColor
from sugar.graphics import units
from sugar.graphics import color
from sugar.activity import activityfactory
from sugar.clipboard import clipboardservice
from sugar import util
@ -43,9 +44,9 @@ class ClipboardIcon(CanvasIcon):
self._menu.set_state(name, percent, preview, activity)
if activity and percent < 100:
self.set_property('color', XoColor("#000000,#424242"))
self.props.xo_color = XoColor("#000000,#424242")
else:
self.set_property('color', XoColor("#000000,#FFFFFF"))
self.props.xo_color = XoColor("#000000,#FFFFFF")
def _activity_create_success_cb(self, handler, activity):
activity.start(util.unique_id())
@ -81,3 +82,9 @@ class ClipboardIcon(CanvasIcon):
def get_object_id(self):
return self._object_id
def prelight(self, enter):
if enter:
self.props.background_color = color.BLACK.get_int()
else:
self.props.background_color = color.TOOLBAR_BACKGROUND.get_int()

View File

@ -13,7 +13,7 @@ class ClipboardProgressBar(ClipboardBubble):
def __init__(self, percent = 0):
self._text_item = None
ClipboardBubble.__init__(self, percent=percent)
self._text_item = hippo.CanvasText(text=str(percent) + ' %')
self._text_item.props.color = color.LABEL_TEXT.get_int()
self._text_item.props.font_desc = font.DEFAULT.get_pango_desc()
@ -35,6 +35,7 @@ class ClipboardMenu(Menu):
def __init__(self, name, percent, preview, activity):
Menu.__init__(self, name)
self.props.border = 0
if percent < 100:
self._progress_bar = ClipboardProgressBar(percent)

View File

@ -17,15 +17,30 @@
import hippo
from sugar.graphics.canvasicon import CanvasIcon
from sugar.graphics import color
from sugar.presence import PresenceService
from view.BuddyIcon import BuddyIcon
from model.BuddyModel import BuddyModel
class FriendIcon(BuddyIcon):
def __init__(self, shell, popup_context, buddy):
BuddyIcon.__init__(self, shell, popup_context, buddy)
self._popup_context = popup_context
def get_popup_context(self):
return self._popup_context
def prelight(self, enter):
if enter:
self.props.background_color = color.BLACK.get_int()
else:
self.props.background_color = color.TOOLBAR_BACKGROUND.get_int()
class FriendsBox(hippo.CanvasBox):
def __init__(self, shell, menu_shell):
def __init__(self, shell, popup_context):
hippo.CanvasBox.__init__(self)
self._shell = shell
self._menu_shell = menu_shell
self._popup_context = popup_context
self._activity_ps = None
self._joined_hid = -1
self._left_hid = -1
@ -48,7 +63,7 @@ class FriendsBox(hippo.CanvasBox):
return
model = BuddyModel(buddy=buddy)
icon = BuddyIcon(self._shell, self._menu_shell, model)
icon = FriendIcon(self._shell, self._popup_context, model)
self.append(icon)
self._buddies[buddy.get_name()] = icon

View File

@ -36,7 +36,7 @@ class FramePopupContext(PopupContext):
left_x = item_x + item_w
left_y = item_y
right_x = item_x + item_w
right_x = item_x - popup_w
right_y = item_y
top_x = item_x
top_y = item_y + item_h

View File

@ -13,6 +13,7 @@ _system_colors = {
'label-text' : '#FFFFFF',
'desktop-background' : '#E2E2E3',
'menu-background' : '#000000',
'menu-background-hover' : '#424242',
'menu-separator' : '#D1D1D2',
'menu-border' : '#D1D1D2',
'button-normal' : '#FFFFFF',
@ -90,6 +91,7 @@ ENTRY_BORDER = SystemColor('entry-border')
LABEL_TEXT = SystemColor('label-text')
DESKTOP_BACKGROUND = SystemColor('desktop-background')
MENU_BACKGROUND = SystemColor('menu-background')
MENU_BACKGROUND_HOVER = SystemColor('menu-background-hover')
MENU_SEPARATOR = SystemColor('menu-separator')
MENU_BORDER = SystemColor('menu-border')
BUTTON_NORMAL = SystemColor('button-normal')

View File

@ -56,6 +56,14 @@ class MenuItem(hippo.CanvasBox):
self._canvas_text.props.color = color.LABEL_TEXT.get_int()
self._canvas_text.props.font_desc = font.DEFAULT.get_pango_desc()
self.append(self._canvas_text)
self.connect('motion-notify-event', self._motion_notify_event_cb)
def _motion_notify_event_cb(self, menu_item, event):
if event.detail == hippo.MOTION_DETAIL_ENTER:
self.props.background_color = color.MENU_BACKGROUND_HOVER.get_int()
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
self.props.background_color = color.MENU_BACKGROUND.get_int()
def do_set_property(self, pspec, value):
if pspec.name == 'action-id':

View File

@ -31,7 +31,7 @@ class RoundBox(hippo.CanvasBox, hippo.CanvasItem):
hippo.CanvasBox.__init__(self, **kwargs)
# TODO: we should calculate this value depending on the height of the box.
self._radius = units.points_to_pixels(10)
self._radius = units.points_to_pixels(7)
self.props.orientation = hippo.ORIENTATION_HORIZONTAL
self.props.border_top = self._BORDER_DEFAULT

View File

@ -85,7 +85,7 @@ class SnowflakeBox(hippo.CanvasBox, hippo.CanvasItem):
return width
def do_allocate(self, width, height, origin_changed):
hippo.CanvasBox.do_allocate(self, width, height)
hippo.CanvasBox.do_allocate(self, width, height, origin_changed)
self._layout_root()