Hi Amy, prefs.js is not a part of gnome-shell but it is part of a GTK+3 program called /usr/bin/gnome-shell-extension-prefs.
gnome-shell-extension-prefs is a shell script that accepts the UUID as argument to bring up your extension it's prefs.js. It invokes gjs with the searchpath to /usr/share/gnome-shell/js to import and make use of several non shell functionality in the js scripts, and to lauch it's main part called /usr/share/gnome-shell/js/extensionPrefs/main.js. prefs.js mainly exists to provide a GObject widget to gnome-shell-extension-prefs. You have to find out for yourself which scripts you can import in prefs.js Sometimes you can find the source of what you want inside a import that for instance main.js uses, so you can use that directly, also copying code can solve things, for instance I copied some spawning code from imports.misc.util which does not let it import into non shell environments. Look at the sourcecode of /usr/bin/gnome-shell-extension-prefs and /usr/share/gnome-shell/js/extensionPrefs/main.js to provide you with the mental picture of what happens. I suggest to use signaling of the settings database to let your prefs.js talk with your extension, so that your extension can take orders from prefs.js and can execute parts you need in gnome-shell. for example I use let reload = this._settings.get_int('reload'); this._settings.set_int('reload', (reload + 1)); this is just an integer increment that cause a signal to be fired, that signal is picked up by the subscribers of that signal. this._settings.connect("changed::reload", Lang.bind(this, this._onChanged)); to let any part of my project reload certain things in prefs.js and extension.js Dressed down it is a DBus signaling through dconf/gconf/gsettings system. Just use your imagination with this, the possibilities are numerous. Success!! -- (o_ //\ Regards, Groeten, V_/_ Bas Burger. On Wed, 8 Aug 2012 23:07:51 +1000 Amy C <mathematical.cof...@gmail.com> wrote: > Hi all, > > In my prefs.js I'm trying to import imports.ui.Main. > > However this causes the following error on selecting the extension in > gnome-shell: > > JS ERROR: !!! Exception was: Error: Requiring Meta, version > none: Typelib file for namespace 'Meta' (any version) not found > > I guess Main imports Meta which is not included in the import path for > gnome-shell-extension-prefs. > > The workaround is not to import Main in prefs.js and leave that until > the settings.connect('changed::...') listener in extension.js. > > However I'm only importing Main because I want to query > `Main.panel._leftBox.get_children().length` and depending on the > result I'll do a this._settings.set_int(...). I'm incorporating a > wrap-around effect: if the number increases past the > get_children().length I'll set it back to 0 instead. > > If I defer this processing to the listener in extension.js, it's going > to look like this: > > settings.connect('changed::my_key', function () { > let value = settings.get_int('my_key'); > if (value >= Main.panel._leftBox.get_children().length) { > value = 0; > settings.set_int(value); > return; > } > /* ... more stuff to do with value */ > } > > It just seems awkward because this will fire the 'changed::my_key' > signal twice, once with the first value and the proper adjusted value > of 0. > > So, is there any way to import Main into prefs.js? > > cheers > _______________________________________________ > gnome-shell-list mailing list > gnome-shell-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gnome-shell-list _______________________________________________ gnome-shell-list mailing list gnome-shell-list@gnome.org https://mail.gnome.org/mailman/listinfo/gnome-shell-list