diff --git a/display-infobar-if-night-light-unsupported.patch b/display-infobar-if-night-light-unsupported.patch new file mode 100644 index 0000000..62a3e2b --- /dev/null +++ b/display-infobar-if-night-light-unsupported.patch @@ -0,0 +1,416 @@ +From c999bade4d27e0384b6495ee3bbf88df1b9e256b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonas=20=C3=85dahl?= +Date: Thu, 24 Feb 2022 12:30:23 +0100 +Subject: [PATCH 1/2] display: Add 'NightLightSupported' property support + +--- + panels/display/cc-display-config-manager-dbus.c | 17 +++++++++++++++++ + panels/display/cc-display-config-manager.c | 6 ++++++ + panels/display/cc-display-config-manager.h | 3 +++ + 3 files changed, 26 insertions(+) + +diff --git a/panels/display/cc-display-config-manager-dbus.c b/panels/display/cc-display-config-manager-dbus.c +index 392140101..678b696db 100644 +--- a/panels/display/cc-display-config-manager-dbus.c ++++ b/panels/display/cc-display-config-manager-dbus.c +@@ -33,6 +33,7 @@ struct _CcDisplayConfigManagerDBus + GVariant *current_state; + + gboolean apply_allowed; ++ gboolean night_light_supported; + }; + + G_DEFINE_TYPE (CcDisplayConfigManagerDBus, +@@ -169,6 +170,12 @@ bus_gotten (GObject *object, + else + g_warning ("Missing property 'ApplyMonitorsConfigAllowed' on DisplayConfig API"); + ++ variant = g_dbus_proxy_get_cached_property (proxy, "NightLightSupported"); ++ if (variant) ++ self->night_light_supported = g_variant_get_boolean (variant); ++ else ++ g_warning ("Missing property 'NightLightSupported' on DisplayConfig API"); ++ + get_current_state (self); + } + +@@ -176,6 +183,7 @@ static void + cc_display_config_manager_dbus_init (CcDisplayConfigManagerDBus *self) + { + self->apply_allowed = TRUE; ++ self->night_light_supported = TRUE; + self->cancellable = g_cancellable_new (); + g_bus_get (G_BUS_TYPE_SESSION, self->cancellable, bus_gotten, self); + } +@@ -205,6 +213,14 @@ cc_display_config_manager_dbus_get_apply_allowed (CcDisplayConfigManager *pself) + return self->apply_allowed; + } + ++static gboolean ++cc_display_config_manager_dbus_get_night_light_supported (CcDisplayConfigManager *pself) ++{ ++ CcDisplayConfigManagerDBus *self = CC_DISPLAY_CONFIG_MANAGER_DBUS (pself); ++ ++ return self->night_light_supported; ++} ++ + static void + cc_display_config_manager_dbus_class_init (CcDisplayConfigManagerDBusClass *klass) + { +@@ -215,6 +231,7 @@ cc_display_config_manager_dbus_class_init (CcDisplayConfigManagerDBusClass *klas + + parent_class->get_current = cc_display_config_manager_dbus_get_current; + parent_class->get_apply_allowed = cc_display_config_manager_dbus_get_apply_allowed; ++ parent_class->get_night_light_supported = cc_display_config_manager_dbus_get_night_light_supported; + } + + CcDisplayConfigManager * +diff --git a/panels/display/cc-display-config-manager.c b/panels/display/cc-display-config-manager.c +index 3d683c53d..f231edd69 100644 +--- a/panels/display/cc-display-config-manager.c ++++ b/panels/display/cc-display-config-manager.c +@@ -65,3 +65,9 @@ cc_display_config_manager_get_apply_allowed (CcDisplayConfigManager *self) + { + return CC_DISPLAY_CONFIG_MANAGER_GET_CLASS (self)->get_apply_allowed (self); + } ++ ++gboolean ++cc_display_config_manager_get_night_light_supported (CcDisplayConfigManager *self) ++{ ++ return CC_DISPLAY_CONFIG_MANAGER_GET_CLASS (self)->get_night_light_supported (self); ++} +diff --git a/panels/display/cc-display-config-manager.h b/panels/display/cc-display-config-manager.h +index 64f0775e9..ab1e84f85 100644 +--- a/panels/display/cc-display-config-manager.h ++++ b/panels/display/cc-display-config-manager.h +@@ -35,12 +35,15 @@ struct _CcDisplayConfigManagerClass + + CcDisplayConfig * (*get_current) (CcDisplayConfigManager *self); + gboolean (* get_apply_allowed) (CcDisplayConfigManager *self); ++ gboolean (* get_night_light_supported) (CcDisplayConfigManager *self); + }; + + CcDisplayConfig * cc_display_config_manager_get_current (CcDisplayConfigManager *self); + + gboolean cc_display_config_manager_get_apply_allowed (CcDisplayConfigManager *self); + ++gboolean cc_display_config_manager_get_night_light_supported (CcDisplayConfigManager *self); ++ + void _cc_display_config_manager_emit_changed (CcDisplayConfigManager *self); + + G_END_DECLS +-- +2.34.1 + + +From 414e23272f89198efc452a4f8d50442c72a07956 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonas=20=C3=85dahl?= +Date: Thu, 24 Feb 2022 12:31:00 +0100 +Subject: [PATCH 2/2] display: Show infobar if night light isn't supported + +This may be the case on e.g. fully remote / headless sessions, or as of +now, when using the NVIDIA driver to run a Wayland session. + +Closes: https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1659 +--- + panels/display/cc-night-light-page.c | 153 +++++++++++++++----------- + panels/display/cc-night-light-page.ui | 41 ++++++- + 2 files changed, 129 insertions(+), 65 deletions(-) + +diff --git a/panels/display/cc-night-light-page.c b/panels/display/cc-night-light-page.c +index f51b0ba69..482b90fea 100644 +--- a/panels/display/cc-night-light-page.c ++++ b/panels/display/cc-night-light-page.c +@@ -29,15 +29,18 @@ + #include "list-box-helper.h" + + #include "shell/cc-object-storage.h" ++#include "cc-display-config-manager-dbus.h" + + struct _CcNightLightPage { + GtkBin parent; + ++ GtkWidget *night_light_settings; + GtkWidget *box_manual; + GtkButton *button_from_am; + GtkButton *button_from_pm; + GtkButton *button_to_am; + GtkButton *button_to_pm; ++ GtkWidget *infobar_unsupported; + GtkWidget *infobar_disabled; + GtkListBox *listbox; + GtkWidget *scale_color_temperature; +@@ -64,6 +67,8 @@ struct _CcNightLightPage { + gboolean ignore_value_changed; + guint timer_id; + GDesktopClockFormat clock_format; ++ ++ CcDisplayConfigManager *config_manager; + }; + + G_DEFINE_TYPE (CcNightLightPage, cc_night_light_page, GTK_TYPE_BIN); +@@ -122,88 +127,97 @@ dialog_adjustments_set_frac_hours (CcNightLightPage *self, + static void + dialog_update_state (CcNightLightPage *self) + { +- gboolean automatic; +- gboolean disabled_until_tomorrow = FALSE; +- gboolean enabled; +- gdouble value = 0.f; +- +- /* only show the infobar if we are disabled */ +- if (self->proxy_color != NULL) ++ if (cc_display_config_manager_get_night_light_supported (self->config_manager)) + { +- g_autoptr(GVariant) disabled = NULL; +- disabled = g_dbus_proxy_get_cached_property (self->proxy_color, +- "DisabledUntilTomorrow"); +- if (disabled != NULL) +- disabled_until_tomorrow = g_variant_get_boolean (disabled); +- } +- gtk_widget_set_visible (self->infobar_disabled, disabled_until_tomorrow); ++ gboolean automatic; ++ gboolean disabled_until_tomorrow = FALSE; ++ gboolean enabled; ++ gdouble value = 0.f; + +- /* make things insensitive if the switch is disabled */ +- enabled = g_settings_get_boolean (self->settings_display, "night-light-enabled"); +- automatic = g_settings_get_boolean (self->settings_display, "night-light-schedule-automatic"); ++ /* only show the infobar if we are disabled */ ++ if (self->proxy_color != NULL) ++ { ++ g_autoptr(GVariant) disabled = NULL; ++ disabled = g_dbus_proxy_get_cached_property (self->proxy_color, ++ "DisabledUntilTomorrow"); ++ if (disabled != NULL) ++ disabled_until_tomorrow = g_variant_get_boolean (disabled); ++ } ++ gtk_widget_set_visible (self->infobar_disabled, disabled_until_tomorrow); + +- gtk_widget_set_sensitive (self->box_manual, enabled && !automatic); ++ /* make things insensitive if the switch is disabled */ ++ enabled = g_settings_get_boolean (self->settings_display, "night-light-enabled"); ++ automatic = g_settings_get_boolean (self->settings_display, "night-light-schedule-automatic"); + +- gtk_combo_box_set_active_id (self->schedule_type_combo, automatic ? "automatic" : "manual"); ++ gtk_widget_set_sensitive (self->box_manual, enabled && !automatic); + +- /* set from */ +- if (automatic && self->proxy_color != NULL) +- { +- g_autoptr(GVariant) sunset = NULL; +- sunset = g_dbus_proxy_get_cached_property (self->proxy_color, "Sunset"); +- if (sunset != NULL) ++ gtk_combo_box_set_active_id (self->schedule_type_combo, automatic ? "automatic" : "manual"); ++ ++ /* set from */ ++ if (automatic && self->proxy_color != NULL) + { +- value = g_variant_get_double (sunset); ++ g_autoptr(GVariant) sunset = NULL; ++ sunset = g_dbus_proxy_get_cached_property (self->proxy_color, "Sunset"); ++ if (sunset != NULL) ++ { ++ value = g_variant_get_double (sunset); ++ } ++ else ++ { ++ value = 16.0f; ++ g_warning ("no sunset data, using %02.2f", value); ++ } + } + else + { +- value = 16.0f; +- g_warning ("no sunset data, using %02.2f", value); ++ value = g_settings_get_double (self->settings_display, "night-light-schedule-from"); ++ value = fmod (value, 24.f); + } +- } +- else +- { +- value = g_settings_get_double (self->settings_display, "night-light-schedule-from"); +- value = fmod (value, 24.f); +- } +- dialog_adjustments_set_frac_hours (self, value, +- self->adjustment_from_hours, +- self->adjustment_from_minutes, +- self->stack_from, +- self->button_from_am, +- self->button_from_pm); +- +- /* set to */ +- if (automatic && self->proxy_color != NULL) +- { +- g_autoptr(GVariant) sunset = NULL; +- sunset = g_dbus_proxy_get_cached_property (self->proxy_color, "Sunrise"); +- if (sunset != NULL) ++ dialog_adjustments_set_frac_hours (self, value, ++ self->adjustment_from_hours, ++ self->adjustment_from_minutes, ++ self->stack_from, ++ self->button_from_am, ++ self->button_from_pm); ++ ++ /* set to */ ++ if (automatic && self->proxy_color != NULL) + { +- value = g_variant_get_double (sunset); ++ g_autoptr(GVariant) sunset = NULL; ++ sunset = g_dbus_proxy_get_cached_property (self->proxy_color, "Sunrise"); ++ if (sunset != NULL) ++ { ++ value = g_variant_get_double (sunset); ++ } ++ else ++ { ++ value = 8.0f; ++ g_warning ("no sunrise data, using %02.2f", value); ++ } + } + else + { +- value = 8.0f; +- g_warning ("no sunrise data, using %02.2f", value); ++ value = g_settings_get_double (self->settings_display, "night-light-schedule-to"); ++ value = fmod (value, 24.f); + } ++ dialog_adjustments_set_frac_hours (self, value, ++ self->adjustment_to_hours, ++ self->adjustment_to_minutes, ++ self->stack_to, ++ self->button_to_am, ++ self->button_to_pm); ++ ++ self->ignore_value_changed = TRUE; ++ value = (gdouble) g_settings_get_uint (self->settings_display, "night-light-temperature"); ++ gtk_adjustment_set_value (self->adjustment_color_temperature, value); ++ self->ignore_value_changed = FALSE; + } + else + { +- value = g_settings_get_double (self->settings_display, "night-light-schedule-to"); +- value = fmod (value, 24.f); ++ gtk_widget_set_visible (self->infobar_unsupported, TRUE); ++ gtk_widget_set_visible (self->infobar_disabled, FALSE); ++ gtk_widget_set_sensitive (self->night_light_settings, FALSE); + } +- dialog_adjustments_set_frac_hours (self, value, +- self->adjustment_to_hours, +- self->adjustment_to_minutes, +- self->stack_to, +- self->button_to_am, +- self->button_to_pm); +- +- self->ignore_value_changed = TRUE; +- value = (gdouble) g_settings_get_uint (self->settings_display, "night-light-temperature"); +- gtk_adjustment_set_value (self->adjustment_color_temperature, value); +- self->ignore_value_changed = FALSE; + } + + static void +@@ -549,6 +563,13 @@ dialog_am_pm_to_button_clicked_cb (GtkButton *button, + g_debug ("new value = %.3f", value); + } + ++static void ++config_manager_changed_cb (CcDisplayConfigManager *config_manager, ++ CcNightLightPage *self) ++{ ++ dialog_update_state (self); ++} ++ + /* GObject overrides */ + static void + cc_night_light_page_finalize (GObject *object) +@@ -583,11 +604,13 @@ cc_night_light_page_class_init (CcNightLightPageClass *klass) + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, adjustment_to_hours); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, adjustment_to_minutes); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, adjustment_color_temperature); ++ gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, night_light_settings); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, box_manual); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, button_from_am); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, button_from_pm); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, button_to_am); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, button_to_pm); ++ gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, infobar_unsupported); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, infobar_disabled); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, listbox); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, night_light_toggle_switch); +@@ -700,6 +723,10 @@ cc_night_light_page_init (CcNightLightPage *self) + G_CALLBACK (dialog_clock_settings_changed_cb), + self, G_CONNECT_SWAPPED); + ++ self->config_manager = cc_display_config_manager_dbus_new (); ++ g_signal_connect (self->config_manager, "changed", ++ G_CALLBACK (config_manager_changed_cb), self); ++ + dialog_update_state (self); + } + +diff --git a/panels/display/cc-night-light-page.ui b/panels/display/cc-night-light-page.ui +index 02b14f731..cb18837ad 100644 +--- a/panels/display/cc-night-light-page.ui ++++ b/panels/display/cc-night-light-page.ui +@@ -6,9 +6,45 @@ + + True + False +- center + start + vertical ++ ++ ++ False ++ infobar_unsupported ++ warning ++ ++ ++ True ++ vertical ++ True ++ 16 ++ ++ ++ True ++ start ++ 6 ++ False ++ Night Light unavailable ++ ++ ++ ++ ++ ++ ++ ++ True ++ start ++ 6 ++ False ++ This could be the result of the graphics driver being used, or the desktop being used remotely ++ ++ ++ ++ ++ ++ ++ + + + infobar_disabled +@@ -70,8 +106,9 @@ + + + +- ++ + True ++ center + False + 30 + 12 +-- +2.34.1 + diff --git a/gnome-control-center.spec b/gnome-control-center.spec index 2c825e4..da88708 100644 --- a/gnome-control-center.spec +++ b/gnome-control-center.spec @@ -14,7 +14,7 @@ Name: gnome-control-center Version: 40.0 -Release: 26%{?dist} +Release: 27%{?dist} Summary: Utilities to configure the GNOME desktop License: GPLv2+ and CC-BY-SA @@ -45,6 +45,8 @@ Patch9: 0001-network-Fix-OWE-settings.patch Patch10: gnome-control-center-timezones.patch # https://bugzilla.redhat.com/show_bug.cgi?id=2061182 Patch11: change-device-name-with-enter-key.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=2057154 +Patch12: display-infobar-if-night-light-unsupported.patch BuildRequires: chrpath BuildRequires: cups-devel @@ -235,6 +237,10 @@ chrpath --delete $RPM_BUILD_ROOT%{_bindir}/gnome-control-center %dir %{_datadir}/gnome/wm-properties %changelog +* Mon Aug 01 2022 Felipe Borges - 40.0-27 +- Show infobar if night light isn't supported + Resolves: rhbz#2057154 + * Mon Aug 01 2022 Felipe Borges - 40.0-26 - Allow changing "Device Name" by pressing "Enter" Resolves: rhbz#2061182