Based on earlier work by Raul Gutierrez and Walter Bender.
The tricky part here is not placing frame elements in the corners of the
screen, where grid-cell-sized squares are reserved, and also drawing
the little grey border around the inner edges of the frame.
Both of these issues are tackled with a custom container (FrameContainer)
class which provides the frame's child elements with a precisely defined
box to work in (which leaves the screen corners blank), and (like hippo)
uses cairo to draw the border on the appropriate edge.
---
src/jarabe/frame/clipboardpanelwindow.py |5 +-
src/jarabe/frame/frame.py| 16 +--
src/jarabe/frame/framewindow.py | 188 +-
src/jarabe/frame/zoomtoolbar.py |4 +
4 files changed, 140 insertions(+), 73 deletions(-)
diff --git a/src/jarabe/frame/clipboardpanelwindow.py
b/src/jarabe/frame/clipboardpanelwindow.py
index f5d537c..aefec7b 100644
--- a/src/jarabe/frame/clipboardpanelwindow.py
+++ b/src/jarabe/frame/clipboardpanelwindow.py
@@ -18,7 +18,6 @@ import logging
from urlparse import urlparse
import gtk
-import hippo
from jarabe.frame.framewindow import FrameWindow
from jarabe.frame.clipboardtray import ClipboardTray
@@ -39,8 +38,8 @@ class ClipboardPanelWindow(FrameWindow):
self._clipboard.connect('owner-change', self._owner_change_cb)
self._clipboard_tray = ClipboardTray()
-canvas_widget = hippo.CanvasWidget(widget=self._clipboard_tray)
-self.append(canvas_widget, hippo.PACK_EXPAND)
+self._clipboard_tray.show()
+self.append(self._clipboard_tray)
# Receiving dnd drops
self.drag_dest_set(0, [], 0)
diff --git a/src/jarabe/frame/frame.py b/src/jarabe/frame/frame.py
index 079eeeb..7407e18 100644
--- a/src/jarabe/frame/frame.py
+++ b/src/jarabe/frame/frame.py
@@ -18,7 +18,6 @@ import logging
import gtk
import gobject
-import hippo
from sugar.graphics import animator
from sugar.graphics import style
@@ -178,17 +177,12 @@ class Frame(object):
def _create_top_panel(self):
panel = self._create_panel(gtk.POS_TOP)
-# TODO: setting box_width and hippo.PACK_EXPAND looks like a hack to
-# me. Why hippo isn't respecting the request size of these controls?
-
zoom_toolbar = ZoomToolbar()
-panel.append(hippo.CanvasWidget(widget=zoom_toolbar,
-box_width=4 * style.GRID_CELL_SIZE))
+panel.append(zoom_toolbar, expand=False)
zoom_toolbar.show()
activities_tray = ActivitiesTray()
-panel.append(hippo.CanvasWidget(widget=activities_tray),
-hippo.PACK_EXPAND)
+panel.append(activities_tray)
activities_tray.show()
return panel
@@ -196,10 +190,8 @@ class Frame(object):
def _create_bottom_panel(self):
panel = self._create_panel(gtk.POS_BOTTOM)
-# TODO: same issue as in _create_top_panel()
devices_tray = DevicesTray()
-panel.append(hippo.CanvasWidget(widget=devices_tray),
- hippo.PACK_EXPAND)
+panel.append(devices_tray)
devices_tray.show()
return panel
@@ -208,7 +200,7 @@ class Frame(object):
panel = self._create_panel(gtk.POS_RIGHT)
tray = FriendsTray()
-panel.append(hippo.CanvasWidget(widget=tray), hippo.PACK_EXPAND)
+panel.append(tray)
tray.show()
return panel
diff --git a/src/jarabe/frame/framewindow.py b/src/jarabe/frame/framewindow.py
index c77e76c..b15b87e 100644
--- a/src/jarabe/frame/framewindow.py
+++ b/src/jarabe/frame/framewindow.py
@@ -15,11 +15,129 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import gtk
-import hippo
+from gtk import gdk
+import gobject
from sugar.graphics import style
+class FrameContainer(gtk.Container):
+A container class for frame panel rendering. Hosts a child 'box' where
+frame elements can be added. Excludes grid-sized squares at each end
+of the frame panel, and a space alongside the inside of the screen where
+a border is drawn.
+
+__gtype_name__ = 'SugarFrameContainer'
+
+def __init__(self, position):
+gtk.Container.__init__(self)
+self._position = position
+
+if self.is_vertical():
+self._box = gtk.VBox()
+else:
+self._box = gtk.HBox()
+self._box.set_parent(self)
+self._box.show()
+
+def is_vertical(self):
+return self._position in (gtk.POS_LEFT, gtk.POS_RIGHT)
+
+@gobject.property
+def box(self):
+return self._box
+
+def do_realize(self):
+self.set_flags(gtk.REALIZED)
+
+self.window = gdk.Window(
+self.get_parent_window(),
+window_type=gdk.WINDOW_CHILD,
+x=self.allocation.x,
+y=self.allocation.y,
+width=self.allocation.width,
+height=self.allocation.height,
+