Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ static private void createAndShowGUI(String[] args) {
// run static initialization that grabs all the prefs
Preferences.init();

PreferencesEvents.onUpdated(Preferences::init);

// boolean flag indicating whether to create new server instance or not
boolean createNewInstance = DEBUG || !SingleInstance.alreadyRunning(args);

Expand Down
25 changes: 18 additions & 7 deletions app/src/processing/app/Preferences.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package processing.app

import androidx.compose.runtime.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.delay
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.dropWhile
import kotlinx.coroutines.launch
import processing.utils.Settings
import java.io.File
import java.io.InputStream
Expand Down Expand Up @@ -134,10 +131,9 @@ fun PreferencesProvider(content: @Composable () -> Unit) {
.joinToString("\n") { (key, value) -> "$key=$value" }
.toByteArray()
)

// Reload legacy Preferences
Preferences.init()
output.close()

PreferencesEvents.updated()
}
}
}
Expand Down Expand Up @@ -205,4 +201,19 @@ fun watchFile(file: File): Any? {
}
}
return event
}

class PreferencesEvents {
companion object {
val updatedListeners = mutableListOf<Runnable>()

@JvmStatic
fun onUpdated(callback: Runnable) {
updatedListeners.add(callback)
}

fun updated() {
updatedListeners.forEach { it.run() }
}
}
}
1 change: 1 addition & 0 deletions app/src/processing/app/ui/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ public void actionPerformed(ActionEvent e) {
});
}

PreferencesEvents.onUpdated(this::updateTheme);
}


Expand Down