Re: [Sugar-devel] [PATCH] Remove hippo from the frame

2011-09-26 Thread Sascha Silbe
Excerpts from Daniel Drake's message of 2011-09-18 14:47:09 +0200:

 Based on earlier work by Raul Gutierrez and Walter Bender.
[...]

Thanks for the patch!

[src/jarabe/frame/framewindow.py]
[class FrameContainer]
 +def do_realize(self):
 +self.set_flags(gtk.REALIZED)
 +
 +self.window = gdk.Window(
 +self.get_parent_window(),
[...]

Why do we need additional windows? AIUI we already have one
SugarFrameWindow for each edge (which is probably what
self.get_parent_window() returns). Shouldn't adding the container (or
maybe HBoxes and VBoxes if gtk.Container is too generic) to
SugarFrameWindow suffice?

Feel free to point me to GTK documentation if it's already explained
somewhere - I couldn't figure it out myself.

Sascha

-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/


signature.asc
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH] Remove hippo from the frame

2011-09-18 Thread Daniel Drake
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,
+ 

Re: [Sugar-devel] [PATCH] Remove hippo from the frame

2011-09-18 Thread Marco Pesenti Gritti
On 18 Sep 2011, at 13:47, Daniel Drake d...@laptop.org wrote:
 +# ask not to be collapsed if possible
 +self.set_size_request(4 * style.GRID_CELL_SIZE, -1)

This sucks a bit. Doesn't packing the toolbar with expand true work?

Not a big deal anyway, hopefully we can improve things with the gtk3 layout 
stuff. Rest looks cool to me.

Marco
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel



Re: [Sugar-devel] [PATCH] Remove hippo from the frame

2011-09-18 Thread Daniel Drake
On Sun, Sep 18, 2011 at 6:14 PM, Marco Pesenti Gritti ma...@marcopg.org wrote:
 On 18 Sep 2011, at 13:47, Daniel Drake d...@laptop.org wrote:
 +        # ask not to be collapsed if possible
 +        self.set_size_request(4 * style.GRID_CELL_SIZE, -1)

 This sucks a bit. Doesn't packing the toolbar with expand true work?

If expand=True, the zoom toolbar gets given one half of the frame
space, with the other half used by the activity icon list. This
results in the zoom toolbar being shown in the top left, followed by a
big uncomfortable gap, then the activity icon list mid way through the
frame.

This matches the GTK+ documentation which says:
expand :TRUE if the new child is to be given extra space allocated
to box. The extra space will be divided evenly between all children of
box that use this option

In this case we don't want even division.

GTK3 may indeed be better, with widgets now able to provide both a
natural and a minimum size in size requests, rather than just the
single measurement they have now.

Daniel
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel