On May 4, 2009, Bert Freudenberg wrote:
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.
Very cool. I think such functionality could also add interest in Squeak... Would it makes sense to add Squeak to this list
http://www.freedesktop.org/wiki/Software/DBusBindings ?
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 ...
Or exiting any application :) This is worth a blog by itself. World Menu -> Open -> DbusExplorer. Expand DBus sessionBus open KDE system konsole org.kde.konsole/konsole/MainWindow_1/actions/file_quit/ com.Trolltech.QT.QAction.trigger yellow(middle or right)-click, select "invoke method" konsole gone Neat...
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.
I will debug it.
Could the difference be it because Freecell, on startup, does not setup some DBus interaction?
No, that should not be the problem.
OK.
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:
- 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.
I did not think of saving only the state of the game, but it is definitely a better approach. Maybe I am missing something here though. For example, in Etoys, saving a project writes the whole project as a pr file - I assume .PR is some for of serialized everything in the project, not just what have changed.
When attempting to store only FreeCell's state, I have a few things to learn and understand: - without looking I am surptised FreeCell's state is only 10 numbers, it seems that position of the cards must be more than that unless it's packed somehow - I will look - which objects represent the state stored - how to serialize it (well that should be relatively straightforward knowing the objects) - what method will write the serialized FreeCell state to Journal instead of SugarDatastoreDirectory>>#writeProjectinFileNamed:fromDirectory: - what does assign the "ownership" of that file on Journal as FreeCell - how to deserialize the state - how to import it back to the game
- 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.
yes
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.
yes
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
logic in SugarLauncher.startup?
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.
and load the state read from the Datastore/Journal?
- 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.
ah i see - so the getProperties reads the database key-values and update just puts it back with whatever changes we may have done.
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.
i saw the example but did not study it - actually I tried, but did not get far enough. I will play with it from workspace, and likely ask some questions.
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.
I see - will play with that as well.
- 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).
Ah I thought the bar was SugarLauncher. Another thing to look at.
- More interaction such as copy/paste on Journal
What would you like to paste into FreeCell? Not sure how useful that would be.
Well I though of it as an exercise, rather then useful feature, but it could be used like this: User could copy and later paste another state of FreeCell from the Sugar black ribbon on the left - this would replace the current game with the one that was pasted
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-activit y.html
Nice. I commented about two misconceptions.
Thanks! That means that section of blog is really for a developer that wants to do things manually (rather then just install FreeCell by clicking "download" - I will modify the blog with that comment so it is less confusing
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 :)
I am actually quite excited about this - you did lots of great stuff there that deserves attention, use, and maybe we can do some marketing for it :) by having a few blogs and a small tutorial at some point. Long time ago I played with DCOP in KDE and Dbus is similar but that's not the point - The point is that apart from it's usefulness for Sugar, what you did can be also used for Squeak / Etoys applications to be integral part of KDE and Gnome desktops (perhaps even OS X - I am reading Dbus is ported there there but probably not integrated). I especially like the idea trying to write a KDE Panel applet in Squeak :)
ok time to go, I have stuff to try during the week and weekend, but I should have some questions earlier...
Later, Milan
- Bert -
Etoys mailing list Etoys@lists.laptop.org http://lists.laptop.org/listinfo/etoys