forked from aparoksha/adwaita-swift
Add support for spawning windows outside the app
This commit is contained in:
parent
d63dec3c6b
commit
8b27a08764
@ -41,6 +41,14 @@ extension App {
|
|||||||
|
|
||||||
/// The application's entry point.
|
/// The application's entry point.
|
||||||
public static func main() {
|
public static func main() {
|
||||||
|
let app = setupApp()
|
||||||
|
app.run()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Initialize and get the GTUI app.
|
||||||
|
///
|
||||||
|
/// To run the app, call the ``GTUIApp/run()`` function.
|
||||||
|
public static func setupApp() -> GTUIApp {
|
||||||
var appInstance = self.init()
|
var appInstance = self.init()
|
||||||
appInstance.app = GTUIApp(appInstance.id) { appInstance }
|
appInstance.app = GTUIApp(appInstance.id) { appInstance }
|
||||||
GTUIApp.updateHandlers.append { force in
|
GTUIApp.updateHandlers.append { force in
|
||||||
@ -57,7 +65,7 @@ extension App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
GTUIApp.appID = appInstance.id
|
GTUIApp.appID = appInstance.id
|
||||||
appInstance.app.run()
|
return appInstance.app
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,8 +48,16 @@ public class GTUIApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Run the application.
|
/// Run the application.
|
||||||
public func run() {
|
/// - Parameters:
|
||||||
let data = ViewStorage.SignalData { self.onActivate() }
|
/// - automaticSetup: Whether the initial windows should be added.
|
||||||
|
/// - manualSetup: A closure that is executed in the main loop.
|
||||||
|
public func run(automaticSetup: Bool = true, manualSetup: @escaping () -> Void = { }) {
|
||||||
|
let data = ViewStorage.SignalData {
|
||||||
|
if automaticSetup {
|
||||||
|
self.onActivate()
|
||||||
|
}
|
||||||
|
manualSetup()
|
||||||
|
}
|
||||||
fields["run"] = data
|
fields["run"] = data
|
||||||
g_signal_connect_data(
|
g_signal_connect_data(
|
||||||
pointer?.cast(),
|
pointer?.cast(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user