static void
set_locale (GDBusProxy *proxy)
{
        GSettings *locale_settings;
        gchar *region;

        /* Set locale environment */
        locale_settings = g_settings_new ("org.gnome.system.locale");
        region = g_settings_get_string (locale_settings, "region");
        if (region[0]) {
                /* Only set the locale settings if the user has ever customized them */
                set_session_env (proxy, "LC_TIME", region);
                set_session_env (proxy, "LC_NUMERIC", region);
                set_session_env (proxy, "LC_MONETARY", region);
                set_session_env (proxy, "LC_MEASUREMENT", region);
        }
        g_free (region);

        g_object_unref (locale_settings);
}
static void
got_session_name (GObject      *object,
                  GAsyncResult *res,
                  gpointer      data)
{
        GDBusProxy *proxy;
        GVariant *result, *variant;
        const gchar *session_name = NULL;
        GError *error = NULL;

        proxy = G_DBUS_PROXY (object);

        result = g_dbus_proxy_call_finish (proxy, res, &error);
        if (!result) {
                g_debug ("Failed to get session name: %s", error->message);
                g_error_free (error);
                register_with_gnome_session (proxy);
                return;
        }

        g_variant_get (result, "(v)", &variant);
        g_variant_unref (result);

        g_variant_get (variant, "&s", &session_name);

        if (g_strcmp0 (session_name, "gnome") == 0 &&
            is_program_in_path ("ibus-daemon") &&
            keyboard_plugin_is_enabled ()) {
                set_session_env (proxy, "QT_IM_MODULE", "ibus");
                set_session_env (proxy, "XMODIFIERS", "@im=ibus");
        }

        g_variant_unref (variant);

        /* Finally we can register. */
        register_with_gnome_session (proxy);
}