From 4200f1edeb81807bc2e25812dc3d0be75259d4ea Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Sat, 24 Feb 2007 00:39:54 +0100 Subject: [PATCH 1/6] replace _connect_to_server with a protocol/cm independent equivalent --- services/presence2/presenceservice.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/services/presence2/presenceservice.py b/services/presence2/presenceservice.py index 109fd0fd..532c77d9 100644 --- a/services/presence2/presenceservice.py +++ b/services/presence2/presenceservice.py @@ -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'] From 52fc6826ab0d3962f710da2a55ddc2dcf868708a Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sat, 24 Feb 2007 14:23:18 +0100 Subject: [PATCH 2/6] Typo. --- shell/view/clipboardicon.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/view/clipboardicon.py b/shell/view/clipboardicon.py index faf2e18d..3725ba9f 100644 --- a/shell/view/clipboardicon.py +++ b/shell/view/clipboardicon.py @@ -43,9 +43,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()) From 940b50b4e6d507b4e4a1e4a6aa42f418219df87b Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sat, 24 Feb 2007 14:35:31 +0100 Subject: [PATCH 3/6] Add hover to ClipboardIcon. --- shell/view/clipboardicon.py | 7 +++++++ shell/view/clipboardmenu.py | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/shell/view/clipboardicon.py b/shell/view/clipboardicon.py index 3725ba9f..caa949ad 100644 --- a/shell/view/clipboardicon.py +++ b/shell/view/clipboardicon.py @@ -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 @@ -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() diff --git a/shell/view/clipboardmenu.py b/shell/view/clipboardmenu.py index 1ea53616..3e8239d6 100644 --- a/shell/view/clipboardmenu.py +++ b/shell/view/clipboardmenu.py @@ -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) From ce800fbc66c2790f5bf9a38006812a16478342aa Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sat, 24 Feb 2007 14:58:38 +0100 Subject: [PATCH 4/6] Add hover to BuddyIcon in the Frame. --- shell/view/BuddyMenu.py | 2 ++ shell/view/frame/FriendsBox.py | 21 ++++++++++++++++++--- shell/view/frame/framepopupcontext.py | 2 +- sugar/graphics/snowflakebox.py | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/shell/view/BuddyMenu.py b/shell/view/BuddyMenu.py index b4548224..ad4a5d40 100644 --- a/shell/view/BuddyMenu.py +++ b/shell/view/BuddyMenu.py @@ -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() diff --git a/shell/view/frame/FriendsBox.py b/shell/view/frame/FriendsBox.py index 9b12f6c2..481b1288 100644 --- a/shell/view/frame/FriendsBox.py +++ b/shell/view/frame/FriendsBox.py @@ -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 diff --git a/shell/view/frame/framepopupcontext.py b/shell/view/frame/framepopupcontext.py index b4b5c094..63304cc1 100644 --- a/shell/view/frame/framepopupcontext.py +++ b/shell/view/frame/framepopupcontext.py @@ -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 diff --git a/sugar/graphics/snowflakebox.py b/sugar/graphics/snowflakebox.py index 9e2fd784..f0d446c2 100644 --- a/sugar/graphics/snowflakebox.py +++ b/sugar/graphics/snowflakebox.py @@ -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() From 2b1445be6cb71b0eef611b397c2a17278409667b Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sat, 24 Feb 2007 15:22:16 +0100 Subject: [PATCH 5/6] Adjusted rounded box radius. --- sugar/graphics/roundbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sugar/graphics/roundbox.py b/sugar/graphics/roundbox.py index a24f8202..1559ec2a 100644 --- a/sugar/graphics/roundbox.py +++ b/sugar/graphics/roundbox.py @@ -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 From 5714396e342d77de5bcc69d4d00da90c010e0e27 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sat, 24 Feb 2007 15:30:16 +0100 Subject: [PATCH 6/6] Add hovering to MenuItem. --- sugar/graphics/color.py | 2 ++ sugar/graphics/menu.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/sugar/graphics/color.py b/sugar/graphics/color.py index e07df4a7..32d248cc 100644 --- a/sugar/graphics/color.py +++ b/sugar/graphics/color.py @@ -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') diff --git a/sugar/graphics/menu.py b/sugar/graphics/menu.py index e60bd61a..2a80c878 100644 --- a/sugar/graphics/menu.py +++ b/sugar/graphics/menu.py @@ -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':