Closed asarch closed 4 years ago
const Gtk = imports.gi.Gtk;
let tv, tvc, crt;
tv = new Gtk.TreeView(); crt = new Gtk.CellRendererText(); tvc = new Gtk.TreeViewColumn; tvc.new_with_attributes("id", crt, 0); tv.append_column(tvc);
that work.
var column = new Gtk.TreeViewColumn(); column.new_with_attributes("id", Gtk.CellRendererText.new(), 0);
You still get the same error:
(gjs:8620): Gjs-WARNING **: JS ERROR: TypeError: column.new_with_attributes is not a function
JS_EvaluateScript() failed
And even if you do it sepparately:
var treeview = new Gtk.TreeView();
var renderer = new Gtk.CellRendererText(); var column = new Gtk.TreeViewColumn();
column.pack_start(renderer, false); column.add_attribute(renderer, "id", 0);
(gjs:10586): Gtk-WARNING **: Cannot connect attribute 'id' for cell renderer class 'GtkCellRendererText' since attribute does not exist
tvc = new Gtk.TreeViewColumn;
tvc.new_with_attributes("id", crt, 0);
Definitely don't do that. If it works, it's only by coincidence.
I recommend the workaround by @asarch (although the code pasted there doesn't work because the id
attribute doesn't exist. Try one like text
.)
In any case, new_with_attributes
and set_attributes
, and other functions with C varargs, should not be shown in the JS documentation.
If you try to do:
treeview.append_column(Gtk.TreeViewColumn.new_with_attributes("id", Gtk.CellRendererText.new(), 0));
you'll get:
(gjs:12258): Gjs-WARNING**: JS ERROR: TypeError: Gtk.TreeViewColumn.new_with_attributes is not a fu nction
JS_EvaluateScript() failed
shell returned 1
In the documentation this function appears:
http://devdocs.baznga.org/gtk30~3.22.12/gtk.treeviewcolumn#constructor-new_with_attributes