gcal-window: datetime settings shortcut

Shortcut is added so that time-related system settings can be easily
accessed. See #1023

The code is largely just a copy-paste of the code that opens the
"Online Accounts…" menu.

Fixes #1023
This commit is contained in:
Victoria Lacroix
2023-07-15 23:04:51 +00:00
committed by Georges Basile Stavracas Neto
parent 8afc4bd129
commit 3526cadcca
4 changed files with 71 additions and 0 deletions
+52
View File
@@ -1123,6 +1123,58 @@ create_dbus_proxy (GDBusConnection *connection,
NULL);
}
void
gcal_utils_launch_date_time_settings_panel (GDBusConnection *connection,
const gchar *action,
const gchar *arg)
{
g_autoptr (GDBusProxy) proxy = NULL;
GVariantBuilder builder;
GVariant *params[3];
GVariant *array[1];
g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
if (!action && !arg)
{
g_variant_builder_add (&builder, "v", g_variant_new_string (""));
}
else
{
if (action)
g_variant_builder_add (&builder, "v", g_variant_new_string (action));
if (arg)
g_variant_builder_add (&builder, "v", g_variant_new_string (arg));
}
array[0] = g_variant_new ("v", g_variant_new ("(sav)", "datetime", &builder));
params[0] = g_variant_new_string ("launch-panel");
params[1] = g_variant_new_array (G_VARIANT_TYPE ("v"), array, 1);
params[2] = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0);
proxy = create_dbus_proxy (connection, "org.gnome.Settings", "/org/gnome/Settings");
/* Fallback for old GNOME versions */
if (!proxy)
proxy = create_dbus_proxy (connection, "org.gnome.ControlCenter", "/org/gnome/ControlCenter");
if (!proxy)
{
g_warning ("Couldn't open Date & Time panel");
return;
}
g_dbus_proxy_call_sync (proxy,
"Activate",
g_variant_new_tuple (params, 3),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
NULL);
}
void
gcal_utils_launch_online_accounts_panel (GDBusConnection *connection,
const gchar *action,