<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.sugarlabs.org/index.php?action=history&amp;feed=atom&amp;title=User%3AWalter%2Ffavoritesview.py</id>
	<title>User:Walter/favoritesview.py - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.sugarlabs.org/index.php?action=history&amp;feed=atom&amp;title=User%3AWalter%2Ffavoritesview.py"/>
	<link rel="alternate" type="text/html" href="https://wiki.sugarlabs.org/index.php?title=User:Walter/favoritesview.py&amp;action=history"/>
	<updated>2026-05-14T15:36:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.sugarlabs.org/index.php?title=User:Walter/favoritesview.py&amp;diff=49187&amp;oldid=prev</id>
		<title>Patrol: moved Walter is a wanker 2/favoritesview.py to User:Walter/favoritesview.py over redirect: revert</title>
		<link rel="alternate" type="text/html" href="https://wiki.sugarlabs.org/index.php?title=User:Walter/favoritesview.py&amp;diff=49187&amp;oldid=prev"/>
		<updated>2010-03-01T18:26:10Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/index.php?title=Walter_is_a_wanker_2/favoritesview.py&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Walter is a wanker 2/favoritesview.py (page does not exist)&quot;&gt;Walter is a wanker 2/favoritesview.py&lt;/a&gt; to &lt;a href=&quot;/go/User:Walter/favoritesview.py&quot; title=&quot;User:Walter/favoritesview.py&quot;&gt;User:Walter/favoritesview.py&lt;/a&gt; over redirect: revert&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:26, 1 March 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Patrol</name></author>
	</entry>
	<entry>
		<id>https://wiki.sugarlabs.org/index.php?title=User:Walter/favoritesview.py&amp;diff=49102&amp;oldid=prev</id>
		<title>Pmv2: moved User:Walter/favoritesview.py to Walter is a wanker 2/favoritesview.py:&amp;#32;Walter is a wanker</title>
		<link rel="alternate" type="text/html" href="https://wiki.sugarlabs.org/index.php?title=User:Walter/favoritesview.py&amp;diff=49102&amp;oldid=prev"/>
		<updated>2010-03-01T18:19:43Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/go/User:Walter/favoritesview.py&quot; title=&quot;User:Walter/favoritesview.py&quot;&gt;User:Walter/favoritesview.py&lt;/a&gt; to &lt;a href=&quot;/index.php?title=Walter_is_a_wanker_2/favoritesview.py&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Walter is a wanker 2/favoritesview.py (page does not exist)&quot;&gt;Walter is a wanker 2/favoritesview.py&lt;/a&gt;: Walter is a wanker&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:19, 1 March 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Pmv2</name></author>
	</entry>
	<entry>
		<id>https://wiki.sugarlabs.org/index.php?title=User:Walter/favoritesview.py&amp;diff=45666&amp;oldid=prev</id>
		<title>Patrol: moved Anal bleaching 3/favoritesview.py to User:Walter/favoritesview.py over redirect: revert</title>
		<link rel="alternate" type="text/html" href="https://wiki.sugarlabs.org/index.php?title=User:Walter/favoritesview.py&amp;diff=45666&amp;oldid=prev"/>
		<updated>2010-02-21T23:03:03Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/index.php?title=Anal_bleaching_3/favoritesview.py&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Anal bleaching 3/favoritesview.py (page does not exist)&quot;&gt;Anal bleaching 3/favoritesview.py&lt;/a&gt; to &lt;a href=&quot;/go/User:Walter/favoritesview.py&quot; title=&quot;User:Walter/favoritesview.py&quot;&gt;User:Walter/favoritesview.py&lt;/a&gt; over redirect: revert&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:03, 21 February 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Patrol</name></author>
	</entry>
	<entry>
		<id>https://wiki.sugarlabs.org/index.php?title=User:Walter/favoritesview.py&amp;diff=44498&amp;oldid=prev</id>
		<title>Anal bleaching: moved User:Walter/favoritesview.py to Anal bleaching 3/favoritesview.py:&amp;#32;Anal bleaching</title>
		<link rel="alternate" type="text/html" href="https://wiki.sugarlabs.org/index.php?title=User:Walter/favoritesview.py&amp;diff=44498&amp;oldid=prev"/>
		<updated>2010-02-21T22:15:47Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/go/User:Walter/favoritesview.py&quot; title=&quot;User:Walter/favoritesview.py&quot;&gt;User:Walter/favoritesview.py&lt;/a&gt; to &lt;a href=&quot;/index.php?title=Anal_bleaching_3/favoritesview.py&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Anal bleaching 3/favoritesview.py (page does not exist)&quot;&gt;Anal bleaching 3/favoritesview.py&lt;/a&gt;: Anal bleaching&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 18:15, 21 February 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Anal bleaching</name></author>
	</entry>
	<entry>
		<id>https://wiki.sugarlabs.org/index.php?title=User:Walter/favoritesview.py&amp;diff=9612&amp;oldid=prev</id>
		<title>Walter at 23:32, 13 October 2008</title>
		<link rel="alternate" type="text/html" href="https://wiki.sugarlabs.org/index.php?title=User:Walter/favoritesview.py&amp;diff=9612&amp;oldid=prev"/>
		<updated>2008-10-13T23:32:28Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:32, 13 October 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==/usr/share/sugar/shell/view/home/favoritesview.py==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Copyright (C) 2006-2007 Red Hat, Inc.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Copyright (C) 2006-2007 Red Hat, Inc.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Walter</name></author>
	</entry>
	<entry>
		<id>https://wiki.sugarlabs.org/index.php?title=User:Walter/favoritesview.py&amp;diff=9604&amp;oldid=prev</id>
		<title>Walter: New page: &lt;pre&gt; # Copyright (C) 2006-2007 Red Hat, Inc. # Copyright (C) 2008 One Laptop Per Child # # This program is free software; you can redistribute it and/or modify # it under the terms of the...</title>
		<link rel="alternate" type="text/html" href="https://wiki.sugarlabs.org/index.php?title=User:Walter/favoritesview.py&amp;diff=9604&amp;oldid=prev"/>
		<updated>2008-10-13T23:05:04Z</updated>

		<summary type="html">&lt;p&gt;New page: &amp;lt;pre&amp;gt; # Copyright (C) 2006-2007 Red Hat, Inc. # Copyright (C) 2008 One Laptop Per Child # # This program is free software; you can redistribute it and/or modify # it under the terms of the...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# Copyright (C) 2006-2007 Red Hat, Inc.&lt;br /&gt;
# Copyright (C) 2008 One Laptop Per Child&lt;br /&gt;
#&lt;br /&gt;
# This program is free software; you can redistribute it and/or modify&lt;br /&gt;
# it under the terms of the GNU General Public License as published by&lt;br /&gt;
# the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;
# (at your option) any later version.&lt;br /&gt;
#&lt;br /&gt;
# This program is distributed in the hope that it will be useful,&lt;br /&gt;
# but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
# GNU General Public License for more details.&lt;br /&gt;
#&lt;br /&gt;
# You should have received a copy of the GNU General Public License&lt;br /&gt;
# along with this program; if not, write to the Free Software&lt;br /&gt;
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA&lt;br /&gt;
&lt;br /&gt;
import logging&lt;br /&gt;
from gettext import gettext as _&lt;br /&gt;
&lt;br /&gt;
import gobject&lt;br /&gt;
import gtk&lt;br /&gt;
import hippo&lt;br /&gt;
&lt;br /&gt;
from sugar.graphics import style&lt;br /&gt;
from sugar.graphics.palette import Palette&lt;br /&gt;
from sugar.graphics.icon import Icon, CanvasIcon&lt;br /&gt;
from sugar.graphics.menuitem import MenuItem&lt;br /&gt;
from sugar.graphics.alert import Alert&lt;br /&gt;
from sugar.profile import get_profile&lt;br /&gt;
from sugar import activity&lt;br /&gt;
&lt;br /&gt;
import view.Shell&lt;br /&gt;
from view.palettes import JournalPalette&lt;br /&gt;
from view.palettes import CurrentActivityPalette, ActivityPalette&lt;br /&gt;
from view.home.MyIcon import MyIcon&lt;br /&gt;
from view.home import favoriteslayout&lt;br /&gt;
from model import shellmodel&lt;br /&gt;
from model.shellmodel import ShellModel&lt;br /&gt;
from hardware import schoolserver&lt;br /&gt;
from hardware.schoolserver import RegisterError&lt;br /&gt;
from controlpanel.gui import ControlPanel&lt;br /&gt;
from session import get_session_manager&lt;br /&gt;
&lt;br /&gt;
_logger = logging.getLogger(&amp;#039;FavoritesView&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
_ICON_DND_TARGET = (&amp;#039;activity-icon&amp;#039;, gtk.TARGET_SAME_WIDGET, 0)&lt;br /&gt;
&lt;br /&gt;
# enumerate the various layout types we will display in the dropdown palette.&lt;br /&gt;
# add a constant for your layout here, and add it to the _LAYOUT_MAP to get&lt;br /&gt;
# it to appear in the palette.&lt;br /&gt;
RING_LAYOUT, BOX_LAYOUT, TRIANGLE_LAYOUT, SUNFLOWER_LAYOUT, MY_LAYOUT, RANDOM_LAYOUT = \&lt;br /&gt;
             xrange(6)&lt;br /&gt;
&lt;br /&gt;
_LAYOUT_MAP = {RING_LAYOUT: favoriteslayout.RingLayout,&lt;br /&gt;
               BOX_LAYOUT: favoriteslayout.BoxLayout,&lt;br /&gt;
               TRIANGLE_LAYOUT: favoriteslayout.TriangleLayout,&lt;br /&gt;
               SUNFLOWER_LAYOUT: favoriteslayout.SunflowerLayout,&lt;br /&gt;
               MY_LAYOUT: favoriteslayout.MyLayout,&lt;br /&gt;
               RANDOM_LAYOUT: favoriteslayout.RandomLayout}&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;Map numeric layout identifiers to uninstantiated subclasses of&lt;br /&gt;
`FavoritesLayout` which implement the layouts.  Additional information&lt;br /&gt;
about the layout can be accessed with fields of the class.&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
class FavoritesView(hippo.Canvas):&lt;br /&gt;
    __gtype_name__ = &amp;#039;SugarFavoritesView&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    __gsignals__ = {&lt;br /&gt;
        &amp;#039;erase-activated&amp;#039; : (gobject.SIGNAL_RUN_FIRST,&lt;br /&gt;
                             gobject.TYPE_NONE, ([str])),&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, **kwargs):&lt;br /&gt;
        gobject.GObject.__init__(self, **kwargs)&lt;br /&gt;
&lt;br /&gt;
        # DND stuff&lt;br /&gt;
        self._pressed_button = None&lt;br /&gt;
        self._press_start_x = None&lt;br /&gt;
        self._press_start_y = None&lt;br /&gt;
        self._last_clicked_icon = None&lt;br /&gt;
&lt;br /&gt;
        self._box = hippo.CanvasBox()&lt;br /&gt;
        self._box.props.background_color = style.COLOR_WHITE.get_int()&lt;br /&gt;
        self.set_root(self._box)&lt;br /&gt;
&lt;br /&gt;
        self._my_icon = None&lt;br /&gt;
        self._current_activity = None&lt;br /&gt;
        self._layout = None&lt;br /&gt;
        self._alert = None&lt;br /&gt;
&lt;br /&gt;
        registry = activity.get_registry()&lt;br /&gt;
        registry.connect(&amp;#039;activity-added&amp;#039;, self.__activity_added_cb)&lt;br /&gt;
        registry.connect(&amp;#039;activity-removed&amp;#039;, self.__activity_removed_cb)&lt;br /&gt;
        registry.connect(&amp;#039;activity-changed&amp;#039;, self.__activity_changed_cb)&lt;br /&gt;
&lt;br /&gt;
        # More DND stuff&lt;br /&gt;
        self.add_events(gtk.gdk.BUTTON_PRESS_MASK |&lt;br /&gt;
                        gtk.gdk.POINTER_MOTION_HINT_MASK)&lt;br /&gt;
        self.connect(&amp;#039;motion-notify-event&amp;#039;, self.__motion_notify_event_cb)&lt;br /&gt;
        self.connect(&amp;#039;button-press-event&amp;#039;, self.__button_press_event_cb)&lt;br /&gt;
        self.connect(&amp;#039;drag-begin&amp;#039;, self.__drag_begin_cb)&lt;br /&gt;
        self.connect(&amp;#039;drag-motion&amp;#039;, self.__drag_motion_cb)&lt;br /&gt;
        self.connect(&amp;#039;drag-drop&amp;#039;, self.__drag_drop_cb)&lt;br /&gt;
        self.connect(&amp;#039;drag-data-received&amp;#039;, self.__drag_data_received_cb)&lt;br /&gt;
&lt;br /&gt;
    def _add_activity(self, activity_info):&lt;br /&gt;
        icon = ActivityIcon(activity_info)&lt;br /&gt;
        icon.connect(&amp;#039;erase-activated&amp;#039;, self.__erase_activated_cb)&lt;br /&gt;
        icon.props.size = style.STANDARD_ICON_SIZE&lt;br /&gt;
        self._layout.append(icon)&lt;br /&gt;
&lt;br /&gt;
    def __erase_activated_cb(self, activity_icon, bundle_id):&lt;br /&gt;
        self.emit(&amp;#039;erase-activated&amp;#039;, bundle_id)&lt;br /&gt;
&lt;br /&gt;
    def _get_activities_cb(self, activity_list):&lt;br /&gt;
        for info in activity_list:&lt;br /&gt;
            if info.favorite and info.bundle_id != &amp;quot;org.laptop.JournalActivity&amp;quot;:&lt;br /&gt;
                self._add_activity(info)&lt;br /&gt;
&lt;br /&gt;
    def __activity_added_cb(self, activity_registry, activity_info):&lt;br /&gt;
        if activity_info.favorite and \&lt;br /&gt;
                activity_info.bundle_id != &amp;quot;org.laptop.JournalActivity&amp;quot;:&lt;br /&gt;
            self._add_activity(activity_info)&lt;br /&gt;
&lt;br /&gt;
    def _find_activity_icon(self, bundle_id, version):&lt;br /&gt;
        for icon in self._box.get_children():&lt;br /&gt;
            if isinstance(icon, ActivityIcon) and \&lt;br /&gt;
                    icon.bundle_id == bundle_id and icon.version == version:&lt;br /&gt;
                return icon&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
    def __activity_removed_cb(self, activity_registry, activity_info):&lt;br /&gt;
        icon = self._find_activity_icon(activity_info.bundle_id,&lt;br /&gt;
                activity_info.version)&lt;br /&gt;
        if icon is not None:&lt;br /&gt;
            self._layout.remove(icon)&lt;br /&gt;
&lt;br /&gt;
    def __activity_changed_cb(self, activity_registry, activity_info):&lt;br /&gt;
        if activity_info.bundle_id == &amp;#039;org.laptop.JournalActivity&amp;#039;:&lt;br /&gt;
            return&lt;br /&gt;
        icon = self._find_activity_icon(activity_info.bundle_id,&lt;br /&gt;
                activity_info.version)&lt;br /&gt;
        if icon is not None:&lt;br /&gt;
            self._box.remove(icon)&lt;br /&gt;
        if activity_info.favorite:&lt;br /&gt;
            self._add_activity(activity_info)&lt;br /&gt;
&lt;br /&gt;
    def do_size_allocate(self, allocation):&lt;br /&gt;
        width = allocation.width        &lt;br /&gt;
        height = allocation.height&lt;br /&gt;
&lt;br /&gt;
        min_w_, my_icon_width = self._my_icon.get_width_request()&lt;br /&gt;
        min_h_, my_icon_height = self._my_icon.get_height_request(my_icon_width)&lt;br /&gt;
        x = (width - my_icon_width) / 2&lt;br /&gt;
        y = (height - my_icon_height - style.GRID_CELL_SIZE) / 2&lt;br /&gt;
        self._layout.move_icon(self._my_icon, x, y, locked=True)&lt;br /&gt;
&lt;br /&gt;
        min_w_, icon_width = self._current_activity.get_width_request()&lt;br /&gt;
        min_h_, icon_height = \&lt;br /&gt;
                self._current_activity.get_height_request(icon_width)&lt;br /&gt;
        x = (width - icon_width) / 2&lt;br /&gt;
        y = (height - my_icon_height - style.GRID_CELL_SIZE) / 2 + \&lt;br /&gt;
                my_icon_height + style.DEFAULT_PADDING&lt;br /&gt;
        self._layout.move_icon(self._current_activity, x, y, locked=True)&lt;br /&gt;
&lt;br /&gt;
        hippo.Canvas.do_size_allocate(self, allocation)&lt;br /&gt;
&lt;br /&gt;
    def enable_xo_palette(self):&lt;br /&gt;
        self._my_icon.enable_palette()&lt;br /&gt;
        if self._my_icon.register_menu is not None:&lt;br /&gt;
            self._my_icon.register_menu.connect(&amp;#039;activate&amp;#039;, &lt;br /&gt;
                                                self.__register_activate_cb)&lt;br /&gt;
&lt;br /&gt;
    # TODO: Dnd methods. This should be merged somehow inside hippo-canvas.&lt;br /&gt;
    def __button_press_event_cb(self, widget, event):&lt;br /&gt;
        if event.button == 1 and event.type == gtk.gdk.BUTTON_PRESS:&lt;br /&gt;
            self._last_clicked_icon = self._get_icon_at_coords(event.x, event.y)&lt;br /&gt;
            if self._last_clicked_icon is not None:&lt;br /&gt;
                self._pressed_button = event.button&lt;br /&gt;
                self._press_start_x = event.x&lt;br /&gt;
                self._press_start_y = event.y&lt;br /&gt;
&lt;br /&gt;
        return False&lt;br /&gt;
&lt;br /&gt;
    def _get_icon_at_coords(self, x, y):&lt;br /&gt;
        for icon in self._box.get_children():&lt;br /&gt;
            icon_x, icon_y = icon.get_context().translate_to_widget(icon)&lt;br /&gt;
            icon_width, icon_height = icon.get_allocation()&lt;br /&gt;
&lt;br /&gt;
            if (x &amp;gt;= icon_x ) and (x &amp;lt;= icon_x + icon_width) and \&lt;br /&gt;
                    (y &amp;gt;= icon_y ) and (y &amp;lt;= icon_y + icon_height) and \&lt;br /&gt;
                    isinstance(icon, ActivityIcon):&lt;br /&gt;
                return icon&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
    def __motion_notify_event_cb(self, widget, event):&lt;br /&gt;
        if not self._pressed_button:&lt;br /&gt;
            return False&lt;br /&gt;
        &lt;br /&gt;
        # if the mouse button is not pressed, no drag should occurr&lt;br /&gt;
        if not event.state &amp;amp; gtk.gdk.BUTTON1_MASK:&lt;br /&gt;
            self._pressed_button = None&lt;br /&gt;
            return False&lt;br /&gt;
&lt;br /&gt;
        if event.is_hint:&lt;br /&gt;
            x, y, state_ = event.window.get_pointer()&lt;br /&gt;
        else:&lt;br /&gt;
            x = event.x&lt;br /&gt;
            y = event.y&lt;br /&gt;
&lt;br /&gt;
        if widget.drag_check_threshold(int(self._press_start_x),&lt;br /&gt;
                                       int(self._press_start_y),&lt;br /&gt;
                                       int(x),&lt;br /&gt;
                                       int(y)):&lt;br /&gt;
            context_ = widget.drag_begin([_ICON_DND_TARGET],&lt;br /&gt;
                                         gtk.gdk.ACTION_MOVE,&lt;br /&gt;
                                         1,&lt;br /&gt;
                                         event)&lt;br /&gt;
        return False&lt;br /&gt;
&lt;br /&gt;
    def __drag_begin_cb(self, widget, context):&lt;br /&gt;
        icon_file_name = self._last_clicked_icon.props.file_name&lt;br /&gt;
        # TODO: we should get the pixbuf from the widget, so it has colors, etc&lt;br /&gt;
        pixbuf = gtk.gdk.pixbuf_new_from_file(icon_file_name)&lt;br /&gt;
        &lt;br /&gt;
        hot_spot = style.zoom(10)&lt;br /&gt;
        context.set_icon_pixbuf(pixbuf, hot_spot, hot_spot)&lt;br /&gt;
&lt;br /&gt;
    def __drag_motion_cb(self, widget, context, x, y, time):&lt;br /&gt;
        if self._last_clicked_icon is not None:&lt;br /&gt;
            context.drag_status(context.suggested_action, time)&lt;br /&gt;
            return True&lt;br /&gt;
        else:&lt;br /&gt;
            return False&lt;br /&gt;
&lt;br /&gt;
    def __drag_drop_cb(self, widget, context, x, y, time):&lt;br /&gt;
        if self._last_clicked_icon is not None:&lt;br /&gt;
            self.drag_get_data(context, _ICON_DND_TARGET[0])&lt;br /&gt;
&lt;br /&gt;
            self._layout.move_icon(self._last_clicked_icon, x, y)&lt;br /&gt;
&lt;br /&gt;
            self._pressed_button = None&lt;br /&gt;
            self._press_start_x = None&lt;br /&gt;
            self._press_start_y = None&lt;br /&gt;
            self._last_clicked_icon = None&lt;br /&gt;
&lt;br /&gt;
            return True&lt;br /&gt;
        else:&lt;br /&gt;
            return False&lt;br /&gt;
&lt;br /&gt;
    def __drag_data_received_cb(self, widget, context, x, y, selection_data,&lt;br /&gt;
                                info, time):&lt;br /&gt;
        context.drop_finish(success=True, time=time)&lt;br /&gt;
&lt;br /&gt;
    def _set_layout(self, layout):&lt;br /&gt;
        if layout not in _LAYOUT_MAP:&lt;br /&gt;
            raise ValueError(&amp;#039;Unknown favorites layout: %r&amp;#039; % layout)&lt;br /&gt;
        if type(self._layout) != _LAYOUT_MAP[layout]:&lt;br /&gt;
            self._box.clear()&lt;br /&gt;
            self._layout = _LAYOUT_MAP[layout]()&lt;br /&gt;
            self._box.set_layout(self._layout)&lt;br /&gt;
&lt;br /&gt;
            self._my_icon = _MyIcon(style.XLARGE_ICON_SIZE)&lt;br /&gt;
            self._layout.append(self._my_icon, locked=True)&lt;br /&gt;
&lt;br /&gt;
            self._current_activity = CurrentActivityIcon()&lt;br /&gt;
            self._layout.append(self._current_activity, locked=True)&lt;br /&gt;
&lt;br /&gt;
            registry = activity.get_registry()&lt;br /&gt;
            registry.get_activities_async(reply_handler=self._get_activities_cb)&lt;br /&gt;
&lt;br /&gt;
            if self._layout.allow_dnd():&lt;br /&gt;
                self.drag_source_set(0, [], 0)&lt;br /&gt;
                self.drag_dest_set(0, [], 0)&lt;br /&gt;
            else:&lt;br /&gt;
                self.drag_source_unset()&lt;br /&gt;
                self.drag_dest_unset()&lt;br /&gt;
&lt;br /&gt;
    layout = property(None, _set_layout)&lt;br /&gt;
&lt;br /&gt;
    def add_alert(self, alert):&lt;br /&gt;
        if self._alert is not None:&lt;br /&gt;
            self.remove_alert()&lt;br /&gt;
        alert.set_size_request(gtk.gdk.screen_width(), -1)&lt;br /&gt;
        self._alert = hippo.CanvasWidget(widget=alert)&lt;br /&gt;
        self._box.append(self._alert, hippo.PACK_FIXED)&lt;br /&gt;
&lt;br /&gt;
    def remove_alert(self):&lt;br /&gt;
        self._box.remove(self._alert)&lt;br /&gt;
        self._alert = None&lt;br /&gt;
&lt;br /&gt;
    def __register_activate_cb(self, menuitem):&lt;br /&gt;
        alert = Alert()&lt;br /&gt;
        try:&lt;br /&gt;
            schoolserver.register_laptop()&lt;br /&gt;
        except RegisterError, e:&lt;br /&gt;
            alert.props.title = _(&amp;#039;Registration Failed&amp;#039;)&lt;br /&gt;
            alert.props.msg = _(&amp;#039;%s&amp;#039;) % e&lt;br /&gt;
        else:    &lt;br /&gt;
            alert.props.title = _(&amp;#039;Registration Successful&amp;#039;)&lt;br /&gt;
            alert.props.msg = _(&amp;#039;You are now registered with your school server.&amp;#039;) &lt;br /&gt;
            palette = self._my_icon.get_palette()&lt;br /&gt;
            palette.menu.remove(menuitem)&lt;br /&gt;
&lt;br /&gt;
        ok_icon = Icon(icon_name=&amp;#039;dialog-ok&amp;#039;)&lt;br /&gt;
        alert.add_button(gtk.RESPONSE_OK, _(&amp;#039;Ok&amp;#039;), ok_icon)&lt;br /&gt;
&lt;br /&gt;
        self.add_alert(alert)&lt;br /&gt;
        alert.connect(&amp;#039;response&amp;#039;, self.__register_alert_response_cb)            &lt;br /&gt;
            &lt;br /&gt;
    def __register_alert_response_cb(self, alert, response_id):&lt;br /&gt;
        self.remove_alert()&lt;br /&gt;
&lt;br /&gt;
class ActivityIcon(CanvasIcon):&lt;br /&gt;
    __gtype_name__ = &amp;#039;SugarFavoriteActivityIcon&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    __gsignals__ = {&lt;br /&gt;
        &amp;#039;erase-activated&amp;#039; : (gobject.SIGNAL_RUN_FIRST,&lt;br /&gt;
                             gobject.TYPE_NONE, ([str])),&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, activity_info):&lt;br /&gt;
        CanvasIcon.__init__(self, cache=True, file_name=activity_info.icon)&lt;br /&gt;
        self._activity_info = activity_info&lt;br /&gt;
        self._uncolor()&lt;br /&gt;
        self.connect(&amp;#039;hovering-changed&amp;#039;, self.__hovering_changed_event_cb)&lt;br /&gt;
        self.connect(&amp;#039;button-release-event&amp;#039;, self.__button_release_event_cb)&lt;br /&gt;
&lt;br /&gt;
    def create_palette(self):&lt;br /&gt;
        palette = ActivityPalette(self._activity_info)&lt;br /&gt;
        palette.connect(&amp;#039;erase-activated&amp;#039;, self.__erase_activated_cb)&lt;br /&gt;
        return palette&lt;br /&gt;
&lt;br /&gt;
    def __erase_activated_cb(self, palette):&lt;br /&gt;
        self.emit(&amp;#039;erase-activated&amp;#039;, self._activity_info.bundle_id)&lt;br /&gt;
&lt;br /&gt;
    def _color(self):&lt;br /&gt;
        self.props.xo_color = get_profile().color&lt;br /&gt;
&lt;br /&gt;
    def _uncolor(self):&lt;br /&gt;
        self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()&lt;br /&gt;
        self.props.fill_color = style.COLOR_TRANSPARENT.get_svg()&lt;br /&gt;
&lt;br /&gt;
    def __hovering_changed_event_cb(self, icon, hovering):&lt;br /&gt;
        if hovering:&lt;br /&gt;
            self._color()&lt;br /&gt;
        else:&lt;br /&gt;
            self._uncolor()&lt;br /&gt;
&lt;br /&gt;
    def __button_release_event_cb(self, icon, event):&lt;br /&gt;
        self.palette.popdown(immediate=True)&lt;br /&gt;
        self._uncolor()&lt;br /&gt;
        view.Shell.get_instance().start_activity(self._activity_info.bundle_id)&lt;br /&gt;
&lt;br /&gt;
    def get_bundle_id(self):&lt;br /&gt;
        return self._activity_info.bundle_id&lt;br /&gt;
    bundle_id = property(get_bundle_id, None)&lt;br /&gt;
&lt;br /&gt;
    def get_version(self):&lt;br /&gt;
        return self._activity_info.version&lt;br /&gt;
    version = property(get_version, None)&lt;br /&gt;
&lt;br /&gt;
    def _get_installation_time(self):&lt;br /&gt;
        return self._activity_info.installation_time&lt;br /&gt;
    installation_time = property(_get_installation_time, None)&lt;br /&gt;
&lt;br /&gt;
    def _get_fixed_position(self):&lt;br /&gt;
        return self._activity_info.position&lt;br /&gt;
    fixed_position = property(_get_fixed_position, None)&lt;br /&gt;
&lt;br /&gt;
class CurrentActivityIcon(CanvasIcon, hippo.CanvasItem):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
        CanvasIcon.__init__(self, cache=True)&lt;br /&gt;
        self._home_model = shellmodel.get_instance().get_home()&lt;br /&gt;
&lt;br /&gt;
        if self._home_model.get_active_activity() is not None:&lt;br /&gt;
            self._update(self._home_model.get_active_activity())&lt;br /&gt;
&lt;br /&gt;
        self._home_model.connect(&amp;#039;active-activity-changed&amp;#039;,&lt;br /&gt;
                                 self.__active_activity_changed_cb)&lt;br /&gt;
&lt;br /&gt;
        self.connect(&amp;#039;button-release-event&amp;#039;, self.__button_release_event_cb)&lt;br /&gt;
&lt;br /&gt;
    def __button_release_event_cb(self, icon, event):&lt;br /&gt;
        self._home_model.get_active_activity().get_window().activate(1)&lt;br /&gt;
&lt;br /&gt;
    def _update(self, home_activity):&lt;br /&gt;
        self.props.file_name = home_activity.get_icon_path()&lt;br /&gt;
        self.props.xo_color = home_activity.get_icon_color()&lt;br /&gt;
        self.props.size = style.STANDARD_ICON_SIZE&lt;br /&gt;
&lt;br /&gt;
        if self.palette is not None:&lt;br /&gt;
            self.palette.destroy()&lt;br /&gt;
            self.palette = None&lt;br /&gt;
&lt;br /&gt;
        if home_activity.is_journal():&lt;br /&gt;
            palette = JournalPalette(home_activity)&lt;br /&gt;
        else:&lt;br /&gt;
            palette = CurrentActivityPalette(home_activity)&lt;br /&gt;
        self.set_palette(palette)&lt;br /&gt;
&lt;br /&gt;
    def __active_activity_changed_cb(self, home_model, home_activity):&lt;br /&gt;
        self._update(home_activity)&lt;br /&gt;
&lt;br /&gt;
class _MyIcon(MyIcon):&lt;br /&gt;
    def __init__(self, scale):&lt;br /&gt;
        MyIcon.__init__(self, scale)&lt;br /&gt;
&lt;br /&gt;
        self._power_manager = None&lt;br /&gt;
        self._profile = get_profile()&lt;br /&gt;
        self.register_menu = None&lt;br /&gt;
&lt;br /&gt;
    def enable_palette(self):&lt;br /&gt;
        palette_icon = Icon(icon_name=&amp;#039;computer-xo&amp;#039;, &lt;br /&gt;
                            icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,&lt;br /&gt;
                            xo_color=self._profile.color)&lt;br /&gt;
        palette = Palette(self._profile.nick_name,&lt;br /&gt;
                          #secondary_text=&amp;#039;Sample secondary label&amp;#039;,&lt;br /&gt;
                          icon=palette_icon)&lt;br /&gt;
&lt;br /&gt;
        item = MenuItem(_(&amp;#039;Control Panel&amp;#039;), &amp;#039;preferences-system&amp;#039;)&lt;br /&gt;
        item.connect(&amp;#039;activate&amp;#039;, self.__controlpanel_activate_cb)&lt;br /&gt;
        palette.menu.append(item)&lt;br /&gt;
        item.show()&lt;br /&gt;
&lt;br /&gt;
        item = MenuItem(_(&amp;#039;Restart&amp;#039;), &amp;#039;system-restart&amp;#039;)&lt;br /&gt;
        item.connect(&amp;#039;activate&amp;#039;, self._reboot_activate_cb)&lt;br /&gt;
        palette.menu.append(item)&lt;br /&gt;
        item.show()&lt;br /&gt;
&lt;br /&gt;
        item = MenuItem(_(&amp;#039;Shutdown&amp;#039;), &amp;#039;system-shutdown&amp;#039;)&lt;br /&gt;
        item.connect(&amp;#039;activate&amp;#039;, self._shutdown_activate_cb)&lt;br /&gt;
        palette.menu.append(item)&lt;br /&gt;
        item.show()&lt;br /&gt;
&lt;br /&gt;
        if not self._profile.is_registered():&lt;br /&gt;
            self.register_menu = MenuItem(_(&amp;#039;Register&amp;#039;), &amp;#039;media-record&amp;#039;)&lt;br /&gt;
            palette.menu.append(self.register_menu)&lt;br /&gt;
            self.register_menu.show()&lt;br /&gt;
 &lt;br /&gt;
        self.set_palette(palette)&lt;br /&gt;
&lt;br /&gt;
    def _reboot_activate_cb(self, menuitem):&lt;br /&gt;
        session_manager = get_session_manager()&lt;br /&gt;
        session_manager.reboot()&lt;br /&gt;
&lt;br /&gt;
    def _shutdown_activate_cb(self, menuitem):&lt;br /&gt;
        session_manager = get_session_manager()&lt;br /&gt;
        session_manager.shutdown()&lt;br /&gt;
        &lt;br /&gt;
    def get_toplevel(self):&lt;br /&gt;
        return hippo.get_canvas_for_item(self).get_toplevel()&lt;br /&gt;
&lt;br /&gt;
    def __controlpanel_activate_cb(self, menuitem):&lt;br /&gt;
        panel = ControlPanel()&lt;br /&gt;
        panel.set_transient_for(self.get_toplevel())&lt;br /&gt;
        panel.show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Walter</name></author>
	</entry>
</feed>