Commit Graph

69 Commits

Author SHA1 Message Date
Florian Müllner
10818c74a6 extensionPrefs: Don't (re-)bind text domain
Gettext is already set up from the binary, no need to do it again
in JS.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/918
2020-01-06 13:10:43 +00:00
Florian Müllner
a2044c61ae extensionPrefs: Always redefine getCurrentExtension() on prefsModule access
We have three interactions with an extension's prefs module:
 - we import the module
 - we call its init() hook
 - we call its buildPrefsWidget() hook

The first two are one-time actions where we expect most getCurrentExtension()
calls (local imports, initTranslations() etc.).

However it's still possible that the extension will use the utility function
in buildPrefsWidget() as well, either directly or via other functions like
getSettings(): Make sure getCurrentExtension() returns the correct extension
in that case, not the last one whose preferences were initialized.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/873
2019-12-05 15:24:34 +00:00
Florian Müllner
2703eed446 extensionPrefs: Simplify state change handling
The new `ExtensionStateChanged` signal already passes the changed
extension object, no need to request it again with `GetExtensionInfo`.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/873
2019-12-05 15:24:34 +00:00
Florian Müllner
e44adb92cf cleanup: Avoid unnecessary parentheses
Extra parentheses usually add noise rather than clarity, so avoid
them.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
ebf77748a8 cleanup: Require "dangling" commas
Since ES5, trailing commas in arrays and object literals are valid.
We generally haven't used them so far, but they are actually a good
idea, as they make additions and removals in diffs much cleaner.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
c860409da5 cleanup: Use object shorthand where possible
ES6 allows to omit property names where they match the name of the
assigned variable, which makes code less redunant and thus cleaner.
We will soon enforce that in our eslint rules, so make sure we use
the shorthand wherever possible.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
9eaa0089d0 cleanup: Fix missing/stray spaces
Those are wrong according to our style guidelines, but the previous
eslint ruleset didn't catch them.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +00:00
Florian Müllner
284ace5b5f cleanup: Use (un)block_signal_handler() convenience wrapper
We now depend on a gjs version that is guaranteed to provide those
more idiomatic wrappers, so use them instead of the clunkier static
methods.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/795
2019-10-30 19:40:15 +00:00
Marco Trevisan (Treviño)
39e6fc9e9d js: Use Gjs GTypeName computation for all classes
As per previous commit we can remove the explicit GTypeName definitions
and use gjs auto computation for all the GObject registered classes.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/790
2019-10-29 18:38:35 +00:00
Florian Müllner
10b2083d3e extensionPrefs: Trick xgettext into accepting odd number of backticks
Xgettext learned about template strings now, which is good. However
it's still buggy, so instead of the "classic" xgettext issue with
backticks, we now have exciting new issues to find work-arounds for.

One issue is that it doesn't detect backticks inside string constants
as regular characters, so having an odd number of backticks throws off
its regex.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/792
2019-10-29 17:38:06 +00:00
Florian Müllner
471165ca9b cleanup: Use consistent brace style of blocks
Our coding style has always been to either put braces around all
blocks, or avoid them for all. Fix the couple of places that slipped
through.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/731
2019-09-15 16:02:45 +02:00
Jonas Dreßler
1e68e78d8e extensionPrefs: Block notify::active signal handler while updating state
We disable and enable extensions inside the `notify::active` signal
handler, but we shouldn't do that in case the change didn't come from
the user but because something else changed the state of the extension.

This causes an issue when the extensionPrefs window is open and the
session gets locked: The extensions are temporarily disabled by the
shell, extensionPrefs updates its switches on the state change and adds
those extensions to the `disabled-extensions` gsettings key inside the
signal handler. Now when the session is unlocked again, the extensions
won't be enabled again since they're forced-disabled.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/705
2019-09-09 19:50:31 +00:00
Jonas Dreßler
17fa5a2db4 extensionPrefs: Connect to ExtensionStateChanged after building UI
Since we manipulate parts of the UI (like the switch) in this signal
handler, let's only connect it after setting up the UI.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/705
2019-09-09 19:50:31 +00:00
Florian Müllner
5bd295842b extensionPrefs: Request correct GDK/GTK versions
gjs no longer has an implicit dependency on GTK 3.0, so without
requesting an explicit version, we will get the highest available.

Our code isn't GTK-4 ready, so request 3.0 explicitly.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/686
2019-08-21 19:43:33 +02:00
Florian Müllner
e357559582 cleanup: Mark globals used from other modules as exported
eslint cannot figure out that those symbols are used from other modules
via imports, so they trigger unused-variable errors. To fix, explicitly
mark those symbols as exported.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/627
2019-07-24 00:28:45 +02:00
Florian Müllner
dd1fdf88ff extensionPrefs: Add missing return value
When commit a7ec7583aa merged two functions into one, it left
out the expected return value from one branch.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/635
2019-07-22 13:18:55 +00:00
Didier Roche
9928125e7d extensionPrefs: Switch to D-Bus API to get extension live state
By direclty using the underlying GSetting, whether or not an extension
appears as enabled or disabled currently depends only on whether it is
included in the 'enabled-extensions' list or not.

However this doesn't necessarily reflect the real extension state, as an
extension may be in error state, or enabled via the session mode.

Switch to the extensions D-Bus API to ensure that the list of extensions
and each extension's state correctly reflects the state in gnome-shell.

https://bugzilla.gnome.org/show_bug.cgi?id=789852
2019-07-20 14:17:35 +00:00
Florian Müllner
1c63893c4b extensionPrefs: Override getCurrentExtension() for extensions
Extensions are used to calling the getCurrentExtension() utility function,
both from the extension itself and from its preferences. For the latter,
that relies on the extensions map in ExtensionUtils being populated from
the separated extension-prefs process just like from gnome-shell.

This won't be the case anymore when we switch to the extensions D-Bus API,
but as we know which extension we are showing the prefs dialog for, we
can patch in a simple replacement that gives extensions the expected API.

https://bugzilla.gnome.org/show_bug.cgi?id=789852
2019-07-20 14:17:35 +00:00
Didier Roche
a7ec7583aa extensionPrefs: Attach extension object to each row
Each row represents an extension, so it makes sense to associate the
rows with the actual extensions instead of linking rows and extensions
by looking up the UUID in the external extensions map in ExtensionUtils.

This will also make it much easier to stop using the shared extension
loading / map in favor of the extension D-Bus API.

https://bugzilla.gnome.org/show_bug.cgi?id=789852
2019-07-20 14:17:35 +00:00
Florian Müllner
32e0b895a4 shellDBus: Add new 'ExtensionStateChanged' signal
The existing 'ExtensionStatusChanged' signal has a fixed set of parameters,
which means we cannot add additional state without an API break.  Deprecate
it in favor of a new 'ExtensionStateChanged' signal which addresses this
issue by taking the full serialized extension as parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=789852
2019-07-20 14:17:35 +00:00
Marco Trevisan (Treviño)
b82b553b9e extensionPrefs: Inherit from Gtk.Application
Extension preferences Application class is just a container for a GtkApplication
so instead of using composition we can inherit from the base GObject class.

Also replace signal connections with vfunc's.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/631
2019-07-17 12:59:08 +00:00
Florian Müllner
0d035a4e53 cleanup: Prefer template strings
Template strings are much nicer than string concatenation, so use
them where possible; this excludes translatable strings and any
strings containing '/' (until we can depend on gettext >= 0.20[0]).

[0] https://savannah.gnu.org/bugs/?50920

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/612
2019-07-05 11:32:31 +00:00
Florian Müllner
95b80eec01 extensionPrefs: Avoid awkward indentation in string literal
The current code is carefully avoiding an overly wide line length as
well as adding literal new lines to the string due to indentation. It's
clever and barely legible.

Instead, use one string per line similar to how they appear in the actual
output, and join them together when setting the clipboard text.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/608
2019-07-02 12:17:46 +00:00
Florian Müllner
fe83cd91bb cleanup: Use rest parameters instead of arguments
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:10 +02:00
Florian Müllner
f6b4b96737 cleanup: Use Array.includes() to check for element existence
We can use that newer method where we don't care about the actual position
of an element inside the array.

(Array.includes() and Array.indexOf() do behave differently in edge cases,
for example in the handling of NaN, but those don't matter to us)

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/152
2019-07-01 21:28:52 +00:00
Florian Müllner
5d9f80bc73 extensionPrefs: Fix pref button appearance
After the Adwaita refresh, the button shows up oval rather than
circular. To address this, make sure that the "image-button" class
is applied as well by using the dedicated setter function.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/482
2019-04-12 00:51:44 +02:00
Florian Müllner
fd50b9a45e cleanup: Use destructuring for imports from GI
This is *much* nicer than repetitive "imports.gi" lines ...

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/399
2019-02-09 07:39:20 +01:00
Florian Müllner
5dbf09c008 extensionPrefs: Work around xgettext bug
xgettext is thrown off by the combination of backticks and slashes,
which makes template string a fun trap to fall into. Just use
String.format() for now ...

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/383
2019-02-03 16:11:09 +00:00
Florian Müllner
43a19739ab extensionPrefs: Improve error UI
Currently when a preference widget fails to load, we throw a raw
backtrace at the user. While that is undoubtedly useful information
for extension developers and bug reports, it is gibberish to most
users and hardly the first thing they should be exposed to.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/193
2019-01-31 00:38:19 +01:00
Florian Müllner
36f9147b21 extensionPrefs: Add blank state
We currently show a big white window in case no extensions are
installed, which clearly isn't helpful. Add a small blank state
that explains what's going on.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/193
2019-01-31 00:38:19 +01:00
Florian Müllner
e68dfed1f7 cleanup: Port GObject classes to JS6 classes
GJS added API for defining GObject classes with ES6 class syntax
last cycle, use it to port the remaining Lang.Class classes to
the new syntax.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
2019-01-25 14:02:44 +00:00
Florian Müllner
bacfdbbb03 cleanup: Port non-GObject classes to JS6 classes
ES6 finally adds standard class syntax to the language, so we can
replace our custom Lang.Class framework with the new syntax. Any
classes that inherit from GObject will need special treatment,
so limit the port to regular javascript classes for now.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/361
2019-01-25 14:02:44 +00:00
Florian Müllner
94423151b2 dbus: Move all interface descriptions into the resource
https://gitlab.gnome.org/GNOME/gnome-shell/issues/537
2018-09-17 07:34:49 +00:00
Marco Trevisan (Treviño)
dbf993300a js: use ES6 template strings for dbus interfaces
Use multiline template strings for dbus interfaces as they're easier to maintain
2018-08-27 19:23:00 +02:00
Florian Müllner
3b1330880f cleanup: Use Function.prototype.bind()
When not using arrow notation with anonymous functions, we use Lang.bind()
to bind `this` to named callbacks. However since ES5, this functionality
is already provided by Function.prototype.bind() - in fact, Lang.bind()
itself uses it when no extra arguments are specified. Just use the built-in
function directly where possible, and use arrow notation in the few places
where we pass additional arguments.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:02 +00:00
Florian Müllner
213e38c2ef cleanup: Use arrow notation for anonymous functions
Arrow notation is great, use it consistently through-out the code base
to bind `this` to anonymous functions, replacing the more overbose
Lang.bind(this, function() {}).

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:00 +00:00
Florian Müllner
76f09b1e49 cleanup: Use method syntax
Modern javascript has a short-hand for function properties, embrace
it for better readability and to prepare for an eventual port to
ES6 classes.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:54:58 +00:00
Florian Müllner
2582d16ca7 Define classes with 'var' instead of 'const'
Any symbols (including class properties) that should be visible
outside the module it's defined in need to be defined as global.
For now gjs still allows the access for 'const', but get rid of
the warnings spill now by changing it.

https://bugzilla.gnome.org/show_bug.cgi?id=785084
2017-07-18 21:52:06 +02:00
Florian Müllner
06fdf2fdc8 extensionPrefs: Avoid a runtime warning
Since 5b3fb024be, the main window is only shown when not launched
with a valid UUID. As GtkDialog isn't meant to be used standalone,
we currently trigger a (harmless but annoying) warning in case
the main window isn't shown; we can avoid the warning by setting
up the preference dialog manually instead of using the GtkDialog
convenience class.

https://bugzilla.gnome.org/show_bug.cgi?id=781545
2017-04-20 19:18:23 +02:00
Florian Müllner
7a20683728 extensionPrefs: Fix enum member name 2017-04-20 17:35:35 +02:00
Florian Müllner
75f8279a19 extensionPrefs: Tweak UI
Update according to the latest mockups:
 - don't use a border around the list as specified
   by the latest HIG version
 - use more generous spacing between controls
 - allow extension descriptions to take up two lines
 - drop GNOME branding from the window title
 - make the app name consistent with the window title

https://bugzilla.gnome.org/show_bug.cgi?id=778672
2017-02-15 23:20:14 +01:00
Florian Müllner
5d07832e96 extensionPrefs: Expose kill-switch
While the extension prefs tool is not meant as the primary way for
users to configure extensions - that will be Tweak Tool - it still
doesn't hurt to expose the extension kill switch to easily turn
extensions back on after a session crash.

https://bugzilla.gnome.org/show_bug.cgi?id=778664
2017-02-15 23:20:14 +01:00
Florian Müllner
695bfb9616 extensionPrefs: Fix extension list width
ScrolledWindow changed its allocation behavior, and the extension
list only takes up the minimum width rather than the available
width as intended. To get the previous behavior back, we need
to set the newly added :propagate-natural-width property ...

https://bugzilla.gnome.org/show_bug.cgi?id=771391
2016-09-14 09:18:23 +02:00
Florian Müllner
75ba75900c extensionPrefs: Stop using custom CSS
GTK+ now has a documented CSS class for circular buttons that we can
use for the preference buttons instead of custom CSS.
2016-03-10 18:16:33 +01:00
Florian Müllner
669d20bcf0 extensionPrefs: Fix prefs button 2016-02-11 15:01:53 +01:00
Giovanni Campagna
36d9cc329d ExtensionPrefs: remove unused GSettings object
Each ExtensionRow has its own

https://bugzilla.gnome.org/show_bug.cgi?id=746509
2015-03-27 13:11:22 -07:00
Florian Müllner
593acb954d extensionPrefs: Improve handling of OutOfDate extensions
Our current UI is horrible in dealing with outdated extensions - we
don't give users any indication at all that something is not working as
expected (unless hiding the prefs button as we did until the last commit
counts).
To fix this, make the enable switch insensitive to indicate OutOfDate
extensions.

https://bugzilla.gnome.org/show_bug.cgi?id=736185
2014-09-06 22:06:23 +02:00
Florian Müllner
d209bc69b6 extensionPrefs: Remove version check from extensionAvailable()
It is confusing to treat outdated extensions as if they didn't exist
in some places, but like any other extensions elsewhere. In particular
gnome-tweak-tool still allows to launch prefs for them while making
it clear to users that the extension will not work - opening the
list of installed extensions in that case is unexpected and confusing.
Just remove the version check for now, we will soon follow tweak-tool
and use it to disable the extension switch instead.

https://bugzilla.gnome.org/show_bug.cgi?id=736185
2014-09-06 22:06:23 +02:00
Florian Müllner
d77c7a407c extensionPrefs: Respect 'disable-extension-version-validation' setting 2014-07-18 10:47:02 +02:00
Jasper St. Pierre
83cb26d70e js: Adapt to GSettings API change
The 'schema' property has been deprecated for a long time. Even though
this will likely be reverted in glib, let's stop using it.
2014-06-24 15:17:09 -04:00