void xkb_layouts_prepare_selected_tree (GtkBuilder * dialog, MateConfChangeSet * changeset) { GtkListStore *list_store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); GtkWidget *tree_view = WID ("xkb_layouts_selected"); GtkTreeSelection *selection; GtkTargetEntry self_drag_target = { "xkb_layouts_selected", GTK_TARGET_SAME_WIDGET, 0 }; GtkTreeViewColumn *desc_column; text_renderer = GTK_CELL_RENDERER (gtk_cell_renderer_text_new ()); desc_column = gtk_tree_view_column_new_with_attributes (_("Layout"), text_renderer, "text", SEL_LAYOUT_TREE_COL_DESCRIPTION, "sensitive", SEL_LAYOUT_TREE_COL_ENABLED, NULL); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (list_store)); gtk_tree_view_column_set_sizing (desc_column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_column_set_resizable (desc_column, TRUE); gtk_tree_view_column_set_expand (desc_column, TRUE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), desc_column); g_signal_connect_swapped (G_OBJECT (selection), "changed", G_CALLBACK (xkb_layouts_enable_disable_buttons), dialog); max_selected_layouts = xkl_engine_get_max_num_groups (engine); /* Setting up DnD */ gtk_drag_source_set (tree_view, GDK_BUTTON1_MASK, &self_drag_target, 1, GDK_ACTION_MOVE); gtk_drag_source_set_icon_name (tree_view, "input-keyboard"); gtk_drag_dest_set (tree_view, GTK_DEST_DEFAULT_ALL, &self_drag_target, 1, GDK_ACTION_MOVE); g_signal_connect (G_OBJECT (tree_view), "drag_data_get", G_CALLBACK (xkb_layouts_dnd_data_get), dialog); g_signal_connect (G_OBJECT (tree_view), "drag_data_received", G_CALLBACK (xkb_layouts_dnd_data_received), dialog); }
void xkb_layouts_prepare_selected_tree (GtkBuilder * dialog) { GtkListStore *list_store; GtkWidget *tree_view = WID ("xkb_layouts_selected"); GtkTreeSelection *selection; GtkTreeViewColumn *desc_column; list_store = gtk_list_store_new (SEL_LAYOUT_N_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); text_renderer = GTK_CELL_RENDERER (gtk_cell_renderer_text_new ()); desc_column = gtk_tree_view_column_new_with_attributes (_("Layout"), text_renderer, "text", SEL_LAYOUT_TREE_COL_DESCRIPTION, "sensitive", SEL_LAYOUT_TREE_COL_ENABLED, NULL); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (list_store)); gtk_tree_view_column_set_sizing (desc_column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_column_set_resizable (desc_column, TRUE); gtk_tree_view_column_set_expand (desc_column, TRUE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), desc_column); g_signal_connect_swapped (G_OBJECT (selection), "changed", G_CALLBACK (xkb_layouts_enable_disable_buttons), dialog); max_selected_layouts = xkl_engine_get_max_num_groups (engine); /* Setting up DnD */ gtk_tree_view_set_reorderable (GTK_TREE_VIEW (tree_view), TRUE); g_signal_connect (G_OBJECT (tree_view), "drag-end", G_CALLBACK (xkb_layouts_drag_end), dialog); }
void gkbd_indicator_config_load_image_filenames (GkbdIndicatorConfig * ind_config, GkbdKeyboardConfig * kbd_config) { int i; ind_config->image_filenames = NULL; if (!ind_config->show_flags) return; for (i = xkl_engine_get_max_num_groups (ind_config->engine); --i >= 0;) { gchar *image_file = gkbd_indicator_config_get_images_file (ind_config, kbd_config, i); ind_config->image_filenames = g_slist_prepend (ind_config->image_filenames, image_file); } }
static void apply_xkb_settings (void) { GConfClient *conf_client; GkbdKeyboardConfig current_sys_kbd_config; int group_to_activate = -1; char *gdm_layout; char *s; if (!inited_ok) return; conf_client = gconf_client_get_default (); /* With GDM the user can already set a layout from the login * screen. Try to keep that setting. * We clear gdm_keyboard_layout early, so we don't risk * recursion from gconf notification. */ gdm_layout = g_strdup (gdm_keyboard_layout); gdm_keyboard_layout = NULL; /* gdm's configuration and $GDM_KEYBOARD_LAYOUT separates layout and * variant with a space, but gconf uses tabs; so convert to be robust * with both */ for (s = gdm_layout; s && *s; ++s) { if (*s == ' ') { *s = '\t'; } } if (gdm_layout != NULL) { GSList *layouts; GSList *found_node; int max_groups; max_groups = xkl_engine_get_max_num_groups (xkl_engine); layouts = gconf_client_get_list (conf_client, GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS, GCONF_VALUE_STRING, NULL); /* Add the layout if it doesn't already exist. XKB limits the * total number of layouts. If we already have the maximum * number of layouts configured, we replace the last one. This * prevents the list from becoming full if the user has a habit * of selecting many different keyboard layouts in GDM. */ found_node = g_slist_find_custom (layouts, gdm_layout, (GCompareFunc) g_strcmp0); if (!found_node) { /* Insert at the last valid place, or at the end of * list, whichever comes first */ layouts = g_slist_insert (layouts, g_strdup (gdm_layout), max_groups - 1); if (g_slist_length (layouts) > max_groups) { GSList *last; GSList *free_layouts; last = g_slist_nth (layouts, max_groups - 1); free_layouts = last->next; last->next = NULL; g_slist_foreach (free_layouts, (GFunc) g_free, NULL); g_slist_free (free_layouts); } gconf_client_set_list (conf_client, GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS, GCONF_VALUE_STRING, layouts, NULL); } g_slist_foreach (layouts, (GFunc) g_free, NULL); g_slist_free (layouts); } gkbd_keyboard_config_init (¤t_sys_kbd_config, conf_client, xkl_engine); gkbd_keyboard_config_load_from_gconf (¤t_kbd_config, &initial_sys_kbd_config); gkbd_keyboard_config_load_from_x_current (¤t_sys_kbd_config, NULL); if (!try_activating_xkb_config_if_new (¤t_sys_kbd_config)) { if (filter_xkb_config ()) { if (!try_activating_xkb_config_if_new (¤t_sys_kbd_config)) { g_warning ("Could not activate the filtered XKB configuration"); activation_error (); } } else { g_warning ("Could not activate the XKB configuration"); activation_error (); } } else xkl_debug (100, "Actual KBD configuration was not changed: redundant notification\n"); if (gdm_layout != NULL) { /* If there are multiple layouts, * try to find the one closest to the gdm layout */ GSList *l; int i; size_t len = strlen (gdm_layout); for (i = 0, l = current_kbd_config.layouts_variants; l; i++, l = l->next) { char *lv = l->data; if (strncmp (lv, gdm_layout, len) == 0 && (lv[len] == '\0' || lv[len] == '\t')) { group_to_activate = i; break; } } } g_free (gdm_layout); if (group_to_activate != -1) xkl_engine_lock_group (current_config.engine, group_to_activate); gkbd_keyboard_config_term (¤t_sys_kbd_config); }