<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<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>Hi Marcel,</p>
<p><br>
</p>
<p>> <span>you are proposing an interface to temporarily override specific preferences with an automatic restoring to their previous values after a work block.</span></p>
<p><span><br>
</span></p>
<p><span>I think that's not actually a new interface, it's just a convenience method for #<span>setPreference:toValue:during:. It should only complement #setPreferences: which was my actual proposal.</span></span></p>
<p><span><span><br>
</span></span></p>
<p><span><span>Do you think we should prefer the pair-based implementation (#setPreferencesFrom:) over the association-based proposal? If yes, I would like to complement it with a #setPreferencesFrom:during: implementation, just to align it with #setPreference:toValue:
 and #setPreference:toValue:during:.</span></span></p>
<p><span><span><br>
</span></span></p>
<p><span><span>> </span></span><span style="font-size: 12pt;">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><span><span></span></span></p>
<div><br>
</div>
<div>Thank you for the pointer! I have often used this in test code and always ignored the fact that this reveals the private storage format of the Preferences class.</div>
<div>However, I find it quite useful to control all preferences from one central place. Should we maybe introduce an extra protocol for accessing pragma preferences?</div>
<div><b>Preferences setPreferenceFrom: Model key: #useColorfulWindows toValue: #false.</b></div>
<div>It feels so inconsistent to mix calls to Preferences with calls to separate classes ...</div>
<div><br>
</div>
<div>I would definitively favor something like</div>
<div><b>Preferences</b></div>
<div><b>    setPreferencesFrom: #(</b></div>
<div><b>        (balloonHelpEnabled false)</b></div>
<div><b>        (Model useColorfulWindows false)</b></div>
<div><b>        (TextEditor autoEnclose true))</b></div>
<div><b>    during: [self perfomTest]</b></div>
<div>-over-</div>
<div><b>Preferences setPreference: #balloonHelpEnabled toValue: false during: [</b></div>
<div><b>    lastModel := Model useColorfulWindows.</b></div>
<div><b>    enclose := TextEditor enclose.</b></div>
<div><b>    Model useColorfulWindows: false.</b></div>
<div><b>    TextEditor autoEnclose: true.</b></div>
<div><b>    [self performTest] ensure: [</b></div>
<div><b>        Model useColorfulWindows: lastModel.</b></div>
<div><b>        TextEditor autoEnclose: enclose]]!</b></div>
<div><br>
</div>
<div>(I'm a big fan of the execution around pattern :-))</div>
<div><br>
</div>
<div>Regarding your proposal #<span>restoreAfter: - wouldn't this be an O(n) approach instead of an O(1) approach?</span></div>
<p></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><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" 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 14:51:32<br>
<b>An:</b> John Pfersich via Squeak-dev<br>
<b>Betreff:</b> Re: [squeak-dev] The Inbox: System-ct.1119.mcz</font>
<div> </div>
</div>
<div>
<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>
</div>
</body>
</html>