Skip to content

Commit af47d12

Browse files
authored
CalendarView: absorb network connectivity infobar (#909)
1 parent ca84cb5 commit af47d12

4 files changed

Lines changed: 31 additions & 64 deletions

File tree

po/POTFILES

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ src/SourceDialog/SourceDialog.vala
4242
src/TodayEventMonitor.vala
4343
src/Widgets/AgendaEventRow.vala
4444
src/Widgets/CalendarChooser.vala
45-
src/Widgets/ConnectivityInfoBar.vala
4645
src/Widgets/DateSwitcher.vala
4746
src/Widgets/DateTimePicker.vala
4847
src/Widgets/DynamicSpinner.vala

src/Grid/CalendarView.vala

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,20 @@ public class Maya.View.CalendarView : Gtk.Box {
6161
};
6262
error_bar.get_content_area ().add (error_label);
6363

64-
var info_bar = new Calendar.Widgets.ConnectivityInfoBar ();
64+
var info_label = new Gtk.Label ("<b>%s</b> %s".printf (
65+
_("Network Not Available."),
66+
_("Connect to the Internet to see additional details and new events from online calendars.")
67+
)) {
68+
use_markup = true,
69+
wrap = true
70+
};
71+
72+
var info_bar = new Gtk.InfoBar () {
73+
message_type = WARNING,
74+
revealed = false
75+
};
76+
info_bar.get_content_area ().add (info_label);
77+
info_bar.add_button (_("Network Settings…"), Gtk.ResponseType.ACCEPT);
6578

6679
var application_instance = ((Gtk.Application) GLib.Application.get_default ());
6780

@@ -142,6 +155,22 @@ public class Maya.View.CalendarView : Gtk.Box {
142155
add (stack);
143156
show_all ();
144157

158+
var network_monitor = GLib.NetworkMonitor.get_default ();
159+
network_monitor.network_changed.connect (() => {
160+
info_bar.revealed = !(
161+
network_monitor.get_network_available () &&
162+
network_monitor.get_connectivity () == FULL
163+
);
164+
});
165+
166+
info_bar.response.connect (() => {
167+
try {
168+
AppInfo.launch_default_for_uri ("settings://network", null);
169+
} catch (GLib.Error e) {
170+
critical (e.message);
171+
}
172+
});
173+
145174
error_bar.response.connect ((id) => error_bar.set_revealed (false));
146175

147176
Calendar.EventStore.get_default ().error_received.connect ((message) => {

src/Widgets/ConnectivityInfoBar.vala

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/meson.build

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ calendar_files = files(
3535
'Widgets/DynamicSpinner.vala',
3636
'Widgets/EventMenu.vala',
3737
'Widgets/SourcePopover.vala',
38-
'Widgets/SourceRow.vala',
39-
'Widgets/ConnectivityInfoBar.vala'
38+
'Widgets/SourceRow.vala'
4039
)
4140

4241
calendar_deps = [

0 commit comments

Comments
 (0)