Issue 5633 in pharo: Cleaning addUpdating: wordingSelector target: target selector: aSymbol argumentList: argList

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 5633 in pharo: Cleaning addUpdating: wordingSelector target: target selector: aSymbol argumentList: argList

pharo
Status: Accepted
Owner: [hidden email]
Labels: Milestone-2.0

New issue 5633 by [hidden email]: Cleaning addUpdating:  
wordingSelector target: target selector: aSymbol argumentList: argList
http://code.google.com/p/pharo/issues/detail?id=5633

addUpdating: wordingSelector target: target selector: aSymbol argumentList:  
argList

parses a string containing <yes> to know what to do.

addUpdating: wordingSelector target: target selector: aSymbol argumentList:  
argList
        "Append a menu item with the given label. If the item is selected, it will  
send the given selector to the target object with the given arguments. If  
the selector takes one more argument than the number of arguments in the  
given list, then the triggering event is supplied as as the last argument.  
In this variant, the initial wording of the menu item is obtained by  
sending the wordingSelector to the target. If the wording prefixed with  
<yes> or <no>, the on/off state of the menu item will reflect it."

        |aString str|
        aString := (MessageSend receiver: target selector: wordingSelector)
                valueWithEnoughArguments: argList.
        str := aString readStream.
        (str skipTo: $>) ifTrue: [aString := str upToEnd].
        self
                addToggle: aString
                target: target
                selector: aSymbol
                getStateSelector: wordingSelector
                enablementSelector: nil
                argumentList: argList

cool no? A message send instead of a perform


The API is bad because client such as layoutMenuPropertyString: aSymbol  
from: currentSetting are forced to pass string instead of a structure with  
a {{true . string} . { false. string}


layoutMenuPropertyString: aSymbol from: currentSetting
        | onOff wording |
        onOff := aSymbol == currentSetting
                                ifTrue: ['<on>']
                                ifFalse: ['<off>'].
        ""
        wording := String
                                streamContents: [:stream |
                                        | index |
                                        index := 1.
                                        aSymbol
                                                keysAndValuesDo: [:idx :ch | ch isUppercase
                                                                ifTrue: [""stream nextPutAll: (aSymbol copyFrom: index to: idx - 1)  
asLowercase.
                                                                        stream nextPutAll: ' '.
                                                                        index := idx]].
                                        index < aSymbol size
                                                ifTrue: [stream nextPutAll: (aSymbol copyFrom: index to: aSymbol  
size) asLowercase]].
        ""
        ^ onOff , wording translated


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5633 in pharo: Cleaning addUpdating: wordingSelector target: target selector: aSymbol argumentList: argList

pharo

Comment #1 on issue 5633 by [hidden email]: Cleaning addUpdating:  
wordingSelector target: target selector: aSymbol argumentList: argList
http://code.google.com/p/pharo/issues/detail?id=5633

contents: aString withMarkers: aBool inverse: inverse
        "Set the menu item entry. If aBool is true, parse aString for embedded  
markers."

        | markerIndex marker |
        self contentString: nil. "get rid of old"
        aBool ifFalse: [^super contents: aString].
        self removeAllMorphs. "get rid of old markers if updating"
        self hasIcon ifTrue: [ self icon: nil ].
        (aString notEmpty and: [aString first = $<])
                ifFalse: [^super contents: aString].
        markerIndex := aString indexOf: $>.
        markerIndex = 0 ifTrue: [^super contents: aString].
        marker := (aString copyFrom: 1 to: markerIndex) asLowercase.
        (#('<on>' '<off>' '<yes>' '<no>') includes: marker)
                ifFalse: [^super contents: aString].
        self contentString: aString. "remember actual string"
        marker := (marker = '<on>' or: [marker = '<yes>']) ~= inverse
                                ifTrue: [self onImage]
                                ifFalse: [self offImage].
        super contents:  (aString copyFrom: markerIndex + 1 to: aString size).
        "And set the marker"
        marker := ImageMorph new image: marker.
        marker position: self left @ (self top + 2).
        self addMorphFront: marker


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5633 in pharo: Cleaning addUpdating: wordingSelector target: target selector: aSymbol argumentList: argList

pharo

Comment #2 on issue 5633 by [hidden email]: Cleaning addUpdating:  
wordingSelector target: target selector: aSymbol argumentList: argList
http://code.google.com/p/pharo/issues/detail?id=5633

analyzeLabel
        "For Morphic compatiblity. Some labels include markup such as <on>, <off>  
etc.
        Analyze the label for these annotations and take appropriate action."
        label ifNotNil: [
                | marker |
                marker := label copyFrom: 1 to: (label indexOf: $>).
                (marker = '<on>' or:[marker = '<yes>']) ifTrue:[
                        checked := true.
                        label := label copyFrom: marker size+1 to: label size.
                ].
                (marker = '<off>' or:[marker = '<no>']) ifTrue:[
                        checked := false.
                        label := label copyFrom: marker size+1 to: label size.
                ]]



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5633 in pharo: Cleaning addUpdating: wordingSelector target: target selector: aSymbol argumentList: argList

pharo
In reply to this post by pharo
Updates:
        Status: FixToInclude

Comment #4 on issue 5633 by [hidden email]: Cleaning addUpdating:  
wordingSelector target: target selector: aSymbol argumentList: argList
http://code.google.com/p/pharo/issues/detail?id=5633

I will produce a slice

Attachments:
        Cleaning.1.cs  17.1 KB


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 5633 in pharo: Cleaning addUpdating: wordingSelector target: target selector: aSymbol argumentList: argList

pharo
Updates:
        Status: Integrated

Comment #5 on issue 5633 by [hidden email]: Cleaning addUpdating:  
wordingSelector target: target selector: aSymbol argumentList: argList
http://code.google.com/p/pharo/issues/detail?id=5633

in 2.0 022


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker