#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Tue, 01 May 2018 10:39:13 +0200
changeset 4083014bc5ef8149
parent 4082 f2ffa50dcf0b
child 4084 c8e84f0ba64e
#FEATURE by cg
class: Menu
also search for slices in the view itself
(if the app does not provide one)

added:
#findGuiResourcesIn:for:
#findGuiResourcesIn:for:rememberResourcesIn:
changed:
#findGuiResourcesIn:
#findGuiResourcesIn:rememberResourcesIn:
Menu.st
     1.1 --- a/Menu.st	Mon Apr 16 17:31:54 2018 +0200
     1.2 +++ b/Menu.st	Tue May 01 10:39:13 2018 +0200
     1.3 @@ -579,17 +579,27 @@
     1.4      "resolve national language translations from aResourceContainerOrApplication.
     1.5       Unless already set, remember aResourceContainerOrApplication as menu receiver"
     1.6  
     1.7 +    ^ self findGuiResourcesIn:aResourceContainerOrApplication for:nil
     1.8 +
     1.9 +    "Modified: / 26-10-2006 / 16:37:57 / cg"
    1.10 +!
    1.11 +
    1.12 +findGuiResourcesIn:aResourceContainerOrApplication for:aViewOrNil
    1.13 +    "resolve national language translations from aResourceContainerOrApplication.
    1.14 +     Unless already set, remember aResourceContainerOrApplication as menu receiver"
    1.15 +
    1.16      receiver isNil ifTrue:[
    1.17          receiver := aResourceContainerOrApplication
    1.18      ].
    1.19      self 
    1.20 -        findGuiResourcesIn:aResourceContainerOrApplication 
    1.21 +        findGuiResourcesIn:aResourceContainerOrApplication
    1.22 +        for:aViewOrNil
    1.23          rememberResourcesIn:(ValueHolder new)
    1.24  
    1.25      "Modified: / 26-10-2006 / 16:37:57 / cg"
    1.26  !
    1.27  
    1.28 -findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil
    1.29 +findGuiResourcesIn:aResourceContainerOrApplication for:aViewOrNil rememberResourcesIn:aValueHolderOrNil
    1.30      "resolve national language translations from aResourceContainerOrApplication"
    1.31  
    1.32      |need resolvedItems rcv|
    1.33 @@ -625,10 +635,18 @@
    1.34              rcv := aResourceContainerOrApplication.
    1.35              [rcv notNil and:[resItems isNil]] whileTrue:[
    1.36                  "/ pass down the original app while walking the master chain,
    1.37 -                "/ so that subclices can be redefined (is that what we want???)
    1.38 +                "/ so that subclices can be redefined by the master
    1.39 +                "/ (is that what we want???)
    1.40                  resItems := anItem resolveSliceMenuItemsIn:rcv for:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil.
    1.41                  rcv := rcv perform:#masterApplication ifNotUnderstood:nil.
    1.42              ].
    1.43 +            "/ if there is no mastApp, or it did not provide the slice,
    1.44 +            "/ ask the view itself.
    1.45 +            resItems isNil ifTrue:[
    1.46 +                aViewOrNil notNil ifTrue:[
    1.47 +                    resItems := anItem resolveSliceMenuItemsIn:aViewOrNil for:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil.
    1.48 +                ].
    1.49 +            ].
    1.50  
    1.51              resItems notEmptyOrNil ifTrue:[
    1.52                  resolvedItems addAll:resItems.
    1.53 @@ -641,6 +659,15 @@
    1.54      items := resolvedItems.
    1.55  
    1.56      "Modified: / 23-07-2017 / 12:17:58 / cg"
    1.57 +!
    1.58 +
    1.59 +findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil
    1.60 +    "resolve national language translations from aResourceContainerOrApplication"
    1.61 +
    1.62 +    ^ self 
    1.63 +        findGuiResourcesIn:aResourceContainerOrApplication 
    1.64 +        for:nil
    1.65 +        rememberResourcesIn:aValueHolderOrNil
    1.66  ! !
    1.67  
    1.68  !Menu methodsFor:'adding & removing'!