static void update_layouts_list (GtkTreeModel *model, GtkBuilder *dialog) { gboolean cont; GtkTreeIter iter; GPtrArray *array; array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free); cont = gtk_tree_model_get_iter_first (model, &iter); while (cont) { char *id; gtk_tree_model_get (model, &iter, SEL_LAYOUT_TREE_COL_ID, &id, -1); g_ptr_array_add (array, id); cont = gtk_tree_model_iter_next (model, &iter); } g_ptr_array_add (array, NULL); xkb_layouts_set_selected_list (array->pdata); g_ptr_array_free (array, TRUE); xkb_layouts_enable_disable_buttons (dialog); }
void xkb_layouts_fill_selected_tree (GtkBuilder * dialog) { GSList *layouts = xkb_layouts_get_selected_list (); GSList *cur_layout; GtkListStore *list_store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (WID ("xkb_layouts_selected")))); int counter = 0; /* temporarily disable the buttons' status update */ disable_buttons_sensibility_update = TRUE; gtk_list_store_clear (list_store); for (cur_layout = layouts; cur_layout != NULL; cur_layout = cur_layout->next, counter++) { GtkTreeIter iter; const char *visible = (char *) cur_layout->data; gchar *utf_visible = xkb_layout_description_utf8 (visible); gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, SEL_LAYOUT_TREE_COL_DESCRIPTION, utf_visible, SEL_LAYOUT_TREE_COL_ID, cur_layout->data, SEL_LAYOUT_TREE_COL_ENABLED, counter < max_selected_layouts, -1); g_free (utf_visible); } clear_xkb_elements_list (layouts); /* enable the buttons' status update */ disable_buttons_sensibility_update = FALSE; if (idx2select != -1) { GtkTreeSelection *selection = gtk_tree_view_get_selection ((GTK_TREE_VIEW (WID ("xkb_layouts_selected")))); GtkTreePath *path = gtk_tree_path_new_from_indices (idx2select, -1); gtk_tree_selection_select_path (selection, path); gtk_tree_path_free (path); idx2select = -1; } else { /* if there is nothing to select - just enable/disable the buttons, otherwise it would be done by the selection change */ xkb_layouts_enable_disable_buttons (dialog); } }
void xkb_layouts_fill_selected_tree (GtkBuilder * dialog) { gchar **layouts = xkb_layouts_get_selected_list (); guint i; GtkListStore *list_store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (WID ("xkb_layouts_selected")))); /* temporarily disable the buttons' status update */ disable_buttons_sensibility_update = TRUE; gtk_list_store_clear (list_store); for (i = 0; layouts != NULL && layouts[i] != NULL; i++) { char *cur_layout = layouts[i]; gchar *utf_visible = xkb_layout_description_utf8 (cur_layout); gtk_list_store_insert_with_values (list_store, NULL, G_MAXINT, SEL_LAYOUT_TREE_COL_DESCRIPTION, utf_visible, SEL_LAYOUT_TREE_COL_ID, cur_layout, SEL_LAYOUT_TREE_COL_ENABLED, i < max_selected_layouts, -1); g_free (utf_visible); } g_strfreev (layouts); /* enable the buttons' status update */ disable_buttons_sensibility_update = FALSE; if (idx2select != -1) { GtkTreeSelection *selection = gtk_tree_view_get_selection ((GTK_TREE_VIEW (WID ("xkb_layouts_selected")))); GtkTreePath *path = gtk_tree_path_new_from_indices (idx2select, -1); gtk_tree_selection_select_path (selection, path); gtk_tree_path_free (path); idx2select = -1; } else { /* if there is nothing to select - just enable/disable the buttons, otherwise it would be done by the selection change */ xkb_layouts_enable_disable_buttons (dialog); } }