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:
committed by
Georges Basile Stavracas Neto
parent
8afc4bd129
commit
3526cadcca
@@ -425,6 +425,16 @@ on_window_new_event_cb (GSimpleAction *action,
|
||||
gtk_widget_set_visible (GTK_WIDGET (self->event_editor), TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
on_window_open_date_time_settings_cb (GSimpleAction *action,
|
||||
GVariant *param,
|
||||
gpointer user_data)
|
||||
{
|
||||
GApplication *application = g_application_get_default ();
|
||||
|
||||
gcal_utils_launch_date_time_settings_panel (g_application_get_dbus_connection (application), NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
on_window_open_online_accounts_cb (GSimpleAction *action,
|
||||
GVariant *param,
|
||||
@@ -1095,6 +1105,7 @@ gcal_window_init (GcalWindow *self)
|
||||
{"change-view", on_view_action_activated, "i" },
|
||||
{"next-date", on_window_next_date_activated_cb },
|
||||
{"new-event", on_window_new_event_cb },
|
||||
{"open-date-time-settings", on_window_open_date_time_settings_cb },
|
||||
{"open-online-accounts", on_window_open_online_accounts_cb },
|
||||
{"previous-date", on_window_previous_date_activated_cb },
|
||||
{"show-calendars", on_show_calendars_action_activated },
|
||||
|
||||
@@ -302,6 +302,10 @@
|
||||
|
||||
<menu id='menu'>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Date & Time Settings…</attribute>
|
||||
<attribute name="action">win.open-date-time-settings</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Online Accounts…</attribute>
|
||||
<attribute name="action">win.open-online-accounts</attribute>
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -120,6 +120,10 @@ GList* filter_children_by_uid_and_modtype (GtkWidget
|
||||
GcalRecurrenceModType mod,
|
||||
const gchar *uid);
|
||||
|
||||
void gcal_utils_launch_date_time_settings_panel (GDBusConnection *connection,
|
||||
const gchar *action,
|
||||
const gchar *arg);
|
||||
|
||||
void gcal_utils_launch_online_accounts_panel (GDBusConnection *connection,
|
||||
const gchar *action,
|
||||
const gchar *arg);
|
||||
|
||||
Reference in New Issue
Block a user