<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Luxi Sans'; font-size:11pt; font-weight:400; font-style:normal;">On May 4, 2009, Bert Freudenberg wrote:<br>
> On 04.05.2009, at 07:31, Milan Zimmermann wrote:<br>
> > Hi Bert,<br>
> ><br>
> > I finally did some investigation into Squeak interaction with DBus and<br>
> > Datastore. I went through the classes that implement the DBus and<br>
> > Datastore<br>
> > interaction. This is some great stuff! Among others, if I understand<br>
> > this correctly, your Squeak DBus client framework could, for<br>
> > example, allow to use Squeak to write a KDE or gnome panel applet?<br>
> > But that is an aside.<br>
><br>
> Yes indeed. <br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>Very cool. I think such functionality could also add interest in Squeak... Would it makes sense to add Squeak to this list<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>http://www.freedesktop.org/wiki/Software/DBusBindings<br>
?<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>> A fun way to explore it is to run Squeak on a regular KDE/<br>
> Gnome desktop and open the DBus Explorer from the World menu. You can,<br>
> for example, find the screen saver on the session bus and tell it to<br>
> blank the screen ...<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>Or exiting any application :) This is worth a blog by itself. <br>
        World Menu -> Open -> DbusExplorer. <br>
        Expand DBus sessionBus<br>
        open KDE system konsole<br>
        org.kde.konsole/konsole/MainWindow_1/actions/file_quit/<br>
                com.Trolltech.QT.QAction.trigger<br>
        yellow(middle or right)-click, select "invoke method"<br>
        konsole gone<br>
Neat...<br>
        <br>
><br>
> > As Step 1, my goal was to figure out how to save a project in<br>
> > Journal from a set of commands in Workspace. Going to the debugger,<br>
> > I found that if I open a project in Etoys, and in a workspace, and do<br>
> ><br>
> > Project current storeOnServerWithNoInteractionThenQuit.<br>
> ><br>
> > the project is saved in Journal, and on restart, Etoys must have read<br>
> > the Journal saved project because it shows any changes I have made in<br>
> > the project. It seems that the core method called from<br>
> > storeOnServerWithNoInteractionThenQuit that interacts with Datastore<br>
> > is<br>
> ><br>
> > SugarDatastoreDirectory>> #writeProject: self<br>
> > inFileNamed: fileName<br>
> > fromDirectory: localDirectory<br>
> ><br>
> > So I tried to do the the same (Project current<br>
> > storeOnServerWithNoInteractionThenQuit.) from a workspace in the<br>
> > FreeCell activity. When performed, it does write to the Journal, but<br>
> > upon restart, I get an exception that appears a DBus object cannot<br>
> > be found -<br>
> > picture attached.<br>
><br>
> No, this is a regular file-not-found prompt. It looks like an file<br>
> from the Datastore could not be opened. You should press alt-. at this<br>
> prompt and investigate what it's trying to do.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>I will debug it.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>><br>
> > Could the difference be it because Freecell, on startup, does not<br>
> > setup some DBus interaction?<br>
><br>
> No, that should not be the problem.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>OK.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>><br>
> > Well in any case, I am looking for some help trying to figure this<br>
> > out. I was thinking about these steps I'd like to achieve:<br>
> ><br>
> > 1) Command in Workspace that saves the FreeCell project on Journal.<br>
> > I seem to be able to do that, but on fairly high level ( Project<br>
> > current storeOnServerWithNoInteractionThenQuit.). Eventually I'd<br>
> > like to get it done with more but lower level commands.<br>
><br>
> Well. IMHO we should *not* save the whole project to the Journal. This<br>
> is not supposed to be an Etoys activity, but a Squeak application. It<br>
> should only store and retrieve its relevant state. For starters I'd<br>
> only store the statistics, which is about 10 numbers.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>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. <br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>When attempting to store only FreeCell's state, I have a few things to learn and understand: <br>
        - 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<br>
        - which objects represent the state stored <br>
        - how to serialize it (well that should be relatively straightforward knowing the objects)<br>
        - what method will write the serialized FreeCell state to Journal<br>
                instead of SugarDatastoreDirectory>>#writeProjectinFileNamed:fromDirectory:<br>
        - what does assign the "ownership" of that file on Journal as FreeCell<br>
        - how to deserialize the state<br>
        - how to import it back to the game<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>><br>
> > 2) Sure and understood way to open the saved Journal Project in<br>
> > FreeCell. (So far within Etoys it seems to work, but I have little<br>
> > understanding of it. In FreeCell it does not)<br>
><br>
> The regular Etoys Sugar startup happens in SugarLauncher>>startUp.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>yes<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>> There it looks for the ACTIVITY_ID parameter to see if we are actually<br>
> running under Sugar, and an OBJECT_ID which is present if we are<br>
> resuming a Journal entry.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>yes<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>><br>
> I think the best way would be to use different parameter names in<br>
> FreeCell.sh, perhaps FREECELL_ACTIVITY_ID and FREECELL_OBJECT_ID. Then<br>
> the Etoys logic would not kick off<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>logic in SugarLauncher.startup?<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>> and would not try to open the<br>
> object as project, but we could provide our own startup method that we<br>
> would simply call at the end of FreeCell.st.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>and load the state read from the Datastore/Journal?<br>
><br>
> > 3) A command or set of commands in workspace, which wil allow to<br>
> > Rename the FreeCell project (and save on Journal under the new name)<br>
><br>
> Renaming means nothing more than storing in the DataStore with<br>
> different meta data. Inspect<br>
><br>
>         SugarDataStore new getProperties: someObjectId<br>
><br>
> (see the SugarDataStore class example to find out object ids). This<br>
> meta data is just a dictionary that you can modify and later pass to<br>
> the datastore's "update" function.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>ah i see - so the getProperties reads the database key-values and update just puts it back with whatever changes we may have done.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>><br>
> You should try to create and retrieve a file for the datastore<br>
> manually in a workspace first. Like in this example, where a file is<br>
> first read from the datastore, then modified, the saved again:<br>
><br>
> http://wiki.squeakland.org/display/sq/Saving+to+a+file+in+Sugar<br>
><br>
> This is actually a pretty complete example of what would have to<br>
> happen for FreeCell on startup and on saving (reading a datastore<br>
> object on startup, and creating or updating the datastore object to<br>
> save). The difference would be that no find call is necessary because<br>
> we would know the object id (if any) already.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>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.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>><br>
> One minor thing missing is that an activity is supposed to watch the<br>
> journal entry so it catches e.g. renames done on the Journal screen.<br>
> Etoys actually does this (try resuming an Etoys project, switch to<br>
> Journal, rename it there, switch back to Etoys, name should have<br>
> changed there, too). See #monitorJournalEntry.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>I see - will play with that as well.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>><br>
> > 4) Ability to start using the black Launcher ribbon on top, with the<br>
> > standard Etoys project name a project stop widget that would call<br>
> > the commands from 1 and 2. .<br>
><br>
> Well if you look at the end of FreeCell.st you see the tool bar is<br>
> explicitly toggled off. Before re-enabling it we would have to<br>
> customize it (see class SugarNavigatorBar).<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>Ah I thought the bar was SugarLauncher. Another thing to look at.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>><br>
> > 5) More interaction such as copy/paste on Journal<br>
><br>
> What would you like to paste into FreeCell? Not sure how useful that<br>
> would be.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>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<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>><br>
> > Do these goals and order make sense?<br>
> ><br>
> > I will try to maintain a blog about what I am playing with.<br>
> ><br>
> > http://mzimmerm.blogspot.com/2009/05/how-to-install-and-run-sugar-activit<br>
> >y.html<br>
><br>
> Nice. I commented about two misconceptions.<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>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<br>
><br>
> > I am unfortunately frustratingly slow and sometimes fail to respond<br>
> > for a long time, combination of lack of time and experience in this<br>
> > area (Squeak/DBus/Sugar), but will keep going... Appreciate any help.<br>
><br>
> Just take your time, I'm glad someone else is finally looking at this<br>
> stuff :)<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>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 :)<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>ok time to go, I have stuff to try during the week and weekend, but I should have some questions earlier...<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>Later, Milan<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>><br>
> - Bert -<br>
><br>
><br>
> _______________________________________________<br>
> Etoys mailing list<br>
> Etoys@lists.laptop.org<br>
> http://lists.laptop.org/listinfo/etoys<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p></body></html>