GNOME Bugzilla – Bug 579312
can't access GdkAtoms
Last modified: 2015-01-27 17:26:45 UTC
(need to add "Return value: (transfer none):" to gdk_atom_intern annotations) const Gtk = imports.gi.Gtk; const Gdk = imports.gi.Gdk; Gtk.init(0, null); let atom = Gdk.atom_intern("CLIPBOARD", false); log("atom="+atom); Above fails to reach log() and isn't even throwing any exceptions: JS G FUNC: Call is to function Gdk.atom_intern with argc 2, expected: 2 in args, 0 out args, 2 total args JS G FUNC: Converting jsval to GArgument utf8 JS G FUNC: Converting jsval to GArgument boolean JS G FUNC: Converting GArgument interface to jsval JS G FUNC: gtype of SYMBOL is void JS G BXD: Wrapping struct Atom 0x45 with JSObject JS G NS: Resolve prop 'Atom' hook obj 0x8072900 priv 0x8054ed0 JS G NS: Found info type STRUCT for 'Atom' in namespace 'Gdk' JS GI USE: { GI_INFO_TYPE_STRUCT, "Gdk", "", "Atom", .details = { .nothing = {} } }, JS G NS: Resolve prop 'Atom' hook obj 0x8072900 priv 0x8054ed0 JS G NS: Found info type STRUCT for 'Atom' in namespace 'Gdk' JS GI USE: { GI_INFO_TYPE_STRUCT, "Gdk", "", "Atom", .details = { .nothing = {} } }, JS G REPO: Initializing dynamic class Atom 0x80ad5a0 JS G BXD: boxed constructor, obj 0x80729a0 priv 0x80b1ea0 JS G BXD: boxed instance __proto__ is 0x80723e0 JS G BXD: boxed instance constructing proto 1, obj class _private_Gdk_Atom proto class Object JS G BXD: Defined class Atom prototype is 0x80729a0 class 0x80ad5a0 in object 0x8072900 JS G REPO: Constructing instance of dynamic class _private_Gdk_Atom 0x80ad5a0 from proto 0x80729a0 JS G BXD: boxed constructor, obj 0x80729c0 priv 0x80b1eb0 JS G BXD: boxed instance __proto__ is 0x80729a0 JS G BXD: boxed instance constructing proto 0, obj class _private_Gdk_Atom proto class _private_Gdk_Atom JS G BXD: JSObject created by directly allocating Atom JS G FUNC: Releasing GArgument utf8 in param JS G FUNC: Releasing GArgument boolean in param JS CTX: Script evaluation failed JS CTX: JS_EvaluateScript() failed but no exception message? JS CTX: Script evaluation succeeded JS_EvaluateScript() failed but no exception message?
This is still the case, you get the warning: Gjs-WARNING **: JS ERROR: Error: Can't create a Javascript object for Atom; no way to copy Can this be fixed? Is it a matter of the Gdk side or something that could be handled by gjs? I would be willing to look into it if I got some pointers. I want to be able to copy to clipboard from gjs, is there another way? Jonas
We need a better clipboard API in GTK+, really. GdkAtoms are opaque struct types, which we can't refcount in gjs safely.
I see :) How do you think a patch that added something like: GdkClipboard * gtk_clipboard_for_name (GdkDisplay *display, const char *name); Would be welcomed? A function that does the GdkAtom dance on the inside.
I'm not sure. X is the only thing with two clipboards; all other systems (including Mir) just have one. You might have better luck with separate methods like gtk_clipboard_get (); and gtk_clipboard_get_primary_selection (); or similar, and on other platforms they both return the same thing.
Thank you! Added a bug: bug 712752
I would close this bug as WONTFIX, as the real goal is getting access to clipboards from introspected languages, not raw GdkAtom access.
The patch in bug 712752 got merged, which means that the primary use case for the functionality requested in this bug is now covered. I'll now close this as per comment 6. Please file a new bug should any other uses of GdkAtom be warranted from applications.