Commit 89fabad8 authored by Petr Kubánek's avatar Petr Kubánek Committed by Robert Ancell

datetime: grayout automatic timezone

Automatic timezone does not work if location sharing is disabled in privacy.

Grays out automatic timezone setting if location sharing is disabled in privacy
settings. Enable automatic timezone seting if location sharing is enabled.

https://bugzilla.gnome.org/show_bug.cgi?id=788714
parent 66981da2
Pipeline #29925 passed with stages
in 3 minutes and 59 seconds
......@@ -53,6 +53,8 @@ enum {
#define DATETIME_PERMISSION "org.gnome.controlcenter.datetime.configure"
#define DATETIME_TZ_PERMISSION "org.freedesktop.timedate1.set-timezone"
#define LOCATION_SETTINGS "org.gnome.system.location"
#define LOCATION_ENABLED "enabled"
#define CLOCK_SCHEMA "org.gnome.desktop.interface"
#define CLOCK_FORMAT_KEY "clock-format"
......@@ -121,6 +123,7 @@ struct _CcDateTimePanel
GPermission *permission;
GPermission *tz_permission;
GSettings *location_settings;
};
CC_PANEL_REGISTER (CcDateTimePanel, cc_date_time_panel)
......@@ -151,6 +154,7 @@ cc_date_time_panel_dispose (GObject *object)
g_clear_object (&panel->dtm);
g_clear_object (&panel->permission);
g_clear_object (&panel->tz_permission);
g_clear_object (&panel->location_settings);
g_clear_object (&panel->clock_settings);
g_clear_object (&panel->datetime_settings);
g_clear_object (&panel->filechooser_settings);
......@@ -726,16 +730,17 @@ on_permission_changed (GPermission *permission,
gpointer data)
{
CcDateTimePanel *self = CC_DATE_TIME_PANEL (data);
gboolean allowed, tz_allowed, auto_timezone, using_ntp;
gboolean allowed, location_allowed, tz_allowed, auto_timezone, using_ntp;
allowed = (self->permission != NULL && g_permission_get_allowed (self->permission));
location_allowed = g_settings_get_boolean (self->location_settings, LOCATION_ENABLED);
tz_allowed = (self->tz_permission != NULL && g_permission_get_allowed (self->tz_permission));
using_ntp = gtk_switch_get_active (GTK_SWITCH (self->network_time_switch));
auto_timezone = gtk_switch_get_active (GTK_SWITCH (self->auto_timezone_switch));
/* All the widgets but the lock button and the 24h setting */
gtk_widget_set_sensitive (self->auto_datetime_row, allowed);
gtk_widget_set_sensitive (self->auto_timezone_row, allowed || tz_allowed);
gtk_widget_set_sensitive (self->auto_timezone_row, location_allowed && (allowed || tz_allowed));
gtk_widget_set_sensitive (self->datetime_button, allowed && !using_ntp);
gtk_widget_set_sensitive (self->timezone_button, (allowed || tz_allowed) && !auto_timezone);
......@@ -746,6 +751,14 @@ on_permission_changed (GPermission *permission,
gtk_widget_hide (GTK_WIDGET (self->timezone_dialog));
}
static void
on_location_settings_changed (GSettings *settings,
const char *key,
CcDateTimePanel *panel)
{
on_permission_changed (panel->permission, NULL, panel);
}
static void
on_can_ntp_changed (CcDateTimePanel *self)
{
......@@ -1210,6 +1223,11 @@ cc_date_time_panel_init (CcDateTimePanel *self)
DATETIME_PERMISSION);
}
self->location_settings = g_settings_new (LOCATION_SETTINGS);
g_signal_connect (self->location_settings, "changed",
G_CALLBACK (on_location_settings_changed), self);
on_location_settings_changed (self->location_settings, NULL, self);
self->date = g_date_time_new_now_local ();
/* Top level windows from GtkBuilder that need to be destroyed explicitly */
......
......@@ -408,7 +408,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Requires internet access</property>
<property name="label" translatable="yes">Requires location services enabled and internet access</property>
<style>
<class name="dim-label"/>
</style>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment