[Etoys] Etoys Based Activity - FreeCell Sugar interactions
Bert Freudenberg
bert at freudenbergs.de
Mon May 4 16:37:31 EDT 2009
On 04.05.2009, at 07:31, Milan Zimmermann wrote:
> Hi Bert,
>
> I finally did some investigation into Squeak interaction with DBus and
> Datastore. I went through the classes that implement the DBus and
> Datastore
> interaction. This is some great stuff! Among others, if I understand
> this correctly, your Squeak DBus client framework could, for
> example, allow to use Squeak to write a KDE or gnome panel applet?
> But that is an aside.
Yes indeed. A fun way to explore it is to run Squeak on a regular KDE/
Gnome desktop and open the DBus Explorer from the World menu. You can,
for example, find the screen saver on the session bus and tell it to
blank the screen ...
> As Step 1, my goal was to figure out how to save a project in
> Journal from a set of commands in Workspace. Going to the debugger,
> I found that if I open a project in Etoys, and in a workspace, and do
>
> Project current storeOnServerWithNoInteractionThenQuit.
>
> the project is saved in Journal, and on restart, Etoys must have read
> the Journal saved project because it shows any changes I have made in
> the project. It seems that the core method called from
> storeOnServerWithNoInteractionThenQuit that interacts with Datastore
> is
>
> SugarDatastoreDirectory>> #writeProject: self
> inFileNamed: fileName
> fromDirectory: localDirectory
>
> So I tried to do the the same (Project current
> storeOnServerWithNoInteractionThenQuit.) from a workspace in the
> FreeCell activity. When performed, it does write to the Journal, but
> upon restart, I get an exception that appears a DBus object cannot
> be found -
> picture attached.
No, this is a regular file-not-found prompt. It looks like an file
from the Datastore could not be opened. You should press alt-. at this
prompt and investigate what it's trying to do.
> Could the difference be it because Freecell, on startup, does not
> setup some DBus interaction?
No, that should not be the problem.
> Well in any case, I am looking for some help trying to figure this
> out. I was thinking about these steps I'd like to achieve:
>
> 1) Command in Workspace that saves the FreeCell project on Journal.
> I seem to be able to do that, but on fairly high level ( Project
> current storeOnServerWithNoInteractionThenQuit.). Eventually I'd
> like to get it done with more but lower level commands.
Well. IMHO we should *not* save the whole project to the Journal. This
is not supposed to be an Etoys activity, but a Squeak application. It
should only store and retrieve its relevant state. For starters I'd
only store the statistics, which is about 10 numbers.
> 2) Sure and understood way to open the saved Journal Project in
> FreeCell. (So far within Etoys it seems to work, but I have little
> understanding of it. In FreeCell it does not)
The regular Etoys Sugar startup happens in SugarLauncher>>startUp.
There it looks for the ACTIVITY_ID parameter to see if we are actually
running under Sugar, and an OBJECT_ID which is present if we are
resuming a Journal entry.
I think the best way would be to use different parameter names in
FreeCell.sh, perhaps FREECELL_ACTIVITY_ID and FREECELL_OBJECT_ID. Then
the Etoys logic would not kick off and would not try to open the
object as project, but we could provide our own startup method that we
would simply call at the end of FreeCell.st.
> 3) A command or set of commands in workspace, which wil allow to
> Rename the FreeCell project (and save on Journal under the new name)
Renaming means nothing more than storing in the DataStore with
different meta data. Inspect
SugarDataStore new getProperties: someObjectId
(see the SugarDataStore class example to find out object ids). This
meta data is just a dictionary that you can modify and later pass to
the datastore's "update" function.
You should try to create and retrieve a file for the datastore
manually in a workspace first. Like in this example, where a file is
first read from the datastore, then modified, the saved again:
http://wiki.squeakland.org/display/sq/Saving+to+a+file+in+Sugar
This is actually a pretty complete example of what would have to
happen for FreeCell on startup and on saving (reading a datastore
object on startup, and creating or updating the datastore object to
save). The difference would be that no find call is necessary because
we would know the object id (if any) already.
One minor thing missing is that an activity is supposed to watch the
journal entry so it catches e.g. renames done on the Journal screen.
Etoys actually does this (try resuming an Etoys project, switch to
Journal, rename it there, switch back to Etoys, name should have
changed there, too). See #monitorJournalEntry.
> 4) Ability to start using the black Launcher ribbon on top, with the
> standard Etoys project name a project stop widget that would call
> the commands from 1 and 2. .
Well if you look at the end of FreeCell.st you see the tool bar is
explicitly toggled off. Before re-enabling it we would have to
customize it (see class SugarNavigatorBar).
> 5) More interaction such as copy/paste on Journal
What would you like to paste into FreeCell? Not sure how useful that
would be.
> Do these goals and order make sense?
>
> I will try to maintain a blog about what I am playing with.
>
> http://mzimmerm.blogspot.com/2009/05/how-to-install-and-run-sugar-activity.html
Nice. I commented about two misconceptions.
> I am unfortunately frustratingly slow and sometimes fail to respond
> for a long time, combination of lack of time and experience in this
> area (Squeak/DBus/Sugar), but will keep going... Appreciate any help.
Just take your time, I'm glad someone else is finally looking at this
stuff :)
- Bert -
More information about the Etoys
mailing list