[Sugar-devel] [PATCH] Add support for selecting new XO icon skin
This patch adds the ability fo the Sugar user to select a new skin for the XO icon from a collection of icons in ~/.sugar/skins. It is an extension of the aboutme panel, where the user is also able to change colors and the nick. This patch contains the modifications to model.py and view.py. It does not include the sample icons. Caveat: We need to discuss the mechanism for actually changing the icon, which is currently stored in /usr/share/icons/sugar/, which is read-only to Sugar users. Two ideas have been discussed so far: (1) to make the xo-computer.svg icon read-write; and (2) to add ~/.sugar/icons/ to the head of the icon-themes list, so if a modified xo-computer is found there, it will be used to override the on ein /usr/share. This code assumes solution #1 above. For that reason try (for now) to do: chmod -R 777 /usr/share/icons/sugar/scalable/device/computer-xo.svg --- extensions/cpsection/aboutme/model.py | 18 + extensions/cpsection/aboutme/view.py | 146 +++--- 2 files changed, 153 insertions(+), 11 deletions(-) diff --git a/extensions/cpsection/aboutme/model.py b/extensions/cpsection/aboutme/model.py index ad1de66..7395ae9 100644 --- a/extensions/cpsection/aboutme/model.py +++ b/extensions/cpsection/aboutme/model.py @@ -17,6 +17,8 @@ from gettext import gettext as _ from gi.repository import GConf +import shutil +import os _COLORS = { @@ -123,3 +125,19 @@ def set_color_xo(color): client = GConf.Client.get_default() client.set_string('/desktop/sugar/user/color', color) return 1 + + +def set_xo_icon(path, icon_name): + Replace computer-xo.svg icon +pt = os.path.join(os.path.expanduser('~'), '.current') +fd = open(pt, 'w') +fd.write(icon_name) +fd.close() +if os.path.exists('/usr/share/icons/sugar/scalable/device/'): +iconpath = '/usr/share/icons/sugar/scalable/device/computer-xo.svg' +shutil.copy(path, iconpath) +if os.path.exists('/opt/sweets/sugar-artwork/share/icons/sugar/scalable/device'): +iconpath = '/opt/sweets/sugar-artwork/share/icons/sugar/scalable/device/computer-xo.svg' +shutil.copy(path, iconpath) +else: +pass diff --git a/extensions/cpsection/aboutme/view.py b/extensions/cpsection/aboutme/view.py index 2d4b1e8..ac01bc2 100644 --- a/extensions/cpsection/aboutme/view.py +++ b/extensions/cpsection/aboutme/view.py @@ -16,15 +16,19 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GConf from gi.repository import GObject from gettext import gettext as _ from sugar3.graphics import style from sugar3.graphics.xocolor import XoColor, colors from sugar3.graphics.icon import CanvasIcon +from sugar3.graphics.icon import Icon from jarabe.controlpanel.sectionview import SectionView from jarabe.controlpanel.inlinealert import InlineAlert +import os _STROKE_COLOR = 0 _FILL_COLOR = 1 @@ -118,8 +122,8 @@ class ColorPicker(CanvasIcon): ([object])), } -def __init__(self, picker): -CanvasIcon.__init__(self, icon_name='computer-xo', +def __init__(self, picker, icon): +CanvasIcon.__init__(self, icon_name=icon, pixel_size=style.XLARGE_ICON_SIZE) self._picker = picker self._color = None @@ -156,25 +160,58 @@ class AboutMe(SectionView): self._nick_valid = True self.set_border_width(style.DEFAULT_SPACING * 2) -self.set_spacing(style.DEFAULT_SPACING) +#self.set_spacing(style.DEFAULT_SPACING) self._group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) self._color_label = Gtk.HBox(spacing=style.DEFAULT_SPACING) self._color_box = Gtk.HBox(spacing=style.DEFAULT_SPACING) self._color_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING) self._color_alert = None +# Examples. # +self._scroll_icon = Gtk.ScrolledWindow() +self._scroll_icon.set_policy(Gtk.PolicyType.AUTOMATIC, +Gtk.PolicyType.NEVER) +self._hbox_icon = Gtk.HBox(spacing=style.DEFAULT_SPACING) +self._scroll_icon.add_with_viewport(self._hbox_icon) +self._frame_icon = Gtk.Frame() +self._vbox_icon = Gtk.VBox() +self._vbox_icon.pack_start(self._scroll_icon, True, True, 0) + +self._alert = InlineAlert() +label_color = \ +Gtk.Label(_('Example icons: Copyright (c) TheNounProject')) +label_color.modify_fg(Gtk.StateType.NORMAL, +style.COLOR_SELECTION_GREY.get_gdk_color()) +self._vbox_icon.pack_start(label_color, False, False, 0) +self._vbox_icon.pack_start(self._alert, False, False, 0) + +self._frame_icon.add(self._vbox_icon) +self._widgets = [] +self._widget = [] +self._icons_images = [] +self._join = os.path.join(os.path.expanduser('~'), '.sugar',
[Sugar-devel] [ASLO] Release WikipediaPT-35
Activity Homepage: http://activities.sugarlabs.org/addon/4631 Sugar Platform: 0.82 - 0.98 Download Now: http://activities.sugarlabs.org/downloads/file/28427/wikipedia_pt-35.xo Release notes: The first release of wikipedia in portuguese. Sugar Labs Activities http://activities.sugarlabs.org ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [PATCH] Add support for selecting new XO icon skin
Good job! Only one thing to remove: +else:+pass ;-) Date: Thu, 10 Jan 2013 10:19:49 -0200 From: igna...@sugarlabs.org To: sugar-devel@lists.sugarlabs.org Subject: Re: [Sugar-devel] [PATCH] Add support for selecting new XO icon skin I attached a couple of skins. Please extract this file in ~/.sugar/Thx.Ignacio Rodríguez 2013/1/10 Ignacio Rodríguez igna...@sugarlabs.org This patch adds the ability fo the Sugar user to select a new skin for the XO icon from a collection of icons in ~/.sugar/skins. It is an extension of the aboutme panel, where the user is also able to change colors and the nick. This patch contains the modifications to model.py and view.py. It does not include the sample icons. Caveat: We need to discuss the mechanism for actually changing the icon, which is currently stored in /usr/share/icons/sugar/, which is read-only to Sugar users. Two ideas have been discussed so far: (1) to make the xo-computer.svg icon read-write; and (2) to add ~/.sugar/icons/ to the head of the icon-themes list, so if a modified xo-computer is found there, it will be used to override the on ein /usr/share. This code assumes solution #1 above. For that reason try (for now) to do: chmod -R 777 /usr/share/icons/sugar/scalable/device/computer-xo.svg --- extensions/cpsection/aboutme/model.py | 18 + extensions/cpsection/aboutme/view.py | 146 +++--- 2 files changed, 153 insertions(+), 11 deletions(-) diff --git a/extensions/cpsection/aboutme/model.py b/extensions/cpsection/aboutme/model.py index ad1de66..7395ae9 100644 --- a/extensions/cpsection/aboutme/model.py +++ b/extensions/cpsection/aboutme/model.py @@ -17,6 +17,8 @@ from gettext import gettext as _ from gi.repository import GConf +import shutil +import os _COLORS = { @@ -123,3 +125,19 @@ def set_color_xo(color): client = GConf.Client.get_default() client.set_string('/desktop/sugar/user/color', color) return 1 + + +def set_xo_icon(path, icon_name): + Replace computer-xo.svg icon +pt = os.path.join(os.path.expanduser('~'), '.current') +fd = open(pt, 'w') +fd.write(icon_name) +fd.close() +if os.path.exists('/usr/share/icons/sugar/scalable/device/'): +iconpath = '/usr/share/icons/sugar/scalable/device/computer-xo.svg' +shutil.copy(path, iconpath) +if os.path.exists('/opt/sweets/sugar-artwork/share/icons/sugar/scalable/device'): +iconpath = '/opt/sweets/sugar-artwork/share/icons/sugar/scalable/device/computer-xo.svg' +shutil.copy(path, iconpath) +else: +pass diff --git a/extensions/cpsection/aboutme/view.py b/extensions/cpsection/aboutme/view.py index 2d4b1e8..ac01bc2 100644 --- a/extensions/cpsection/aboutme/view.py +++ b/extensions/cpsection/aboutme/view.py @@ -16,15 +16,19 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GConf from gi.repository import GObject from gettext import gettext as _ from sugar3.graphics import style from sugar3.graphics.xocolor import XoColor, colors from sugar3.graphics.icon import CanvasIcon +from sugar3.graphics.icon import Icon from jarabe.controlpanel.sectionview import SectionView from jarabe.controlpanel.inlinealert import InlineAlert +import os _STROKE_COLOR = 0 _FILL_COLOR = 1 @@ -118,8 +122,8 @@ class ColorPicker(CanvasIcon): ([object])), } -def __init__(self, picker): -CanvasIcon.__init__(self, icon_name='computer-xo', +def __init__(self, picker, icon): +CanvasIcon.__init__(self, icon_name=icon, pixel_size=style.XLARGE_ICON_SIZE) self._picker = picker self._color = None @@ -156,25 +160,58 @@ class AboutMe(SectionView): self._nick_valid = True self.set_border_width(style.DEFAULT_SPACING * 2) -self.set_spacing(style.DEFAULT_SPACING) +#self.set_spacing(style.DEFAULT_SPACING) self._group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) self._color_label = Gtk.HBox(spacing=style.DEFAULT_SPACING) self._color_box = Gtk.HBox(spacing=style.DEFAULT_SPACING) self._color_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING) self._color_alert = None +# Examples. # +self._scroll_icon = Gtk.ScrolledWindow() +self._scroll_icon.set_policy(Gtk.PolicyType.AUTOMATIC, +Gtk.PolicyType.NEVER) +self._hbox_icon = Gtk.HBox(spacing=style.DEFAULT_SPACING) +self._scroll_icon.add_with_viewport(self._hbox_icon) +self._frame_icon = Gtk.Frame() +self._vbox_icon = Gtk.VBox() +self._vbox_icon.pack_start(self._scroll_icon, True, True, 0) + +self._alert = InlineAlert() +label_color = \
[Sugar-devel] [PATCH] SDXO#2620 Add ability to save unfinished games in Memorize.
From: Ajay Garg a...@activitycentral.com The approach followed has been simply to save the current-game image when closing the game. The game resumes from that image next time onwards. Tests conducted :: a) (i) User exits, without finishing the current game. (ii) When she next starts, she will proceed from the same game, from the same stage. b) (i) User exits, without finishing the current game. (ii) She then transfers the journal-entry to another XO. (iii) Tries to resume the game, from the (transferred) journal entry. (iv) Game resumes, from the same stage. Signed-off-by: Ajay Garg a...@activitycentral.com --- activity.py| 16 ++-- cardlist.py| 3 ++- game.py| 14 -- memorizetoolbar.py | 2 +- model.py | 12 +++- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/activity.py b/activity.py index 8bfd758..8bc679d 100644 --- a/activity.py +++ b/activity.py @@ -107,7 +107,7 @@ class MemorizeActivity(Activity): # Play game mode self.table = cardtable.CardTable() self.scoreboard = scoreboard.Scoreboard() -self.cardlist = cardlist.CardList() +self.cardlist = cardlist.CardList(self) self.createcardpanel = createcardpanel.CreateCardPanel() self.cardlist.connect('pair-selected', self.createcardpanel.pair_selected) @@ -127,7 +127,7 @@ class MemorizeActivity(Activity): self._memorizeToolbarBuilder.reset) self._createToolbarBuilder.connect('create_equal_pairs', self.change_equal_pairs) -self.game = game.MemorizeGame() +self.game = game.MemorizeGame(self) self._edit_button.connect('toggled', self._change_mode_bt) @@ -232,11 +232,16 @@ class MemorizeActivity(Activity): def write_file(self, file_path): logging.debug('WRITE_FILE is_demo %s', self.game.model.is_demo) + +# We want to save the game-image for demo games too !!! + if self.game.model.is_demo: # if is a demo game only want keep the metadata self._jobject.set_file_path(None) raise NotImplementedError return + + if self.cardlist.pair_list_modified: self.cardlist.update_model(self.game.model) @@ -285,6 +290,13 @@ class MemorizeActivity(Activity): game_zip.close() self.metadata['mime_type'] = 'application/x-memorize-project' +# Store the game image as a string - that is simpler instead of +# having to deal with the dbus-converted list. +# When reading back, we use eval to convert the string into +# the correct type (list in this case). +self.metadata['saved_game_data_image'] = str(self.game.model.grid) +self.metadata['size'] = int(self.game.model.data['size']) + def _complete_close(self): self._remove_temp_files() Activity._complete_close(self) diff --git a/cardlist.py b/cardlist.py index 6bc781c..65e44f1 100644 --- a/cardlist.py +++ b/cardlist.py @@ -40,8 +40,9 @@ class CardList(gtk.EventBox): 'update-create-toolbar': (SIGNAL_RUN_FIRST, None, 3 * [TYPE_PYOBJECT]), } -def __init__(self): +def __init__(self, activity_instance): gtk.EventBox.__init__(self) +self._activity_instance = activity_instance self.pairs = [] self.current_pair = None self.current_game_key = None diff --git a/game.py b/game.py index c5e54d1..9d21b4b 100644 --- a/game.py +++ b/game.py @@ -57,7 +57,7 @@ class MemorizeGame(GObject): 'change-turn': (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]), } -def __init__(self): +def __init__(self, activity_instance): gobject.GObject.__init__(self) self.myself = None self.players_score = {} @@ -70,7 +70,7 @@ class MemorizeGame(GObject): self.messenger = None self.sentitive = True -self.model = Model() +self.model = Model(activity_instance=activity_instance) self.flip_block = False self._flop_cards = None @@ -109,6 +109,16 @@ class MemorizeGame(GObject): self.change_turn() self.model.data['running'] = 'False' +# Card 'state' is an aawesome field. +# Its takes on the following values :: +# +# 0 ==for flopped cards. +# +# 1 ==for flipped unmatched cards +# (can be a maximum of 1 such card). +# +# stroke_color, fill_color ==for flipped matched cards + for card in self.model.grid: if card['state'] == '1': self.emit('flip-card', self.model.grid.index(card), False) diff --git a/memorizetoolbar.py b/memorizetoolbar.py index 1a06da7..07ceecf 100644 --- a/memorizetoolbar.py +++
Re: [Sugar-devel] [PATCH] SDXO#2620 Add ability to save unfinished games in Memorize.
Thanks Ajay and Ariel. I filled sl #4373 to follow this issue. Comments: * Now you save the game data and the game session data every time. There are small games, like aritmetic or letters, but can be big if have images or sounds attached. Should be good save the data only if is a custom game. * I think is better use json to persist a structure like a list instead of str/eval. I haven't tested this yet. Gonzalo On Thu, Jan 10, 2013 at 11:44 AM, Ariel Calzada ariel.calz...@gmail.comwrote: From: Ajay Garg a...@activitycentral.com The approach followed has been simply to save the current-game image when closing the game. The game resumes from that image next time onwards. Tests conducted :: a) (i) User exits, without finishing the current game. (ii) When she next starts, she will proceed from the same game, from the same stage. b) (i) User exits, without finishing the current game. (ii) She then transfers the journal-entry to another XO. (iii) Tries to resume the game, from the (transferred) journal entry. (iv) Game resumes, from the same stage. Signed-off-by: Ajay Garg a...@activitycentral.com --- activity.py| 16 ++-- cardlist.py| 3 ++- game.py| 14 -- memorizetoolbar.py | 2 +- model.py | 12 +++- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/activity.py b/activity.py index 8bfd758..8bc679d 100644 --- a/activity.py +++ b/activity.py @@ -107,7 +107,7 @@ class MemorizeActivity(Activity): # Play game mode self.table = cardtable.CardTable() self.scoreboard = scoreboard.Scoreboard() -self.cardlist = cardlist.CardList() +self.cardlist = cardlist.CardList(self) self.createcardpanel = createcardpanel.CreateCardPanel() self.cardlist.connect('pair-selected', self.createcardpanel.pair_selected) @@ -127,7 +127,7 @@ class MemorizeActivity(Activity): self._memorizeToolbarBuilder.reset) self._createToolbarBuilder.connect('create_equal_pairs', self.change_equal_pairs) -self.game = game.MemorizeGame() +self.game = game.MemorizeGame(self) self._edit_button.connect('toggled', self._change_mode_bt) @@ -232,11 +232,16 @@ class MemorizeActivity(Activity): def write_file(self, file_path): logging.debug('WRITE_FILE is_demo %s', self.game.model.is_demo) + +# We want to save the game-image for demo games too !!! + if self.game.model.is_demo: # if is a demo game only want keep the metadata self._jobject.set_file_path(None) raise NotImplementedError return + + if self.cardlist.pair_list_modified: self.cardlist.update_model(self.game.model) @@ -285,6 +290,13 @@ class MemorizeActivity(Activity): game_zip.close() self.metadata['mime_type'] = 'application/x-memorize-project' +# Store the game image as a string - that is simpler instead of +# having to deal with the dbus-converted list. +# When reading back, we use eval to convert the string into +# the correct type (list in this case). +self.metadata['saved_game_data_image'] = str(self.game.model.grid) +self.metadata['size'] = int(self.game.model.data['size']) + def _complete_close(self): self._remove_temp_files() Activity._complete_close(self) diff --git a/cardlist.py b/cardlist.py index 6bc781c..65e44f1 100644 --- a/cardlist.py +++ b/cardlist.py @@ -40,8 +40,9 @@ class CardList(gtk.EventBox): 'update-create-toolbar': (SIGNAL_RUN_FIRST, None, 3 * [TYPE_PYOBJECT]), } -def __init__(self): +def __init__(self, activity_instance): gtk.EventBox.__init__(self) +self._activity_instance = activity_instance self.pairs = [] self.current_pair = None self.current_game_key = None diff --git a/game.py b/game.py index c5e54d1..9d21b4b 100644 --- a/game.py +++ b/game.py @@ -57,7 +57,7 @@ class MemorizeGame(GObject): 'change-turn': (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]), } -def __init__(self): +def __init__(self, activity_instance): gobject.GObject.__init__(self) self.myself = None self.players_score = {} @@ -70,7 +70,7 @@ class MemorizeGame(GObject): self.messenger = None self.sentitive = True -self.model = Model() +self.model = Model(activity_instance=activity_instance) self.flip_block = False self._flop_cards = None @@ -109,6 +109,16 @@ class MemorizeGame(GObject): self.change_turn() self.model.data['running'] = 'False' +# Card 'state' is an aawesome field. +# Its takes on the
Re: [Sugar-devel] [PATCH] SDXO#2620 Add ability to save unfinished games in Memorize.
On Thu, Jan 10, 2013 at 8:49 PM, Gonzalo Odiard gonz...@laptop.org wrote: Thanks Ajay and Ariel. I filled sl #4373 to follow this issue. Comments: * Now you save the game data and the game session data every time. There are small games, like aritmetic or letters, but can be big if have images or sounds attached. Should be good save the data only if is a custom game. Or may be ask the user (while exiting), that whether the user wishes to save the game? * I think is better use json to persist a structure like a list instead of str/eval. Hmm.. the current approach kind of copies the game-image, thus making it immune to any change in the game-state-image. Also, having it persisted in any other form will just make the code too bloatful and error-prone. I haven't tested this yet. Gonzalo On Thu, Jan 10, 2013 at 11:44 AM, Ariel Calzada ariel.calz...@gmail.comwrote: From: Ajay Garg a...@activitycentral.com The approach followed has been simply to save the current-game image when closing the game. The game resumes from that image next time onwards. Tests conducted :: a) (i) User exits, without finishing the current game. (ii) When she next starts, she will proceed from the same game, from the same stage. b) (i) User exits, without finishing the current game. (ii) She then transfers the journal-entry to another XO. (iii) Tries to resume the game, from the (transferred) journal entry. (iv) Game resumes, from the same stage. Signed-off-by: Ajay Garg a...@activitycentral.com --- activity.py| 16 ++-- cardlist.py| 3 ++- game.py| 14 -- memorizetoolbar.py | 2 +- model.py | 12 +++- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/activity.py b/activity.py index 8bfd758..8bc679d 100644 --- a/activity.py +++ b/activity.py @@ -107,7 +107,7 @@ class MemorizeActivity(Activity): # Play game mode self.table = cardtable.CardTable() self.scoreboard = scoreboard.Scoreboard() -self.cardlist = cardlist.CardList() +self.cardlist = cardlist.CardList(self) self.createcardpanel = createcardpanel.CreateCardPanel() self.cardlist.connect('pair-selected', self.createcardpanel.pair_selected) @@ -127,7 +127,7 @@ class MemorizeActivity(Activity): self._memorizeToolbarBuilder.reset) self._createToolbarBuilder.connect('create_equal_pairs', self.change_equal_pairs) -self.game = game.MemorizeGame() +self.game = game.MemorizeGame(self) self._edit_button.connect('toggled', self._change_mode_bt) @@ -232,11 +232,16 @@ class MemorizeActivity(Activity): def write_file(self, file_path): logging.debug('WRITE_FILE is_demo %s', self.game.model.is_demo) + +# We want to save the game-image for demo games too !!! + if self.game.model.is_demo: # if is a demo game only want keep the metadata self._jobject.set_file_path(None) raise NotImplementedError return + + if self.cardlist.pair_list_modified: self.cardlist.update_model(self.game.model) @@ -285,6 +290,13 @@ class MemorizeActivity(Activity): game_zip.close() self.metadata['mime_type'] = 'application/x-memorize-project' +# Store the game image as a string - that is simpler instead of +# having to deal with the dbus-converted list. +# When reading back, we use eval to convert the string into +# the correct type (list in this case). +self.metadata['saved_game_data_image'] = str(self.game.model.grid) +self.metadata['size'] = int(self.game.model.data['size']) + def _complete_close(self): self._remove_temp_files() Activity._complete_close(self) diff --git a/cardlist.py b/cardlist.py index 6bc781c..65e44f1 100644 --- a/cardlist.py +++ b/cardlist.py @@ -40,8 +40,9 @@ class CardList(gtk.EventBox): 'update-create-toolbar': (SIGNAL_RUN_FIRST, None, 3 * [TYPE_PYOBJECT]), } -def __init__(self): +def __init__(self, activity_instance): gtk.EventBox.__init__(self) +self._activity_instance = activity_instance self.pairs = [] self.current_pair = None self.current_game_key = None diff --git a/game.py b/game.py index c5e54d1..9d21b4b 100644 --- a/game.py +++ b/game.py @@ -57,7 +57,7 @@ class MemorizeGame(GObject): 'change-turn': (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]), } -def __init__(self): +def __init__(self, activity_instance): gobject.GObject.__init__(self) self.myself = None self.players_score = {} @@ -70,7 +70,7 @@ class MemorizeGame(GObject): self.messenger = None
[Sugar-devel] [ASLO] Release Portfolio-37
Activity Homepage: http://activities.sugarlabs.org/addon/4437 Sugar Platform: 0.96 - 0.98 Download Now: http://activities.sugarlabs.org/downloads/file/28428/portfolio-37.xo Release notes: 37 ENHANCEMENT: * Add hardware support for XO4 BUG FIX: * Properly scale fonts for PDF output Sugar Labs Activities http://activities.sugarlabs.org ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [PATCH] SDXO#2620 Add ability to save unfinished games in Memorize.
On Thu, Jan 10, 2013 at 11:02 AM, Ajay Garg a...@activitycentral.com wrote: On Thu, Jan 10, 2013 at 8:49 PM, Gonzalo Odiard gonz...@laptop.org wrote: Thanks Ajay and Ariel. I filled sl #4373 to follow this issue. Comments: * Now you save the game data and the game session data every time. There are small games, like aritmetic or letters, but can be big if have images or sounds attached. Should be good save the data only if is a custom game. Or may be ask the user (while exiting), that whether the user wishes to save the game? Not a very Sugary approach. * I think is better use json to persist a structure like a list instead of str/eval. Hmm.. the current approach kind of copies the game-image, thus making it immune to any change in the game-state-image. Also, having it persisted in any other form will just make the code too bloatful and error-prone. Not sure how json makes things either more bloated or more error-prone. regards. -walter I haven't tested this yet. Gonzalo On Thu, Jan 10, 2013 at 11:44 AM, Ariel Calzada ariel.calz...@gmail.com wrote: From: Ajay Garg a...@activitycentral.com The approach followed has been simply to save the current-game image when closing the game. The game resumes from that image next time onwards. Tests conducted :: a) (i) User exits, without finishing the current game. (ii) When she next starts, she will proceed from the same game, from the same stage. b) (i) User exits, without finishing the current game. (ii) She then transfers the journal-entry to another XO. (iii) Tries to resume the game, from the (transferred) journal entry. (iv) Game resumes, from the same stage. Signed-off-by: Ajay Garg a...@activitycentral.com --- activity.py| 16 ++-- cardlist.py| 3 ++- game.py| 14 -- memorizetoolbar.py | 2 +- model.py | 12 +++- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/activity.py b/activity.py index 8bfd758..8bc679d 100644 --- a/activity.py +++ b/activity.py @@ -107,7 +107,7 @@ class MemorizeActivity(Activity): # Play game mode self.table = cardtable.CardTable() self.scoreboard = scoreboard.Scoreboard() -self.cardlist = cardlist.CardList() +self.cardlist = cardlist.CardList(self) self.createcardpanel = createcardpanel.CreateCardPanel() self.cardlist.connect('pair-selected', self.createcardpanel.pair_selected) @@ -127,7 +127,7 @@ class MemorizeActivity(Activity): self._memorizeToolbarBuilder.reset) self._createToolbarBuilder.connect('create_equal_pairs', self.change_equal_pairs) -self.game = game.MemorizeGame() +self.game = game.MemorizeGame(self) self._edit_button.connect('toggled', self._change_mode_bt) @@ -232,11 +232,16 @@ class MemorizeActivity(Activity): def write_file(self, file_path): logging.debug('WRITE_FILE is_demo %s', self.game.model.is_demo) + +# We want to save the game-image for demo games too !!! + if self.game.model.is_demo: # if is a demo game only want keep the metadata self._jobject.set_file_path(None) raise NotImplementedError return + + if self.cardlist.pair_list_modified: self.cardlist.update_model(self.game.model) @@ -285,6 +290,13 @@ class MemorizeActivity(Activity): game_zip.close() self.metadata['mime_type'] = 'application/x-memorize-project' +# Store the game image as a string - that is simpler instead of +# having to deal with the dbus-converted list. +# When reading back, we use eval to convert the string into +# the correct type (list in this case). +self.metadata['saved_game_data_image'] = str(self.game.model.grid) +self.metadata['size'] = int(self.game.model.data['size']) + def _complete_close(self): self._remove_temp_files() Activity._complete_close(self) diff --git a/cardlist.py b/cardlist.py index 6bc781c..65e44f1 100644 --- a/cardlist.py +++ b/cardlist.py @@ -40,8 +40,9 @@ class CardList(gtk.EventBox): 'update-create-toolbar': (SIGNAL_RUN_FIRST, None, 3 * [TYPE_PYOBJECT]), } -def __init__(self): +def __init__(self, activity_instance): gtk.EventBox.__init__(self) +self._activity_instance = activity_instance self.pairs = [] self.current_pair = None self.current_game_key = None diff --git a/game.py b/game.py index c5e54d1..9d21b4b 100644 --- a/game.py +++ b/game.py @@ -57,7 +57,7 @@ class MemorizeGame(GObject): 'change-turn': (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]), } -def __init__(self): +def __init__(self,
Re: [Sugar-devel] [PATCH] SDXO#2620 Add ability to save unfinished games in Memorize.
On Thu, Jan 10, 2013 at 9:56 PM, Walter Bender walter.ben...@gmail.comwrote: On Thu, Jan 10, 2013 at 11:02 AM, Ajay Garg a...@activitycentral.com wrote: On Thu, Jan 10, 2013 at 8:49 PM, Gonzalo Odiard gonz...@laptop.org wrote: Thanks Ajay and Ariel. I filled sl #4373 to follow this issue. Comments: * Now you save the game data and the game session data every time. There are small games, like aritmetic or letters, but can be big if have images or sounds attached. Should be good save the data only if is a custom game. Or may be ask the user (while exiting), that whether the user wishes to save the game? Not a very Sugary approach. :D * I think is better use json to persist a structure like a list instead of str/eval. Hmm.. the current approach kind of copies the game-image, thus making it immune to any change in the game-state-image. Also, having it persisted in any other form will just make the code too bloatful and error-prone. Not sure how json makes things either more bloated or more error-prone. Hmmm.. I was just a bit sceptical, since we seem to be doing the byte_arrays=True and byte_arrays=False at different places. Having it as a string, will eliminate all such issues :) regards. -walter I haven't tested this yet. Gonzalo On Thu, Jan 10, 2013 at 11:44 AM, Ariel Calzada ariel.calz...@gmail.com wrote: From: Ajay Garg a...@activitycentral.com The approach followed has been simply to save the current-game image when closing the game. The game resumes from that image next time onwards. Tests conducted :: a) (i) User exits, without finishing the current game. (ii) When she next starts, she will proceed from the same game, from the same stage. b) (i) User exits, without finishing the current game. (ii) She then transfers the journal-entry to another XO. (iii) Tries to resume the game, from the (transferred) journal entry. (iv) Game resumes, from the same stage. Signed-off-by: Ajay Garg a...@activitycentral.com --- activity.py| 16 ++-- cardlist.py| 3 ++- game.py| 14 -- memorizetoolbar.py | 2 +- model.py | 12 +++- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/activity.py b/activity.py index 8bfd758..8bc679d 100644 --- a/activity.py +++ b/activity.py @@ -107,7 +107,7 @@ class MemorizeActivity(Activity): # Play game mode self.table = cardtable.CardTable() self.scoreboard = scoreboard.Scoreboard() -self.cardlist = cardlist.CardList() +self.cardlist = cardlist.CardList(self) self.createcardpanel = createcardpanel.CreateCardPanel() self.cardlist.connect('pair-selected', self.createcardpanel.pair_selected) @@ -127,7 +127,7 @@ class MemorizeActivity(Activity): self._memorizeToolbarBuilder.reset) self._createToolbarBuilder.connect('create_equal_pairs', self.change_equal_pairs) -self.game = game.MemorizeGame() +self.game = game.MemorizeGame(self) self._edit_button.connect('toggled', self._change_mode_bt) @@ -232,11 +232,16 @@ class MemorizeActivity(Activity): def write_file(self, file_path): logging.debug('WRITE_FILE is_demo %s', self.game.model.is_demo) + +# We want to save the game-image for demo games too !!! + if self.game.model.is_demo: # if is a demo game only want keep the metadata self._jobject.set_file_path(None) raise NotImplementedError return + + if self.cardlist.pair_list_modified: self.cardlist.update_model(self.game.model) @@ -285,6 +290,13 @@ class MemorizeActivity(Activity): game_zip.close() self.metadata['mime_type'] = 'application/x-memorize-project' +# Store the game image as a string - that is simpler instead of +# having to deal with the dbus-converted list. +# When reading back, we use eval to convert the string into +# the correct type (list in this case). +self.metadata['saved_game_data_image'] = str(self.game.model.grid) +self.metadata['size'] = int(self.game.model.data['size']) + def _complete_close(self): self._remove_temp_files() Activity._complete_close(self) diff --git a/cardlist.py b/cardlist.py index 6bc781c..65e44f1 100644 --- a/cardlist.py +++ b/cardlist.py @@ -40,8 +40,9 @@ class CardList(gtk.EventBox): 'update-create-toolbar': (SIGNAL_RUN_FIRST, None, 3 * [TYPE_PYOBJECT]), } -def __init__(self): +def __init__(self, activity_instance):
Re: [Sugar-devel] [PATCH] SDXO#2620 Add ability to save unfinished games in Memorize.
* I think is better use json to persist a structure like a list instead of str/eval. Hmm.. the current approach kind of copies the game-image, thus making it immune to any change in the game-state-image. Also, having it persisted in any other form will just make the code too bloatful and error-prone. Not sure how json makes things either more bloated or more error-prone. Hmmm.. I was just a bit sceptical, since we seem to be doing the byte_arrays=True and byte_arrays=False at different places. Having it as a string, will eliminate all such issues :) We are using json in a lot of activities without any problem, you can safely ignore your skepticism ;) Gonzalo ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] Request to get maintainer + release rights on an inactive activity
I have worked on the Costellation Flash Cards activity including enhancements: Cairo Port, Gtk3 Port, i18n Port and some fixes on how the points were handled. The new repository is located at http://git.sugarlabs.org/constellationsflashcards As the activity hasn't received any form of development since July 6, 2010, I would like to take over the maintainership to continue the development. I would also require admin rights for the activity on http://activities.sugarlabs.org/ to make the releases. -- Thanks Aneesh Dogra (lionaneesh) ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] Request to get maintainer + release rights on an inactive activity
First, thanks for taking care of this activity. Probably is pretty safe think the activity is unmaintained, but as the mainteiner as not provided a email address, then may be you can ask in sugar-devel with a title more specific, wait a week and request access for you in git and aslo. A policy to manage this process is one of the things we have pending for a while, we are discussing this right now (thanks Bernie) give us a few days, but not give up, push if you have no reply :) Gonzalo On Thu, Jan 10, 2013 at 3:56 PM, Aneesh Dogra lionane...@gmail.com wrote: I have worked on the Costellation Flash Cards activity including enhancements: Cairo Port, Gtk3 Port, i18n Port and some fixes on how the points were handled. The new repository is located at http://git.sugarlabs.org/constellationsflashcards As the activity hasn't received any form of development since July 6, 2010, I would like to take over the maintainership to continue the development. I would also require admin rights for the activity on http://activities.sugarlabs.org/ to make the releases. -- Thanks Aneesh Dogra (lionaneesh) ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] [PATCH] Add support for selecting new XO icon skin
Thx. 2013/1/10 Alan Jhonn Aguiar Schwyn alan...@hotmail.com Good job! Only one thing to remove: +else: +pass ;-) -- Date: Thu, 10 Jan 2013 10:19:49 -0200 From: igna...@sugarlabs.org To: sugar-devel@lists.sugarlabs.org Subject: Re: [Sugar-devel] [PATCH] Add support for selecting new XO icon skin I attached a couple of skins. Please extract this file in ~/.sugar/ Thx. Ignacio Rodríguez 2013/1/10 Ignacio Rodríguez igna...@sugarlabs.org This patch adds the ability fo the Sugar user to select a new skin for the XO icon from a collection of icons in ~/.sugar/skins. It is an extension of the aboutme panel, where the user is also able to change colors and the nick. This patch contains the modifications to model.py and view.py. It does not include the sample icons. Caveat: We need to discuss the mechanism for actually changing the icon, which is currently stored in /usr/share/icons/sugar/, which is read-only to Sugar users. Two ideas have been discussed so far: (1) to make the xo-computer.svg icon read-write; and (2) to add ~/.sugar/icons/ to the head of the icon-themes list, so if a modified xo-computer is found there, it will be used to override the on ein /usr/share. This code assumes solution #1 above. For that reason try (for now) to do: chmod -R 777 /usr/share/icons/sugar/scalable/device/computer-xo.svg --- extensions/cpsection/aboutme/model.py | 18 + extensions/cpsection/aboutme/view.py | 146 +++--- 2 files changed, 153 insertions(+), 11 deletions(-) diff --git a/extensions/cpsection/aboutme/model.py b/extensions/cpsection/aboutme/model.py index ad1de66..7395ae9 100644 --- a/extensions/cpsection/aboutme/model.py +++ b/extensions/cpsection/aboutme/model.py @@ -17,6 +17,8 @@ from gettext import gettext as _ from gi.repository import GConf +import shutil +import os _COLORS = { @@ -123,3 +125,19 @@ def set_color_xo(color): client = GConf.Client.get_default() client.set_string('/desktop/sugar/user/color', color) return 1 + + +def set_xo_icon(path, icon_name): + Replace computer-xo.svg icon +pt = os.path.join(os.path.expanduser('~'), '.current') +fd = open(pt, 'w') +fd.write(icon_name) +fd.close() +if os.path.exists('/usr/share/icons/sugar/scalable/device/'): +iconpath = '/usr/share/icons/sugar/scalable/device/computer-xo.svg' +shutil.copy(path, iconpath) +if os.path.exists('/opt/sweets/sugar-artwork/share/icons/sugar/scalable/device'): +iconpath = '/opt/sweets/sugar-artwork/share/icons/sugar/scalable/device/computer-xo.svg' +shutil.copy(path, iconpath) +else: +pass diff --git a/extensions/cpsection/aboutme/view.py b/extensions/cpsection/aboutme/view.py index 2d4b1e8..ac01bc2 100644 --- a/extensions/cpsection/aboutme/view.py +++ b/extensions/cpsection/aboutme/view.py @@ -16,15 +16,19 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301USA from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GConf from gi.repository import GObject from gettext import gettext as _ from sugar3.graphics import style from sugar3.graphics.xocolor import XoColor, colors from sugar3.graphics.icon import CanvasIcon +from sugar3.graphics.icon import Icon from jarabe.controlpanel.sectionview import SectionView from jarabe.controlpanel.inlinealert import InlineAlert +import os _STROKE_COLOR = 0 _FILL_COLOR = 1 @@ -118,8 +122,8 @@ class ColorPicker(CanvasIcon): ([object])), } -def __init__(self, picker): -CanvasIcon.__init__(self, icon_name='computer-xo', +def __init__(self, picker, icon): +CanvasIcon.__init__(self, icon_name=icon, pixel_size=style.XLARGE_ICON_SIZE) self._picker = picker self._color = None @@ -156,25 +160,58 @@ class AboutMe(SectionView): self._nick_valid = True self.set_border_width(style.DEFAULT_SPACING * 2) -self.set_spacing(style.DEFAULT_SPACING) +#self.set_spacing(style.DEFAULT_SPACING) self._group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) self._color_label = Gtk.HBox(spacing=style.DEFAULT_SPACING) self._color_box = Gtk.HBox(spacing=style.DEFAULT_SPACING) self._color_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING) self._color_alert = None +# Examples. # +self._scroll_icon = Gtk.ScrolledWindow() +self._scroll_icon.set_policy(Gtk.PolicyType.AUTOMATIC, +Gtk.PolicyType.NEVER) +self._hbox_icon = Gtk.HBox(spacing=style.DEFAULT_SPACING) +self._scroll_icon.add_with_viewport(self._hbox_icon) +self._frame_icon = Gtk.Frame() +self._vbox_icon = Gtk.VBox() +