[squeak-dev] The Inbox: DesktopBackgroundLoader-sbw.20.mcz

Balázs Kósi rebmekop at gmail.com
Sun Apr 25 15:16:05 UTC 2010


Hi,

> Now that the simple thing is in place, it's time to refactor so add-on packages can add menu entries without having to modify existing packages. Your's is the first to want to do so, there was no need before (even though it was foreseeable).

My first stab at the problem is in The Inbox: Morphic-kb.248
I wrote some explanation about how it works in the commit message [1].
It uses pragmas to fill the docking bar. I tried to keep it simple.
What do you think?

Balázs

[1] I copy the commit message here:

First stab at refactoring TheWorldMainDockingBar to allow external
packages to insert new menus, or menu items. We use two pragmas to
fill the docking bar.

A method in TheWorldMainDockingBar marked with pragma:
<createDockingBarMenuWithPriority: NN> will get a chance to build on
the DockingBarMorph, which it gets as its sole argument.

A method in TheWorldMainDockingBar marked with pragma:
<fillDockingBarMenu: #MENUNAME priority: NN> will get a chance to
build on a menu, which it gets as its sole argument, when someone
calls TheWorldMainDockingBar >> fillMenu: menu with: #MENUNAME

Priority controls the order in which these methods are called.

Currently there are three menus filled with this technique: #tools,
#extras, #help

So if you want to add a new menu item to the #extras menu from your
package, you'll need to create an extension method on
TheWorldMainDockingBar containing the pragma <fillDockingBarMenu:
#extras priority: 50>, and evaluate [TheWorldMainDockingBar
updateInstances]

You can find examples in TheWorldMainDockingBar.



More information about the Squeak-dev mailing list