• Emanuele Aina's avatar
    shell: Expose panel launching with DBus-activation · ab0576f1
    Emanuele Aina authored
    Turn Control Center in a DBus-activable service and export a
    'launch-panel' GAction which accepts a tuple containing the id of the
    desired panel and its parameters as a GVariant array.
    The snippet below show how the custom shortcuts section of the keyboard
    panel can be invoked by a external programs through DBus:
    GVariantBuilder *flags = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);
    GVariantBuilder *params = g_variant_builder_new (G_VARIANT_TYPE ("av"));
    g_variant_builder_add (params, "v", g_variant_builder_end (flags));
    g_variant_builder_add (params, "v", g_variant_new_string ("shortcuts"));
    g_variant_builder_add (params, "v", g_variant_new_string ("custom"));
    GVariant *v = g_variant_new ("(s@av)", "keyboard", g_variant_builder_end (params));
    GApplication *gnomecc = g_application_new (id, G_APPLICATION_IS_LAUNCHER);
    if (!g_application_register (gnomecc, NULL, &error))
      g_error ("Failed to register launcher for %s: %s", id, error->message);
    g_action_group_activate_action (G_ACTION_GROUP (gnomecc), "launch-panel", v);
org.gnome.ControlCenter.service.in 80 Bytes