--- a/NewLauncher.st Sun Aug 20 14:32:21 2000 +0200
+++ b/NewLauncher.st Sun Aug 20 14:38:35 2000 +0200
@@ -134,56 +134,11 @@
!NewLauncher class methodsFor:'accessing'!
-addMenuItem:newItem in:where position:positionSpecOrNilArg space:space
- |positionSpecOrNil itemNameOrNil before what subMenuPath|
-
- positionSpecOrNil := positionSpecOrNilArg.
- positionSpecOrNil isArray ifTrue:[
- positionSpecOrNil size > 1 ifTrue:[
- itemNameOrNil := positionSpecOrNil at:2.
- ].
- positionSpecOrNil := positionSpecOrNil at:1.
- ].
- before := (positionSpecOrNil == #first) or:[positionSpecOrNil == #before].
-
- what := where.
- (what isNil or: [what = 'toolbar']) ifTrue:[
- UserAddedToolBarItems isNil ifTrue: [UserAddedToolBarItems := Dictionary new].
- UserAddedToolBarItems at:newItem put:(AddedToolInfo new
- item:newItem;
- positionSpec:positionSpecOrNilArg;
- space:space;
- before:before;
- menuWithNewItem:nil;
- yourself)
- ].
- subMenuPath := #( 'tools' ).
- (what notNil and:[what includes:$.]) ifTrue:[
- subMenuPath := (what asCollectionOfSubstringsSeparatedBy:$.) copyFrom:2.
- what := #menu.
- ].
-
- (what isNil or: [what = 'menu']) ifTrue:[
- UserAddedMenuItems isNil ifTrue: [UserAddedMenuItems := Dictionary new].
- UserAddedMenuItems at:newItem put:(AddedToolInfo new
- item:newItem;
- positionSpec:positionSpecOrNilArg;
- space:space;
- before:before;
- menuWithNewItem:nil;
- yourself)
- ]
-!
-
label
- ^'Launcher'
-
-
-!
-
-removeAllUserAddedTools
- UserAddedTools := nil
+ ^'ST/X Launcher'
+
+
! !
!NewLauncher class methodsFor:'defaults'!
@@ -743,6 +698,143 @@
"Modified: / 29.1.1999 / 14:55:37 / stefan"
! !
+!NewLauncher class methodsFor:'menu configuration'!
+
+addMenuItem:newItem in:where position:positionSpecOrNilArg space:space
+ |positionSpecOrNil itemNameOrNil before what subMenuPath launcherApp|
+
+ (Transcript notNil
+ and:[ Transcript isStream not
+ and:[ (launcherApp := Transcript application) notNil
+ and:[ launcherApp isKindOf:self]]]) ifTrue:[
+ "/ add to instance
+ launcherApp addMenuItem:newItem in:where position:positionSpecOrNilArg space:space.
+ ^ self
+ ].
+
+ positionSpecOrNil := positionSpecOrNilArg.
+ positionSpecOrNil isArray ifTrue:[
+ positionSpecOrNil size > 1 ifTrue:[
+ itemNameOrNil := positionSpecOrNil at:2.
+ ].
+ positionSpecOrNil := positionSpecOrNil at:1.
+ ].
+ before := (positionSpecOrNil == #first) or:[positionSpecOrNil == #before].
+
+ what := where.
+ (what isNil or: [what = 'toolbar']) ifTrue:[
+ UserAddedToolBarItems isNil ifTrue: [UserAddedToolBarItems := Dictionary new].
+ UserAddedToolBarItems at:newItem put:(AddedToolInfo new
+ item:newItem;
+ positionSpec:positionSpecOrNilArg;
+ space:space;
+ before:before;
+ menuWithNewItem:nil;
+ yourself)
+ ].
+ subMenuPath := #( 'tools' ).
+ (what notNil and:[what includes:$.]) ifTrue:[
+ subMenuPath := (what asCollectionOfSubstringsSeparatedBy:$.) copyFrom:2.
+ what := #menu.
+ ].
+
+ (what isNil or: [what = 'menu']) ifTrue:[
+ UserAddedMenuItems isNil ifTrue: [UserAddedMenuItems := Dictionary new].
+ UserAddedMenuItems at:newItem put:(AddedToolInfo new
+ item:newItem;
+ positionSpec:positionSpecOrNilArg;
+ space:space;
+ before:before;
+ menuWithNewItem:nil;
+ yourself)
+ ]
+!
+
+removeAllUserAddedTools
+ UserAddedTools := nil
+!
+
+removeUserTool:toolNameOrMenuItem
+ "removes a menu item labeled toolName
+ This can be invoked by a classes #deinitialize method,
+ to remove its item from the toolbar or menu.
+ "
+
+ self removeUserTool:toolNameOrMenuItem from:UserAddedToolBarItems.
+ self removeUserTool:toolNameOrMenuItem from:UserAddedMenuItems.
+
+ "
+ Transcript topView application
+ removeUserTool:'Bar'
+ "
+ "
+ Transcript topView application
+ removeUserTool:'Foo'
+ "
+
+
+!
+
+removeUserTool:toolNameOrMenuItem from:addedToolsCollection
+ "removes a menu item labeled toolName
+ This can be invoked by a classes #deinitialize method,
+ to remove its item from the toolbar or menu.
+ "
+
+ |info space menuIndex removeInMenuBlock whichMenu before menuItemToRemove|
+
+ addedToolsCollection size == 0 ifTrue: [^nil].
+
+ [true] whileTrue:[
+ (toolNameOrMenuItem isString or:[toolNameOrMenuItem isSymbol]) ifTrue:[
+ info := addedToolsCollection detect:[:eachInfo | |eachItem|
+ eachItem := eachInfo item.
+ (eachItem nameKey notNil and:[ toolNameOrMenuItem = eachItem nameKey])
+ or:[ (eachItem activeHelpKey notNil and:[ toolNameOrMenuItem = eachItem activeHelpKey])
+ or:[ (eachItem label notNil and:[ toolNameOrMenuItem = eachItem label])]]
+ ]
+ ifNone:nil.
+ ] ifFalse:[
+ info := addedToolsCollection detect:[:eachInfo | |eachItem| eachItem := eachInfo item. (eachItem == toolNameOrMenuItem)] ifNone:nil.
+ ].
+ info isNil ifTrue:[^ self].
+
+ space := info space.
+ whichMenu := info menuWithNewItem.
+ menuItemToRemove := info item.
+ before := info before.
+
+ menuIndex := whichMenu findFirst:[:item |
+ (item nameKey notNil and:[item nameKey == menuItemToRemove nameKey])
+ or:[ (item activeHelpKey notNil and:[item activeHelpKey == menuItemToRemove activeHelpKey])
+ or:[ (item label notNil and:[item label = menuItemToRemove label]) ]]
+ ].
+ menuIndex ~~ 0 ifTrue:[
+ whichMenu remove: menuIndex.
+ space ifTrue: [
+ whichMenu remove:(menuIndex - (before ifTrue:0 ifFalse:1))
+ ].
+ addedToolsCollection removeKey:menuItemToRemove
+ ] ifFalse:[
+ addedToolsCollection removeKey:menuItemToRemove.
+ ^ self
+ ].
+ ].
+
+
+ "
+ Transcript topView application
+ removeUserTool:'Bar'
+ "
+ "
+ Transcript topView application
+ removeUserTool:'Foo'
+ "
+
+
+
+! !
+
!NewLauncher class methodsFor:'menu specs'!
menu
@@ -2879,19 +2971,7 @@
This can be invoked by a classes #deinitialize method,
to remove its item from the toolbar or menu.
"
-
- self removeUserTool:toolNameOrMenuItem from:UserAddedToolBarItems.
- self removeUserTool:toolNameOrMenuItem from:UserAddedMenuItems.
-
- "
- Transcript topView application
- removeUserTool:'Bar'
- "
- "
- Transcript topView application
- removeUserTool:'Foo'
- "
-
+ self class removeUserTool:toolNameOrMenuItem
!
removeUserTool:toolNameOrMenuItem from:addedToolsCollection
@@ -2900,46 +2980,7 @@
to remove its item from the toolbar or menu.
"
- |info space menuIndex removeInMenuBlock whichMenu before menuItemToRemove|
-
- addedToolsCollection size == 0 ifTrue: [^nil].
-
- [true] whileTrue:[
- (toolNameOrMenuItem isString or:[toolNameOrMenuItem isSymbol]) ifTrue:[
- info := addedToolsCollection detect:[:eachInfo | |eachItem|
- eachItem := eachInfo item.
- (eachItem nameKey notNil and:[ toolNameOrMenuItem = eachItem nameKey])
- or:[ (eachItem activeHelpKey notNil and:[ toolNameOrMenuItem = eachItem activeHelpKey])
- or:[ (eachItem label notNil and:[ toolNameOrMenuItem = eachItem label])]]
- ]
- ifNone:nil.
- ] ifFalse:[
- info := addedToolsCollection detect:[:eachInfo | |eachItem| eachItem := eachInfo item. (eachItem == toolNameOrMenuItem)] ifNone:nil.
- ].
- info isNil ifTrue:[^ self].
-
- space := info space.
- whichMenu := info menuWithNewItem.
- menuItemToRemove := info item.
- before := info before.
-
- menuIndex := whichMenu findFirst:[:item |
- (item nameKey notNil and:[item nameKey == menuItemToRemove nameKey])
- or:[ (item activeHelpKey notNil and:[item activeHelpKey == menuItemToRemove activeHelpKey])
- or:[ (item label notNil and:[item label = menuItemToRemove label]) ]]
- ].
- menuIndex ~~ 0 ifTrue:[
- whichMenu remove: menuIndex.
- space ifTrue: [
- whichMenu remove:(menuIndex - (before ifTrue:0 ifFalse:1))
- ].
- addedToolsCollection removeKey:menuItemToRemove
- ] ifFalse:[
- addedToolsCollection removeKey:menuItemToRemove.
- ^ self
- ].
- ].
-
+ self class removeUserTool:toolNameOrMenuItem from:addedToolsCollection
"
Transcript topView application
@@ -3470,5 +3511,5 @@
!NewLauncher class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/NewLauncher.st,v 1.192 2000-08-20 12:32:21 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/NewLauncher.st,v 1.193 2000-08-20 12:38:35 cg Exp $'
! !