Enhancement: Add gtk_tree_model_set_value() / gtk_tree_model_set() method
This enhancement request aims to make it easier for the user to change a value "inside" a GtkTreeModel. Currently I feel a real challenge to accomplish (especially for novices) "making a cell editable". There is already a lot of "knowledge noise" through Renderer and the function signature of current value set functions.
Currently Situation:
It is very difficult to change the value of a cell through GtkTreeModel: The user must use GtkTreeStore methods or GtkListStore methods to change values. In case of GtkTreeModelSorted, things get even more difficult. The necessity for differentiation results in the uselessness of the GtkTreeModel interface, as it cannot be used universally.
Suggestion:
Provide the following function:
void
gtk_tree_model_set (GtkTreeModel *tree_store,
GtkTreeIter *iter,
...);
Implementation:
-
GtkListStore already has gtk_list_store_set()
-
GtkTreeStore already has gtk_tree_store_set()
-
GtkTreeModelSort has no implementation, yet. It might look like the following:
GtkTreeModelSort * model_sorted = GTK_TREE_MODEL_SORT(p_model_sorted); GtkTreeIter iter_sortedModel; gtk_tree_model_get_iter_from_string((GtkTreeModel*)model_sorted, &iter_sortedModel, path_string); GtkListStore * model_raw; model_raw = GTK_LIST_STORE(gtk_tree_model_sort_get_model(model_sorted)); GtkTreeIter iter_rawModel; gtk_tree_model_sort_convert_iter_to_child_iter(model_sorted, &iter_rawModel, &iter_sortedModel); gtk_list_store_set(model_raw, &iter_rawModel, LIST_COL_NAME, new_text, -1);
-
Of course, the respective function should be called through gtk_tree_model_set.
Remark:
Changing the signature of the callback on "edited" to include a direct link to the cell content, which could then be changed directly, would of course be a much better solution. I did not suggest that one, as I expect it to be much harder to implement and therefore less likely to be implemented.