Get back presence list to work
This commit is contained in:
parent
847f69fce7
commit
6479962ca7
@ -4,7 +4,7 @@ from view.BuddyMenu import BuddyMenu
|
||||
class BuddyIcon(MenuIcon):
|
||||
def __init__(self, shell, menu_shell, buddy):
|
||||
MenuIcon.__init__(self, menu_shell, icon_name='stock-buddy',
|
||||
color=buddy.get_color(), size=112)
|
||||
color=buddy.get_color())
|
||||
|
||||
self._shell = shell
|
||||
self._buddy = buddy
|
||||
|
@ -5,6 +5,7 @@ import wnck
|
||||
|
||||
from view.frame.ActivitiesBox import ActivitiesBox
|
||||
from view.frame.ZoomBox import ZoomBox
|
||||
from view.frame.FriendsBox import FriendsBox
|
||||
from view.frame.PanelWindow import PanelWindow
|
||||
from sugar.graphics.timeline import Timeline
|
||||
from sugar.graphics.menushell import MenuShell
|
||||
@ -143,10 +144,13 @@ class Frame:
|
||||
[x, y] = grid.point(1, 0)
|
||||
bottom_panel.move(box, x, y)
|
||||
|
||||
left_panel = self._create_panel(grid, 0, 1, 1, 10)
|
||||
|
||||
right_panel = self._create_panel(grid, 15, 1, 1, 10)
|
||||
|
||||
box = FriendsBox(self._shell, self._menu_shell)
|
||||
right_panel.append(box)
|
||||
|
||||
left_panel = self._create_panel(grid, 0, 1, 1, 10)
|
||||
|
||||
def _create_panel(self, grid, x, y, width, height):
|
||||
panel = PanelWindow()
|
||||
|
||||
|
@ -1,15 +1,16 @@
|
||||
import hippo
|
||||
|
||||
from sugar.graphics.CanvasIcon import CanvasIcon
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics.iconcolor import IconColor
|
||||
from sugar.graphics import style
|
||||
from sugar.presence import PresenceService
|
||||
from view.BuddyIcon import BuddyIcon
|
||||
from model.BuddyModel import BuddyModel
|
||||
from view.frame.MenuStrategy import MenuStrategy
|
||||
|
||||
class RightPanel(hippo.CanvasBox):
|
||||
class FriendsBox(hippo.CanvasBox):
|
||||
def __init__(self, shell, menu_shell):
|
||||
CanvasBox.__init__(self)
|
||||
hippo.CanvasBox.__init__(self)
|
||||
self._shell = shell
|
||||
self._menu_shell = menu_shell
|
||||
self._activity_ps = None
|
||||
@ -26,18 +27,18 @@ class RightPanel(hippo.CanvasBox):
|
||||
def add(self, buddy):
|
||||
model = BuddyModel(buddy=buddy)
|
||||
icon = BuddyIcon(self._shell, self._menu_shell, model)
|
||||
style.apply_stylesheet(icon, 'frame.BuddyIcon')
|
||||
icon.set_menu_strategy(MenuStrategy())
|
||||
self.append(icon, 0)
|
||||
self.append(icon)
|
||||
|
||||
self._buddies[buddy.get_name()] = icon
|
||||
|
||||
def remove(self, buddy):
|
||||
i = self.find_child(self._buddies[buddy.get_name()])
|
||||
self.remove_child(i)
|
||||
self.remove(self._buddies[buddy.get_name()])
|
||||
|
||||
def clear(self):
|
||||
while (self.get_n_children() > 0):
|
||||
self.remove_child(0)
|
||||
for item in self.get_children():
|
||||
self.remove(item)
|
||||
self._buddies = {}
|
||||
|
||||
def __activity_appeared_cb(self, pservice, activity_ps):
|
@ -1,7 +1,21 @@
|
||||
import hippo
|
||||
|
||||
from sugar.graphics.grid import Grid
|
||||
|
||||
class MenuStrategy:
|
||||
def get_menu_position(self, menu, x, y, width, height):
|
||||
def get_menu_position(self, menu, item):
|
||||
[x, y] = item.get_context().translate_to_widget(item)
|
||||
|
||||
canvas = item
|
||||
while (not isinstance(canvas, hippo.Canvas)):
|
||||
canvas = canvas.get_context()
|
||||
|
||||
[origin_x, origin_y] = canvas.window.get_origin()
|
||||
x += origin_x
|
||||
y += origin_y
|
||||
|
||||
[width, height] = item.get_allocation()
|
||||
|
||||
grid = Grid()
|
||||
|
||||
[grid_x1, grid_y1] = grid.fit_point(x, y)
|
||||
|
@ -23,11 +23,11 @@ frame_ActivityIcon = {
|
||||
'size' : _standard_icon_size
|
||||
}
|
||||
|
||||
ring_ActivityIcon = {
|
||||
'size' : _medium_icon_size
|
||||
frame_ZoomIcon = {
|
||||
'size' : _standard_icon_size
|
||||
}
|
||||
|
||||
frame_ZoomIcon = {
|
||||
frame_BuddyIcon = {
|
||||
'size' : _standard_icon_size
|
||||
}
|
||||
|
||||
@ -55,6 +55,10 @@ home_MyIcon = {
|
||||
'size' : _xlarge_icon_size
|
||||
}
|
||||
|
||||
ring_ActivityIcon = {
|
||||
'size' : _medium_icon_size
|
||||
}
|
||||
|
||||
friends_MyIcon = {
|
||||
'size' : _large_icon_size
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ import gobject
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
|
||||
class _MenuStrategy:
|
||||
def get_menu_position(self, menu, x1, y1, x2, y2):
|
||||
return [x1, y1]
|
||||
def get_menu_position(self, menu, item):
|
||||
return item.get_context().translate_to_widget(self)
|
||||
|
||||
class MenuIcon(CanvasIcon):
|
||||
def __init__(self, menu_shell, **kwargs):
|
||||
@ -29,7 +29,7 @@ class MenuIcon(CanvasIcon):
|
||||
def set_menu_strategy(self, strategy):
|
||||
self._menu_strategy = strategy
|
||||
|
||||
def _popup(self, x1, y1, x2, y2):
|
||||
def _popup(self):
|
||||
self.popdown()
|
||||
|
||||
self._menu_shell.set_active(None)
|
||||
@ -41,7 +41,7 @@ class MenuIcon(CanvasIcon):
|
||||
self._menu_leave_notify_event_cb)
|
||||
|
||||
strategy = self._menu_strategy
|
||||
[x, y] = strategy.get_menu_position(self._menu, x1, y1, x2, y2)
|
||||
[x, y] = strategy.get_menu_position(self._menu, self)
|
||||
|
||||
self._menu.move(x, y)
|
||||
self._menu.show()
|
||||
@ -73,11 +73,7 @@ class MenuIcon(CanvasIcon):
|
||||
|
||||
def _motion_notify_enter(self):
|
||||
self._stop_popdown_timeout()
|
||||
|
||||
[x, y] = self.get_context().translate_to_widget(self)
|
||||
[width, height] = self.get_allocation()
|
||||
|
||||
self._popup(x, y, width, height)
|
||||
self._popup()
|
||||
|
||||
def _motion_notify_leave(self):
|
||||
self._start_popdown_timeout()
|
||||
|
Loading…
Reference in New Issue
Block a user