IdeApplication: Builder SDK Reference

## IdeApplication IdeApplication — Application singleton and extensions |

## Functions

GThread * | ide_application_get_main_thread ()
IdeApplicationMode | ide_application_get_mode ()
IdeApplication * | ide_application_new ()
GDateTime * | ide_application_get_started_at ()
IdeTransferManager * | ide_application_get_transfer_manager ()
IdeRecentProjects * | ide_application_get_recent_projects ()
void | ide_application_show_projects_window ()
const gchar * | ide_application_get_keybindings_mode ()
void | ide_application_get_worker_async ()
GDBusProxy * | ide_application_get_worker_finish ()
gboolean | ide_application_open_project ()
void | ide_application_add_reaper ()
GFile * | ide_application_get_projects_directory ()
gboolean | ide_application_has_network ()

## Types and Values

#define | IDE_TYPE_APPLICATION
#define | IDE_APPLICATION_DEFAULT
enum | IdeApplicationMode
| IdeApplication

## Object Hierarchy

        GObject
        ╰── GApplication
            ╰── GtkApplication
                ╰── DzlApplication
                    ╰── IdeApplication

## Implemented Interfaces

IdeApplication implements GActionGroup and GActionMap.

## Description

The IdeApplication class is a singleton whose lifetime is synchronized to the lifetime of the process. This manages necessary tweaks required by the application (such as menus, theming, and keybindings) as well as application plugins.

#### Extensions

If you need to extend Builder in a way that requires services that are tied to the lifetime of the process (rather than the lifetime of the project), then IdeApplicationAddin provides the extension point you need.

## Functions

### ide_application_get_main_thread ()

    GThread *
    ide_application_get_main_thread (void);

This function returns the thread-id of the main thread for the application. This is only really useful to determine if you are in the main UI thread. This is used by IDE_IS_MAIN_THREAD for assertion checks.

#### Returns

a GThread.

[transfer none]

### ide_application_get_mode ()

    IdeApplicationMode
    ide_application_get_mode (IdeApplication *self);

Gets the mode of the application which describes if we are the UI process, worker process, or internal test runner.

#### Parameters

self | An IdeApplication |

#### Returns

the IdeApplicationMode

Since: 3.20

### ide_application_new ()

    IdeApplication *
    ide_application_new (void);

Creates a new IdeApplication. This should only be used by the application entry point.

Since: 3.22

### ide_application_get_started_at ()

    GDateTime *
    ide_application_get_started_at (IdeApplication *self);

Gets the startup time of the application.

#### Parameters

self | an IdeApplication. |

#### Returns

a GDateTime.

[transfer none]

### ide_application_get_transfer_manager ()

    IdeTransferManager *
    ide_application_get_transfer_manager (IdeApplication *self);

Gets the transfer manager for the application.

#### Parameters

self | a IdeApplication |

#### Returns

An IdeTransferManager.

[transfer none]

Since: 3.28

### ide_application_get_recent_projects ()

    IdeRecentProjects *
    ide_application_get_recent_projects (IdeApplication *self);

This method will retreive an IdeRecentProjects for the application that represents recent and discover projects on the system.

#### Parameters

self | An IdeApplication. |

#### Returns

An IdeRecentProjects.

[transfer none]

### ide_application_show_projects_window ()

    void
    ide_application_show_projects_window (IdeApplication *self);

### ide_application_get_keybindings_mode ()

    const gchar *
    ide_application_get_keybindings_mode (IdeApplication *self);

### ide_application_get_worker_async ()

    void
    ide_application_get_worker_async (IdeApplication *self,
                                      const gchar *plugin_name,
                                      GCancellable *cancellable,
                                      GAsyncReadyCallback callback,
                                      gpointer user_data);

Asynchronously requests a GDBusProxy to a service provided in a worker process. The worker should be an IdeWorker implemented by the plugin named `plugin_name` . The IdeWorker is responsible for created both the service registered on the bus and the proxy to it.

The IdeApplication is responsible for spawning a subprocess for the worker.

`callback` should call `ide_application_get_worker_finish()` with the result provided to retrieve the result.

#### Parameters

self | an IdeApplication |
plugin_name | The name of the plugin. |
cancellable | a GCancellable or `NULL`. | [allow-none]
callback | a GAsyncReadyCallback or `NULL`. |
user_data | user data for `callback` . |

### ide_application_get_worker_finish ()

    GDBusProxy *
    ide_application_get_worker_finish (IdeApplication *self,
                                       GAsyncResult *result,
                                       GError **error);

Completes an asynchronous request to get a proxy to a worker process.

#### Parameters

self | an IdeApplication. |
result | a GAsyncResult |
error | a location for a GError, or `NULL`. |

#### Returns

a GDBusProxy or `NULL`.

[transfer full]

### ide_application_open_project ()

    gboolean
    ide_application_open_project (IdeApplication *self,
                                  GFile *file);

Attempts to load the project found at `file` .

#### Parameters

self | a IdeApplication |
file | a GFile |

#### Returns

`TRUE` if the project is already open, otherwise `FALSE`.

Since: 3.22

### ide_application_add_reaper ()

    void
    ide_application_add_reaper (IdeApplication *self,
                                DzlDirectoryReaper *reaper);

Adds a directory reaper which will be executed as part of the cleanup process when exiting Builder.

#### Parameters

self | a IdeApplication |
reaper | a DzlDirectoryReaper |

Since: 3.24

### ide_application_get_projects_directory ()

    GFile *
    ide_application_get_projects_directory
                                   (IdeApplication *self);

Gets the directory to store projects within.

First, this checks GSettings for a directory. If that directory exists, it is returned.

If not, it then checks for the non-translated name "Projects" in the users home directory. If it exists, that is returned.

If that does not exist, and a GSetting path existed, but was non-existant that is returned.

If the GSetting was empty, the translated name "Projects" is returned.

#### Parameters

self | an IdeApplication |

#### Returns

a GFile.

[not nullable][transfer full]

Since: 3.28

### ide_application_has_network ()

    gboolean
    ide_application_has_network (IdeApplication *self);

This is a helper that uses an internal GNetworkMonitor to track if we have access to the network. It works around some issues we've seen in the wild that make determining if we have network access difficult.

#### Parameters

self | a IdeApplication. | [nullable]

#### Returns

`TRUE` if we think there is network access.

Since: 3.30

## Types and Values

### IDE_TYPE_APPLICATION

    #define IDE_TYPE_APPLICATION    (ide_application_get_type())

### IDE_APPLICATION_DEFAULT

    #define IDE_APPLICATION_DEFAULT (IDE_APPLICATION (g_application_get_default()))

### enum IdeApplicationMode

#### Members

IDE_APPLICATION_MODE_PRIMARY |  |
IDE_APPLICATION_MODE_WORKER |  |
IDE_APPLICATION_MODE_TOOL |  |
IDE_APPLICATION_MODE_TESTS |  |

### IdeApplication

    typedef struct _IdeApplication IdeApplication;