Commit Graph

87 Commits

Author SHA1 Message Date
Florian Müllner
033277b68f Define externally accessible contants with 'var' instead of 'const'
Just as we did with classes, define other constants that are (or
may be) used from other modules with 'var' to cut down on warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=785084
2017-07-18 21:52:06 +02:00
Florian Müllner
e845f4105a extensionSystem: Handle all initExtension() extension errors
The method currently catches errors that occur when calling the
extension's init() method, but throws itself an error if the
expected extension.js file is missing. The former is pointless
if we expect all callers to handle errors themselves anyway, and
we should avoid the latter if we don't - opt for the second option
and handle a missing extension.js file gracefully.

https://bugzilla.gnome.org/show_bug.cgi?id=781728
2017-07-17 13:03:19 +02:00
Florian Müllner
d461d02cdc extensionSystem: Catch import errors
While we catch errors that occur when calling init(), enable() or
disable(), the import itself can throw an exception, for instance
if the extension imports an unavailable typelib or tries to draw
in a conflicting library.

https://bugzilla.gnome.org/show_bug.cgi?id=781728
2017-07-17 13:00:00 +02:00
Florian Müllner
88b1a5d3a0 extensions: Consistently handle createExtensionObject() errors
The method may throw an error, for example when metadata.json is
missing or cannot be parsed, however we are currently not always
handling it.

https://bugzilla.gnome.org/show_bug.cgi?id=781728
2017-07-17 13:00:00 +02:00
Florian Müllner
8d6efde091 Revert "extensionSystem: handle reloading broken extensions"
Both reloadExtensions() and enableExtensions() are already expected
to catch extension errors. If they don't, this is the bug that
should be fixed instead of catching unhandled exceptions in the
caller.

This reverts commit ff425d1db7.

https://bugzilla.gnome.org/show_bug.cgi?id=781728
2017-07-17 13:00:00 +02:00
Emilio Pozuelo Monfort
ff425d1db7 extensionSystem: handle reloading broken extensions
Some extensions out there may fail to reload. When that happens,
we need to catch any exceptions so that we don't leave things in
a broken state that could lead to leaving extensions enabled in
the screen shield.

https://bugzilla.gnome.org/show_bug.cgi?id=781728
2017-04-25 17:47:08 +02:00
Florian Müllner
7395aaf9b4 extensionSystem: Add kill-switch setting to disable user extensions
When gnome-shell fails to start on login, gnome-session tries to
re-launch it again with all extensions disabled. This is currently
implemented by clearing the list of enabled extensions, which means
the user needs to re-enable their extensions manually again.
To make this process less annoying, add a single 'kill-switch' setting
gnome-session can use without interfering with the user setting.

https://bugzilla.gnome.org/show_bug.cgi?id=778664
2017-02-15 23:20:14 +01:00
Florian Müllner
a36686a6aa extensionSystem: Fix updating extension list on session update
Before reenabling all extensions, we update the list of enabled extensions
to catch any changes that happened while extensions were enabled. However
this is currently broken as onEnabledExtensionsChanged() is a nop while
disabled, so just call getEnabledExtensions() directly.
2015-12-16 23:50:42 +01:00
Cosimo Cecchi
642bf2b778 theme: convert stylesheet loading to GFile
In preparation to making it a GResource.

https://bugzilla.gnome.org/show_bug.cgi?id=736936
2014-10-14 18:54:00 -07:00
Florian Müllner
4d64bbcf7d extensionSystem: Fix reloading on version-validation changes
The current code only works for enabled extensions, which means
that extensions that were marked OUT_OF_DATE cannot be enabled
without a restart when disabling the version check.
Fix this by reloading all extensions while making sure to only
enable any extensions when we're supposed to.

https://bugzilla.gnome.org/show_bug.cgi?id=736185
2014-09-06 22:06:07 +02:00
Adel Gadllah
1af40b1345 extensionSystem: Add a gsettings key to disable version validation
Add a key 'disable-extension-version-validation' key that disables
the validation of extension's claimed to be supported shell version
with the shell version and just load all extensions unconditionally.

https://bugzilla.gnome.org/show_bug.cgi?id=724683
2014-02-19 17:07:38 +01:00
Jasper St. Pierre
da4238ec68 Synchronize shell startup
The asynchronous nature of extension loading, session loading, and more,
makes the code racy as to what is initialized first, and hard to debug.
Additionally, since gjs is single-threaded, the only code we're running
in a thread anyway is readdir, which is going to be I/O bound, so the
code here is actually likely to be faster.

Drop this in favor of some good old fashioned synchronous loading.
2013-11-04 11:50:20 -05:00
Sebastien Lafargue
2c538d247b catch more errors on extensions enable() and disable()
https://bugzilla.gnome.org/show_bug.cgi?id=688331
2013-10-26 16:35:47 +02:00
Tomeu Vizoso
88ce65266e Disable all extensions in reverse order
So we avoid having to disable and enable an extension that is to
be disabled later anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=700784
2013-05-22 07:51:23 +02:00
Florian Müllner
2344706462 extensionSystem: Allow extensions to provide mode-specific styling
Allow extensions to integrate with modes that provide a distinct
style by providing a mode-specific stylesheet.

https://bugzilla.gnome.org/show_bug.cgi?id=693219
2013-02-05 19:54:17 +01:00
Florian Müllner
378df515d0 extensionSystem: Fix error reporting in lg / ListExtensionErrors()
Commit c99e8eb29 removed this line probably accidentally, as no
effort has been made to replace consumers in lookingGlass and
shellDBus.

https://bugzilla.gnome.org/show_bug.cgi?id=690173
2012-12-13 19:55:33 +01:00
Florian Müllner
31f75e4607 extensionSystem: Add support for mode-specific extensions
As currently envisioned, the fallback replacement in 3.8 should be
a separate session at the login screen. As we will use extensions
to implement this mode, we need a way to specify extensions per
session rather than per user, so add a session-mode property for
extensions that should be loaded in addition to the user-defined
ones.

https://bugzilla.gnome.org/show_bug.cgi?id=689305
2012-12-05 21:56:57 +01:00
Jasper St. Pierre
ca73017100 extensionSystem: Don't spam the error log with OUT_OF_DATE errors
Nobody cares

https://bugzilla.gnome.org/show_bug.cgi?id=689108
2012-11-26 15:11:58 -05:00
Giovanni Campagna
77c15b76b5 Fix extension styling
St.Theme.load_stylesheet() does not queue a theme context change, so
any styling of widgets created before will not be updated. To fix this,
load the stylesheet before the extension builds its own UI in enable()

https://bugzilla.gnome.org/show_bug.cgi?id=682128
2012-09-13 22:41:17 +02:00
Jasper St. Pierre
ca2e09fe8b sessionMode: Allow changing the session mode at runtime
Since we eventually want to add a system for changing the top panel
contents depending on the current state of the shell, let's use the
"session mode" feature for this, and add a mechanism for updating the
session mode at runtime. Add support for every key besides the two
functional keys, and make all the components update automatically when the
session mode is changed. Add a new lock-screen mode, and make the lock
screen change to this when locked.

https://bugzilla.gnome.org/show_bug.cgi?id=683156
2012-09-04 18:42:44 -03:00
Jasper St. Pierre
4ca2697271 shellDBus: Fix reloadExtension
We need to recreate and reimport the extension here, not just reimport
the same exact code.

https://bugzilla.gnome.org/show_bug.cgi?id=682578
2012-08-23 22:57:46 -03:00
Jasper St. Pierre
4696bfbb80 extensionSystem: Make unloadExtension take an extension object, not a UUID
For consistency with loadExtension.

https://bugzilla.gnome.org/show_bug.cgi?id=682578
2012-08-23 22:57:45 -03:00
Jasper St. Pierre
e1ec89a133 extensionSystem: Fix error emitting when enabling/disabling
We don't have an extension object here.
2012-07-11 22:46:59 -04:00
Jasper St. Pierre
c99e8eb29d extensionSystem: Be saner at error handling
Use our native JS error system in the "extension system" API, only
using the signal/log-based error reporting at the last mile. Additionally,
delete the directory if loading the extension failed, and report the error
back over DBus.

https://bugzilla.gnome.org/show_bug.cgi?id=679099
2012-07-02 18:29:56 -04:00
Jasper St. Pierre
75570b7995 extensionSystem: Add a method to unload an extension
https://bugzilla.gnome.org/show_bug.cgi?id=677586
2012-06-12 17:16:09 -04:00
Jasper St. Pierre
3290bfae68 extensionSystem: Remove the two-step initialize
Initially, extensions were loaded after they shell had fully created
the session and all objects, but this didn't allow extensions easy
ways to monkey patch prototypes, as most functions had already been
bound. Remove the historical vestigal function, and just merge the
two together.

https://bugzilla.gnome.org/show_bug.cgi?id=677586
2012-06-12 17:16:09 -04:00
Jasper St. Pierre
0805d7a35f extensionSystem: Make the init function optional
A large amount of extensions have something like this in them:

    function init() {}

Since we have encouraged extension authors to try and not make any
changes in init, it feels weird and strange to have to create an
initialization function that does nothing. From now on, don't require
it.

https://bugzilla.gnome.org/show_bug.cgi?id=677586
2012-06-12 17:16:09 -04:00
Jasper St. Pierre
11278a0814 extensionSystem: Load/unload stylesheets on enable/disable
I'm not entirely sure why this wasn't caught earlier.

https://bugzilla.gnome.org/show_bug.cgi?id=677586
2012-06-12 17:16:08 -04:00
Jasper St. Pierre
86de6f5861 extensionUtils: Create and load the extension object when scanning
This reduces some duplicate code when loading extensions.

https://bugzilla.gnome.org/show_bug.cgi?id=677586
2012-06-12 17:16:08 -04:00
Jasper St. Pierre
498b023989 extensionUtils: Use signals rather than callbacks for finding extensions
This allows us to move to a file-monitor based approach in the future.

Since we need signals, we convert the current set of functions to an
object we attach signals too, leading to the new ExtensionFinder object.

https://bugzilla.gnome.org/show_bug.cgi?id=677586
2012-06-12 17:16:08 -04:00
Jasper St. Pierre
5265884af9 extensionUtils: Remove userExtensionsDir
Make this less stateful

https://bugzilla.gnome.org/show_bug.cgi?id=677586
2012-06-12 17:16:08 -04:00
Jasper St. Pierre
3ff51da529 extensionSystem: Split off the extension downloader into a separate file
This keeps all UI out of the extension system, leaving it strictly for
loading and unloading extensions.

https://bugzilla.gnome.org/show_bug.cgi?id=677586
2012-06-12 17:16:08 -04:00
Jasper St. Pierre
c7b4022283 extensionSystem: Initialize the HTTP session after parse time
We really shouldn't be creating GObjects while we're still parsing other
files for performance and clarity reasons.

https://bugzilla.gnome.org/show_bug.cgi?id=677586
2012-06-11 13:07:40 -04:00
Jasper St. Pierre
a7ecc4cdd6 Revert "extensionSystem: Initialize the HTTP session after parse time"
This reverts commit df5298d59c.
2012-06-11 13:06:14 -04:00
Jasper St. Pierre
df5298d59c extensionSystem: Initialize the HTTP session after parse time
We really shouldn't be creating GObjects while we're still parsing other
files for performance and clarity reasons.
2012-06-11 13:04:56 -04:00
Jasper St. Pierre
3f942302d1 extensionSystem: Show an icon in the install dialog
https://bugzilla.gnome.org/show_bug.cgi?id=676837
2012-05-25 18:25:51 -04:00
Jasper St. Pierre
96396163cf extensionSystem: Replace Shell.write_soup_message_to_stream with GBytes usage
https://bugzilla.gnome.org/show_bug.cgi?id=676837
2012-05-25 18:25:51 -04:00
Jasper St. Pierre
0c736c4561 extensionSystem: Use Gio.File.new_tmp
https://bugzilla.gnome.org/show_bug.cgi?id=676837
2012-05-25 18:25:51 -04:00
Jasper St. Pierre
33ad9d1035 extensionSystem: Clean up
https://bugzilla.gnome.org/show_bug.cgi?id=676837
2012-05-25 18:25:51 -04:00
Jasper St. Pierre
d57658d059 extensionSystem: Remove custom CA file handling
libsoup (well, glib-networking) now handles this automatically

https://bugzilla.gnome.org/show_bug.cgi?id=676837
2012-05-25 18:25:51 -04:00
Jasper St. Pierre
031206cf1f extensionSystem: Remove now-unused version_tag, clean up other code as well
https://bugzilla.gnome.org/show_bug.cgi?id=676837
2012-05-25 18:25:51 -04:00
Jasper St. Pierre
ce041a3190 js: Don't use global.log*
These are "deprecated", and are just references to the gjs logging functoins

https://bugzilla.gnome.org/show_bug.cgi?id=675790
2012-05-18 14:09:00 -04:00
Jasper St. Pierre
3a01aaf7fb extensionSystem: Don't spam stdout with "Loaded extension"
https://bugzilla.gnome.org/show_bug.cgi?id=675790
2012-05-18 14:09:00 -04:00
Jasper St. Pierre
b095319a16 extensionSystem: Make it a non-fatal error to re-load an extension
https://bugzilla.gnome.org/show_bug.cgi?id=673613
2012-04-09 14:02:31 -03:00
Giovanni Campagna
64ce622f83 ExtensionSystem: fix uninstalling from website
uninstall function was still referring to the old state and error
objects, which were removed by the refactoring.

https://bugzilla.gnome.org/show_bug.cgi?id=671134
2012-03-01 20:45:32 +01:00
Giovanni Campagna
772638c78e ExtensionSystem: fix installing from website
loadExtension() fails if the extension object is already created,
but the installation dialog was creating a dummy object in the
downloading state. Since nothing requires that (and the object is
not in the correct format anyway), just kill it.

https://bugzilla.gnome.org/show_bug.cgi?id=671134
2012-03-01 20:45:32 +01:00
Giovanni Campagna
d0cd6ba47d extensionSystem: fix runtime enable()/disable() after last changes
disableExtension still used the old way to retrieve the state object,
and enableExtension called loadExtension at a time that would
always fail.

https://bugzilla.gnome.org/show_bug.cgi?id=669694
2012-02-08 23:29:39 +01:00
Jasper St. Pierre
a622aba7eb extensionUtils: Create and allow access to a new "extension" object
The "extension" object is what I previously called the "helper" object.
It contains the extension importer object as well as the metadata object.
Things that were previously added on to the metadata (state, path, dir, etc.)
are now part of this new "extension" object.

With the new importer changes brought on by the extension prefs tool,
extensions are left without a way to import submodules at the global scope,
which would make them rely on techniques like:

  var MySubModule;

  function init(meta) {
      MySubModule = meta.importer.mySubModule;
  }

That is, there's now a lot more meaningless boilerplate that nobody wants
to write and nobody wants to reivew.

Let's solve this with a few clever hacks.
Allow extensions to get their current extension object with:

  let extension = imports.misc.extensionUtils.getCurrentExtension();

As such, extensions can now get their own extension object before the
'init' method is called, so they can import submodules or do other things
at the module scope:

  const MySubModule = extension.imports.mySubModule;
  const dataPath = GLib.build_filenamev([extension.path, 'awesome-data.json']);

https://bugzilla.gnome.org/show_bug.cgi?id=668429
2012-02-07 16:00:37 -05:00
Jasper St. Pierre
80ff6ff797 Move a lot of miscellaneous code related to extensions into a new module
ExtensionUtils is a new module that has a lot of miscellaneous things related
to loading extensions and the extension system put into a place that does not
depend on Shell or St.

Note that this will break extensions that have with multiple files by replacing
the old uuid-based importer with an object directly on the meta object.

https://bugzilla.gnome.org/show_bug.cgi?id=668429
2012-02-07 16:00:37 -05:00
Jasper St. Pierre
2f27b94757 extensionSystem: Fix an error related to extension importing
If an extension fails to import, we will pass the error object
to logExtensionError, which fails to pass it onto DBus as an
error object is not a string. To fix, convert the error object
to a string before passing it to logExtensionError.

https://bugzilla.gnome.org/show_bug.cgi?id=668429
2012-02-07 16:00:37 -05:00