--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SystemChangeNotifier.st Mon Oct 12 21:11:38 2009 +0200
@@ -0,0 +1,70 @@
+"{ Package: 'stx:libbasic' }"
+
+Object subclass:#SystemChangeNotifier
+ instanceVariableNames:'silenceLevel'
+ classVariableNames:'UniqueInstance'
+ poolDictionaries:''
+ category:'Kernel-Classes'
+!
+
+!SystemChangeNotifier class methodsFor:'documentation'!
+
+documentation
+"
+ For now, this implementation is mostly for squeak compatibility.
+ However, over time, we will move the change notification code from ClassDescription to here,
+ to make things easier to understand, and classDescription a little bit more lightweight.
+"
+! !
+
+!SystemChangeNotifier class methodsFor:'instance creaton'!
+
+uniqueInstance
+ "I am a singleton"
+
+ UniqueInstance isNil ifTrue: [UniqueInstance := self basicNew initialize].
+ ^ UniqueInstance
+
+ "
+ UniqueInstance releaseAll.
+ UniqueInstance := nil
+ "
+! !
+
+!SystemChangeNotifier methodsFor:'initialization'!
+
+initialize
+ "/ eventSource := SystemEventManager new.
+ silenceLevel := 0.
+! !
+
+!SystemChangeNotifier methodsFor:'public'!
+
+doSilently: aBlock
+ "Perform the block, and ensure that no system notification are broadcasted while doing so."
+
+ |result|
+
+ silenceLevel := silenceLevel + 1.
+ [
+ "/ temporary hack:
+ Class withoutUpdatingChangesDo:[
+ result := aBlock value
+ ]
+ ] ensure: [
+ silenceLevel > 0 ifTrue: [
+ silenceLevel := silenceLevel - 1
+ ]
+ ].
+ ^ result.
+!
+
+isBroadcasting
+ ^ silenceLevel = 0
+! !
+
+!SystemChangeNotifier class methodsFor:'documentation'!
+
+version_CVS
+ ^ '$Header: /cvs/stx/stx/libbasic/SystemChangeNotifier.st,v 1.1 2009-10-12 19:11:38 cg Exp $'
+! !