Commit Graph

104 Commits

Author SHA1 Message Date
Florian Müllner
2510bb3625 extensions: Stop using run_dispose()
It is considered bad practice, and mainly a lazy way of disconnecting
signal handlers without tracking individual handler IDs.

We can do better by using connectObject(), which provides the same
level of convenience without the dodginess of getting behind the
garbage collector's back.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/275>
2023-09-26 15:21:41 +00:00
Florian Müllner
f54b96c327 auto-move: Fix signal name
The functionality is still broken for wayland windows that use
xdg-activation, because the workspace information from the startup
sequence is handled later.

But at least it's a baby step towards a fix.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/272>
2023-09-06 00:00:36 +02:00
Florian Müllner
b7f285d733 Make project compatible with Reuse Software spec
Provide all licenses used in the project in a LICENSES folder and
add SPDX license and copyright information for all files in
accordance with the Reuse Software[0] specification.

The copyright information is based on the file's git history,
using a fairly generous definition of "non-trivial".

As of the spec recommendation, the information is generally added
as comments in the files themselves, except for

 - NEWS, README and similar top-level standard files, so that
   a SPDX code isn't the first thing people encounter
 - files that don't support comments (json) or where they'd
   be a bit awkward (.desktop, .service)
 - anything under po/, to not interfere with translation teams

Those are covered by a .reuse/dep5 files, except for image assets,
where separate .license files are used (It would be possible to
add comments to SVG files, but I don't trust image editors to
preserve them).

[0] https://reuse.software/

Part-of:
<https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/224>
2023-08-17 11:51:48 +00:00
Florian Müllner
a911447375 js: Port to ESM
The shell pulled the trigger and switched to ESM for all its
imports, follow suit.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/269>
2023-08-06 15:59:35 +02:00
Florian Müllner
f2c73329be extensions: Use new convenience classes
Convenience APIs for extensions are now provided as Extension/Prefs
base classes.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/268>
2023-08-05 18:53:41 +02:00
Florian Müllner
e75a1a15ac extensions: Import ExtensionUtils as module
ExtensionUtils has been converted to ESM and split into two modules,
for extensions and prefs respectively.

Adjust to those changes.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/266>
2023-07-15 14:13:25 +02:00
Florian Müllner
3bfaf6f88a js: Use connectObject()
gnome-shell added (dis)connectObject() methods to partially automate
signal handling. It doesn't only save a significant amount of code,
but also makes it harder to miss cleaning up on destroy.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/263>
2023-07-09 18:45:07 +02:00
Florian Müllner
cf007dd472 extensions: Turn extensions into modules
As gnome-shell is moving to ESM, it will now load extensions as
standard modules instead of using legacy imports. The change boils
down to exporting the Extension class as default, but we can also
start using standard imports for introspected modules now, so do
that at the same time.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/259>
2023-07-07 00:35:08 +02:00
Florian Müllner
701b14ecbf extensions: Use extension class for all extensions
This will be the only supported entry point when extension loading
switches to dynamic imports, so prepare for that by wrapping the
remaining standalone enable()/disable() methods in Extension classes.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/259>
2023-07-07 00:12:41 +02:00
Florian Müllner
563d7770d3 lint: Sync with gnome-shell
gnome-shell started transitioning to gjs' object spacing rule,
i.e. `{foo: 42}` instead of `{ foo: 42 }`.

We have a much smaller code base than the shell and aren't using
a secondary "allowed-but-deprecated" configuration that allows a
gradual transition, so just pull the switch and update to the new
style.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/240>
2022-08-20 19:00:32 +02:00
Florian Müllner
72a9696249 build: Remove unused stylesheets
The only reason for installing empty stylesheets is minimizing
build system differences between extensions. That's not a very
good reason and we don't do this for other optional files like
schemas.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/223>
2022-03-24 00:53:13 +01:00
Florian Müllner
3c5a56b440 auto-move: Bind list to model
Using a model gives us a clear separation between data and representation,
as well as between regular rows and the "new item" row at the end.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/218>
2022-02-18 13:09:35 +01:00
Florian Müllner
725cf83551 auto-move-windows: Change 'update' action to 'rename'
Limiting the action to the row that changed instead of the list as
a whole makes it easier to only update the changed value and not
recreate the entire list.

This doesn't make a difference right now, because we carefully sync
the list to reuse existing rows, but we are about to back the list
with a GListModel instead of updating it manually.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/218>
2022-02-18 13:08:09 +01:00
Florian Müllner
9f673f27ef cleanup: Use static class blocks for gtype registration
gjs enabled support for static class blocks, which gives us a
less error-prone and more readable alternative to _classInit(),
provided we make sure to call registerClass() first.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/215>
2022-02-18 03:34:06 +00:00
Florian Müllner
08db193b31 cleanup: Use regular constructors in GObject subclasses
As a side-effect of supporting class fields, regular constructors
now work in GObject subclasses. Using _init() still works and
there's no functional difference, but it's simply much nicer
to use the same syntax for all classes.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/215>
2022-02-18 03:34:06 +00:00
Florian Müllner
0be8b10995 cleanup: Simplify action handling
GTK4 has dedicated API for widget-specific actions, make use of that
instead of explicitly managing an action group.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/215>
2022-02-18 03:34:06 +00:00
Florian Müllner
f7b5836c75 auto-move-windows: Use custom spin button in prefs
Gtk.SpinButton doesn't look great in lists, so replace it with a
small custom widget based on current mockups from the design team.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/213>
2022-02-12 02:05:50 +00:00
Florian Müllner
ffb2b27477 auto-move-windows: Use libadwaita's row widgets
We get to remove a bunch of boring code, and get something better
looking and more standardized in return.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/213>
2022-02-12 02:05:50 +00:00
Florian Müllner
dd3c524c49 prefs: Replace 'content' list style
It's deprecated in favor of 'boxed-list'.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/213>
2022-02-12 02:05:50 +00:00
Florian Müllner
62628b25c6 auto-move-windows: Use libadwaita for preferences
libadwaita has now become stable and will be part of the GNOME 42
platform. Time to embrace it and get fancier preferences with
less code.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/209>
2022-02-08 19:22:41 +00:00
Florian Müllner
cc45bd63ab cleanup: Use new gettext() convenience
gnome-shell now includes convenience helpers for gettext functions that
use an extension's text domain (as initialized by initTranslations()).

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/183>
2021-08-14 23:15:56 +02:00
Florian Müllner
d0b9c9b54a cleanup: Document functions
gjs now enforces this in its eslint configuration. Adding type
information generally is a good idea, so add appropriate comments
to public functions before picking up that configuration change.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/180>
2021-08-13 04:48:22 +02:00
Florian Müllner
0d06cc685e extensions: Pick up gettext domain from metadata
Since commit a6ee142f21, the extension archives that are uploaded
to extensions.gnome.org only contain strings that are relevant for
the extension, not all translations from all extensions.

Unfortunately all extensions still share a common gettext domain,
so the extension with the last bind_textdomain() call wins and
leaves the others without translations.

We'll address this by using distinct domains when not installed
system-wide. That becomes easier if there is a canonical place
for the text domain, with the existing metadata key being the
natural choice.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/issues/335

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/179>
2021-08-11 18:42:43 +02:00
Daniel van Vugt
8a5e793b3d auto-move-windows: Don't move windows already on all workspaces
This fixes a particular case of mutter#992.

Although gnome-shell will also be softened to not crash in future, it's
also a good idea for the extension to explicitly decide how it wants to
handle windows that are already on all workspaces.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/157>
2021-01-28 16:33:50 +08:00
Florian Müllner
d381a0b89b auto-move-windows: Use Gtk.Button.icon_name property
Image buttons are a very common pattern, so GTK4 added some
convenience API we can use to construct them.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/148>
2021-01-14 14:40:55 +01:00
Florian Müllner
d5c31273ee auto-move-windows: Stop using header func for separators
GTK4 added built-in support for this common pattern, so use that
instead.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/148>
2021-01-14 14:40:55 +01:00
Florian Müllner
67d96993ce auto-move-windows: Port to GTK4
Just like the previous ports, this consists mostly of
replacing the old Gtk.Container methods.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/148>
2021-01-14 14:40:55 +01:00
Florian Müllner
61cf679b8c auto-move-windows: Exclude sticky windows from empty-check
We modify gnome-shell's workspace tracker to only remove empty
workspaces from the end. However we currently don't take into
account that sticky windows appear on all workspaces, so those
are preventing any workspace from getting removed at the moment.

Exclude them when determining whether a workspace is empty to
get the expected behavior.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/135
2020-11-13 23:53:49 +00:00
Florian Müllner
c87cfc822a auto-move: Overhaul preference dialog
auto-move uses the same outdated UI pattern as workspace-indicator did
until commit 90d3c5c51d, imposing the same problems for a future GTK4
port.

So replace treeview and toolbar with an editable list like we did for
the other extension.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/121
2020-05-03 19:51:24 +02:00
Florian Müllner
4722b89cc3 cleanup: Don't linebreak before closing parentheses
Otherwise recent versions of eslint want "dangling" commas,
which is at least ugly considering that most functions don't
allow adding arguments at leisure.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/116
2020-04-11 01:03:38 +02:00
Florian Müllner
30ad3d670f extensions: Stop setting GTypeName
The type name generated by gjs now includes the filename, so we
don't have to set it ourselves to make sure it's unique.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/95
2019-11-21 22:25:43 +01:00
Florian Müllner
7c170e7e90 cleanup: Always use type-safe comparisons
The type coercion performed by the regular == and != operators can
have surprising results. It is therefore considered good practice
to use the type-safe === and !== variants instead.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/91
2019-08-21 15:13:44 +00:00
Florian Müllner
ed7a292805 cleanup: Don't use comparison operator when checking falsy values
We mostly use the regular == and != comparison operators over their
type-safe === and !== counterparts. This is about to change, but there
are some places where we don't care whether a value is null, undefined
or 0; just check for falsiness there instead of using operators, so
we can start to consistently use the type-safe operators everywhere
else in a follow-up commit.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/91
2019-08-21 15:13:44 +00:00
Florian Müllner
eb79f5b512 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-extensions/merge_requests/91
2019-08-21 15:13:44 +00:00
Florian Müllner
63c07bdc73 cleanup: Don't shadow variables
Having variables that share the same name in overlapping scopes is
confusing and error-prone, and is best avoided.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/91
2019-08-21 15:13:44 +00:00
Florian Müllner
fca516e58a cleanup: Disambiguate assignments in arrow functions
As arrow functions have an implicit return value, an assignment of
this.foo = bar could have been intended as a this.foo === bar
comparison. To catch those errors, we will disallow these kinds
of assignments unless they are marked explicitly by an extra pair
of parentheses.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/91
2019-08-21 15:13:43 +00:00
Florian Müllner
2497dc6d31 cleanup: Use object destructuring where possible
ES6's destructuring is a nice way of assigning a variable in a concise way,
without duplicating the name of the object property. Use it consistently
where possible.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/91
2019-08-21 15:13:43 +00:00
Florian Müllner
9646149f9a 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 redundant 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-extensions/merge_requests/91
2019-08-21 15:13:43 +00:00
Florian Müllner
5f96b3c11c cleanup: Don't omit parens when constructing
While it is legal to omit parentheses when invoking a constructor
with no arguments, we generally avoid that in our coding style.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/91
2019-08-21 15:13:43 +00:00
Florian Müllner
2db4589dea cleanup: Re-order imports
They should be grouped between external (GI/gjs) and shell and in
alphabetical order. Until commit bab4be1a ExtensionUtils was special
as it was required for some imports, but that's no longer the case
for most extensions.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/76
2019-06-28 21:51:38 +02:00
Florian Müllner
55c493389a auto-move-windows: Reindent to conform with new style
Instead of aligning arguments like we used to do, use a consistent
four-space indent as mandated by gjs' current style guide.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/66
2019-05-22 20:40:18 +02:00
Florian Müllner
a071685c13 auto-move-windows: Clarify some code
Apply some tricks to align column numbers with their corresponding
values for better legibility.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/60
2019-03-04 19:35:10 +01:00
Florian Müllner
599428d292 auto-move-windows: De-duplicate row appending
https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/60
2019-03-04 19:35:10 +01:00
Florian Müllner
d83d6e857a style: Use single-quotes for translated strings
The coding style of using double quotes for translatable strings
and single quotes otherwise is unnecessarily complex and cannot
be enforced with an eslint rule.

Simply use single quotes consistently for all strings.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/57
2019-02-28 23:29:31 +01:00
Florian Müllner
db35d7ae7c style: Change indentation style of object literals
Instead of keeping the first property on the same line as the opening
brace and aligning the properties, use a four-space indent. This brings
us closer to gjs' coding style, and as a bonus helps keeping lines in
the soft 80 character limit.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/57
2019-02-28 23:29:24 +01:00
Florian Müllner
d34b5030b9 style: Use a consistent style for array literals
Most array literals already use a four-space indent, except the ones in
GObject metainfo and function parameters. Reindent those as well to make
the style consistent and bring it closer to gjs' coding style.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/57
2019-02-28 23:29:14 +01:00
Florian Müllner
7f8f1234ae style: Stop using braces for single-line arrow functions
Braces are optional for single-line arrow functions, but there's a
subtle difference:
Without braces, the expression is implicitly used as return value; with
braces, the function returns nothing unless there's an explicit return.

We currently reflect that in our style by only omitting braces when the
function is expected to have a return value, but that's not very obvious,
not an important differentiation to make, and not easy to express in an
automatic rule.

So just omit braces consistently as mandated by gjs' coding style.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/57
2019-02-28 23:29:05 +01:00
Florian Müllner
0d41643866 cleanup: Use destructuring for imports from GI
This is *much* nicer than repetitive "imports.gi" lines ...

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/54
2019-02-16 00:49:44 +01:00
Florian Müllner
bab4be1a59 extensions: Drop Convenience library
Its methods are now provided by gnome-shell itself and can be used
as an easy drop-in replacement.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/44
2019-02-06 20:17:59 +01:00
Florian Müllner
3861ffae31 extensions: Mark exported symbols
eslint obviously doesn't know about gnome-shell's extension API, so
the various entry points trigger unused-variable errors. To fix,
explicitly mark those symbols as exported.

https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/50
2019-01-28 06:51:20 +01:00