diff --git a/data/resources/ui/greeter.ui b/data/resources/ui/greeter.ui
index b36ba6db..2a85b249 100644
--- a/data/resources/ui/greeter.ui
+++ b/data/resources/ui/greeter.ui
@@ -29,7 +29,7 @@
+
+
+ warning
+
+
+ 440
+ 340
+ true
+
+
+ center
+ True
+
+
+
+
+
+
crossfade
@@ -229,3 +247,4 @@
+
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 65c52c28..6c9b4d2c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -45,6 +45,7 @@ src/components/editable_avatar.rs
src/components/location_viewer.rs
src/components/media_content_viewer.rs
src/error_page.rs
+src/greeter.rs
src/login/mod.rs
src/secret.rs
src/session/account_settings/devices_page/device_list.rs
diff --git a/src/greeter.rs b/src/greeter.rs
index 0eb5745d..8517e320 100644
--- a/src/greeter.rs
+++ b/src/greeter.rs
@@ -1,5 +1,7 @@
use adw::subclass::prelude::BinImpl;
-use gtk::{self, glib, prelude::*, subclass::prelude::*, CompositeTemplate};
+use gtk::{self, gio, glib, glib::clone, prelude::*, subclass::prelude::*, CompositeTemplate};
+
+use crate::gettext;
mod imp {
use glib::subclass::InitializingObject;
@@ -13,6 +15,12 @@ mod imp {
pub back_button: TemplateChild,
#[template_child]
pub login_button: TemplateChild,
+ #[template_child]
+ pub development_info_bar: TemplateChild,
+ #[template_child]
+ pub offline_info_bar: TemplateChild,
+ #[template_child]
+ pub offline_info_bar_label: TemplateChild,
}
#[glib::object_subclass]
@@ -31,7 +39,18 @@ mod imp {
}
}
- impl ObjectImpl for Greeter {}
+ impl ObjectImpl for Greeter {
+ fn constructed(&self, obj: &Self::Type) {
+ self.parent_constructed(obj);
+
+ let monitor = gio::NetworkMonitor::default();
+ monitor.connect_network_changed(clone!(@weak obj => move |_, _| {
+ obj.update_network_state();
+ }));
+
+ obj.update_network_state();
+ }
+ }
impl WidgetImpl for Greeter {}
@@ -51,6 +70,28 @@ impl Greeter {
pub fn default_widget(&self) -> gtk::Widget {
self.imp().login_button.get().upcast()
}
+
+ fn update_network_state(&self) {
+ let priv_ = self.imp();
+ let monitor = gio::NetworkMonitor::default();
+
+ if !monitor.is_network_available() {
+ priv_.development_info_bar.set_revealed(false);
+ priv_
+ .offline_info_bar_label
+ .set_label(&gettext("No network connection"));
+ priv_.offline_info_bar.set_revealed(true);
+ } else if monitor.connectivity() < gio::NetworkConnectivity::Full {
+ priv_.development_info_bar.set_revealed(false);
+ priv_
+ .offline_info_bar_label
+ .set_label(&gettext("No Internet connection"));
+ priv_.offline_info_bar.set_revealed(true);
+ } else {
+ priv_.development_info_bar.set_revealed(true);
+ priv_.offline_info_bar.set_revealed(false);
+ }
+ }
}
impl Default for Greeter {
diff --git a/src/login/mod.rs b/src/login/mod.rs
index d093e26e..65ea5564 100644
--- a/src/login/mod.rs
+++ b/src/login/mod.rs
@@ -1,6 +1,6 @@
use adw::{prelude::*, subclass::prelude::BinImpl};
use gettextrs::gettext;
-use gtk::{self, glib, glib::clone, subclass::prelude::*, CompositeTemplate};
+use gtk::{self, gio, glib, glib::clone, subclass::prelude::*, CompositeTemplate};
use log::{debug, warn};
use matrix_sdk::{
config::RequestConfig,
@@ -63,6 +63,10 @@ mod imp {
pub sso_box: TemplateChild,
#[template_child]
pub more_sso_option: TemplateChild,
+ #[template_child]
+ pub offline_info_bar: TemplateChild,
+ #[template_child]
+ pub offline_info_bar_label: TemplateChild,
pub prepared_source_id: RefCell