File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed
Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,8 @@ static private void createAndShowGUI(String[] args) {
198198 // run static initialization that grabs all the prefs
199199 Preferences .init ();
200200
201+ PreferencesEvents .onUpdated (Preferences ::init );
202+
201203 // boolean flag indicating whether to create new server instance or not
202204 boolean createNewInstance = DEBUG || !SingleInstance .alreadyRunning (args );
203205
Original file line number Diff line number Diff line change 11package processing.app
22
33import androidx.compose.runtime.*
4- import kotlinx.coroutines.Dispatchers
5- import kotlinx.coroutines.FlowPreview
6- import kotlinx.coroutines.delay
4+ import kotlinx.coroutines.*
75import kotlinx.coroutines.flow.debounce
86import kotlinx.coroutines.flow.dropWhile
9- import kotlinx.coroutines.launch
107import processing.utils.Settings
118import java.io.File
129import java.io.InputStream
@@ -134,10 +131,9 @@ fun PreferencesProvider(content: @Composable () -> Unit) {
134131 .joinToString(" \n " ) { (key, value) -> " $key =$value " }
135132 .toByteArray()
136133 )
137-
138- // Reload legacy Preferences
139- Preferences .init ()
140134 output.close()
135+
136+ PreferencesEvents .updated()
141137 }
142138 }
143139 }
@@ -205,4 +201,19 @@ fun watchFile(file: File): Any? {
205201 }
206202 }
207203 return event
204+ }
205+
206+ class PreferencesEvents {
207+ companion object {
208+ val updatedListeners = mutableListOf<Runnable >()
209+
210+ @JvmStatic
211+ fun onUpdated (callback : Runnable ) {
212+ updatedListeners.add(callback)
213+ }
214+
215+ fun updated () {
216+ updatedListeners.forEach { it.run () }
217+ }
218+ }
208219}
Original file line number Diff line number Diff line change @@ -371,6 +371,7 @@ public void actionPerformed(ActionEvent e) {
371371 });
372372 }
373373
374+ PreferencesEvents .onUpdated (this ::updateTheme );
374375 }
375376
376377
You can’t perform that action at this time.
0 commit comments