Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-10-12 17:04:50 (GMT)
committer Tomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-10-12 17:04:50 (GMT)
commit25c83a2dbe6e5af7955159c8cf6fe89248ec9b19 (patch)
treef569d0684e713fe474f273a390888394eb519e38
parent3b0d0a403e0e611dbd998f90445ef6596ac90d4e (diff)
Some more hippo removalnohippo
-rw-r--r--src/jarabe/desktop/favoriteslayout.py68
-rw-r--r--src/jarabe/desktop/favoritesview.py58
-rw-r--r--src/jarabe/desktop/homewindow.py10
-rw-r--r--src/jarabe/view/buddyicon.py9
4 files changed, 53 insertions, 92 deletions
diff --git a/src/jarabe/desktop/favoriteslayout.py b/src/jarabe/desktop/favoriteslayout.py
index 7b847ac..b3e9848 100644
--- a/src/jarabe/desktop/favoriteslayout.py
+++ b/src/jarabe/desktop/favoriteslayout.py
@@ -213,27 +213,8 @@ class RingLayout(FavoritesLayout):
def __init__(self):
FavoritesLayout.__init__(self)
- self._locked_children = {}
self._spiral_mode = False
- def append(self, icon, locked=False):
- FavoritesLayout.append(self, icon, locked)
- if locked:
- child = self.box.find_box_child(icon)
- self._locked_children[child] = (0, 0)
-
- def remove(self, icon):
- child = self.box.find_box_child(icon)
- if child in self._locked_children:
- del self._locked_children[child]
- FavoritesLayout.remove(self, icon)
-
- def move_icon(self, icon, x, y, locked=False):
- FavoritesLayout.move_icon(self, icon, x, y, locked)
- if locked:
- child = self.box.find_box_child(icon)
- self._locked_children[child] = (x, y)
-
def _calculate_radius_and_icon_size(self, children_count):
""" Adjust the ring or spiral radius and icon size as needed. """
self._spiral_mode = False
@@ -264,12 +245,9 @@ class RingLayout(FavoritesLayout):
return radius, icon_size
def _calculate_position(self, radius, icon_size, icon_index, children_count,
- sin=math.sin, cos=math.cos):
+ width, height, sin=math.sin, cos=math.cos):
""" Calculate an icon position on a circle or a spiral. """
- width, height = self.box.get_allocation()
if self._spiral_mode:
- min_width_, box_width = self.box.get_width_request()
- min_height_, box_height = self.box.get_height_request(box_width)
angle, radius = self._calculate_angle_and_radius(icon_index,
icon_size)
x, y = self._convert_from_polar_to_cartesian(angle, radius,
@@ -305,44 +283,20 @@ class RingLayout(FavoritesLayout):
radius += (float(icon_spacing) * spiral_spacing / n)
return angle, radius
- def _get_children_in_ring(self):
- children_in_ring = [child for child in self.box.get_layout_children() \
- if child not in self._locked_children]
- return children_in_ring
+ def allocate_icons(self, children, width, height):
+ radius, icon_size = self._calculate_radius_and_icon_size(len(children))
- def do_allocate(self, x, y, width, height, req_width, req_height,
- origin_changed):
- children_in_ring = self._get_children_in_ring()
- if children_in_ring:
- radius, icon_size = \
- self._calculate_radius_and_icon_size(len(children_in_ring))
-
- for n in range(len(children_in_ring)):
- child = children_in_ring[n]
-
- x, y = self._calculate_position(radius, icon_size, n,
- len(children_in_ring))
-
- # We need to always get requests to not confuse hippo
- min_w_, child_width = child.get_width_request()
- min_h_, child_height = child.get_height_request(child_width)
+ allocations = []
+ for n in range(len(children)):
+ child = children[n]
- child.allocate(int(x), int(y), child_width, child_height,
- origin_changed)
- child.item.props.size = icon_size
-
- for child in self._locked_children.keys():
- x, y = self._locked_children[child]
-
- # We need to always get requests to not confuse hippo
- min_w_, child_width = child.get_width_request()
- min_h_, child_height = child.get_height_request(child_width)
+ x, y = self._calculate_position(radius, icon_size, n, len(children),
+ width, height)
- if child_width <= 0 or child_height <= 0:
- return
+ allocation = gtk.gdk.Rectangle(int(x), int(y), icon_size, icon_size)
+ allocations.append(allocation)
- child.allocate(int(x), int(y), child_width, child_height,
- origin_changed)
+ return allocations
def compare_activities(self, icon_a, icon_b):
if hasattr(icon_a, 'installation_time') and \
diff --git a/src/jarabe/desktop/favoritesview.py b/src/jarabe/desktop/favoritesview.py
index 7f3106d..37a6356 100644
--- a/src/jarabe/desktop/favoritesview.py
+++ b/src/jarabe/desktop/favoritesview.py
@@ -69,6 +69,7 @@ class FavoritesContainer(gtk.Container):
self._my_icon = None
self._current_activity = None
self._activity_icons = []
+ self._layout = None
def do_realize(self):
self.set_flags(self.flags() | gtk.REALIZED)
@@ -93,7 +94,7 @@ class FavoritesContainer(gtk.Container):
self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('white'))
def do_forall(self, include_internals, forall_cb, user_data):
- children = self._activity_icons
+ children = self._activity_icons[:]
if self._my_icon is not None:
children.append(self._my_icon)
@@ -121,16 +122,40 @@ class FavoritesContainer(gtk.Container):
if self.flags() & gtk.REALIZED:
self.window.move_resize(*allocation)
- allocations = self._layout.allocate(self._activity_icons)
+ width, height = allocation.width, allocation.height
+
+ my_icon_width, my_icon_height = self._my_icon.size_request()
+ x = (width - my_icon_width) / 2
+ y = (height - my_icon_height - style.GRID_CELL_SIZE) / 2
+
+ child_allocation = gtk.gdk.Rectangle(x, y, my_icon_width, my_icon_height)
+ self._my_icon.size_allocate(child_allocation)
+
+ icon_width, icon_height = self._current_activity.size_request()
+ x = (width - icon_width) / 2
+ y = (height - my_icon_height - style.GRID_CELL_SIZE) / 2 + \
+ my_icon_height + style.DEFAULT_PADDING
+
+ child_allocation = gtk.gdk.Rectangle(x, y, icon_width, icon_height)
+ self._current_activity.size_allocate(child_allocation)
+
+ allocations = self._layout.allocate_icons(self._activity_icons, width,
+ height)
assert len(allocations) == len(self._activity_icons)
for icon, allocation in zip(self._activity_icons, allocations):
icon.size_allocate(allocation)
def set_my_icon(self, icon):
self._my_icon = icon
+ self._my_icon.set_parent(self)
def set_current_activity(self, icon):
self._current_activity = icon
+ self._current_activity.set_parent(self)
+
+ def add_activity_icon(self, icon):
+ self._activity_icons.append(icon)
+ icon.set_parent(self)
def _set_layout(self, layout):
if layout not in LAYOUT_MAP:
@@ -156,11 +181,12 @@ class FavoritesView(FavoritesContainer):
self._my_icon = OwnerIcon(style.XLARGE_ICON_SIZE)
self._my_icon.connect('register-activate', self.__register_activate_cb)
self.set_my_icon(self._my_icon)
+ self._my_icon.show()
self._current_activity = CurrentActivityIcon()
self.set_current_activity(self._current_activity)
+ self._current_activity.show()
- self._layout = None
self._alert = None
self._resume_mode = True
@@ -192,8 +218,8 @@ class FavoritesView(FavoritesContainer):
icon = ActivityIcon(activity_info)
icon.props.pixel_size = style.STANDARD_ICON_SIZE
icon.set_resume_mode(self._resume_mode)
- self._box.insert_sorted(icon, 0, self._layout.compare_activities)
- self._layout.append(icon)
+ self.add_activity_icon(icon)
+ icon.show()
def __activity_added_cb(self, activity_registry, activity_info):
registry = bundleregistry.get_registry()
@@ -228,26 +254,6 @@ class FavoritesView(FavoritesContainer):
activity_info.get_activity_version()):
self._add_activity(activity_info)
- def do_size_allocate(self, allocation):
- width = allocation.width
- height = allocation.height
-
- min_w_, my_icon_width = self._my_icon.get_width_request()
- min_h_, my_icon_height = self._my_icon.get_height_request(my_icon_width)
- x = (width - my_icon_width) / 2
- y = (height - my_icon_height - style.GRID_CELL_SIZE) / 2
- self._layout.move_icon(self._my_icon, x, y, locked=True)
-
- min_w_, icon_width = self._current_activity.get_width_request()
- min_h_, icon_height = \
- self._current_activity.get_height_request(icon_width)
- x = (width - icon_width) / 2
- y = (height - my_icon_height - style.GRID_CELL_SIZE) / 2 + \
- my_icon_height + style.DEFAULT_PADDING
- self._layout.move_icon(self._current_activity, x, y, locked=True)
-
- hippo.Canvas.do_size_allocate(self, allocation)
-
# TODO: Dnd methods. This should be merged somehow inside hippo-canvas.
def __button_press_event_cb(self, widget, event):
if event.button == 1 and event.type == gtk.gdk.BUTTON_PRESS:
@@ -630,7 +636,7 @@ class OwnerIcon(BuddyIcon):
gobject.TYPE_NONE, ([]))
}
def __init__(self, size):
- BuddyIcon.__init__(self, buddy=get_owner_instance(), size=size)
+ BuddyIcon.__init__(self, buddy=get_owner_instance(), pixel_size=size)
self._palette_enabled = False
self._register_menu = None
diff --git a/src/jarabe/desktop/homewindow.py b/src/jarabe/desktop/homewindow.py
index fec4289..b1d10c8 100644
--- a/src/jarabe/desktop/homewindow.py
+++ b/src/jarabe/desktop/homewindow.py
@@ -61,15 +61,15 @@ class HomeWindow(gtk.Window):
self.connect('key-release-event', self.__key_release_event_cb)
self._home_box = HomeBox()
- self._group_box = GroupBox()
- self._mesh_box = MeshBox()
- self._transition_box = TransitionBox()
+ #self._group_box = GroupBox()
+ #self._mesh_box = MeshBox()
+ #self._transition_box = TransitionBox()
self.add(self._home_box)
self._home_box.show()
- self._transition_box.connect('completed',
- self._transition_completed_cb)
+ #self._transition_box.connect('completed',
+ # self._transition_completed_cb)
shell.get_model().zoom_level_changed.connect(
self.__zoom_level_changed_cb)
diff --git a/src/jarabe/view/buddyicon.py b/src/jarabe/view/buddyicon.py
index 37b9167..69bad65 100644
--- a/src/jarabe/view/buddyicon.py
+++ b/src/jarabe/view/buddyicon.py
@@ -14,14 +14,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-from sugar.graphics.icon import CanvasIcon
+from sugar.graphics.icon import Icon
from sugar.graphics import style
from jarabe.view.buddymenu import BuddyMenu
-class BuddyIcon(CanvasIcon):
- def __init__(self, buddy, size=style.STANDARD_ICON_SIZE):
- CanvasIcon.__init__(self, icon_name='computer-xo', size=size)
+class BuddyIcon(Icon):
+ def __init__(self, buddy, pixel_size=style.STANDARD_ICON_SIZE):
+ Icon.__init__(self, icon_name='computer-xo', pixel_size=pixel_size)
self._greyed_out = False
self._buddy = buddy
@@ -41,6 +41,7 @@ class BuddyIcon(CanvasIcon):
self._update_color()
def _update_color(self):
+ return
# keep the icon in the palette in sync with the view
palette = self.get_palette()
if self._greyed_out: