Class Application.Builder<B extends Application.Builder<B>>

Type Parameters:
B - the type of the Builder that is returned
All Implemented Interfaces:
BuilderInterface
Direct Known Subclasses:
Application.Builder
Enclosing class:
Application

public static class Application.Builder<B extends Application.Builder<B>> extends GObject.Builder<B>
Inner class implementing a builder pattern to construct a GObject with properties.
Since:
2.28
  • Constructor Details

    • Builder

      protected Builder()
      Default constructor for a Builder object.
  • Method Details

    • build

      public Application build()
      Finish building the Application object. This will call GObject.withProperties(Type, String[], Value[]) to create a new GObject instance, which is then cast to Application.
      Overrides:
      build in class GObject.Builder<B extends Application.Builder<B>>
      Returns:
      a new instance of Application with the properties that were set in the Builder object.
    • setActionGroup

      @Deprecated public B setActionGroup(ActionGroup actionGroup)
      Deprecated.
      Use the ActionMap interface instead. Never ever mix use of this API with use of GActionMap on the same application or things will go very badly wrong.
      The group of actions that the application exports.
      Parameters:
      actionGroup - the value for the action-group property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.28
    • setApplicationId

      public B setApplicationId(String applicationId)
      The unique identifier for the application.
      Parameters:
      applicationId - the value for the application-id property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.28
    • setFlags

      public B setFlags(Set<ApplicationFlags> flags)
      Flags specifying the behaviour of the application.
      Parameters:
      flags - the value for the flags property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.28
    • setInactivityTimeout

      public B setInactivityTimeout(int inactivityTimeout)
      Time (in milliseconds) to stay alive after becoming idle.
      Parameters:
      inactivityTimeout - the value for the inactivity-timeout property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.28
    • setResourceBasePath

      public B setResourceBasePath(String resourceBasePath)
      The base resource path for the application.
      Parameters:
      resourceBasePath - the value for the resource-base-path property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.28
    • setVersion

      public B setVersion(String version)
      The human-readable version number of the application.
      Parameters:
      version - the value for the version property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.80
    • setFlags

      public B setFlags(ApplicationFlags... flags)
      Flags specifying the behaviour of the application.
      Parameters:
      flags - the value for the flags property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.28
    • onActivate

      public B onActivate(Application.ActivateCallback handler)
      The ::activate signal is emitted on the primary instance when an activation occurs. See g_application_activate().
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onCommandLine

      public B onCommandLine(Application.CommandLineCallback handler)
      The ::command-line signal is emitted on the primary instance when a commandline is not handled locally. See g_application_run() and the GApplicationCommandLine documentation for more information.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onHandleLocalOptions

      public B onHandleLocalOptions(Application.HandleLocalOptionsCallback handler)

      The ::handle-local-options signal is emitted on the local instance after the parsing of the commandline options has occurred.

      You can add options to be recognised during commandline option parsing using g_application_add_main_option_entries() and g_application_add_option_group().

      Signal handlers can inspect options (along with values pointed to from the argData of an installed GOptionEntrys) in order to decide to perform certain actions, including direct local handling (which may be useful for options like --version).

      In the event that the application is marked ApplicationFlags.HANDLES_COMMAND_LINE the "normal processing" will send the options dictionary to the primary instance where it can be read with g_application_command_line_get_options_dict(). The signal handler can modify the dictionary before returning, and the modified dictionary will be sent.

      In the event that ApplicationFlags.HANDLES_COMMAND_LINE is not set, "normal processing" will treat the remaining uncollected command line arguments as filenames or URIs. If there are no arguments, the application is activated by g_application_activate(). One or more arguments results in a call to g_application_open().

      If you want to handle the local commandline arguments for yourself by converting them to calls to g_application_open() or g_action_group_activate_action() then you must be sure to register the application first. You should probably not call g_application_activate() for yourself, however: just return -1 and allow the default handler to do it for you. This will ensure that the --gapplication-service switch works properly (i.e. no activation in that case).

      Note that this signal is emitted from the default implementation of local_command_line(). If you override that function and don't chain up then this signal will never be emitted.

      You can override local_command_line() if you need more powerful capabilities than what is provided here, but this should not normally be required.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.40
      See Also:
    • onNameLost

      public B onNameLost(Application.NameLostCallback handler)

      The ::name-lost signal is emitted only on the registered primary instance when a new instance has taken over. This can only happen if the application is using the ApplicationFlags.ALLOW_REPLACEMENT flag.

      The default handler for this signal calls g_application_quit().

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      2.60
      See Also:
    • onOpen

      public B onOpen(Application.OpenCallback handler)
      The ::open signal is emitted on the primary instance when there are files to open. See g_application_open() for more information.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onShutdown

      public B onShutdown(Application.ShutdownCallback handler)
      The ::shutdown signal is emitted only on the registered primary instance immediately after the main loop terminates.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onStartup

      public B onStartup(Application.StartupCallback handler)
      The ::startup signal is emitted on the primary instance immediately after registration. See g_application_register().
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also: