From 9e8d86c84b422a9760d1b731bb33ca42c44f0789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 2 Feb 2026 12:40:37 -0800 Subject: [PATCH] CalendarView: absorb network connectivity infobar --- po/POTFILES | 1 - src/Grid/CalendarView.vala | 31 +++++++++++++- src/Widgets/ConnectivityInfoBar.vala | 60 ---------------------------- src/meson.build | 3 +- 4 files changed, 31 insertions(+), 64 deletions(-) delete mode 100644 src/Widgets/ConnectivityInfoBar.vala diff --git a/po/POTFILES b/po/POTFILES index 6cf0912c3..c0d385471 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -42,7 +42,6 @@ src/SourceDialog/SourceDialog.vala src/TodayEventMonitor.vala src/Widgets/AgendaEventRow.vala src/Widgets/CalendarChooser.vala -src/Widgets/ConnectivityInfoBar.vala src/Widgets/DateSwitcher.vala src/Widgets/DateTimePicker.vala src/Widgets/DynamicSpinner.vala diff --git a/src/Grid/CalendarView.vala b/src/Grid/CalendarView.vala index a6c550e45..f7c287775 100644 --- a/src/Grid/CalendarView.vala +++ b/src/Grid/CalendarView.vala @@ -100,7 +100,20 @@ public class Maya.View.CalendarView : Gtk.Box { }; error_bar.get_content_area ().add (error_label); - var info_bar = new Calendar.Widgets.ConnectivityInfoBar (); + var info_label = new Gtk.Label ("%s %s".printf ( + _("Network Not Available."), + _("Connect to the Internet to see additional details and new events from online calendars.") + )) { + use_markup = true, + wrap = true + }; + + var info_bar = new Gtk.InfoBar () { + message_type = WARNING, + revealed = false + }; + info_bar.get_content_area ().add (info_label); + info_bar.add_button (_("Network Settings…"), Gtk.ResponseType.ACCEPT); var application_instance = ((Gtk.Application) GLib.Application.get_default ()); @@ -189,6 +202,22 @@ public class Maya.View.CalendarView : Gtk.Box { add (stack); show_all (); + var network_monitor = GLib.NetworkMonitor.get_default (); + network_monitor.network_changed.connect (() => { + info_bar.revealed = !( + network_monitor.get_network_available () && + network_monitor.get_connectivity () == FULL + ); + }); + + info_bar.response.connect (() => { + try { + AppInfo.launch_default_for_uri ("settings://network", null); + } catch (GLib.Error e) { + critical (e.message); + } + }); + error_bar.response.connect ((id) => error_bar.set_revealed (false)); Calendar.EventStore.get_default ().error_received.connect ((message) => { diff --git a/src/Widgets/ConnectivityInfoBar.vala b/src/Widgets/ConnectivityInfoBar.vala deleted file mode 100644 index cdafb84f6..000000000 --- a/src/Widgets/ConnectivityInfoBar.vala +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2020 elementary, Inc. (https://elementary.io) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Authored by: Fabio Zaramella - */ - -public class Calendar.Widgets.ConnectivityInfoBar : Gtk.InfoBar { - public ConnectivityInfoBar () { - Object ( - message_type: Gtk.MessageType.WARNING, - revealed : false, - show_close_button : false - ); - } - - construct { - unowned string title = _("Network Not Available."); - unowned string details = _("Connect to the Internet to see additional details and new events from online calendars."); - - var info_label = new Gtk.Label ("%s %s".printf (title, details)) { - use_markup = true, - wrap = true - }; - - get_content_area ().add (info_label); - add_button (_("Network Settings…"), Gtk.ResponseType.ACCEPT); - - var network_monitor = GLib.NetworkMonitor.get_default (); - network_monitor.network_changed.connect (() => { - bool available = network_monitor.get_network_available (); - - if (available && network_monitor.get_connectivity () == GLib.NetworkConnectivity.FULL) { - set_revealed (false); - } else { - set_revealed (true); - } - }); - - response.connect ((response_id) => { - try { - AppInfo.launch_default_for_uri ("settings://network", null); - } catch (GLib.Error e) { - critical (e.message); - } - }); - } -} diff --git a/src/meson.build b/src/meson.build index 481cd818d..f99d0d443 100644 --- a/src/meson.build +++ b/src/meson.build @@ -35,8 +35,7 @@ calendar_files = files( 'Widgets/DynamicSpinner.vala', 'Widgets/EventMenu.vala', 'Widgets/SourcePopover.vala', - 'Widgets/SourceRow.vala', - 'Widgets/ConnectivityInfoBar.vala' + 'Widgets/SourceRow.vala' ) calendar_deps = [