+static void
+edited_callback (GtkCellRendererText *renderer,
+ const gchar *path_string,
+ const gchar *new_text,
+ GtkTreeView *tree_view)
+{
+ GtkTreeModel *model = NULL;
+ GtkTreeModelSort *sort_model = NULL;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ guint value = atoi (new_text);
+
+ g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
+
+ model = gtk_tree_view_get_model (tree_view);
+
+ if (GTK_IS_TREE_MODEL_SORT (model))
+ {
+ sort_model = GTK_TREE_MODEL_SORT (model);
+ model = gtk_tree_model_sort_get_model (sort_model);
+ }
+
+ if (model == NULL)
+ return;
+
+ if (sort_model)
+ {
+ g_warning ("FIXME implement conversion from TreeModelSort iter to child model iter");
+ return;
+ }
+
+ path = gtk_tree_path_new_from_string (path_string);
+ if (!gtk_tree_model_get_iter (model,
+ &iter, path))
+ {
+ g_warning ("%s: bad path?", G_STRLOC);
+ return;
+ }
+ gtk_tree_path_free (path);
+
+ if (GTK_IS_LIST_STORE (model))
+ {
+ gtk_list_store_set (GTK_LIST_STORE (model),
+ &iter,
+ 4,
+ value,
+ -1);
+ }
+ else if (GTK_IS_TREE_STORE (model))
+ {
+ gtk_tree_store_set (GTK_TREE_STORE (model),
+ &iter,
+ 4,
+ value,
+ -1);
+ }
+ else
+ g_warning ("don't know how to actually toggle value for model type %s",
+ g_type_name (G_TYPE_FROM_INSTANCE (model)));
+}