On Sat, Jan 03, 2009 at 02:23:41PM -0500, Chris Marshall wrote:
>Two specific questions come to mind:
>(1) How does Sugar know that a new top level
>     window has been instantiated?  Is there a
>     hook from the X server or what?

Here's a short code tour for your enjoyment. I'll start by tracing
backwards from what we know:

1. Clone the sugar source code:

   git clone git://git.sugarlabs.org/sugar/mainline.git sugar

2. We know that things including gray circles appear in the top part of
the frame. What causes this?

   cd sugar
   find . -name '*frame*'
   # Inspiration!
   cd src/jarabe/frame

3. Start reading files here looking for info about how the frame is

   Ah hah! We find out from src/jarabe/frame/frame.py that the frame
   consists of four panels.


   What goes in the top panel? Read _create_top_panel():


   Bingo! An ActivitiesTray()!

4. Go find ActivitiesTray():

   First, search for "ActivitiesTray". Find the import line at


   Next, go read src/jarabe/frame/activitiestray.py looking for the
   definition of ActivitiesTray()


5. Figure out what message causes the tray to add icons.

   Doesn't that __activity_added_cb() callback look suspicious? 
   Let's figure out what causes self._home_model to generate
   'activity-added' signals.

6. Track down self._home_model.

   Ah! In ActivitiesTray.__init__, we set it equal to shell.get_model().

   Where does the variable "shell" come from? From here:


7. Track down 'get_model' in src/jarabe/model/shell.py


   So what's a ShellModel?

8. Look more carefully at ShellModel.

   We find the definition of the 'activity-added' signal here:

   alongside several other tasty-sounding signals.


   Oooh, look at the __init__ method:


   Doesn't that "window-open" signal sound interesting?

9. Review.

   We've pretty much figured out the chain of events that results in the
   appearance of a new button on the frame's top panel's activities tray.

   Moreover, while we still don't really know why the buttons sometimes
   display gray circles vs activity icons or how to remove a button, we
   can be fairly sure that the answers lie close by, e.g.

   (where the gray circles come from:)

   and back in jarabe.model.shell.ShellModel, which seems to be driving
   the show w.r.t. to the display and removal of items in the

10. Forward.

   The questions which remain include:

     a) What things are driving the ShellModel? Are they doing so

        hint: nope. read 

        (also, please help me get the ideas in the patches at the top of
          http://dev.laptop.org/git/users/mstone/sugar and 
        merged which, while they won't solve your problem, may still be
        generally useful.)

     b) What icon data should we be feeding into those buttons? Where
     does it come from?

        hint: read 
        and start asking questions.

Hope this helps,

Devel mailing list

Reply via email to