Renamed Rollover to Popup.

This commit is contained in:
Tomeu Vizoso 2007-02-21 10:16:03 +01:00
parent affba784cf
commit bbfe539429
7 changed files with 61 additions and 61 deletions

View File

@ -21,7 +21,7 @@ import wnck
from view.home.HomeWindow import HomeWindow
from sugar.presence import PresenceService
from sugar.graphics.rollovercontext import RolloverContext
from sugar.graphics.popupcontext import PopupContext
from view.ActivityHost import ActivityHost
from sugar.activity import ActivityFactory
from view.frame.frame import Frame
@ -55,7 +55,7 @@ class Shell(gobject.GObject):
home_model.connect('active-activity-changed',
self._active_activity_changed_cb)
self._rollover_context = RolloverContext()
self._popup_context = PopupContext()
self._frame = Frame(self)
self._frame.show_and_hide(3)
@ -102,8 +102,8 @@ class Shell(gobject.GObject):
def get_frame(self):
return self._frame
def get_rollover_context(self):
return self._rollover_context
def get_popup_context(self):
return self._popup_context
def _join_success_cb(self, handler, activity, activity_ps, activity_id, activity_type):
logging.debug("Joining activity %s (%s)" % (activity_id, activity_type))

View File

@ -19,25 +19,25 @@ from gettext import gettext as _
import hippo
from sugar.graphics.rollover import Rollover
from sugar.graphics.popup import Popup
from sugar.graphics.menuicon import MenuIcon
from sugar.graphics.menu import Menu
from sugar.graphics.iconcolor import IconColor
from sugar.graphics.button import Button
import sugar
class ActivityRollover(Rollover):
class ActivityPopup(Popup):
ACTION_SHARE = 1
ACTION_CLOSE = 2
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():
self.add_item(ActivityRollover.ACTION_SHARE, _('Share'),
self.add_item(ActivityPopup.ACTION_SHARE, _('Share'),
'theme:stock-share-mesh')
self.add_item(ActivityRollover.ACTION_CLOSE, _('Close'),
self.add_item(ActivityPopup.ACTION_CLOSE, _('Close'),
'theme:stock-close')
class ActivityButton(Button):
@ -50,13 +50,13 @@ class ActivityButton(Button):
Button.__init__(self, icon_name=icon_name, color=icon_color)
def get_rollover(self):
rollover = ActivityRollover(self._activity_model)
#rollover.connect('action', self._action_cb)
return rollover
def get_popup(self):
popup = ActivityPopup(self._activity_model)
#popup.connect('action', self._action_cb)
return popup
def get_rollover_context(self):
return self._shell.get_rollover_context()
def get_popup_context(self):
return self._shell.get_popup_context()
def _action_cb(self, menu, data):
[action_id, label] = data
@ -68,9 +68,9 @@ class ActivityButton(Button):
logging.error('No active activity.')
return
if action_id == ActivityRollover.ACTION_SHARE:
if action_id == ActivityPopup.ACTION_SHARE:
activity.share()
elif action_id == ActivityRollover.ACTION_CLOSE:
elif action_id == ActivityPopup.ACTION_CLOSE:
activity.close()
class ZoomBox(hippo.CanvasBox):

View File

@ -70,11 +70,11 @@ class Frame:
shell.get_model().connect('notify::state',
self._shell_state_changed_cb)
rollover_context = shell.get_rollover_context()
rollover_context.connect('activated',
self._rollover_context_activated_cb)
rollover_context.connect('deactivated',
self._rollover_context_deactivated_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)
@ -171,10 +171,10 @@ class Frame:
if self._mode != Frame.STICKY and not self._hover_frame:
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)
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:
self._timeline.play('before_slide_out', 'slide_out')
@ -206,7 +206,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_rollover_context().is_active() and \
not self._shell.get_popup_context().is_active() and \
(self._mode == Frame.HIDE_ON_LEAVE or \
self._mode == Frame.AUTOMATIC):
self._timeline.play('before_slide_out', 'slide_out')

View File

@ -16,8 +16,8 @@ sugar_PYTHON = \
menushell.py \
optionmenu.py \
roundbox.py \
rollover.py \
rollovercontext.py \
popup.py \
popupcontext.py \
snowflakebox.py \
spreadbox.py \
timeline.py \

View File

@ -51,8 +51,8 @@ class Button(hippo.CanvasBox):
self._prelight_color = profile.get_color()
self._inactive_color = IconColor('#808080,#424242')
self._active = True
self._rollover = None
self._hover_rollover = False
self._popup = None
self._hover_popup = False
self._icon = CanvasIcon(icon_name=icon_name, cache=True,
color=self._normal_color)
@ -71,51 +71,51 @@ class Button(hippo.CanvasBox):
self.connect('motion-notify-event', self._motion_notify_event_cb)
self.connect('button-press-event', self._button_press_event_cb)
def get_rollover(self):
return self._rollover
def get_popup(self):
return self._popup
def get_rollover_context(self):
def get_popup_context(self):
return None
def do_popup(self, current, n_frames):
if self._rollover:
if self._popup:
return
rollover = self.get_rollover()
if not rollover:
popup = self.get_popup()
if not popup:
return
rollover_context = self.get_rollover_context()
if rollover_context:
rollover_context.popped_up(rollover)
popup_context = self.get_popup_context()
if popup_context:
popup_context.popped_up(popup)
rollover.connect('motion-notify-event',
self._rollover_motion_notify_event_cb)
rollover.connect('action-completed',
self._rollover_action_completed_cb)
popup.connect('motion-notify-event',
self._popup_motion_notify_event_cb)
popup.connect('action-completed',
self._popup_action_completed_cb)
context = self._icon.get_context()
#[x, y] = context.translate_to_screen(self._icon)
[x, y] = context.translate_to_widget(self._icon)
# TODO: Any better place to do this?
rollover.props.box_width = max(rollover.props.box_width,
self.get_width_request())
popup.props.box_width = max(popup.props.box_width,
self.get_width_request())
[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):
if self._rollover:
self._rollover.popdown()
if self._popup:
self._popup.popdown()
rollover_context = self.get_rollover_context()
if rollover_context:
rollover_context.popped_down(self._rollover)
popup_context = self.get_popup_context()
if popup_context:
popup_context.popped_down(self._popup)
self._rollover = None
self._popup = None
def popdown(self):
self._timeline.play('popdown', 'popdown')
@ -124,18 +124,18 @@ class Button(hippo.CanvasBox):
if event.detail == hippo.MOTION_DETAIL_ENTER:
self._timeline.play(None, 'popup')
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
if not self._hover_rollover:
if not self._hover_popup:
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:
self._hover_rollover = True
self._hover_popup = True
self._timeline.play('popup', 'popup')
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
self._hover_rollover = False
self._hover_popup = False
self._timeline.play('popdown', 'popdown')
def _rollover_action_completed_cb(self, rollover):
def _popup_action_completed_cb(self, popup):
self.popdown()
def _set_size(self, size):

View File

@ -28,8 +28,8 @@ from sugar.graphics import color
from sugar.graphics import font
from sugar.graphics.canvasicon import CanvasIcon
class Rollover(hippo.CanvasBox, hippo.CanvasItem):
__gtype_name__ = 'SugarRollover'
class Popup(hippo.CanvasBox, hippo.CanvasItem):
__gtype_name__ = 'SugarPopup'
__gsignals__ = {
'action-completed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([]))

View File

@ -17,8 +17,8 @@
import gobject
import hippo
class RolloverContext(gobject.GObject):
__gtype_name__ = 'SugarRolloverContext'
class PopupContext(gobject.GObject):
__gtype_name__ = 'SugarPopupContext'
__gsignals__ = {
'activated': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])),