Hello,
I can be regarded as a beginner in programming. In my GTK+3 application, I intent to use the tree’s one of the column as a color indicator for list of graphical plots. The thread Gtk treeview cell color change is very helpful in that regard. I intended to make the color change to column more dynamic by using the cell-double click event. But the only event I could find in the GtkCellRenderer is the ‘editing-started’ and ‘edited’ event. What I did was use the ‘editing-started’ cb-function and generate a ‘editing-done’ signal using ‘gtk_cell_editable_editing_done’ and use the code in ‘edited’ callback function to generate a ’ GtkColorChooserDialog’. Using the color got to change the background of the cell. But there is an error “gtk_cell_area_activate_cell: assertion ‘GTK_IS_CELL_EDITABLE (editable_widget)’ failed”. I believe I am missing some sequence of events in the ‘editing-started’ callback. It will be nice if someone can show me the right track. The code follows:
// g_signal_connect(renderer2, "editing-started", G_CALLBACK(on_color_edit_begin), NULL);
void on_color_edit_begin (GtkCellRenderer *renderer,GtkCellEditable *editable,
char *path, gpointer user_data) {
gtk_cell_editable_editing_done (editable);
}
// g_signal_connect(renderer2, "edited", G_CALLBACK(on_color_edit_done), tree);
void on_color_edit_done (GtkCellRendererText *renderer, gchar *path, gchar *new_text, GtkWidget *tree) {
GtkTreeIter iter;
GValue value=G_VALUE_INIT;
g_value_init(&value, G_TYPE_STRING);
GtkTreeModel *store=gtk_tree_view_get_model(GTK_TREE_VIEW(tree));
g_value_set_static_string(&value, "rgba(255,0,0,1)");
GtkTreePath *tree_path=gtk_tree_path_new_from_string(path);
gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, tree_path);
gtk_list_store_set_value(GTK_LIST_STORE(store), &iter, 3, &value);
gtk_tree_path_free(tree_path);
g_value_unset(&value);
}
Thanks