From 4311064c975deb64c3936b7772e7c36a25ce9898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Guzm=C3=A1n?= Date: Fri, 17 Oct 2025 01:27:12 -0600 Subject: [PATCH] mate-control-center: add custom patch to allow edit clock w/o ntp provider. --- ...ble-manual-time-when-no-ntp-provider.patch | 103 ++++++++++++++++++ helpers/make-mate-control-center | 26 +++++ 2 files changed, 129 insertions(+) create mode 100644 helpers/DATA/mate-control-center/patch_changes/001-enable-manual-time-when-no-ntp-provider.patch create mode 100644 helpers/make-mate-control-center diff --git a/helpers/DATA/mate-control-center/patch_changes/001-enable-manual-time-when-no-ntp-provider.patch b/helpers/DATA/mate-control-center/patch_changes/001-enable-manual-time-when-no-ntp-provider.patch new file mode 100644 index 0000000..f7372d2 --- /dev/null +++ b/helpers/DATA/mate-control-center/patch_changes/001-enable-manual-time-when-no-ntp-provider.patch @@ -0,0 +1,103 @@ +diff --git a/capplets/time-admin/src/main.c b/capplets/time-admin/src/main.c +index a15254e6..ac9adb43 100644 +--- a/capplets/time-admin/src/main.c ++++ b/capplets/time-admin/src/main.c +@@ -156,8 +156,14 @@ static void InitMainWindow(TimeAdmin *ta) + + /* NTP sync switch */ + ta->NtpState = GetNtpState(ta); ++ /* If there is no NTP provider, then disable ntp switch and manually set NtpState = FALSE */ ++ if (!GetCanNtp(ta)) { ++ gtk_widget_set_sensitive (ta->NtpSyncSwitch, FALSE); ++ ta->NtpState = FALSE; ++ } + gtk_switch_set_state (GTK_SWITCH(ta->NtpSyncSwitch), ta->NtpState); +- ++ /* Refresh the tooltip state consistently */ ++ ChangeSpinBttonState (ta); + /* Time zone */ + SetupTimezoneDialog(ta); + const char *TimeZone = GetTimeZone(ta); +diff --git a/capplets/time-admin/src/time-tool.c b/capplets/time-admin/src/time-tool.c +index 664f6284..ac41545a 100644 +--- a/capplets/time-admin/src/time-tool.c ++++ b/capplets/time-admin/src/time-tool.c +@@ -138,6 +138,45 @@ EXIT: + + } + ++/* Returns TRUE if timedated reports a network time provider (CanNTP == TRUE). */ ++gboolean GetCanNtp(TimeAdmin *ta) ++{ ++ GDBusProxy *proxy = NULL; ++ GError *error = NULL; ++ GVariant *ret; ++ GVariant *canntp; ++ ++ proxy = g_dbus_proxy_new_sync (ta->Connection, ++ G_DBUS_PROXY_FLAGS_NONE, ++ NULL, ++ "org.freedesktop.timedate1", ++ "/org/freedesktop/timedate1", ++ "org.freedesktop.DBus.Properties", ++ NULL, ++ &error); ++ if (proxy == NULL) ++ goto EXIT; ++ ++ ret = g_dbus_proxy_call_sync (proxy, ++ "Get", ++ g_variant_new ("(ss)", ++ "org.freedesktop.timedate1", ++ "CanNTP"), ++ G_DBUS_CALL_FLAGS_NONE, ++ -1, ++ NULL, ++ &error); ++ if (ret == NULL) ++ goto EXIT; ++ ++ g_variant_get (ret, "(v)", &canntp); ++ return g_variant_get_boolean (canntp); ++ ++EXIT: ++ ErrorMessage (_("GetNtpState"), error ? error->message : _("Unknown error")); ++ if (error) g_error_free (error); ++ return FALSE; ++} + const gchar *GetTimeZone(TimeAdmin *ta) + { + GDBusProxy *proxy = NULL; +@@ -200,10 +238,16 @@ void SetTimeZone(GDBusProxy *proxy,const char *zone) + } + } + +-static void ++void + ChangeSpinBttonState (TimeAdmin *ta) + { ++ /* Enable/disable manual edit widgets based on NTP state */ + gtk_widget_set_sensitive (ta->SaveButton, !ta->NtpState); ++ gtk_widget_set_sensitive (ta->HourSpin, !ta->NtpState); ++ gtk_widget_set_sensitive (ta->MinuteSpin, !ta->NtpState); ++ gtk_widget_set_sensitive (ta->SecondSpin, !ta->NtpState); ++ gtk_widget_set_sensitive (ta->Calendar, !ta->NtpState); ++ + SetTooltip (ta->SaveButton, !ta->NtpState); + SetTooltip (ta->HourSpin, !ta->NtpState); + SetTooltip (ta->MinuteSpin, !ta->NtpState); +diff --git a/capplets/time-admin/src/time-tool.h b/capplets/time-admin/src/time-tool.h +index 9c17703e..dfb0e601 100644 +--- a/capplets/time-admin/src/time-tool.h ++++ b/capplets/time-admin/src/time-tool.h +@@ -42,6 +42,10 @@ void SaveModifyTime (GtkButton *button, + + gboolean GetNtpState (TimeAdmin *ta); + ++gboolean GetCanNtp (TimeAdmin *ta); ++ ++void ChangeSpinBttonState (TimeAdmin *ta); ++ + const gchar *GetTimeZone (TimeAdmin *ta); + + void SetTimeZone (GDBusProxy *proxy, diff --git a/helpers/make-mate-control-center b/helpers/make-mate-control-center new file mode 100644 index 0000000..466817a --- /dev/null +++ b/helpers/make-mate-control-center @@ -0,0 +1,26 @@ +#!/bin/sh +# +# Copyright (C) 2025 Luis Guzmán +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +VERSION=1 +. ./config + +apply_patch_changes + +changelog "Add custom patch to fix TPH#162, non-editable mate clock w/o ntp server." +package