static void xfce_keyboard_layout_helper_set_model (XfceKeyboardLayoutHelper *helper) { gchar *xkbmodel; if (!helper->xkb_disable_settings) { xkbmodel = xfconf_channel_get_string (helper->channel, "/Default/XkbModel", NULL); if (!xkbmodel || !*xkbmodel) { /* If xkb model is not set by user, we want to try to use the system default */ g_free (xkbmodel); xkbmodel = g_strdup (helper->system_keyboard_model); } if (g_strcmp0 (helper->config->model, xkbmodel) != 0) { g_free (helper->config->model); helper->config->model = xkbmodel; xkl_config_rec_activate (helper->config, helper->engine); xfsettings_dbg (XFSD_DEBUG_KEYBOARD_LAYOUT, "set model to \"%s\"", xkbmodel); } else { g_free (xkbmodel); } } }
static void xfce_keyboard_layout_helper_set (XfceKeyboardLayoutHelper *helper, const gchar *xfconf_option_name, gchar ***xkl_config_option, const gchar *debug_name) { gchar *xfconf_values, *xkl_values; gchar **values; if (!helper->xkb_disable_settings) { xfconf_values = g_strjoinv (",", *xkl_config_option); xkl_values = xfconf_channel_get_string (helper->channel, xfconf_option_name, xfconf_values); if (g_strcmp0 (xfconf_values, xkl_values) != 0) { values = g_strsplit_set (xkl_values, ",", 0); g_strfreev (*xkl_config_option); *xkl_config_option = values; xkl_config_rec_activate (helper->config, helper->engine); xfsettings_dbg (XFSD_DEBUG_KEYBOARD_LAYOUT, "set %s to \"%s\"", debug_name, xkl_values); } g_free (xfconf_values); g_free (xkl_values); } }
void mdm_layout_activate (const char *layout) { #ifdef HAVE_LIBXKLAVIER XklConfigRec *config; char *p; int ii, ic; init_xkl (); config = xkl_config_rec_new (); config->model = g_strdup (initial_config->model); if (layout == NULL) { config->layouts = g_strdupv (initial_config->layouts); config->variants = g_strdupv (initial_config->variants); config->options = g_strdupv (initial_config->options); } else { config->layouts = g_new0 (char *, g_strv_length (initial_config->layouts) + 2); config->variants = g_new0 (char *, g_strv_length (initial_config->variants) + 2); config->layouts[0] = g_strdup (layout); p = strchr (config->layouts[0], '\t'); if (p != NULL) { config->layouts[0][p - config->layouts[0]] = 0; config->variants[0] = g_strdup (p + 1); } else { config->variants[0] = g_strdup (""); } /* append other layouts from the initial configuration, so that * the session gets all of them */ ic = 1; for (ii = 0; ii < g_strv_length (initial_config->layouts); ++ii) { if (g_strcmp0 (config->layouts[0], initial_config->layouts[ii]) || strcmp_null_empty (config->variants[0], initial_config->variants[ii])) { config->layouts[ic] = g_strdup (initial_config->layouts[ii]); if (initial_config->variants[ii] != NULL) config->variants[ic] = g_strdup (initial_config->variants[ii]); else config->variants[ic] = g_strdup (""); ++ic; } } config->options = g_strdupv (initial_config->options); } xkl_config_rec_activate (config, engine); g_object_unref (config); #endif }
static void xfce_keyboard_layout_helper_set_option (XfceKeyboardLayoutHelper *helper, const gchar *xkb_option_name, const gchar *xfconf_option_name) { if (!helper->xkb_disable_settings) { gchar *option_value; gchar *xkl_option_value; gchar *other_options; xkl_option_value = xfce_keyboard_layout_get_option (helper->config->options, xkb_option_name, &other_options); option_value = xfconf_channel_get_string (helper->channel, xfconf_option_name, xkl_option_value); if (g_strcmp0 (option_value, xkl_option_value) != 0) { gchar *options_string; if (other_options == NULL) { options_string = g_strdup (option_value); } else { if (strlen (option_value) != 0) { options_string = g_strconcat (option_value, ",", other_options, NULL); } else { options_string = strdup (other_options); } } g_strfreev (helper->config->options); helper->config->options = g_strsplit (options_string, ",", 0); xkl_config_rec_activate (helper->config, helper->engine); xfsettings_dbg (XFSD_DEBUG_KEYBOARD_LAYOUT, "set %s to \"%s\"", xkb_option_name, option_value); g_free (options_string); } g_free (other_options); g_free (option_value); } }