Is it possible to import the Gvc typelib outside o

2019-07-08 19:52发布

问题:

I'd like to use Gvc (libgnome-volume-control) as used in Gnome Shell GIR in GJS, but can't find a way to access it except within the Gnome Shell environment (eg. a Gnome Shell extension). Actually, I can't even figure out where it is. Is this possible?

UPDATE

In line with Philip Withnall's comment (about a hacky workaround), I have found it's possible to import like so:

const GIRepository = imports.gi.GIRepository;
GIRepository.Repository.prepend_search_path("/usr/lib/gnome-shell");
GIRepository.Repository.prepend_library_path("/usr/lib/gnome-shell");
const Gvc = imports.gi.Gvc;

回答1:

Yes.

libgnome-volume-control is currently only meant to be used as a submodule. gnome-shell lists it in its .gitmodules file to import the code, and then in meson.build to build it.

It should be possible to use libgnome-volume-control in your project similarly.

(I determined this using git grep -i gvc on the gnome-shell code.)