Renamed Rollover to Popup.
This commit is contained in:
parent
affba784cf
commit
bbfe539429
@ -21,7 +21,7 @@ import wnck
|
|||||||
|
|
||||||
from view.home.HomeWindow import HomeWindow
|
from view.home.HomeWindow import HomeWindow
|
||||||
from sugar.presence import PresenceService
|
from sugar.presence import PresenceService
|
||||||
from sugar.graphics.rollovercontext import RolloverContext
|
from sugar.graphics.popupcontext import PopupContext
|
||||||
from view.ActivityHost import ActivityHost
|
from view.ActivityHost import ActivityHost
|
||||||
from sugar.activity import ActivityFactory
|
from sugar.activity import ActivityFactory
|
||||||
from view.frame.frame import Frame
|
from view.frame.frame import Frame
|
||||||
@ -55,7 +55,7 @@ class Shell(gobject.GObject):
|
|||||||
home_model.connect('active-activity-changed',
|
home_model.connect('active-activity-changed',
|
||||||
self._active_activity_changed_cb)
|
self._active_activity_changed_cb)
|
||||||
|
|
||||||
self._rollover_context = RolloverContext()
|
self._popup_context = PopupContext()
|
||||||
|
|
||||||
self._frame = Frame(self)
|
self._frame = Frame(self)
|
||||||
self._frame.show_and_hide(3)
|
self._frame.show_and_hide(3)
|
||||||
@ -102,8 +102,8 @@ class Shell(gobject.GObject):
|
|||||||
def get_frame(self):
|
def get_frame(self):
|
||||||
return self._frame
|
return self._frame
|
||||||
|
|
||||||
def get_rollover_context(self):
|
def get_popup_context(self):
|
||||||
return self._rollover_context
|
return self._popup_context
|
||||||
|
|
||||||
def _join_success_cb(self, handler, activity, activity_ps, activity_id, activity_type):
|
def _join_success_cb(self, handler, activity, activity_ps, activity_id, activity_type):
|
||||||
logging.debug("Joining activity %s (%s)" % (activity_id, activity_type))
|
logging.debug("Joining activity %s (%s)" % (activity_id, activity_type))
|
||||||
|
@ -19,25 +19,25 @@ from gettext import gettext as _
|
|||||||
|
|
||||||
import hippo
|
import hippo
|
||||||
|
|
||||||
from sugar.graphics.rollover import Rollover
|
from sugar.graphics.popup import Popup
|
||||||
from sugar.graphics.menuicon import MenuIcon
|
from sugar.graphics.menuicon import MenuIcon
|
||||||
from sugar.graphics.menu import Menu
|
from sugar.graphics.menu import Menu
|
||||||
from sugar.graphics.iconcolor import IconColor
|
from sugar.graphics.iconcolor import IconColor
|
||||||
from sugar.graphics.button import Button
|
from sugar.graphics.button import Button
|
||||||
import sugar
|
import sugar
|
||||||
|
|
||||||
class ActivityRollover(Rollover):
|
class ActivityPopup(Popup):
|
||||||
ACTION_SHARE = 1
|
ACTION_SHARE = 1
|
||||||
ACTION_CLOSE = 2
|
ACTION_CLOSE = 2
|
||||||
|
|
||||||
def __init__(self, activity_model):
|
def __init__(self, activity_model):
|
||||||
Rollover.__init__(self, activity_model.get_title())
|
Popup.__init__(self, activity_model.get_title())
|
||||||
|
|
||||||
if not activity_model.get_shared():
|
if not activity_model.get_shared():
|
||||||
self.add_item(ActivityRollover.ACTION_SHARE, _('Share'),
|
self.add_item(ActivityPopup.ACTION_SHARE, _('Share'),
|
||||||
'theme:stock-share-mesh')
|
'theme:stock-share-mesh')
|
||||||
|
|
||||||
self.add_item(ActivityRollover.ACTION_CLOSE, _('Close'),
|
self.add_item(ActivityPopup.ACTION_CLOSE, _('Close'),
|
||||||
'theme:stock-close')
|
'theme:stock-close')
|
||||||
|
|
||||||
class ActivityButton(Button):
|
class ActivityButton(Button):
|
||||||
@ -50,13 +50,13 @@ class ActivityButton(Button):
|
|||||||
|
|
||||||
Button.__init__(self, icon_name=icon_name, color=icon_color)
|
Button.__init__(self, icon_name=icon_name, color=icon_color)
|
||||||
|
|
||||||
def get_rollover(self):
|
def get_popup(self):
|
||||||
rollover = ActivityRollover(self._activity_model)
|
popup = ActivityPopup(self._activity_model)
|
||||||
#rollover.connect('action', self._action_cb)
|
#popup.connect('action', self._action_cb)
|
||||||
return rollover
|
return popup
|
||||||
|
|
||||||
def get_rollover_context(self):
|
def get_popup_context(self):
|
||||||
return self._shell.get_rollover_context()
|
return self._shell.get_popup_context()
|
||||||
|
|
||||||
def _action_cb(self, menu, data):
|
def _action_cb(self, menu, data):
|
||||||
[action_id, label] = data
|
[action_id, label] = data
|
||||||
@ -68,9 +68,9 @@ class ActivityButton(Button):
|
|||||||
logging.error('No active activity.')
|
logging.error('No active activity.')
|
||||||
return
|
return
|
||||||
|
|
||||||
if action_id == ActivityRollover.ACTION_SHARE:
|
if action_id == ActivityPopup.ACTION_SHARE:
|
||||||
activity.share()
|
activity.share()
|
||||||
elif action_id == ActivityRollover.ACTION_CLOSE:
|
elif action_id == ActivityPopup.ACTION_CLOSE:
|
||||||
activity.close()
|
activity.close()
|
||||||
|
|
||||||
class ZoomBox(hippo.CanvasBox):
|
class ZoomBox(hippo.CanvasBox):
|
||||||
|
@ -70,11 +70,11 @@ class Frame:
|
|||||||
shell.get_model().connect('notify::state',
|
shell.get_model().connect('notify::state',
|
||||||
self._shell_state_changed_cb)
|
self._shell_state_changed_cb)
|
||||||
|
|
||||||
rollover_context = shell.get_rollover_context()
|
popup_context = shell.get_popup_context()
|
||||||
rollover_context.connect('activated',
|
popup_context.connect('activated',
|
||||||
self._rollover_context_activated_cb)
|
self._popup_context_activated_cb)
|
||||||
rollover_context.connect('deactivated',
|
popup_context.connect('deactivated',
|
||||||
self._rollover_context_deactivated_cb)
|
self._popup_context_deactivated_cb)
|
||||||
|
|
||||||
def _create_top_panel(self):
|
def _create_top_panel(self):
|
||||||
panel = self._create_panel(hippo.ORIENTATION_HORIZONTAL)
|
panel = self._create_panel(hippo.ORIENTATION_HORIZONTAL)
|
||||||
@ -171,10 +171,10 @@ class Frame:
|
|||||||
if self._mode != Frame.STICKY and not self._hover_frame:
|
if self._mode != Frame.STICKY and not self._hover_frame:
|
||||||
self._timeline.play('before_slide_out', 'slide_out')
|
self._timeline.play('before_slide_out', 'slide_out')
|
||||||
|
|
||||||
def _rollover_context_activated_cb(self, rollover_context):
|
def _popup_context_activated_cb(self, popup_context):
|
||||||
self._timeline.goto('slide_in', True)
|
self._timeline.goto('slide_in', True)
|
||||||
|
|
||||||
def _rollover_context_deactivated_cb(self, rollover_context):
|
def _popup_context_deactivated_cb(self, popup_context):
|
||||||
if self._mode != Frame.STICKY and not self._hover_frame:
|
if self._mode != Frame.STICKY and not self._hover_frame:
|
||||||
self._timeline.play('before_slide_out', 'slide_out')
|
self._timeline.play('before_slide_out', 'slide_out')
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ class Frame:
|
|||||||
def _leave_notify(self, panel):
|
def _leave_notify(self, panel):
|
||||||
self._hover_frame = False
|
self._hover_frame = False
|
||||||
if not panel.get_menu_shell().is_active() and \
|
if not panel.get_menu_shell().is_active() and \
|
||||||
not self._shell.get_rollover_context().is_active() and \
|
not self._shell.get_popup_context().is_active() and \
|
||||||
(self._mode == Frame.HIDE_ON_LEAVE or \
|
(self._mode == Frame.HIDE_ON_LEAVE or \
|
||||||
self._mode == Frame.AUTOMATIC):
|
self._mode == Frame.AUTOMATIC):
|
||||||
self._timeline.play('before_slide_out', 'slide_out')
|
self._timeline.play('before_slide_out', 'slide_out')
|
||||||
|
@ -16,8 +16,8 @@ sugar_PYTHON = \
|
|||||||
menushell.py \
|
menushell.py \
|
||||||
optionmenu.py \
|
optionmenu.py \
|
||||||
roundbox.py \
|
roundbox.py \
|
||||||
rollover.py \
|
popup.py \
|
||||||
rollovercontext.py \
|
popupcontext.py \
|
||||||
snowflakebox.py \
|
snowflakebox.py \
|
||||||
spreadbox.py \
|
spreadbox.py \
|
||||||
timeline.py \
|
timeline.py \
|
||||||
|
@ -51,8 +51,8 @@ class Button(hippo.CanvasBox):
|
|||||||
self._prelight_color = profile.get_color()
|
self._prelight_color = profile.get_color()
|
||||||
self._inactive_color = IconColor('#808080,#424242')
|
self._inactive_color = IconColor('#808080,#424242')
|
||||||
self._active = True
|
self._active = True
|
||||||
self._rollover = None
|
self._popup = None
|
||||||
self._hover_rollover = False
|
self._hover_popup = False
|
||||||
|
|
||||||
self._icon = CanvasIcon(icon_name=icon_name, cache=True,
|
self._icon = CanvasIcon(icon_name=icon_name, cache=True,
|
||||||
color=self._normal_color)
|
color=self._normal_color)
|
||||||
@ -71,51 +71,51 @@ class Button(hippo.CanvasBox):
|
|||||||
self.connect('motion-notify-event', self._motion_notify_event_cb)
|
self.connect('motion-notify-event', self._motion_notify_event_cb)
|
||||||
self.connect('button-press-event', self._button_press_event_cb)
|
self.connect('button-press-event', self._button_press_event_cb)
|
||||||
|
|
||||||
def get_rollover(self):
|
def get_popup(self):
|
||||||
return self._rollover
|
return self._popup
|
||||||
|
|
||||||
def get_rollover_context(self):
|
def get_popup_context(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def do_popup(self, current, n_frames):
|
def do_popup(self, current, n_frames):
|
||||||
if self._rollover:
|
if self._popup:
|
||||||
return
|
return
|
||||||
|
|
||||||
rollover = self.get_rollover()
|
popup = self.get_popup()
|
||||||
if not rollover:
|
if not popup:
|
||||||
return
|
return
|
||||||
|
|
||||||
rollover_context = self.get_rollover_context()
|
popup_context = self.get_popup_context()
|
||||||
if rollover_context:
|
if popup_context:
|
||||||
rollover_context.popped_up(rollover)
|
popup_context.popped_up(popup)
|
||||||
|
|
||||||
rollover.connect('motion-notify-event',
|
popup.connect('motion-notify-event',
|
||||||
self._rollover_motion_notify_event_cb)
|
self._popup_motion_notify_event_cb)
|
||||||
rollover.connect('action-completed',
|
popup.connect('action-completed',
|
||||||
self._rollover_action_completed_cb)
|
self._popup_action_completed_cb)
|
||||||
|
|
||||||
context = self._icon.get_context()
|
context = self._icon.get_context()
|
||||||
#[x, y] = context.translate_to_screen(self._icon)
|
#[x, y] = context.translate_to_screen(self._icon)
|
||||||
[x, y] = context.translate_to_widget(self._icon)
|
[x, y] = context.translate_to_widget(self._icon)
|
||||||
|
|
||||||
# TODO: Any better place to do this?
|
# TODO: Any better place to do this?
|
||||||
rollover.props.box_width = max(rollover.props.box_width,
|
popup.props.box_width = max(popup.props.box_width,
|
||||||
self.get_width_request())
|
self.get_width_request())
|
||||||
|
|
||||||
[width, height] = self._icon.get_allocation()
|
[width, height] = self._icon.get_allocation()
|
||||||
rollover.popup(x, y + height)
|
popup.popup(x, y + height)
|
||||||
|
|
||||||
self._rollover = rollover
|
self._popup = popup
|
||||||
|
|
||||||
def do_popdown(self, current, frame):
|
def do_popdown(self, current, frame):
|
||||||
if self._rollover:
|
if self._popup:
|
||||||
self._rollover.popdown()
|
self._popup.popdown()
|
||||||
|
|
||||||
rollover_context = self.get_rollover_context()
|
popup_context = self.get_popup_context()
|
||||||
if rollover_context:
|
if popup_context:
|
||||||
rollover_context.popped_down(self._rollover)
|
popup_context.popped_down(self._popup)
|
||||||
|
|
||||||
self._rollover = None
|
self._popup = None
|
||||||
|
|
||||||
def popdown(self):
|
def popdown(self):
|
||||||
self._timeline.play('popdown', 'popdown')
|
self._timeline.play('popdown', 'popdown')
|
||||||
@ -124,18 +124,18 @@ class Button(hippo.CanvasBox):
|
|||||||
if event.detail == hippo.MOTION_DETAIL_ENTER:
|
if event.detail == hippo.MOTION_DETAIL_ENTER:
|
||||||
self._timeline.play(None, 'popup')
|
self._timeline.play(None, 'popup')
|
||||||
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
|
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
|
||||||
if not self._hover_rollover:
|
if not self._hover_popup:
|
||||||
self._timeline.play('before_popdown', 'popdown')
|
self._timeline.play('before_popdown', 'popdown')
|
||||||
|
|
||||||
def _rollover_motion_notify_event_cb(self, rollover, event):
|
def _popup_motion_notify_event_cb(self, popup, event):
|
||||||
if event.detail == hippo.MOTION_DETAIL_ENTER:
|
if event.detail == hippo.MOTION_DETAIL_ENTER:
|
||||||
self._hover_rollover = True
|
self._hover_popup = True
|
||||||
self._timeline.play('popup', 'popup')
|
self._timeline.play('popup', 'popup')
|
||||||
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
|
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
|
||||||
self._hover_rollover = False
|
self._hover_popup = False
|
||||||
self._timeline.play('popdown', 'popdown')
|
self._timeline.play('popdown', 'popdown')
|
||||||
|
|
||||||
def _rollover_action_completed_cb(self, rollover):
|
def _popup_action_completed_cb(self, popup):
|
||||||
self.popdown()
|
self.popdown()
|
||||||
|
|
||||||
def _set_size(self, size):
|
def _set_size(self, size):
|
||||||
|
@ -28,8 +28,8 @@ from sugar.graphics import color
|
|||||||
from sugar.graphics import font
|
from sugar.graphics import font
|
||||||
from sugar.graphics.canvasicon import CanvasIcon
|
from sugar.graphics.canvasicon import CanvasIcon
|
||||||
|
|
||||||
class Rollover(hippo.CanvasBox, hippo.CanvasItem):
|
class Popup(hippo.CanvasBox, hippo.CanvasItem):
|
||||||
__gtype_name__ = 'SugarRollover'
|
__gtype_name__ = 'SugarPopup'
|
||||||
|
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'action-completed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([]))
|
'action-completed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([]))
|
@ -17,8 +17,8 @@
|
|||||||
import gobject
|
import gobject
|
||||||
import hippo
|
import hippo
|
||||||
|
|
||||||
class RolloverContext(gobject.GObject):
|
class PopupContext(gobject.GObject):
|
||||||
__gtype_name__ = 'SugarRolloverContext'
|
__gtype_name__ = 'SugarPopupContext'
|
||||||
|
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
'activated': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])),
|
'activated': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])),
|
Loading…
Reference in New Issue
Block a user