Compare commits
2 Commits
master
...
inhibit-be
Author | SHA1 | Date |
---|---|---|
Xavier Del Campo Romero | 7d075814ea | |
Xavier Del Campo Romero | 78333ce250 |
|
@ -11,6 +11,7 @@ public class ConnectionManager : Object {
|
|||
public signal void stream_attached_modules(Account account, XmppStream stream);
|
||||
public signal void connection_state_changed(Account account, ConnectionState state);
|
||||
public signal void connection_error(Account account, ConnectionError error);
|
||||
public signal void request_inhibit(bool suspend);
|
||||
|
||||
public enum ConnectionState {
|
||||
CONNECTED,
|
||||
|
@ -348,9 +349,10 @@ public class ConnectionManager : Object {
|
|||
}
|
||||
|
||||
private async void on_prepare_for_sleep(bool suspend) {
|
||||
foreach (Account account in connections.keys) {
|
||||
change_connection_state(account, ConnectionState.DISCONNECTED);
|
||||
}
|
||||
request_inhibit(true);
|
||||
// foreach (Account account in connections.keys) {
|
||||
// change_connection_state(account, ConnectionState.DISCONNECTED);
|
||||
// }
|
||||
if (suspend) {
|
||||
debug("Login1: Device suspended");
|
||||
foreach (Account account in connections.keys) {
|
||||
|
@ -367,6 +369,7 @@ public class ConnectionManager : Object {
|
|||
debug("Login1: Device un-suspend");
|
||||
check_reconnects();
|
||||
}
|
||||
request_inhibit(false);
|
||||
}
|
||||
|
||||
private void change_connection_state(Account account, ConnectionState state) {
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
Loading…
Reference in New Issue