ptomato / devdocs

MOVED! Please see https://gitlab.gnome.org/GNOME/devdocsgjs/
https://gitlab.gnome.org/GNOME/devdocsgjs/
Mozilla Public License 2.0
5 stars 5 forks source link

Function Gtk.TreeViewColumn.new_with_attributes is not available #6

Closed asarch closed 4 years ago

asarch commented 6 years ago

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

StellioD commented 6 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.

asarch commented 6 years ago

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

asarch commented 6 years ago

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

ptomato commented 6 years ago
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.

ptomato commented 4 years ago

Moved to https://gitlab.gnome.org/GNOME/devdocsgjs/-/issues/14.