NSObject | +---GTKMain | +---GTKApplication
The GTKApplication class controls the running application, and exactly one instance of this class must be created when the program starts. This GTKApplication object is globally accessible through the variable GTKApp, so there is no need to pass it as an argument to method calls.
Most of the methods of GTKApplication are implemented in its base class GTKMain, so look there for additional methods to control the event loop.
+ (GTKApplication *) sharedApplication
Return the shared application object (as stored in the variable GTKApp). This method will raise an NSGenericException if the application object has not yet been created.
Return the application object's delegate.
This method is invoked automatically by the -run method (see below) just before the application's main event loop will be started. It currently does nothing except for posting (in this order) the GTKApplicationWillFinishLaunchingNotification and GTKApplicationDidFinishLaunchingNotification to the default notification center.
- (id) initWithArgc:(int *) argc argv:(char ***) argv
Initialize a new GTKApplication object and store it in the global variable GTKApp. Note that you cannot create more than one application object in your program. This method will modify the program's command line arguments as given by argc and argv and remove any options related to GTK (such as --display or --class) from the argument list.
If the environment variable GTOOLKIT_DEBUG has been set, the GTKApplication class will activate special debug code to trace object allocation and deallocation calls.
Check whether the application is active.
Check whether the main event loop is running.
- (GTKWindow *) mainWindow
Return the application's current main window (the active window) or nil if the application is not active (or has no windows).
- (void) reportException:(NSException *) exception
Report an exception to stderr. This method simply calls NSLog() to print the exception's name and reason.
Start the application's main event loop.
- (int) runModalForWindow:(GTKWindow *) window
Start a modal event loop for the given window, i.e. restrict all events for this application to the specified window. This input mechanism should only be used for panels or windows that require immediate user interaction. Generally, it is best to avoid modal windows if possible.
-runModalForWindow: does not return until the modal event loop is terminated by a -stopModalWithCode: message, and it returns the status code passed as an argument to this method.
- (void) setDelegate:(id) object
Set the application object's delegate or unset it (if delegate is nil). If the delegate implements any of the methods described in the protocol protocol GTKApplicationDelegate, it will be notified by the application object on the corresponding events.
Stop the application's main event loop (if it is running). This will cause the -run method to return (similar to -terminate:), but will not send any notifications. If a modal event loop is running, it will be stopped instead of the main event loop. The sender parameter is ignored.
Stop a running modal event loop with the code GTKRunStoppedResponse.
- (void) stopModalWithCode:(int) code
Stop a running modal event loop with the given code.
- (void) terminate:(id) sender
Tell the application's main event loop to finish (if it is running). This will cause the -run method to return, which will normally end the program. If a modal event loop is running, the program will be terminated anyway. The sender parameter is ignored.
If the delegate implements the method:
- (BOOL) applicationShouldTerminate:(GTKApplication *) senderthis message is sent to the delegate to determine whether the application should actually terminate. If it returns YES, this method will post the GTKApplicationWillTerminateNotification to the default notification center and terminate the event loop.
Return the application's window list.