Make ClipboardIcon use the new Menu.

This commit is contained in:
Tomeu Vizoso
2007-02-21 21:12:27 +01:00
parent 9ba487fa1f
commit b452b7d718
10 changed files with 121 additions and 94 deletions
+2 -1
View File
@@ -10,4 +10,5 @@ sugar_PYTHON = \
ZoomBox.py \
notificationtray.py \
overlaybox.py \
PanelWindow.py
PanelWindow.py \
framepopupcontext.py
-6
View File
@@ -17,7 +17,6 @@
import gtk
import hippo
from sugar.graphics.menushell import MenuShell
from sugar.graphics import units
class PanelWindow(gtk.Window):
@@ -51,13 +50,8 @@ class PanelWindow(gtk.Window):
self.add(self._canvas)
self._canvas.show()
self._menu_shell = MenuShell(self._canvas)
self.resize(width, height)
def get_menu_shell(self):
return self._menu_shell
def get_root(self):
return self._bg
+6 -5
View File
@@ -42,9 +42,10 @@ class ActivityMenu(Menu):
'theme:stock-close'))
class ActivityButton(IconButton):
def __init__(self, shell, activity_model):
def __init__(self, shell, activity_model, popup_context):
self._shell = shell
self._activity_model = activity_model
self._popup_context = popup_context
icon_name = self._activity_model.get_icon_name()
icon_color = self._activity_model.get_icon_color()
@@ -57,7 +58,7 @@ class ActivityButton(IconButton):
return menu
def get_popup_context(self):
return self._shell.get_popup_context()
return self._popup_context
def _action_cb(self, menu, menu_item):
# TODO: Wouldn't be better to share/close the activity associated with
@@ -73,11 +74,11 @@ class ActivityButton(IconButton):
activity.close()
class ZoomBox(hippo.CanvasBox):
def __init__(self, shell, menu_shell):
def __init__(self, shell, popup_context):
hippo.CanvasBox.__init__(self, orientation=hippo.ORIENTATION_HORIZONTAL)
self._shell = shell
self._menu_shell = menu_shell
self._popup_context = popup_context
self._activity_icon = None
icon = IconButton(icon_name='theme:stock-zoom-mesh')
@@ -106,7 +107,7 @@ class ZoomBox(hippo.CanvasBox):
self.remove(self._activity_icon)
if home_activity:
icon = ActivityButton(self._shell, home_activity)
icon = ActivityButton(self._shell, home_activity, self._popup_context)
self.append(icon)
self._activity_icon = icon
else:
+3 -3
View File
@@ -37,9 +37,9 @@ class _ContextMap:
class ClipboardBox(hippo.CanvasBox):
def __init__(self, menu_shell):
def __init__(self, popup_context):
hippo.CanvasBox.__init__(self)
self._menu_shell = menu_shell
self._popup_context = popup_context
self._icons = {}
self._context_map = _ContextMap()
@@ -74,7 +74,7 @@ class ClipboardBox(hippo.CanvasBox):
on_disk = False)
def _object_added_cb(self, cb_service, object_id, name):
icon = ClipboardIcon(self._menu_shell, object_id, name)
icon = ClipboardIcon(self._popup_context, object_id, name)
self.append(icon)
self._icons[object_id] = icon
+1 -2
View File
@@ -17,10 +17,9 @@ class ClipboardPanelWindow(PanelWindow):
clipboard = gtk.Clipboard()
clipboard.connect("owner-change", self._owner_change_cb)
menu_shell = self.get_menu_shell()
root = self.get_root()
box = ClipboardBox(menu_shell)
box = ClipboardBox(frame.get_popup_context())
root.append(box)
# Receiving dnd drops
+13 -33
View File
@@ -27,9 +27,9 @@ from view.frame.FriendsBox import FriendsBox
from view.frame.PanelWindow import PanelWindow
from view.frame.clipboardpanelwindow import ClipboardPanelWindow
from view.frame.notificationtray import NotificationTray
from view.frame.framepopupcontext import FramePopupContext
from model.ShellModel import ShellModel
from sugar.graphics.timeline import Timeline
from sugar.graphics.menushell import MenuShell
from sugar.graphics import units
_ANIMATION = False
@@ -62,6 +62,12 @@ class Frame:
self._event_frame.connect('leave', self._event_frame_leave_cb)
self._event_frame.show()
self._popup_context = FramePopupContext()
self._popup_context.connect('activated',
self._popup_context_activated_cb)
self._popup_context.connect('deactivated',
self._popup_context_deactivated_cb)
self._top_panel = self._create_top_panel()
self._bottom_panel = self._create_bottom_panel()
self._left_panel = self._create_left_panel()
@@ -70,20 +76,11 @@ class Frame:
shell.get_model().connect('notify::state',
self._shell_state_changed_cb)
popup_context = shell.get_popup_context()
popup_context.connect('activated',
self._popup_context_activated_cb)
popup_context.connect('deactivated',
self._popup_context_deactivated_cb)
def _create_top_panel(self):
panel = self._create_panel(hippo.ORIENTATION_HORIZONTAL)
menu_shell = panel.get_menu_shell()
root = panel.get_root()
menu_shell.set_position(MenuShell.BOTTOM)
box = ZoomBox(self._shell, menu_shell)
box = ZoomBox(self._shell, self._popup_context)
root.append(box)
tray = NotificationTray()
@@ -103,11 +100,8 @@ class Frame:
def _create_bottom_panel(self):
panel = self._create_panel(hippo.ORIENTATION_HORIZONTAL)
menu_shell = panel.get_menu_shell()
root = panel.get_root()
menu_shell.set_position(MenuShell.TOP)
box = ActivitiesBox(self._shell)
root.append(box)
@@ -115,12 +109,9 @@ class Frame:
def _create_right_panel(self):
panel = self._create_panel(hippo.ORIENTATION_VERTICAL)
menu_shell = panel.get_menu_shell()
root = panel.get_root()
menu_shell.set_position(MenuShell.LEFT)
box = FriendsBox(self._shell, menu_shell)
box = FriendsBox(self._shell, self._popup_context)
root.append(box)
return panel
@@ -158,19 +149,6 @@ class Frame:
panel.connect('enter-notify-event', self._enter_notify_cb)
panel.connect('leave-notify-event', self._leave_notify_cb)
menu_shell = panel.get_menu_shell()
menu_shell.connect('activated',
self._menu_shell_activated_cb)
menu_shell.connect('deactivated',
self._menu_shell_deactivated_cb)
def _menu_shell_activated_cb(self, menu_shell):
self._timeline.goto('slide_in', True)
def _menu_shell_deactivated_cb(self, menu_shell):
if self._mode != Frame.STICKY and not self._hover_frame:
self._timeline.play('before_slide_out', 'slide_out')
def _popup_context_activated_cb(self, popup_context):
self._timeline.goto('slide_in', True)
@@ -205,8 +183,7 @@ class Frame:
def _leave_notify(self, panel):
self._hover_frame = False
if not panel.get_menu_shell().is_active() and \
not self._shell.get_popup_context().is_active() and \
if not self._popup_context.is_active() and \
(self._mode == Frame.HIDE_ON_LEAVE or \
self._mode == Frame.AUTOMATIC):
self._timeline.play('before_slide_out', 'slide_out')
@@ -281,3 +258,6 @@ class Frame:
def is_visible(self):
return self._top_panel.props.visible
def get_popup_context(self):
return self._popup_context
+26
View File
@@ -0,0 +1,26 @@
# Copyright (C) 2007, One Laptop Per Child
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
import gobject
import hippo
from sugar.graphics.popupcontext import PopupContext
class FramePopupContext(PopupContext):
__gtype_name__ = 'SugarFramePopupContext'
def __init__(self):
PopupContext.__init__(self)