--- a/NewLauncher.st Thu Jul 30 11:29:04 1998 +0200
+++ b/NewLauncher.st Thu Jul 30 17:04:36 1998 +0200
@@ -14,7 +14,7 @@
ToolApplicationModel subclass:#NewLauncher
instanceVariableNames:'transcript isMainLauncher helpIsOn'
- classVariableNames:'OpenLaunchers NotifyingEmergencyHandler'
+ classVariableNames:'OpenLaunchers NotifyingEmergencyHandler UserAddedTools'
poolDictionaries:''
category:'Interface-Smalltalk'
!
@@ -2427,6 +2427,14 @@
"increase my priority"
self builder window windowGroup process priority:(Processor userSchedulingPriority + 1).
+ UserAddedTools associationsDo:
+ [:userTool|
+ self addUserTool: userTool key
+ action: (userTool value at: 1)
+ in: (userTool value at: 2)
+ icon: (userTool value at: 3)
+ space: (userTool value at: 4)
+ ].
super postOpenWith:aBuilder.
self startClockOnTimedBlock:
[
@@ -5199,6 +5207,77 @@
!NewLauncher methodsFor:'user actions - tools'!
+addUserTool: toolName action: action icon: icon
+ "adds a menu item labeled toolName, and action and icon both to the
+ sub menu 'Tools' and the tool bar.
+ "
+
+ self addUserTool: toolName action: action in: nil icon: icon space: true
+
+!
+
+addUserTool: toolName action: action in: what icon: icon space: space
+ "adds a menu item labeled toolName, and action and icon;
+ for what == #menu menu item is added at the end of the sub menu 'Tools',
+ for what == #toolbar menu item is added at the end of the tool bar,
+ "
+
+ |menuPanel freeMenuIndex|
+
+ (what isNil or: [what == #toolbar])
+ ifTrue:
+ [
+ menuPanel := builder namedComponents at: #menuToolbarView.
+
+ (menuPanel findFirst: [:i| i activeHelpKey = toolName]) == 0
+ ifTrue:
+ [
+ freeMenuIndex := menuPanel numberOfItems + 1.
+ space
+ ifTrue:
+ [
+ (menuPanel createAtIndex: freeMenuIndex) menuItem: (MenuItem labeled: '').
+ freeMenuIndex := freeMenuIndex + 1.
+ ].
+
+ (menuPanel createAtIndex: freeMenuIndex) menuItem:
+ (MenuItem new
+ label: toolName;
+ value: action;
+ isButton: true;
+ labelImage: icon;
+ activeHelpKey: toolName)
+ ].
+ ].
+ (what isNil or: [what== #menu])
+ ifTrue:
+ [
+ menuPanel := ((self builder window subViews at: 1 ifAbsent: [^self]) itemAt: 4) submenu.
+
+ (menuPanel findFirst: [:i| i activeHelpKey = toolName]) == 0
+ ifTrue:
+ [
+ freeMenuIndex := menuPanel numberOfItems + 1.
+ space
+ ifTrue:
+ [
+ (menuPanel createAtIndex: freeMenuIndex) menuItem: (MenuItem labeled: '-').
+ freeMenuIndex := freeMenuIndex + 1.
+ ].
+
+ (menuPanel createAtIndex: freeMenuIndex) menuItem:
+ (MenuItem new
+ label: toolName;
+ value: action;
+ labelImage: (LabelAndIcon icon: icon string: toolName);
+ activeHelpKey: toolName)
+ ].
+ ].
+
+ UserAddedTools isNil ifTrue: [UserAddedTools := Dictionary new].
+ UserAddedTools at: toolName put: (Array with: action with: what with: icon with: space)
+!
+
newProject
"creates a new project & opens a projectView for it"
@@ -5211,6 +5290,34 @@
"Created: / 27.7.1998 / 12:48:30 / cg"
!
+removeUserTool: toolName
+ "removes a menu item labeled toolName
+ "
+
+ |userTool space menuIndex removeInMenuBlock|
+
+ UserAddedTools isNil ifTrue: [^nil].
+ userTool := UserAddedTools at: toolName ifAbsent: [^nil].
+ space := userTool at: 4.
+
+ removeInMenuBlock :=
+ [:menuPanel|
+ (menuIndex := menuPanel findFirst: [:i| i activeHelpKey = toolName]) ~~ 0
+ ifTrue:
+ [
+ menuPanel remove: menuIndex.
+ space ifTrue: [menuPanel remove: menuIndex - 1].
+ ].
+ ].
+
+ removeInMenuBlock value: (builder namedComponents at: #menuToolbarView).
+ removeInMenuBlock value: ((self builder window subViews at: 1 ifAbsent: [^self]) itemAt: 4) submenu.
+
+
+ UserAddedTools removeKey: toolName
+
+!
+
selectProject
"asks for and switch to another project"
@@ -5432,5 +5539,5 @@
!NewLauncher class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/NewLauncher.st,v 1.84 1998-07-28 09:57:47 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/NewLauncher.st,v 1.85 1998-07-30 15:04:36 tz Exp $'
! !