Commit Graph

297 Commits

Author SHA1 Message Date
Florian Müllner
21faae480e polkitAgent: Ensure cleanup if dialog wasn't shown
It is possible for an initiated session to complete without
a request if polkit can authenticate the action without user
input. We fail to clean up after ourselves in that case, as
the cleanup is done after the dialog is closed.

The dialog can still be shown when the code that hides existing
dialogs while the screen is locked shows it on unlock. But as
the session was closed, the dialog is now defunct and cannot
be dismissed by the user.

Fix this by running the cleanup on close() when the dialog
wasn't shown.

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

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1662>
2021-02-11 13:48:54 +01:00
Sebastian Keller
353483b052 automountManager: Remove unused volume queue
This is some leftover from code that was used to keep track of volumes
added/removed while the screen was locked before the move to a
components system in 2a800e4c. All that the remaining code does is
filter devices from an empty list.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1579>
2021-01-19 20:55:11 +00:00
Sebastian Keller
eb95f6a0fa networkAgent: Use VPN specific method to add VPN secrets
Use the method introduced in the previous commit to add VPN secrets
instead of adding them as regular secrets/passwords. This ensures
correct serialization of these secrets.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2105

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1535>
2020-12-25 11:43:13 +01:00
Florian Müllner
40e22eb524 cleanup: Use optional chaining and ?? operator
Those operators have been supported since gjs switched to mozjs78
last cycle. While not ground-breaking, using it makes for a nice
cleanup here and there.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1517>
2020-12-02 15:10:29 +00:00
Florian Müllner
8a47f1c667 cleanup: Remove empty leading/trailing lines in blocks
gjs added a new rule to its eslint ruleset that forbids "block padding",
so make sure we conform to that rule before syncing up the configuration.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1498
2020-11-16 18:04:23 +00:00
Florian Müllner
f5d1a2858d telepathyClient: Promisify the right class
send_message_async() is a method of TpTextChannel, not the generic
TpChannel parent class.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3226
2020-10-22 21:11:01 +02:00
Florian Müllner
9d5165b1aa polkitAgent: Drop separate user icon style
It should use the same style as used elsewhere (like the lock screen),
so stop using a separate style class to pick up the defaults.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3252
2020-10-09 13:23:05 +00:00
Björn Daase
2fc6384bca *: Fix spelling mistakes found by codespell
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1416
2020-08-21 18:25:09 +00:00
Will Thompson
1c0be1a36b polkitAgent: Add missing space to log string
In my journal, I have:

> JS LOG: polkitAuthenticationAgent: Received 2identities that can be
> used for authentication. Only considering one.

There should be a space after the number.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1413
2020-08-18 13:58:20 +00:00
Florian Müllner
990c171bed networkAgent: Add missing Uint8Array => string conversion
When promisifying async operations in commit 764527c8c, the
finish function for read_line_async() was sneakily changed from
read_line_finish_utf8() to read_line_finish().

That is, the call returns a Uint8Array now that requires an
explicit conversion to string.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1407
2020-08-13 23:00:21 +00:00
Florian Müllner
112b139a9e cleanup: Remove old compatibility code
Since gjs moved to mozjs60, return values of int8_t arrays can
no longer be treated as strings. We originally made the conversion
conditional to keep working with the (then) stable gjs release.

That was two years ago and we require a more recent gjs nowadays,
so there's no good reason for keeping the old code path.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1407
2020-08-13 23:00:21 +00:00
Florian Müllner
153b7d525d 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 leasure.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1177
2020-04-28 09:04:49 +00:00
Marco Trevisan (Treviño)
f4d90bc127 polkitAgent: Reset the session request timeout when removing it
When handing the resetDialog request we're leaving a source ID alive,
leading this error:

(gnome-shell:22464): GLib-CRITICAL **: 17:46:11.065: Source ID 12934 was not
found when attempting to remove it:

== Stack trace for context 0x55c9246916c0 ==
#0 55c9249151b8 i   js/ui/components/polkitAgent.js:391 (11f71fd544c0 @ 100)
#1 7ffc55140aa0 b   self-hosted:1009 (3062ba49af88 @ 423)
#2 55c924915120 i   js/ui/modalDialog.js:167 (1c9e50ae9880 @ 62)
#3 55c924915098 i   js/ui/modalDialog.js:186 (1c9e50ae9970 @ 12)
#4 55c924915008 i   js/ui/environment.js:75 (1c9e50a8d5b0 @ 98)
#5 55c924914f78 i   js/ui/environment.js:149 (1c9e50a8d9e8 @ 14)

So, reset the source handle to avoid trying to remove it.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1203
2020-04-17 16:17:51 +00:00
Marco Trevisan (Treviño)
bfa34914db polkitAgent: Return GLib.SOURCE_REMOVE on timeout callback
resetDialog is used (also) as GLib timeout function, so while just returning
an undefined value will stop the timeout anyways, it's just cleaner to
use the GSource expected return values

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1203
2020-04-17 16:17:51 +00:00
Florian Müllner
764527c8c9 js: Promisify async operations
Promises make asynchronous operations easier to manage, in particular
when used through the async/await syntax that allows for asynchronous
code to closely resemble synchronous one.

gjs has included a Gio._promisify() helper for a while now, which
monkey-patches methods that follow GIO's async pattern to return a
Promise when called without a callback argument.

Use that to get rid of all those GAsyncReadyCallbacks!

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1126
2020-03-31 05:43:40 +00:00
Florian Müllner
4f427f4e0d js: Do not set entries' ClutterText:editable property
The property influences the text's (and thus entry's) minimum width[0],
which is generally not what we want. And as we now prevent text from
being entered in non-reactive entries by other means, we can simply
drop it.

[0] https://gitlab.gnome.org/GNOME/mutter/-/blob/master/clutter/clutter/clutter-text.c#L2940

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2423
2020-03-29 22:12:57 +02:00
Florian Müllner
01a57206bc messageTray: Don't create notification policy on demand
This was changed in commit 8f15193b4 as a work-around for an ES6
class limitation, but now that Sources are GObject subclasses, we
no longer need to use that somewhat surprising pattern.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1131
2020-03-26 18:52:10 +00:00
Marco Trevisan (Treviño)
03a46be5c7 telepathyClient: Use proper Object to wrap different tpl messages
In telepathyClient we consider messages both Tpl.TextEvents and
Tpl.Messages, and we manually create JS objects to copy the properties we
care for each one. This may lead to objects not matching the interface we
want.

Instead, use an object with construct-only properties and two factory static
methods to initialize it.

Unfortunately we need to use the ChatMessageClass for the class name or
calling the static methods would trigger a gjs error as per [1].

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1113

[1] https://gitlab.gnome.org/GNOME/gjs/-/issues/310
2020-03-25 22:22:49 +00:00
Marco Trevisan (Treviño)
766288eec1 telepathyClient: Use GObjects based message objects
As per commit b5676a2a5 ChatNotification is a GObject, but I was wrongly
considering that it was using Tp.Message's as children, instead it just
uses custom-built objects to pass information around through signals.

Given gjs can only use GObjects as signal parameters, create a small wrapper
class to hold the ChatNotification messages and use it as signal parameter.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2449

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1112
2020-03-25 21:18:54 +00:00
Florian Müllner
b97fc02e57 networkAgent: Make searching VPN binaries asynchronous
Doing blocking IO in a graphical UI is bad, doing it in the compositor
is much much worse. So even if handling VPN requests is a relatively
rare event, doing it asynchronously is better.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2386
2020-03-17 14:07:15 +00:00
Florian Müllner
eb7533bbf1 networkAgent: Drop VPN plugin cache
libnm doesn't only search for plugins in the regular VPN plugin directory,
but also in the legacy location and the directory pointed to by the
NM_VPN_PLUGIN_DIR environment variable (if set).

We don't monitor the additional directories, so it's possible for our cache
to become outdated.

Instead of trying to play catch-up with libnm's internals, do what nm-applet
does and use the appropriate API to look up the plugin on each request.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2386
2020-03-17 14:07:15 +00:00
Florian Müllner
9d941f8202 js: Don't use templates in files with translations
xgettext gained some support for template strings, and no longer
fails when encountering '/' somewhere between backticks.

Unfortunately its support is still buggy as hell, and it is now
silently dropping translatable strings, yay. I hate making the
code worse, but until xgettext really gets its shit together,
the only viable way forward seems to be to not use template
strings in any files listed in POTFILES.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1014
2020-02-17 23:20:40 +01:00
Jonas Dreßler
95ebbb9360 Update hint texts of all entries
The design team discussed the ellipses at the end of the hint text of
our entries and, even though they are present in most mockups, it turned
out they don't like them, so remove them.

It also turned out they don't like the prefixes like "Enter" before it,
so remove those, too.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/977
2020-02-17 11:03:07 +00:00
Jonas Dreßler
775c3345eb networkAgent: Update dialog entry descriptions for new design
With the new dialog design the descriptions of entries are now
implemented as hint-text of the StEntry. That means the colon at the end
of the descriptions no longer makes sense and should be removed.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/977
2020-02-17 11:03:07 +00:00
Jonas Dreßler
45c5f21f6c dialogs: Hide caps lock warning if password entry is hidden
If all password entries in dialogs are hidden, there is either an entry
that has visible characters or no entry at all. That means we don't have
to show the caps lock warning at all, so hide it.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/942
2020-02-01 08:08:33 +01:00
Jonas Dreßler
3c47923953 networkAgent: Use shorter title strings
Since the headlines of the dialogs now use a much larger font, the
strings need to be shorter so they won't be ellipsized. So use a shorter
strings for those titles and also adjust the title-strings of the
notifications sent by the NetworkAgent to be consistent.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/942
2020-02-01 08:08:33 +01:00
Jonas Dreßler
dbaf5687dd networkAgent: Implement new dialog design
Use a completely vertical layout instead of the ClutterGridLayout based
layout to implement the new design for dialogs in the shell:

- Center-align all the elements of the dialog
- Remove the work-spinner
- Show the entry-labels as hint text of the entry

See https://gitlab.gnome.org/GNOME/gnome-shell/issues/1343

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/942
2020-02-01 08:08:33 +01:00
Jonas Dreßler
dc578a9e79 keyring: Use wiggle effect to inform about new warning message
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/942
2020-02-01 08:08:30 +01:00
Jonas Dreßler
040c1638ea keyring: Implement new dialog design
Replace the ClutterGridLayout of the keyring dialog with a vertical
StBoxLayout based layout according to the new dialog design:

- Center-align all the elements of the dialog
- Remove the work-spinner because requests usually finish fast enough
- Show the entry-labels as hint text of the entry

See https://gitlab.gnome.org/GNOME/gnome-shell/issues/1343

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/942
2020-02-01 08:06:31 +01:00
Jonas Dreßler
ded8412a2a polkitAgent: Use wiggle effect to inform about wrong password or problem
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/942
2020-02-01 08:06:31 +01:00
Jonas Dreßler
2f3738fae0 polkitAgent: Implement new design for polkit dialog
Implement the new design for the polkit according to the mockups in
https://gitlab.gnome.org/GNOME/gnome-shell/issues/1343:

- Center-align all the parts of the dialog
- Use a larger user avatar
- Remove the work-spinner because requests usually finish fast enough
- Show the entry-labels as hint text of the entry

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/942
2020-02-01 08:06:31 +01:00
Jonas Dreßler
9009b50bd1 polkitAgent: Remove styleClass argument for caps lock warning
The caps lock warning now has its own css class that works for this
case, too. Remove the custom class parameter and just use the default
one.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/952
2020-01-30 14:35:26 +00:00
Jonas Dreßler
2fc84e0fe3 dialog: Remove MessageDialogContent.body property
According to the new dialog design, dialogs generally only have a title
and a description, so the `body` property is no longer needed.

At the places where it's still used, we replace it with the description
property or a plain label we add to MessageDialogContent ourselves.

See https://gitlab.gnome.org/GNOME/gnome-shell/issues/1343

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/886
2020-01-15 00:17:25 +01:00
Jonas Dreßler
5d99bdbe5e dialog: Remove icons from dialogs
According to the new mockups, remove the icon from MessageDialogContent

See https://gitlab.gnome.org/GNOME/gnome-shell/issues/1343

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/886
2020-01-15 00:05:34 +01:00
Jonas Dreßler
929c2c3921 js: Move dialog parts out of messageBox
Since MessageDialogContent.messageBox is going to be removed in a
subsequent commit, move the parts where it's used out of messageBox and
into the contentLayout instead. This will introduce wrong spacings in
some dialogs, which we're going to fix when implementing the redesigned
individual dialogs.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/886
2020-01-15 00:05:04 +01:00
Florian Müllner
1ef4d85b50 networkAgent: Handle 'vpn' connections when delaying request
Since commit 90a08ba0b6, we only open a network secret dialog immediately
in response to user action, and show a notification otherwise.

While for the actual request VPNs are handled separately from other connections,
this isn't true when we show the notification - we need to handle 'vpn' together
with the other types there, or we fall through to the default 'invalid type'
exception.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2008
2020-01-09 01:26:01 +00:00
Umang Jain
474dda7ffe js: Add caps-lock Warning to the dialogs
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/619
2019-12-17 23:08:43 +01:00
Umang Jain
684b918915 js: Use StPasswordEntry for password entry fields
Use the new StPasswordEntry for password entry fields
and remove all direct handling of clutter text of the entry
 via clutter_text_set_password_char to show/hide the password
text. StPasswordEntry will provides a peek-password-icon which
will allow to show/hide the password present in the field to
the user in subsequent commits.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/619
2019-12-17 23:08:43 +01:00
Florian Müllner
acaa9f7f77 polkitAgent: Fix spinner
Commit 6af25b282c accidentally changed the case of the property.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/840
2019-11-21 22:04:39 +01:00
Joonas Henriksson
6af25b282c animation: Turn Spinner animate parameter into Params option
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/832
2019-11-19 19:54:13 +02:00
Jonas Dreßler
45ebb94b33 polkitAgent: Cancel session after disconnecting signal handlers
When cancelling the PolkitAgent session before disconnecting the signal
handlers, we receive a "completed" signal where `gained_authorization`
is set to FALSE, which means we show an error message inside
`_onSessionCompleted()`.

This in turn means we show an error message every time we cancel a
session. In practice this wasn't really relevant so far since we only
destroyed the session when an actual error occurred before. Now that the
dialog supports empty passwords, we also call `_destroySession()` when
the user changes and no longer has a password set, and in this case we
want to cancel the current session without showing an error message.

So to fix this, disconnect the signal handlers before cancelling the
session, which makes sure we don't receive the last "completed" signal
in case we cancelled the session ourselves. This change also allows
removing `this._wasDismissed`.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/829
2019-11-16 12:09:25 +01:00
Joaquim Rocha
89bf360bad polkitAgent: Use dialog as confirmation when the user has no password
When a user has no password and a polkit authentication is started,
instead of blindly initiating the admin session, show the regular
"Authentication Requested" dialog (but without the password entry). This
makes sure that the user's admin session is only effectively started
after the user chooses to proceed with the authentication, which
provides an extra confirmation step that can be vital for critical
tasks.

To do this, we show the dialog inside `_onUserChanged()` right after the
dialog was created instead of calling `performAuthentication()` from
`_onInitiate()`. The bug mentioned in `_onInitiate()` is no longer an
issue since we show the dialog in all cases now anyway.

Ideally we should use a different wording than "authentication" when the
user has no password set, and use "confirmation" instead. However polkit
already sends the requests with such messages (e.g. "Authentication is
required to configure software repositories"), and it's important to
show those to the user, so this patch keeps the regular wording.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/829
2019-11-16 12:09:25 +01:00
Jonas Dreßler
3a7228cf2f polkitAgent: Only reset UI on session resets while opened
Since `_destroySession()` is not only called before we try to initiate a
new authentication session with Polkit, but also when the dialog is
closed, it's currently possible that key focus is grabbed by the close
button after the dialog was dismissed and hidden. This is causing a bug
where after dismissing one of multiple queued dialogs, key focus goes
away and keyboard navigation with the new dialog is impossible.

Fix this by only resetting the UI of the dialog if the dialog is still
opened/visible at that point.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/828
2019-11-15 23:26:47 +00:00
Florian Müllner
61210fdae1 cleanup: Use JSDoc for documentation comments
It's a better fit than gtk-doc, and eslint can validate that they
are complete and use correct syntax.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
2019-11-11 19:25:14 +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
07cc84f632 cleanup: Only omit braces for single-line blocks
Braces can be avoided when a block consists of a single statement,
but readability suffers when the statement spans more than a single
line.

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
682bd7e97c 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/merge_requests/805
2019-11-11 19:25:14 +00:00