mate-control-center: add custom patch to allow edit clock w/o ntp provider.

This commit is contained in:
Luis Guzmán 2025-10-17 01:27:12 -06:00 committed by Ark74
parent ca516c71dc
commit 4311064c97
2 changed files with 129 additions and 0 deletions

View file

@ -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,

View file

@ -0,0 +1,26 @@
#!/bin/sh
#
# Copyright (C) 2025 Luis Guzmán <ark@switnet.org>
#
# 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