diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-05-06 16:35:51 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-05-06 16:35:51 +0200 |
| commit | 7d075814ea7bd67a2e421929fbd829cb78b0ac8f (patch) | |
| tree | 035e881d7d27d318ab89194eeff32648e3af3668 /main/src/ui/application.vala | |
| parent | 78333ce2506cf51f4e228ec5ee879262a19847a8 (diff) | |
Inhibit suspend on login1 PrepareForSleepinhibit-before-suspend
Diffstat (limited to 'main/src/ui/application.vala')
| -rw-r--r-- | main/src/ui/application.vala | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index 6c02087f..047fd57e 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -20,6 +20,7 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { public StreamInteractor stream_interactor { get; set; } public Plugins.Registry plugin_registry { get; set; default = new Plugins.Registry(); } public SearchPathGenerator? search_path_generator { get; set; } + private uint inhibit_cookie; internal static bool print_version = false; private const OptionEntry[] options = { @@ -30,6 +31,22 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { public Application() throws Error { Object(application_id: "im.dino.Dino", flags: ApplicationFlags.HANDLES_OPEN); init(); + + stream_interactor.connection_manager.request_inhibit.connect((do_inhibit) => { + debug(@"requested inhibit [%i]", do_inhibit); + + if (do_inhibit) { + inhibit_cookie = inhibit(window, SUSPEND, "Preparing for sleep"); + + if (inhibit_cookie == 0) { + warning("suspend inhibit request failed or unsupported"); + } + } + else if (inhibit_cookie != 0) { + uninhibit(inhibit_cookie); + } + }); + Environment.set_application_name("Dino"); Window.set_default_icon_name("im.dino.Dino"); |
