Some refactoring. Store each panel in his own variable, since slide_in/slide_out handling will be different for each of them.
This commit is contained in:
parent
1456c872bc
commit
ff4054742a
@ -14,6 +14,8 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
import gobject
|
import gobject
|
||||||
import wnck
|
import wnck
|
||||||
|
@ -40,10 +40,15 @@ class Frame:
|
|||||||
AUTOMATIC = 4
|
AUTOMATIC = 4
|
||||||
|
|
||||||
def __init__(self, shell):
|
def __init__(self, shell):
|
||||||
self._windows = []
|
self._left_panel = None
|
||||||
|
self._right_panel = None
|
||||||
|
self._top_panel = None
|
||||||
|
self._bottom_panel = None
|
||||||
|
|
||||||
self._hover_frame = False
|
self._hover_frame = False
|
||||||
self._shell = shell
|
self._shell = shell
|
||||||
self._mode = Frame.INACTIVE
|
self._mode = Frame.INACTIVE
|
||||||
|
self._grid = Grid()
|
||||||
|
|
||||||
self._timeline = Timeline(self)
|
self._timeline = Timeline(self)
|
||||||
self._timeline.add_tag('slide_in', 18, 24)
|
self._timeline.add_tag('slide_in', 18, 24)
|
||||||
@ -56,90 +61,85 @@ class Frame:
|
|||||||
self._event_frame.connect('leave', self._event_frame_leave_cb)
|
self._event_frame.connect('leave', self._event_frame_leave_cb)
|
||||||
self._event_frame.show()
|
self._event_frame.show()
|
||||||
|
|
||||||
grid = Grid()
|
self._create_top_panel()
|
||||||
|
self._create_bottom_panel()
|
||||||
|
self._create_left_panel()
|
||||||
|
self._create_right_panel()
|
||||||
|
|
||||||
# Top panel
|
shell.get_model().connect('notify::state',
|
||||||
panel = self._create_panel(grid, 0, 0, 16, 1)
|
self._shell_state_changed_cb)
|
||||||
menu_shell = panel.get_menu_shell()
|
|
||||||
root = panel.get_root()
|
def _create_top_panel(self):
|
||||||
|
self._top_panel = self._create_panel(0, 0, 16, 1)
|
||||||
|
menu_shell = self._top_panel.get_menu_shell()
|
||||||
|
root = self._top_panel.get_root()
|
||||||
|
|
||||||
menu_shell.set_position(MenuShell.BOTTOM)
|
menu_shell.set_position(MenuShell.BOTTOM)
|
||||||
|
|
||||||
box = ZoomBox(self._shell, menu_shell)
|
box = ZoomBox(self._shell, menu_shell)
|
||||||
|
|
||||||
[x, y] = grid.point(1, 0)
|
[x, y] = self._grid.point(1, 0)
|
||||||
root.append(box, hippo.PACK_FIXED)
|
root.append(box, hippo.PACK_FIXED)
|
||||||
root.set_position(box, x, y)
|
root.set_position(box, x, y)
|
||||||
|
|
||||||
tray = NotificationTray()
|
tray = NotificationTray()
|
||||||
tray_box = hippo.CanvasBox(box_width=grid.dimension(1),
|
tray_box = hippo.CanvasBox(box_width=self._grid.dimension(1),
|
||||||
box_height=grid.dimension(1),
|
box_height=self._grid.dimension(1),
|
||||||
xalign=hippo.ALIGNMENT_END)
|
xalign=hippo.ALIGNMENT_END)
|
||||||
|
|
||||||
tray_widget = hippo.CanvasWidget()
|
tray_widget = hippo.CanvasWidget()
|
||||||
tray_widget.props.widget = tray
|
tray_widget.props.widget = tray
|
||||||
tray_box.append(tray_widget, gtk.EXPAND)
|
tray_box.append(tray_widget, gtk.EXPAND)
|
||||||
|
|
||||||
[x, y] = grid.point(13, 0)
|
[x, y] = self._grid.point(13, 0)
|
||||||
root.append(tray_box, hippo.PACK_FIXED)
|
root.append(tray_box, hippo.PACK_FIXED)
|
||||||
root.set_position(tray_box, x, y)
|
root.set_position(tray_box, x, y)
|
||||||
|
|
||||||
box = OverlayBox(self._shell)
|
box = OverlayBox(self._shell)
|
||||||
|
|
||||||
[x, y] = grid.point(14, 0)
|
[x, y] = self._grid.point(14, 0)
|
||||||
root.append(box, hippo.PACK_FIXED)
|
root.append(box, hippo.PACK_FIXED)
|
||||||
root.set_position(box, x, y)
|
root.set_position(box, x, y)
|
||||||
|
|
||||||
# Bottom panel
|
def _create_bottom_panel(self):
|
||||||
panel = self._create_panel(grid, 0, 11, 16, 1)
|
self._bottom_panel = self._create_panel(0, 11, 16, 1)
|
||||||
menu_shell = panel.get_menu_shell()
|
menu_shell = self._bottom_panel.get_menu_shell()
|
||||||
root = panel.get_root()
|
root = self._bottom_panel.get_root()
|
||||||
|
|
||||||
menu_shell.set_position(MenuShell.TOP)
|
menu_shell.set_position(MenuShell.TOP)
|
||||||
|
|
||||||
box = ActivitiesBox(self._shell)
|
box = ActivitiesBox(self._shell)
|
||||||
root.append(box, hippo.PACK_FIXED)
|
root.append(box, hippo.PACK_FIXED)
|
||||||
|
|
||||||
[x, y] = grid.point(1, 0)
|
[x, y] = self._grid.point(1, 0)
|
||||||
root.set_position(box, x, y)
|
root.set_position(box, x, y)
|
||||||
|
|
||||||
# Right panel
|
def _create_right_panel(self):
|
||||||
panel = self._create_panel(grid, 15, 1, 1, 10)
|
self._right_panel = self._create_panel(15, 1, 1, 10)
|
||||||
menu_shell = panel.get_menu_shell()
|
menu_shell = self._right_panel.get_menu_shell()
|
||||||
root = panel.get_root()
|
root = self._right_panel.get_root()
|
||||||
|
|
||||||
menu_shell.set_position(MenuShell.LEFT)
|
menu_shell.set_position(MenuShell.LEFT)
|
||||||
|
|
||||||
box = FriendsBox(self._shell, menu_shell)
|
box = FriendsBox(self._shell, menu_shell)
|
||||||
root.append(box)
|
root.append(box)
|
||||||
|
|
||||||
# Left panel
|
def _create_left_panel(self):
|
||||||
panel = self._create_clipboard_panel(grid, 0, 1, 1, 10)
|
[x, y, width, height] = self._grid.rectangle(0, 1, 1, 10)
|
||||||
|
self._left_panel = ClipboardPanelWindow(self, x, y, width, height)
|
||||||
|
|
||||||
shell.get_model().connect('notify::state',
|
self._connect_to_panel(self._left_panel)
|
||||||
self._shell_state_changed_cb)
|
self._left_panel.connect('drag-motion', self._drag_motion_cb)
|
||||||
|
self._left_panel.connect('drag-leave', self._drag_leave_cb)
|
||||||
|
|
||||||
def _shell_state_changed_cb(self, model, pspec):
|
def _shell_state_changed_cb(self, model, pspec):
|
||||||
if model.props.state == ShellModel.STATE_SHUTDOWN:
|
if model.props.state == ShellModel.STATE_SHUTDOWN:
|
||||||
self._timeline.goto('slide_out', True)
|
self._timeline.goto('slide_out', True)
|
||||||
|
|
||||||
def _create_clipboard_panel(self, grid, x, y, width, height):
|
def _create_panel(self, x, y, width, height):
|
||||||
[x, y, width, height] = grid.rectangle(x, y, width, height)
|
[x, y, width, height] = self._grid.rectangle(x, y, width, height)
|
||||||
panel = ClipboardPanelWindow(self, x, y, width, height)
|
|
||||||
|
|
||||||
self._connect_to_panel(panel)
|
|
||||||
panel.connect('drag-motion', self._drag_motion_cb)
|
|
||||||
panel.connect('drag-leave', self._drag_leave_cb)
|
|
||||||
|
|
||||||
self._windows.append(panel)
|
|
||||||
|
|
||||||
return panel
|
|
||||||
|
|
||||||
def _create_panel(self, grid, x, y, width, height):
|
|
||||||
[x, y, width, height] = grid.rectangle(x, y, width, height)
|
|
||||||
panel = PanelWindow(x, y, width, height)
|
panel = PanelWindow(x, y, width, height)
|
||||||
self._connect_to_panel(panel)
|
self._connect_to_panel(panel)
|
||||||
self._windows.append(panel)
|
|
||||||
|
|
||||||
return panel
|
return panel
|
||||||
|
|
||||||
@ -225,18 +225,24 @@ class Frame:
|
|||||||
self._timeline.play('before_slide_out', 'slide_out')
|
self._timeline.play('before_slide_out', 'slide_out')
|
||||||
|
|
||||||
def do_slide_in(self, current=0, n_frames=0):
|
def do_slide_in(self, current=0, n_frames=0):
|
||||||
if not self._windows[0].props.visible:
|
if not self._top_panel.props.visible:
|
||||||
for panel in self._windows:
|
self._left_panel.show()
|
||||||
panel.show()
|
self._right_panel.show()
|
||||||
|
self._top_panel.show()
|
||||||
|
self._bottom_panel.show()
|
||||||
|
|
||||||
self._event_frame.hide()
|
self._event_frame.hide()
|
||||||
|
|
||||||
def do_slide_out(self, current=0, n_frames=0):
|
def do_slide_out(self, current=0, n_frames=0):
|
||||||
if self._windows[0].props.visible:
|
if self._top_panel.props.visible:
|
||||||
for panel in self._windows:
|
self._left_panel.hide()
|
||||||
panel.hide()
|
self._right_panel.hide()
|
||||||
|
self._top_panel.hide()
|
||||||
|
self._bottom_panel.hide()
|
||||||
|
|
||||||
self._event_frame.show()
|
self._event_frame.show()
|
||||||
|
|
||||||
def is_visible(self):
|
def is_visible(self):
|
||||||
if self._windows[0].props.visible:
|
if self._top_panel.props.visible:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user