Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-10-02 14:37:30 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-10-02 14:37:30 (GMT)
commita951b36347bfb5350c4c6031ba1126c25b94f44d (patch)
tree63db8d067f78bdfe53d69b3eb472cbdffeba08ad /shell
parent4958c43b33f3a02982b58f612f2ba46b069d12bf (diff)
Reimplement menu using hippo and hook it up for the
activity menu.
Diffstat (limited to 'shell')
-rw-r--r--shell/view/frame/MenuStrategy.py33
-rw-r--r--shell/view/frame/ZoomBox.py20
2 files changed, 20 insertions, 33 deletions
diff --git a/shell/view/frame/MenuStrategy.py b/shell/view/frame/MenuStrategy.py
index 314cb04..0519d23 100644
--- a/shell/view/frame/MenuStrategy.py
+++ b/shell/view/frame/MenuStrategy.py
@@ -1,28 +1,15 @@
-class MenuStrategy:
- def get_menu_position(self, menu, grid_x1, grid_y1, grid_x2, grid_y2):
- grid = menu.get_grid()
+from sugar.graphics.grid import Grid
- [x1, y1] = grid.micro_to_macro(grid_x1, grid_y1)
- [x2, y2] = grid.micro_to_macro(grid_x2, grid_y2)
+class MenuStrategy:
+ def get_menu_position(self, menu, x, y, width, height):
+ grid = Grid()
- if x1 == 0:
- x = x2
- y = y1
- elif x2 == grid.get_macro_cols():
- x = x1
- y = y1
- elif y2 == grid.get_macro_rows():
- x = x1
- y = y1
- else:
- x = x1
- y = y2
+ [grid_x1, grid_y1] = grid.fit_point(x, y)
+ [grid_x2, grid_y2] = grid.fit_point(x + width, y + height)
- [grid_x, grid_y] = grid.macro_to_micro(x, y)
+ menu_grid_x = grid_x1
+ menu_grid_y = grid_y2
- if x2 == grid.get_macro_cols():
- grid_x -= menu.get_width()
- elif y2 == grid.get_macro_rows():
- grid_y -= menu.get_height()
+ [menu_x, menu_y] = grid.point(menu_grid_x, menu_grid_y)
- return [grid_x, grid_y]
+ return [menu_x, menu_y]
diff --git a/shell/view/frame/ZoomBox.py b/shell/view/frame/ZoomBox.py
index 8e78979..26fda37 100644
--- a/shell/view/frame/ZoomBox.py
+++ b/shell/view/frame/ZoomBox.py
@@ -3,9 +3,8 @@ import hippo
from sugar.graphics.canvasicon import CanvasIcon
from sugar.graphics.menuicon import MenuIcon
+from sugar.graphics.menu import Menu
from sugar.graphics import style
-from sugar.canvas.Menu import Menu
-from sugar.canvas.IconItem import IconItem
from view.frame.MenuStrategy import MenuStrategy
import sugar
@@ -14,13 +13,14 @@ class ActivityMenu(Menu):
ACTION_CLOSE = 2
def __init__(self, grid, activity_host):
- title = activity_host.get_title()
- Menu.__init__(self, grid, title)
+ Menu.__init__(self, activity_host.get_title())
- icon = IconItem(icon_name='stock-share-mesh')
+ icon = CanvasIcon(icon_name='stock-share-mesh')
+ style.apply_stylesheet(icon, 'menu-action-icon')
self.add_action(icon, ActivityMenu.ACTION_SHARE)
- icon = IconItem(icon_name='stock-close')
+ icon = CanvasIcon(icon_name='stock-close')
+ style.apply_stylesheet(icon, 'menu-action-icon')
self.add_action(icon, ActivityMenu.ACTION_CLOSE)
class ActivityIcon(MenuIcon):
@@ -64,22 +64,22 @@ class ZoomBox(hippo.CanvasBox):
icon = CanvasIcon(icon_name='stock-zoom-mesh')
style.apply_stylesheet(icon, 'frame-zoom-icon')
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_MESH)
- self.append(icon, 0)
+ self.append(icon)
icon = CanvasIcon(icon_name='stock-zoom-friends')
style.apply_stylesheet(icon, 'frame-zoom-icon')
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_FRIENDS)
- self.append(icon, 0)
+ self.append(icon)
icon = CanvasIcon(icon_name='stock-zoom-home')
style.apply_stylesheet(icon, 'frame-zoom-icon')
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_HOME)
- self.append(icon, 0)
+ self.append(icon)
icon = CanvasIcon(icon_name='stock-zoom-activity')
style.apply_stylesheet(icon, 'frame-zoom-icon')
icon.connect('activated', self._level_clicked_cb, sugar.ZOOM_ACTIVITY)
- self.append(icon, 0)
+ self.append(icon)
shell.connect('activity-changed', self._activity_changed_cb)
self._set_current_activity(shell.get_current_activity())