Replace Menu for Palette.
This commit is contained in:
@@ -25,17 +25,13 @@ from sugar import profile
|
||||
from model import bundleregistry
|
||||
|
||||
class ActivityButton(IconButton):
|
||||
def __init__(self, activity, popup_context):
|
||||
IconButton.__init__(self, icon_name=activity.get_icon(),
|
||||
tooltip=activity.get_name())
|
||||
def __init__(self, activity):
|
||||
IconButton.__init__(self, icon_name=activity.get_icon())
|
||||
self.set_tooltip(activity.get_name())
|
||||
self._activity = activity
|
||||
self._popup_context = popup_context
|
||||
|
||||
def get_bundle_id(self):
|
||||
return self._activity.get_service_name()
|
||||
|
||||
def get_popup_context(self):
|
||||
return self._popup_context
|
||||
|
||||
class InviteButton(IconButton):
|
||||
def __init__(self, activity, invite):
|
||||
@@ -54,14 +50,13 @@ class InviteButton(IconButton):
|
||||
return self._invite
|
||||
|
||||
class ActivitiesBox(hippo.CanvasBox):
|
||||
def __init__(self, shell, popup_context):
|
||||
def __init__(self, shell):
|
||||
hippo.CanvasBox.__init__(self, orientation=hippo.ORIENTATION_HORIZONTAL)
|
||||
|
||||
self._shell = shell
|
||||
self._shell_model = self._shell.get_model()
|
||||
self._invite_to_item = {}
|
||||
self._invites = self._shell_model.get_invites()
|
||||
self._popup_context = popup_context
|
||||
|
||||
bundle_registry = bundleregistry.get_registry()
|
||||
for bundle in bundle_registry:
|
||||
@@ -93,7 +88,7 @@ class ActivitiesBox(hippo.CanvasBox):
|
||||
self.add_activity(bundle)
|
||||
|
||||
def add_activity(self, activity):
|
||||
item = ActivityButton(activity, self._popup_context)
|
||||
item = ActivityButton(activity)
|
||||
item.connect('activated', self._activity_clicked_cb)
|
||||
self.append(item, 0)
|
||||
|
||||
|
||||
@@ -23,12 +23,8 @@ 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 __init__(self, shell, buddy):
|
||||
BuddyIcon.__init__(self, shell, buddy)
|
||||
|
||||
def prelight(self, enter):
|
||||
if enter:
|
||||
@@ -37,10 +33,9 @@ class FriendIcon(BuddyIcon):
|
||||
self.props.background_color = color.TOOLBAR_BACKGROUND.get_int()
|
||||
|
||||
class FriendsBox(hippo.CanvasBox):
|
||||
def __init__(self, shell, popup_context):
|
||||
def __init__(self, shell):
|
||||
hippo.CanvasBox.__init__(self)
|
||||
self._shell = shell
|
||||
self._popup_context = popup_context
|
||||
self._activity_ps = None
|
||||
self._joined_hid = -1
|
||||
self._left_hid = -1
|
||||
@@ -63,7 +58,7 @@ class FriendsBox(hippo.CanvasBox):
|
||||
return
|
||||
|
||||
model = BuddyModel(buddy=buddy)
|
||||
icon = FriendIcon(self._shell, self._popup_context, model)
|
||||
icon = FriendIcon(self._shell, model)
|
||||
self.append(icon)
|
||||
|
||||
self._buddies[buddy.props.key] = icon
|
||||
|
||||
@@ -57,9 +57,8 @@ class _ContextMap:
|
||||
|
||||
class ClipboardBox(hippo.CanvasBox):
|
||||
|
||||
def __init__(self, popup_context):
|
||||
def __init__(self):
|
||||
hippo.CanvasBox.__init__(self)
|
||||
self._popup_context = popup_context
|
||||
self._icons = {}
|
||||
self._context_map = _ContextMap()
|
||||
self._selected_icon = None
|
||||
@@ -125,7 +124,7 @@ class ClipboardBox(hippo.CanvasBox):
|
||||
on_disk=False)
|
||||
|
||||
def _object_added_cb(self, cb_service, object_id, name):
|
||||
icon = ClipboardIcon(self._popup_context, object_id, name)
|
||||
icon = ClipboardIcon(object_id, name)
|
||||
icon.connect('activated', self._icon_activated_cb)
|
||||
self._set_icon_selected(icon)
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class ClipboardPanelWindow(FrameWindow):
|
||||
|
||||
root = self.get_root()
|
||||
|
||||
self._clipboard_box = ClipboardBox(frame.get_popup_context())
|
||||
self._clipboard_box = ClipboardBox()
|
||||
root.append(self._clipboard_box)
|
||||
|
||||
# Receiving dnd drops
|
||||
|
||||
@@ -26,7 +26,6 @@ from view.frame.overlaybox import OverlayBox
|
||||
from view.frame.FriendsBox import FriendsBox
|
||||
from view.frame.framewindow import FrameWindow
|
||||
from view.frame.clipboardpanelwindow import ClipboardPanelWindow
|
||||
from view.frame.framepopupcontext import FramePopupContext
|
||||
from model.ShellModel import ShellModel
|
||||
from sugar.graphics import animator
|
||||
from sugar.graphics import units
|
||||
@@ -140,12 +139,6 @@ class Frame(object):
|
||||
self._event_area.connect('enter', self._enter_corner_cb)
|
||||
self._event_area.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()
|
||||
@@ -195,9 +188,6 @@ class Frame(object):
|
||||
|
||||
self.visible = True
|
||||
|
||||
def get_popup_context(self):
|
||||
return self._popup_context
|
||||
|
||||
def get_current_position(self):
|
||||
return self._current_position
|
||||
|
||||
@@ -227,7 +217,7 @@ class Frame(object):
|
||||
panel = self._create_panel(hippo.ORIENTATION_HORIZONTAL)
|
||||
root = panel.get_root()
|
||||
|
||||
box = ActivitiesBox(self._shell, self._popup_context)
|
||||
box = ActivitiesBox(self._shell)
|
||||
root.append(box)
|
||||
|
||||
return panel
|
||||
@@ -236,7 +226,7 @@ class Frame(object):
|
||||
panel = self._create_panel(hippo.ORIENTATION_VERTICAL)
|
||||
root = panel.get_root()
|
||||
|
||||
box = FriendsBox(self._shell, self._popup_context)
|
||||
box = FriendsBox(self._shell)
|
||||
root.append(box)
|
||||
|
||||
return panel
|
||||
@@ -268,7 +258,6 @@ class Frame(object):
|
||||
|
||||
def _connect_to_panel(self, panel):
|
||||
panel.connect('enter-notify-event', self._enter_notify_cb)
|
||||
panel.connect('leave-notify-event', self._leave_notify_cb)
|
||||
|
||||
def _update_position(self):
|
||||
screen_h = gtk.gdk.screen_height()
|
||||
@@ -301,34 +290,8 @@ class Frame(object):
|
||||
self.show()
|
||||
gobject.timeout_add(2000, lambda: self.hide())
|
||||
|
||||
def _popup_context_activated_cb(self, popup_context):
|
||||
self._mouse_listener.mouse_enter()
|
||||
|
||||
def _popup_context_deactivated_cb(self, popup_context):
|
||||
if not self._hover:
|
||||
self._mouse_listener.mouse_leave()
|
||||
|
||||
def _enter_notify_cb(self, window, event):
|
||||
# FIXME clicks cause leave/notify, ignore
|
||||
if event.state == gtk.gdk.BUTTON1_MASK:
|
||||
return
|
||||
if self._hover:
|
||||
return
|
||||
|
||||
self._hover = True
|
||||
self._mouse_listener.mouse_enter()
|
||||
|
||||
def _leave_notify_cb(self, window, event):
|
||||
# FIXME clicks cause leave/notify, ignore
|
||||
if event.state == gtk.gdk.BUTTON1_MASK:
|
||||
return
|
||||
if not self._hover:
|
||||
return
|
||||
|
||||
if not self._is_hover():
|
||||
self._hover = False
|
||||
if not self._popup_context.is_active():
|
||||
self._mouse_listener.mouse_leave()
|
||||
|
||||
def _drag_motion_cb(self, window, context, x, y, time):
|
||||
self._mouse_listener.mouse_enter()
|
||||
|
||||
Reference in New Issue
Block a user