<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Good job!<div><br></div><div>Only one thing to remove:</div><div><br></div><div><span style="color: rgb(68, 68, 68); font-size: 15px; line-height: 21px;">+    else:</span><br style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;"><span style="color: rgb(68, 68, 68); font-size: 15px; line-height: 21px;">+        pass</span></div><div><font color="#444444"><span style="font-size: 15px; line-height: 21px;"><br></span></font></div><div><font color="#444444"><span style="font-size: 15px; line-height: 21px;">;-)<br></span></font><br><div><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling">Date: Thu, 10 Jan 2013 10:19:49 -0200<br>From: ignacio@sugarlabs.org<br>To: sugar-devel@lists.sugarlabs.org<br>Subject: Re: [Sugar-devel] [PATCH] Add support for selecting new XO icon skin<br><br><div dir="ltr">I attached a couple of skins.<br><div>Please extract this file in ~/.sugar/</div><div>Thx.</div><div>Ignacio Rodríguez</div></div><div class="ecxgmail_extra"><br><br><div class="ecxgmail_quote">2013/1/10 Ignacio Rodríguez <span dir="ltr"><<a href="mailto:ignacio@sugarlabs.org">ignacio@sugarlabs.org</a>></span><br>
<blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex">This patch adds the ability fo the Sugar user to select a new skin for<br>
the XO icon from a collection of icons in ~/.sugar/skins. It is an<br>
extension of the aboutme panel, where the user is also able to change<br>
colors and the nick.<br>
<br>
This patch contains the modifications to model.py and view.py. It does<br>
not include the sample icons.<br>
<br>
Caveat: We need to discuss the mechanism for actually changing the<br>
icon, which is currently stored in /usr/share/icons/sugar/, which is<br>
read-only to Sugar users. Two ideas have been discussed so far: (1) to<br>
make the xo-computer.svg icon read-write; and (2) to add<br>
~/.sugar/icons/ to the head of the icon-themes list, so if a modified<br>
xo-computer is found there, it will be used to override the on ein<br>
/usr/share. This code assumes solution #1 above.<br>
<br>
For that reason try (for now) to do:<br>
chmod -R 777 /usr/share/icons/sugar/scalable/device/computer-xo.svg<br>
<br>
---<br>
 extensions/cpsection/aboutme/model.py |  18 +++++<br>
 extensions/cpsection/aboutme/view.py  | 146 +++++++++++++++++++++++++++++++---<br>
 2 files changed, 153 insertions(+), 11 deletions(-)<br>
<br>
diff --git a/extensions/cpsection/aboutme/model.py b/extensions/cpsection/aboutme/model.py<br>
index ad1de66..7395ae9 100644<br>
--- a/extensions/cpsection/aboutme/model.py<br>
+++ b/extensions/cpsection/aboutme/model.py<br>
@@ -17,6 +17,8 @@<br>
<br>
 from gettext import gettext as _<br>
 from gi.repository import GConf<br>
+import shutil<br>
+import os<br>
<br>
<br>
 _COLORS = {<br>
@@ -123,3 +125,19 @@ def set_color_xo(color):<br>
     client = GConf.Client.get_default()<br>
     client.set_string('/desktop/sugar/user/color', color)<br>
     return 1<br>
+<br>
+<br>
+def set_xo_icon(path, icon_name):<br>
+    """ Replace computer-xo.svg icon """<br>
+    pt = os.path.join(os.path.expanduser('~'), '.current')<br>
+    fd = open(pt, 'w')<br>
+    fd.write(icon_name)<br>
+    fd.close()<br>
+    if os.path.exists('/usr/share/icons/sugar/scalable/device/'):<br>
+        iconpath = '/usr/share/icons/sugar/scalable/device/computer-xo.svg'<br>
+        shutil.copy(path, iconpath)<br>
+    if os.path.exists('/opt/sweets/sugar-artwork/share/icons/sugar/scalable/device'):<br>
+        iconpath = '/opt/sweets/sugar-artwork/share/icons/sugar/scalable/device/computer-xo.svg'<br>
+        shutil.copy(path, iconpath)<br>
+    else:<br>
+        pass<br>
diff --git a/extensions/cpsection/aboutme/view.py b/extensions/cpsection/aboutme/view.py<br>
index 2d4b1e8..ac01bc2 100644<br>
--- a/extensions/cpsection/aboutme/view.py<br>
+++ b/extensions/cpsection/aboutme/view.py<br>
@@ -16,15 +16,19 @@<br>
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA<br>
<br>
 from gi.repository import Gtk<br>
+from gi.repository import Gdk<br>
+from gi.repository import GConf<br>
 from gi.repository import GObject<br>
 from gettext import gettext as _<br>
<br>
 from sugar3.graphics import style<br>
 from sugar3.graphics.xocolor import XoColor, colors<br>
 from sugar3.graphics.icon import CanvasIcon<br>
+from sugar3.graphics.icon import Icon<br>
<br>
 from jarabe.controlpanel.sectionview import SectionView<br>
 from jarabe.controlpanel.inlinealert import InlineAlert<br>
+import os<br>
<br>
 _STROKE_COLOR = 0<br>
 _FILL_COLOR = 1<br>
@@ -118,8 +122,8 @@ class ColorPicker(CanvasIcon):<br>
                           ([object])),<br>
         }<br>
<br>
-    def __init__(self, picker):<br>
-        CanvasIcon.__init__(self, icon_name='computer-xo',<br>
+    def __init__(self, picker, icon):<br>
+        CanvasIcon.__init__(self, icon_name=icon,<br>
                             pixel_size=style.XLARGE_ICON_SIZE)<br>
         self._picker = picker<br>
         self._color = None<br>
@@ -156,25 +160,58 @@ class AboutMe(SectionView):<br>
         self._nick_valid = True<br>
<br>
         self.set_border_width(style.DEFAULT_SPACING * 2)<br>
-        self.set_spacing(style.DEFAULT_SPACING)<br>
+        #self.set_spacing(style.DEFAULT_SPACING)<br>
         self._group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)<br>
<br>
         self._color_label = Gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
         self._color_box = Gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
         self._color_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
         self._color_alert = None<br>
+        # Examples. #<br>
+        self._scroll_icon = Gtk.ScrolledWindow()<br>
+        self._scroll_icon.set_policy(Gtk.PolicyType.AUTOMATIC,<br>
+        Gtk.PolicyType.NEVER)<br>
+        self._hbox_icon = Gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
+        self._scroll_icon.add_with_viewport(self._hbox_icon)<br>
+        self._frame_icon = Gtk.Frame()<br>
+        self._vbox_icon = Gtk.VBox()<br>
+        self._vbox_icon.pack_start(self._scroll_icon, True, True, 0)<br>
+<br>
+        self._alert = InlineAlert()<br>
+        label_color = \<br>
+Gtk.Label(_('Example icons: Copyright (c) TheNounProject'))<br>
+        label_color.modify_fg(Gtk.StateType.NORMAL,<br>
+        style.COLOR_SELECTION_GREY.get_gdk_color())<br>
+        self._vbox_icon.pack_start(label_color, False, False, 0)<br>
+        self._vbox_icon.pack_start(self._alert, False, False, 0)<br>
+<br>
+        self._frame_icon.add(self._vbox_icon)<br>
+        self._widgets = []<br>
+        self._widget = []<br>
+        self._icons_images = []<br>
+        self._join = os.path.join(os.path.expanduser('~'), '.sugar', 'skins')<br>
+        if os.path.exists(os.path.join(self._join)):<br>
+                self._path = self._join<br>
+                self._icons = os.listdir(self._path)<br>
+                self._icons.sort()<br>
+<br>
+        for x in self._icons:<br>
+                if "svg" in x:<br>
+                        self._create_pixbuf_button(x[:-4])<br>
+                else:<br>
+                    pass<br>
<br>
         self._pickers = {<br>
-            _PREVIOUS_FILL_COLOR: ColorPicker(_PREVIOUS_FILL_COLOR),<br>
-            _NEXT_FILL_COLOR: ColorPicker(_NEXT_FILL_COLOR),<br>
-            _CURRENT_COLOR: ColorPicker(_CURRENT_COLOR),<br>
-            _NEXT_STROKE_COLOR: ColorPicker(_NEXT_STROKE_COLOR),<br>
-            _PREVIOUS_STROKE_COLOR: ColorPicker(_PREVIOUS_STROKE_COLOR),<br>
+            _PREVIOUS_FILL_COLOR: ColorPicker(_PREVIOUS_FILL_COLOR, 'computer-xo'),<br>
+            _NEXT_FILL_COLOR: ColorPicker(_NEXT_FILL_COLOR, 'computer-xo'),<br>
+            _CURRENT_COLOR: ColorPicker(_CURRENT_COLOR, 'computer-xo'),<br>
+            _NEXT_STROKE_COLOR: ColorPicker(_NEXT_STROKE_COLOR, 'computer-xo'),<br>
+            _PREVIOUS_STROKE_COLOR: ColorPicker(_PREVIOUS_STROKE_COLOR, 'computer-xo'),<br>
         }<br>
<br>
         self._setup_color()<br>
-        initial_color = XoColor(self._model.get_color_xo())<br>
-        self._update_pickers(initial_color)<br>
+        self.initial_color = XoColor(self._model.get_color_xo())<br>
+        self._update_pickers(self.initial_color)<br>
<br>
         self._nick_box = Gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
         self._nick_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING)<br>
@@ -182,6 +219,82 @@ class AboutMe(SectionView):<br>
         self._nick_alert = None<br>
         self._setup_nick()<br>
         self.setup()<br>
+        self.pack_end(self._frame_icon, False, False, style.DEFAULT_SPACING)<br>
+        self._frame_icon.show_all()<br>
+        self._alert.hide()<br>
+<br>
+    def _update_icon(self, widget, event):<br>
+        self._icon_name = widget.get_tooltip_text()<br>
+        self._current.set_sensitive(True)<br>
+        widget.set_sensitive(False)<br>
+        # Removes. #<br>
+        for x in self._widget:<br>
+                self._color_alert_box.remove(x)<br>
+        self.remove(self._color_box)<br>
+        for x in self._widgets:<br>
+            self._color_box.remove(x)<br>
+            try:<br>
+                self._color_label.remove(x)<br>
+            except:<br>
+                pass<br>
+            try:<br>
+                self._group.remove_widget(x)<br>
+            except:<br>
+                pass<br>
+<br>
+        self._pickers = {<br>
+        _PREVIOUS_FILL_COLOR: ColorPicker(_PREVIOUS_FILL_COLOR, self._icon_name),<br>
+        _NEXT_FILL_COLOR: ColorPicker(_NEXT_FILL_COLOR, self._icon_name),<br>
+        _CURRENT_COLOR: ColorPicker(_CURRENT_COLOR, self._icon_name),<br>
+        _NEXT_STROKE_COLOR: ColorPicker(_NEXT_STROKE_COLOR, self._icon_name),<br>
+        _PREVIOUS_STROKE_COLOR: ColorPicker(_PREVIOUS_STROKE_COLOR, self._icon_name),<br>
+        }<br>
+        try:<br>
+                self._update_pickers(self._current_color)<br>
+        except AttributeError:<br>
+                self._update_pickers(self.initial_color)<br>
+        self.setup()<br>
+        self._setup_color()<br>
+        self.show()<br>
+        self._current = widget<br>
+        self.restart_alerts.append('icon')<br>
+        if 'icon' in self.restart_alerts:<br>
+            self._alert.props.msg = self.restart_msg<br>
+            self._alert.show()<br>
+        path = self._path + "/" + self._icon_name + ".svg"<br>
+        self._model.set_xo_icon(path, self._icon_name)<br>
+        self.needs_restart = True<br>
+<br>
+    def _create_pixbuf_button(self, name):<br>
+        icon_theme = Gtk.IconTheme.get_default()<br>
+        icon_theme.append_search_path(self._path)<br>
+        self._icon_area = Gtk.EventBox()<br>
+        try:<br>
+                pt = os.path.join(os.path.expanduser('~'), '.current')<br>
+                fd = open(pt, 'r')<br>
+                self._ex_icon = fd.read()<br>
+                fd.close()<br>
+        except:<br>
+                self._ex_icon = '1xo'<br>
+        if name == self._ex_icon:<br>
+                self._icon_area.set_sensitive(False)<br>
+                self._current = self._icon_area<br>
+        if name == '1xo' and self._ex_icon == '1xo':<br>
+                self._icon_area.set_sensitive(False)<br>
+                self._image = Icon(icon_name=name)<br>
+                self._current = self._icon_area<br>
+        self._image = Icon(icon_name=name, pixel_size=100)<br>
+        self._client = GConf.Client.get_default()<br>
+        color = self._client.get_string('/desktop/sugar/user/color')<br>
+        self._color = XoColor(color)<br>
+        self._icon_area.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)<br>
+        self._icon_area.connect('button-press-event', self._update_icon)<br>
+        self._icon_area.set_tooltip_text(name)<br>
+        self._icon_area.props.has_tooltip = False<br>
+        self._image.set_xo_color(self._color)<br>
+        self._icon_area.add(self._image)<br>
+        self._hbox_icon.pack_start(self._icon_area, True, True, 0)<br>
+        self._icons_images.append(self._image)<br>
<br>
     def _setup_nick(self):<br>
         self._nick_entry = Gtk.Entry()<br>
@@ -215,32 +328,37 @@ class AboutMe(SectionView):<br>
         self._group.add_widget(label_color)<br>
         self._color_label.pack_start(label_color, False, True, 0)<br>
         label_color.show()<br>
+        self._widgets.append(label_color)<br>
<br>
         for picker_index in sorted(self._pickers.keys()):<br>
             if picker_index == _CURRENT_COLOR:<br>
                 left_separator = Gtk.SeparatorToolItem()<br>
                 left_separator.show()<br>
                 self._color_box.pack_start(left_separator, False, True, 0)<br>
-<br>
+                self._widgets.append(left_separator)<br>
             picker = self._pickers[picker_index]<br>
             picker.show()<br>
             self._color_box.pack_start(picker, False, True, 0)<br>
+            self._widgets.append(picker)<br>
<br>
             if picker_index == _CURRENT_COLOR:<br>
                 right_separator = Gtk.SeparatorToolItem()<br>
                 right_separator.show()<br>
                 self._color_box.pack_start(right_separator, False, True, 0)<br>
+                self._widgets.append(right_separator)<br>
<br>
         label_color_error = Gtk.Label()<br>
         self._group.add_widget(label_color_error)<br>
         self._color_alert_box.pack_start(label_color_error, False, True, 0)<br>
         label_color_error.show()<br>
+        self._widgets.append(label_color)<br>
<br>
         self._color_alert = InlineAlert()<br>
         self._color_alert_box.pack_start(self._color_alert, True, True, 0)<br>
         if 'color' in self.restart_alerts:<br>
             self._color_alert.props.msg = self.restart_msg<br>
             self._color_alert.show()<br>
+        self._widgets.append(self._color_alert)<br>
<br>
         self._center_in_panel = Gtk.Alignment.new(0.5, 0, 0, 0)<br>
         self._center_in_panel.add(self._color_box)<br>
@@ -266,6 +384,9 @@ class AboutMe(SectionView):<br>
         self._model.undo()<br>
         self._nick_alert.hide()<br>
         self._color_alert.hide()<br>
+        self._alert.hide()<br>
+        path = self._path + "/" + self._ex_icon + '.svg'<br>
+        self._model.set_xo_icon(path, self._ex_icon)<br>
<br>
     def _update_pickers(self, color):<br>
         for picker in self._pickers.values():<br>
@@ -304,6 +425,9 @@ class AboutMe(SectionView):<br>
<br>
     def __color_changed_cb(self, colorpicker, color):<br>
         self._model.set_color_xo(color.to_string())<br>
+        for x in self._icons_images:<br>
+            x.set_xo_color(color)<br>
+            x.show()<br>
         self.needs_restart = True<br>
         self._color_alert.props.msg = self.restart_msg<br>
         self._color_valid = True<br>
<span class="ecxHOEnZb"><font color="#888888">--<br>
1.7.11.7<br>
<br>
</font></span></blockquote></div><br></div>
<br>_______________________________________________
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel</div></div>                                           </div></body>
</html>