<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
                                        
                                        
                                            
                                        
                                        
                                        Hi Christoph,<div><br></div><div>you are proposing an interface to temporarily override specific preferences with an automatic restoring to their previous values after a work block. The examples you pointed to in Flaps and <span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">PreferenceWizardMorph would both not benefit from such a mechanism.</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">You are also proposing an interface to set preferences from a list of associations. Yes, this is kind of duplicate to the already existing #setPreferencesFrom:, which expects a list of pairs . Also, the "key" for pragma preferences (i.e., "Model>>#useColorfulWindows")  is kind of a private implementation detail, I suppose. I would rather not expose it that way.</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">Squeak's current mix of pragma preferences and "old-style" preferences is not optimal. I think we have the policy to add new preferences always as pragma preferencs.</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">I think that it is a good idea to add a mechanism to conveniently restore preferences after a work block. What about this kind of interface:</span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><br></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px"><b>Preferences restoreAfter: [</b></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 16px">   </span><span style="font-family: Calibri, Helvetica, sans-serif;font-size: 12pt">Browser showClassIcons: true.</span></div><span style="font-size: 12pt;font-family: Calibri, Helvetica, sans-serif">   Preferences setFlag: #menuWithIcons toValue: switch.</span><div class="mb_sig"></div>
                                        
                                        <div><span style="font-size: 12pt;font-family: Calibri, Helvetica, sans-serif">   self doSomeThing].</span></div><div><span style="font-size: 12pt;font-family: Calibri, Helvetica, sans-serif"><br></span></div><div><span style="font-size: 12pt;font-family: Calibri, Helvetica, sans-serif">It would be easy to just copy all the preferences and restore them after the workblock.</span></div><div><span style="font-size: 12pt;font-family: Calibri, Helvetica, sans-serif"><br></span></div><div><span style="font-size: 12pt;font-family: Calibri, Helvetica, sans-serif">Still, I would rather not encourage such a trick in regular application code. Yet, it would be easy to hunt down and review all senders of #restoreAfter: from time to time ... Just my two cents. :-)</span></div><div><span style="font-size: 12pt;font-family: Calibri, Helvetica, sans-serif"><br></span></div><div><span style="font-size: 12pt;font-family: Calibri, Helvetica, sans-serif">Best,</span></div><div><span style="font-size: 12pt;font-family: Calibri, Helvetica, sans-serif">Marcel</span></div><blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
                        <p style="color: #AAAAAA; margin-top: 10px;">Am 29.10.2019 12:47:55 schrieb Thiede, Christoph <christoph.thiede@student.hpi.uni-potsdam.de>:</p><div style="font-family:Arial,Helvetica,sans-serif">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif" dir="ltr">
<p>Well, you could use it in methods such as <span>Flaps class >> makeNavigatorFlapResembleGoldenBar or PreferenceWizardMorph >> <span>toggleToolAndMenuIcons as well, but there are few of these senders outside of test methods.</span></span></p>
<p><span><span><br>
</span></span></p>
<p>However, I just discovered a possible duplicate, Preferences >> #setPreferencesFrom:. Do you think that's a problem? I think the old nested array style is less convenient compared to the use of associations, and there is no "during" version ...</p>
<p><br>
</p>
<p>Best,</p>
<p>Christoph</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family: Calibri,Arial,Helvetica,sans-serif;font-size: ;margin: 0">
<div><span style="font-size: 10pt;color: #808080"></span></div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><span style="font-family: Calibri, sans-serif;color: #000000"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel<br>
<b>Gesendet:</b> Dienstag, 29. Oktober 2019 10:59:30<br>
<b>An:</b> John Pfersich via Squeak-dev<br>
<b>Betreff:</b> Re: [squeak-dev] The Inbox: System-ct.1119.mcz</span>
<div> </div>
</div>
<div>
<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
Hmm.... this sounds like it is meant to be used in tests only. Or are there other scenarios? Putting this in regular application code might yield confusing effects or hacky code.
<div><br>
</div>
<div>So, what about putting this into an *SUnit extension category?</div>
<div><br>
</div>
<div>Best,</div>
<div>Marcel</div>
<div class="mb_sig"></div>
<blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
<p style="color: #AAAAAA; margin-top: 10px;">Am 26.10.2019 22:01:13 schrieb commits@source.squeak.org <commits@source.squeak.org>:</p>
<div style="font-family:Arial,Helvetica,sans-serif">A new version of System was added to project The Inbox:<br>
http://source.squeak.org/inbox/System-ct.1119.mcz<br>
<br>
==================== Summary ====================<br>
<br>
Name: System-ct.1119<br>
Author: ct<br>
Time: 26 October 2019, 10:00:59.779469 pm<br>
UUID: dc499ab1-dfe1-064c-a997-271a591d4b18<br>
Ancestors: System-mt.1116<br>
<br>
Adds convenience methods to change multiple preferences<br>
<br>
Usage example:<br>
<br>
Preferences<br>
setPreferences: {<br>
#(UIManager >> #openToolsAttachedToMouseCursor) join asSymbol -> false.<br>
#(Model >> #useColorfulWindows) join asSymbol -> false }<br>
during: [self notify: 'Carpe Squeak!']<br>
<br>
=============== Diff against System-mt.1116 ===============<br>
<br>
Item was added:<br>
+ ----- Method: Preferences class>>setPreferences: (in category 'get/set') -----<br>
+ setPreferences: associations<br>
+ <br>
+ associations associationsDo: [:association |<br>
+ self setPreference: association key toValue: association value].!<br>
<br>
Item was added:<br>
+ ----- Method: Preferences class>>setPreferences:during: (in category 'get/set') -----<br>
+ setPreferences: associations during: aBlock<br>
+ "Changes the given values for the duration of aBlock"<br>
+ <br>
+ | values previousValues |<br>
+ values := associations as: Dictionary.<br>
+ previousValues := values associations collect: [:association |<br>
+ association key -> (self valueOfFlag: association key)].<br>
+ self setPreferences: values.<br>
+ ^ aBlock ensure: [<br>
+ self setPreferences: previousValues]!<br>
<br>
<br>
</div>
</blockquote>
</div>
</div>
</div></blockquote></div>