CellRendererText::edited changes in GTK+ 3


I’ve just run into a change in behavior between GTK+ 2 and GTK+ 3 that
confuses me quite a bit; as I’m not sure whether the change is intentional
or the result of a bug, I’m asking here on the list.

The attached program clearly shows how CellRendererText behaves differently
in GTK+ 3 than it did in GTK+ 2: when using the latter, the "edited" signal
is emitted whenever the user moves the focus from one cell to another,
giving the program a chance to save the contents of the cell; when using the
former, the signal is not emitted, so the cell behaves as if editing had
been canceled, minus the emission of the "editing-canceled" signal.

The new behavior feels completely unnatural to me, and I’m convinced many
people will lose the changes they’ve just made to a cell because of it.

Is this intended? Is there some other signal I can connect to in order to
save changes made to a cell when the focus moves to another one?

Andrea Bolognani <eof kiyuko org>
Resistance is futile, you will be garbage collected.
/* Compile with:
 *     valac --pkg gtk+-2.0 treeviewtest.vala
 * or
 *     valac --pkg gtk+-3.0 treeviewtest.vala

private static const int COL_WHATEVER = 0;
private static const int COL_LAST     = 1;

public static int main (string[] args) {

	Gtk.Window window;
	Gtk.ListStore store;
	Gtk.TreeIter iter;
	Gtk.TreeView treeview;
	Gtk.TreeViewColumn column;
	Gtk.CellRendererText renderer;

	Gtk.init (ref args);

	store = new Gtk.ListStore (COL_LAST,
                               typeof (string));
	store.append (out iter);
	store.set (iter,
	           COL_WHATEVER, "");
	store.append (out iter);
	store.set (iter,
	           COL_WHATEVER, "");

	window = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
	window.delete_event.connect ((ev) => {

		Gtk.main_quit ();
		return true;

	treeview = new Gtk.TreeView ();

	renderer = new Gtk.CellRendererText ();
	renderer.set ("editable", true);
	renderer.edited.connect ((row, val) => {

		Gtk.TreePath path;

		path = new Gtk.TreePath.from_string (row);
		store.get_iter (out iter,
		store.set (iter,
		           COL_WHATEVER, val);
	column = new Gtk.TreeViewColumn.with_attributes ("Whatever",
	                                                 "text", COL_WHATEVER);
	treeview.append_column (column);

	treeview.model = store;

	window.add (treeview);
	window.show_all ();

	Gtk.main ();

	return 0;

Attachment: signature.asc
Description: Digital signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]