Commit Graph

17923 Commits

Author SHA1 Message Date
Florian Müllner
cdd19a7773 dbusServices/extensions: Save stateObj on extension
We don't need it for anything for the time being, but reducing the
differences between extension object in the gnome-shell process and
in preferences still seems a good idea.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2832>
2023-07-15 11:07:12 +00:00
Florian Müllner
9e4de6a005 dbusServices/extensions: Don't use getCurrentExtension()
The prefs dialog is created on behalf of a particular extension.
It's a bit silly to rely on getCurrentExtension() to access it,
instead of just keeping track of it ourselves.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2832>
2023-07-15 11:07:12 +00:00
Florian Müllner
b4c2901e47 dbusServices/extensions: Check earlier for existing dialog
There is no point in making a D-Bus call if we are going to bail
out anyway.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2832>
2023-07-15 11:07:12 +00:00
Florian Müllner
3451c5a182 extensionUtils: Slightly optimize current extension lookup
When looking for a directory name that matches the extension UUID,
we can just as well use GLib's dirname()/basename() functions
instead of wrapping the path in a GFile.

We also know that the original path corresponds to a regular file
and not a directory, so rearrange the loop to avoid a lookup that
is guaranteed to fail.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2832>
2023-07-15 11:07:12 +00:00
Florian Müllner
3289b79433 extensionUtils: Stop using RegExp for stack parsing
We currently use a regular expression to extract the exact file path
from a stack line. That RE is no longer accurate:

 - we assume a line number at the end, but at one point the column
   number was added as well
 - stacks from ES modules use file:// URIs instead of plain paths

Luckily that doesn't matter: We don't want to access any actual
files, so all we need is a path that can be traversed and that
contains the UUID.

We can get that with simple string manipulation, so avoid the regex
overhead.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2832>
2023-07-15 11:07:12 +00:00
Evan Welsh
c2c4d84fc1 dependencies: Migrate to ES module and organize dependencies
gi modules are always loaded (there is no API for "set version without
loading"), so
we need to break dependencies.js into three sections:

- Required
- Compile-time optional
- Runtime optional

Required dependencies are always imported, compile-time optional
dependencies
are loaded if gnome-shell is compiled with support for them, and for
runtime optional dependencies we catch any errors when attempting to
load them.
If runtime optional dependencies fail to load we log a debug-level
message.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
7a5f1e5c9e layout: Add catch when asynchronously setting up the startup animation
This ensures any errors that occur in this stage of startup are clearly
logged.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
3f12f3a87c scripting: Convert to ES module and migrate tests
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
9a2c3da868 environment: Port environment.js to be an ES module
Removes the init() function in favor of executing all environment
changes when the file is imported.

Additionally ports all unit tests using imports.gi.environment.init() to
use the updated module.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
26fa1046a3 tests: Load unit tests as modules
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Florian Müllner
3f667be2e8 ci: Include tests/ for linting
Linting isn't exclusively about coding style, but can detect
actual bugs.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
c570011376 tests/unit: Fix remaining ESLint errors
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Florian Müllner
26e018206d tests/shell: Fix remaining ESlint errors
All tests are currently excluded from linting, so errors can sneak
in more easily.

We should change that, so quickly fix up any remaining errors.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
9e84891240 insertSorted: Refactor comparator functions to be arrow functions
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
df8fb2899d tests: Move assertArrayEquals to shared assertions file
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
b798efcc1d tests: Use gjs_context_eval_file to evaluate test scripts
GJS provides utilities to run scripts given a filename, using those
utilities we can remove most of the logic implementing file loading.

Additionally the REPL logic does not make much sense for a test
runner and is unused, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Florian Müllner
011ac6f83c dependencies: Specify versions of Shell/St
We started to version them last cycle, so docs can be differentiated
between versions. It is not *expected* that two versions show up
on the same system, but then it also doesn't hurt handling it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
e2e3694cbd environment: Split dependencies loading into a new file
Once environment.js is an ES module we need to ensure we can dynamically
specify the version for required GI dependencies such as Clutter.

Moving dependency version setup to dependencies.js ensures gi.require
calls are done before environment.js imports any utilities.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
87d1248dc1 animationUtils: Group together various animation helpers
The environment module is used to initialize the environment, yet it
currently also defines the adjustAnimationTime() function.

Ideally it should not export any utility functions, in particular
once converted to ESM.

The function cannot be moved to the existing Utils module, as that
depends on an initialized environment, and can therefore not be
imported from environment.js, so use that opportunity to group
together several animation helpers in a new animationUtils module.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Florian Müllner
3c9857abad ci: Bump mutter image
Eieiei, mutter now depends on libei.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2846>
2023-07-15 03:27:22 +02:00
Florian Müllner
7eafc248cd lookingGlass: Evaluate command asynchronously
This allows using await in the command (or the header we
add to it), for example when handling Promises or importing
a module dynamically.

The latter will be crucial when porting to ESM.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Florian Müllner
85a8a6f46c lookingGlass: Reformat command header
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Florian Müllner
c0fbd74d07 jsParse: Make getCompletions() asynchronous
Part of the possible completions involves evaluating the part
of the passed in text that looks like an object, so that we
can query it for properties.

Using a Function or eval() for that means that we can only
complete text that does not use `await`. To get over that
limitation, evaluate the text in an AsyncFunction instead.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Florian Müllner
13e20e47bf jsParse: Replace eval()
The evil() function is considered eval, replace it like we
already did in looking glass.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Evan Welsh
a66ffcfc74 jsParse: Use JSDoc to document functions
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Florian Müllner
561d0d3758 lookingGlass: Handle completions asynchronously
They will actually become asynchronous in a following commit,
prepare for that.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Florian Müllner
03025d7cff lookingGlass: Handle unprintable object
We currently throw an error when encountering a result that cannot
be represented as string, with the prompt appearing somewhat stuck
(the input cannot be committed).

Showing a lame fallback instead at least avoids that issue. When
the object has a typeof 'object' but is not an instanceof Object,
we are likely dealing with an ES module, and can show a slightly
less lame fallback.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Florian Müllner
21e4cb142d lint: Relax jsdoc requirement
Requiring a description for every parameter even in internal
functions or in obvious cases ("actor - the actor") is cumbersome,
so relax that rule.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2842>
2023-07-14 12:36:53 +00:00
Florian Müllner
476bf23041 tests: Use different suites
This makes it easier to only run unit- or automation tests.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2845>
2023-07-14 00:56:26 +02:00
Lukáš Tyrychtr
a5cf08ac55 a11y: Don't create a parent loop for quick settings sliders
Rather than returning the parent container of the slider, which presents
itself as the slider, return the parent of the slider container.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6686

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2762>
2023-07-13 18:15:16 +02:00
Florian Müllner
27ffc37668 extensions-app: Style development window
Libadwaita includes a standard style class to distinguish
nightly/development versions from regular instances, but
we never to around applying it.

Do that now.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2841>
2023-07-13 15:33:06 +00:00
Florian Müllner
c67614b522 extensions-app: Include a non-fake Config
We currently include a fake config.js file to satisfy the indirect
import from ExtensionUtils. However we're about to need to pass
build-time information into the program ourselves, so generate
a proper file.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2841>
2023-07-13 15:33:06 +00:00
Florian Müllner
3028d478b8 st/icon-theme: Remove special-casing of symbolic lookup
GThemedIcon considers the "-symbolic" suffix when generating
fallback names (i.e. "foo-bar-symbolic", "foo-symbolic", "foo-bar",
"foo").

That means now that we prefer more accurate name matches from any
theme over fallback matches from higher-priority themes, we no
longer need to special-case symbolic names for preferring symbolic
matches over full-color fallbacks.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2824>
2023-07-13 15:15:56 +00:00
Florian Müllner
b3b4eeb496 st/icon-theme: Pick best-matching name from all themes
When resolving an icon name, we currently look in all themes in
order whether one of the requested names matches.

That means, a "keyboard" icon from the configured theme will
trump over any of "keyboard-shift", "keyboard-brightness" and
"keyboard-preferences" from lower-ranked themes (like "Adwaita"
and "hicolor").

That applies to custom icons we include in the resource, which
are added to the fallback ("hicolor") theme.

We are less bound by the named-icons spec than GTK, so we can
adapt the lookup to prefer the most accurate match to matches
from the highest priority theme.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2824>
2023-07-13 15:15:56 +00:00
Florian Müllner
b0384bee99 tests/shell: Also import built-in modules as modules
The "System" module is provided by gjs itself, and also available
as module.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2836>
2023-07-11 16:44:11 +02:00
Florian Müllner
0929b2a307 tests/shell: Import introspected libraries as modules
Since commit 5e93791708 tests scripts are loaded as modules,
so we can (and should) use "proper" imports.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2835>
2023-07-11 15:59:18 +02:00
Carlos Garnacho
04aaa4b67b keyboard: Spawn "tecla" to show keyboard map
This is a modern replacement for gkbd-keyboard-display, stuck in gtk3
and X11 (libxklavier).

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2834>
2023-07-11 15:06:19 +02:00
Florian Müllner
3a086c43ae ci: Print eslint results to stdout as well
The eslint jobs report their results as artifacts in junit format,
so that gitlab can present them in its UI.

However many people miss that, and unsuccessfully check the logs
instead.

Account for that by also printing the results to stdout.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2829>
2023-07-10 10:19:34 +00:00
Florian Müllner
d52b1576ac main: Replace custom log function with console
console.log() is implemented with structured logging, and as we
set an appropriate log domain, it's identical to the custom function
bar the custom fields with extension data.

Few people know about those custom fields, and adding them comes
at a cost, as we end up producing and parsing a stacktrace on
every log() call.

It therefore seems appropriate to drop the custom function, and
turn the global log() symbol into a simple convenience alias for
console.log().

If it turns out that people do miss the custom fields, we can add
an alternative to ExtensionUtils.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2830>
2023-07-10 09:59:58 +00:00
Florian Müllner
f07bf7b1b6 main: Remove log compatibility
global.log() hasn't been used since 3.6. It seems extremely unlikely
that any extensions are still using it, not least because `log()` is
more convenient.

Time to move on.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2830>
2023-07-10 09:59:58 +00:00
Florian Müllner
b854c1bdbb extensionSystem: Fix signal disconnection
The ::shutdown signal is on Shell.Global, not Meta.Context 🤦️

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2831>
2023-07-09 22:45:03 +02:00
Evan Welsh
812378a00d dateUtils: Refactor so all utilities use cached local timezone
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2827>
2023-07-07 18:58:35 -07:00
Evan Welsh
8d48dc8c6f environment: Remove toLocaleFormat and add dateUtils for date formatting
`toLocaleFormat` is now `formatDateWithCFormatString` and formatTime and
formatTimeSpan are moved into dateUtils.

Instead of overriding system.clearDateCaches, add a helper in dateUtils.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2827>
2023-07-07 18:58:34 -07:00
Evan Welsh
88eb04a42c dateMenu: Fix lint errors prior to refactor
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2827>
2023-07-07 18:32:50 -07:00
Florian Müllner
e7d290bbfb tests: Stop bundling "perf" tests with gnome-shell
Now that scripts are loaded as external modules, there's no reason
anymore for bundling them with the gnome-shell executable. Just
move the scripts into a dedicated folder in tests/ and run them
from there.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2812>
2023-07-07 19:43:28 +02:00
Florian Müllner
e4da6a347b test-tool: Require script argument
The purpose of the tool has shifted from running a limited set
of performance tests repeatedly to collect performance data
and catch regressions, to a wrapper that drives gnome-shell via
scripts for tests.

With that, the concept of a "default" script doesn't really make
sense anymore.

Instead, turn the argument from an optional flag into a required
parameter. This will allow us to stop bundling the existing tests
in a follow-up commit.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2812>
2023-07-07 19:43:28 +02:00
Florian Müllner
9bb003463c test-tool: Rename perf-tool
The original purpose of the tool was to collect performance data
that would optionally be uploaded to a server in Owen's living
room. While the corresponding scripts are still included (although
the server was probably dismantled years ago), the tool is mainly
used for running gnome-shell with scripted tests nowadays.

Rename the tool to reflect that.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2812>
2023-07-07 19:43:28 +02:00
Florian Müllner
bf9b9838c2 main: Pass script on CLI instead of via environment
Environment variables aren't the best option to pass parameters
to a process (wouldn't it be "fun" if SHELL_PERF_MODULE appeared
in a regular user session?).

Instead, use a (hidden) --automation-script command line flag to
specify a script file that should be used to drive an automated
session.

As a side effect, the script no longer has to be relative to the
main module itself, so it will be possible to run scripts that
aren't bundled with the shell sources.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2812>
2023-07-07 19:43:28 +02:00
Florian Müllner
5e93791708 main: Load perf scripts as modules
The perf scripts that can be used to script the gnome-shell UI
for testing are sufficiently separate from the rest of the code
base to allow porting them to ESM modules before the rest of
the code base.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2812>
2023-07-07 19:43:28 +02:00
Florian Müllner
dbc9ebc6ab ci: Look for matching ref in user remote for branch pipeline
We currently only find a matching ref on the same remote in
a merge request pipeline, but not in branch pipelines.

It can occasionally be useful to run a pipeline without opening
a merge request, so try the same remote here as well instead of
just assuming origin.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2814>
2023-07-07 17:28:26 +00:00