Commit Graph

192 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
b5676a2a5c messageTray: Inherit Notification, Source and NotificationPolicy from GObject
Register notifications, sources and policies as GObject gtypes so that they can
be passed in signals and use native properties and signals.

Reimplement all the extending classes.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559
2019-10-16 15:26:12 +00:00
Florian Müllner
133a1e7bef cleanup: Remove trailing spaces
We generally avoid these (not least because Linus hates them enough
to make git complain loudly), but some sneaked in over time ...

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/731
2019-09-15 16:02:45 +02:00
Florian Müllner
111f87a1b2 cleanup: Avoid pointless "renames" in destructuring
ES5 allows to rename variables in object destructuring, however this
only makes sense when we want to use a different name than the object
property.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/731
2019-09-15 16:02:45 +02:00
Florian Müllner
af87bd8c87 cleanup: Use consistent style for ternary operator
We are currently inconsistent whether to put the operators in front
of the corresponding line or at the end of the preceding one. The
most dominant style for now is to put condition and first branch on
the same line, and then align the second branch:

  let foo = condition ? fooValue
                      : notFooValue;

Unfortunately that's a style that eslint doesn't support, so to account
for it, our legacy configuration currently plainly ignores all indentation
in conditionals.

In order to drop that exception and not let messed up indentation slip
through, change all ternary operators to the non-legacy style.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/725
2019-09-15 13:30:19 +00:00
Florian Müllner
2fc4987c73 cleanup: Stop using Mainloop module
It is deprecated in favor of the regular GLib functions.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/718
2019-09-12 19:09:24 +02:00
Will Thompson
e5cde4700f notificationDaemon: Catch exceptions while loading notifications
An Endless OS system was found in the wild with a malformed
.local/share/gnome-shell/notifications which causes _loadNotifications()
to raise an exception. This exception was not previously handled and
bubbles all the way out to gnome_shell_plugin_start(), whereupon the
shell exit(1)s. The user could no longer log into their computer.

Handle exceptions from _loadNotifications(), log them, and attempt to
continue. Ensure that this._isLoading is set to 'false' even on error,
so that future calls to _saveNotifications() can overwrite the (corrupt)
state file.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1552
2019-09-03 01:00:50 +00: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
71759a0769 cleanup: Mark unused (but useful) variables as ignored
While we aren't using those destructured variables, they are still useful
to document the meaning of those elements. We don't want eslint to keep
warning about them though, so mark them accordingly.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/627
2019-07-24 00:28:45 +02: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
6ed5bc2f6c cleanup: Use consistent switch indentation
We are currently inconsistent on whether case labels share the same
indentation level as the corresponding switch statement or not. gjs
goes with the default of no additional indentation, so go along with
that.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/608
2019-07-02 12:17:46 +00:00
Florian Müllner
4c5206954a style: Use camelCase for variable names
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00
Florian Müllner
7ac35c644e style: Fix stray/missing spaces
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00
Florian Müllner
29b04fcbf2 style: Fix stray/missing semi-colons
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00
Florian Müllner
f250643385 style: Use space after catch
We are currently inconsistent with whether or not to put a space
after catch clauses. While the predominant style is to omit it,
that's inconsistent with the style we use for any other statement.
There's not really a good reason to stick with it, so switch to
the style gjs/eslint default to.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +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
a1534dab02 cleanup: Clean up unused imports
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/399
2019-02-09 05:05:07 +01:00
Carlos Garnacho
208c551787 js: Drop unused Gdk/Gtk imports
There's nothing from those modules used in those JS files.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/317
2019-01-30 22:50:01 +01:00
Philip Withnall
e92477a752 screenShield: Show detailed notification data if notifications hint it
Allow notifications to set a x-gnome-privacy-scope hint, with values in
['system', 'user']. If all the notifications in a particular source hint
that their privacy scope is ‘system’, don’t hide the notification
details on the lock screen.

This is aimed at fixing the particular case of power notifications: they
contain information which is not private to the user (it relates to the
system: battery state or AC state, which is obvious to anyone who can
see the machine), so hiding the details of a power management
notification when the screen is locked is pointless.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/gnome-shell/issues/726
2019-01-30 19:14:40 +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
Daniel van Vugt
4b28b90e0f notificationDaemon.js: Fix a typo (missing ')')
Introduced in e0a992af73 it was preventing gnome-shell from starting.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/915
2019-01-17 11:55:04 +08:00
Florian Müllner
e0a992af73 notificationDaemon: Fix warning
Since commit 33b8537bf5, we unconditionally access the 'image-path'
hint, resulting in a gjs warning if the hint is not defined.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/309
2019-01-16 18:57:04 +01:00
Marco Trevisan (Treviño)
367b1c0627 notificationDaemon: Don't pass unused extra hints value
Probably this is a leftover of old implementations of _iconForNotificationData,
but right now this only takes a value, so just pass one.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/285
2018-11-13 15:39:56 +01:00
Marco Trevisan (Treviño)
33b8537bf5 notificationDaemon: support file:// or icon theme names for image-path
While this sounds counter-intuitive, the image-path hint value might also
be used with URIs or icon names.

As per freedesktop standard:
  The "app_icon" parameter and "image-path" hint should be either an URI
  (file:// is the only URI schema supported right now) or a name in a
  freedesktop.org-compliant icon theme (not a GTK+ stock ID).

Thus the image-path hint should also be parsed as it happens for the
app_icon.

Reuse same logic, by falling back on _iconForNotificationData with the
hint value.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/285
2018-11-13 15:39:46 +01:00
Cosimo Cecchi
a98ed08a54 notificationDaemon: use different reason when replacing notification
Differently from the fd.o notifications, Gtk notifications do not
have a mechanism to update themselves. Instead, when a new
notification is received for an ID already known to the notification
daemon, the old notification is dismissed and a replaced with a new
one.

Currently though, there is no way to distinguish a notification that
was dismissed because of an user interaction, or because it was
replaced. That is an useful piece of information, so add a new value
to the NotificationDestroyedReason enum to account for it.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/258
2018-11-10 10:56:49 +00:00
Cosimo Cecchi
80a7547129 notificationDaemon: separate out GtkNotification creation
This way, source subclasses can easily use a notification subclass
if different functionality is required.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/258
2018-11-10 10:56:49 +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
e36ba874a8 Stop using conditional catch statements
It is a mozilla extension that is going away in SpiderMonkey 60.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/151
2018-07-17 17:02:39 +00: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
Krzesimir Nowak
1ef8722c52 notificationDaemon: Guard against invalid D-Bus object paths
When making any D-Bus call through the GDBus' proxy wrapper with an
invalid D-Bus object path, gnome-shell hangs.

Supposedly FdoApplicationProxy constructor should validate the passed
D-Bus object path and throw an error if the path is invalid. Since it
does not do that, we work it around by making sure that the deduced
D-Bus object path is valid or throw an exception if the path is not.

https://bugzilla.gnome.org/show_bug.cgi?id=787902
2017-09-25 15:57:20 +01:00
Krzesimir Nowak
ce7ff27c0c notificationDaemon: Consider hyphens for app ID to object path translations
Some application IDs contain hyphens, which are not allowed in D-Bus object
paths, so we need to update the translation by converting them to something
that's a valid object path. This is consistent with what GApplication does.

https://bugzilla.gnome.org/show_bug.cgi?id=787902
2017-09-25 15:57:07 +01:00
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
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
d815c5dfc0 notificationDaemon: Avoid access to undefined property
Avoid a warning when assigning from an undefined property by making
sure to pass a proper null value instead.

https://bugzilla.gnome.org/show_bug.cgi?id=781471
2017-07-13 17:23:54 +02:00
Florian Müllner
e2f88d67f7 Don't use 'undefined' as boolean
Make sure we pass a proper false value instead of undefined to
avoid warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=781471
2017-07-13 17:23:54 +02:00
Florian Müllner
326d5c7fb8 notificationDaemon: Fix fallback icon names
The gtk-dialog-* names are old and non-standard, and haven't been
provided by the default icon theme for quite a while ...

https://bugzilla.gnome.org/show_bug.cgi?id=784245
2017-07-05 18:40:18 +02:00
Florian Müllner
4e491b6f75 notificationDaemon: Include timestamp in serialized notifications
GNotifications are persistent until dismissed or withdrawn, including
across restarts. As we show the time a notification was received in the
calendar, we need to include that information when serializing the
notification in order to be correct.

https://bugzilla.gnome.org/show_bug.cgi?id=775799
2017-02-27 20:04:09 +01:00
Philip Chimento
aefd61c3db js: Avoid double declarations with let
The following code is a syntax error in ES6:

    let a = 'something';
    let a = 'other thing';

Previously GJS would silently accept this code, but in the next release the
SpiderMonkey JS engine will be more ES6-compliant.

https://bugzilla.gnome.org/show_bug.cgi?id=778425
2017-02-10 13:35:50 -08:00
Florian Müllner
accd24e379 notificationDaemon: Keep source alive when replacing notification
When a GNotification has the same ID as a previous one, it should
be shown as a new notification after withdrawing the old one.
However for this to work, we must not destroy the corresponding
source if withdrawing the old notification lets the notification
count drop to zero, so make sure the source is kept alive until
the replace operation has completed.

https://bugzilla.gnome.org/show_bug.cgi?id=775149
2016-11-28 15:42:23 +01:00
Carlos Garnacho
e1e321d3a7 NotificationDaemon: create the application proxy asynchronously
Clicking on calendar notifications might block till the DBus request times
out if the application being poked happens to be non-responsive. Perform
this asynchronously so we don't block if that is the case.
2016-11-26 15:00:35 +01:00
Giovanni Campagna
8eb236ae41 NotificationDaemon: stop filtering notifications from empathy
Now that we don't have our own code for showing telepathy
notifications, we don't need to filter out empathy's.

https://bugzilla.gnome.org/show_bug.cgi?id=745503
2015-03-03 14:20:48 -08:00
Florian Müllner
9c9da8a176 messageTray: Remove _lastNotificationRemoved()
No Source subclass used it to do anything special, and with sources
no longer having any UI representation on their own, doing anything
else isn't useful either, so just kill off that hook.

https://bugzilla.gnome.org/show_bug.cgi?id=744850
2015-02-20 17:39:59 +01:00
Florian Müllner
b00f122fcf notificationDaemon: Do the same for GTK+ notifications
There is not good reason why activating a GTK+ notification should
behave fundamentally different from fd.o notifications - we don't
raise the app because we expect it to perform an appropriate action,
but that does not include closing overview or calendar for us ...

https://bugzilla.gnome.org/show_bug.cgi?id=744817
2015-02-20 17:39:26 +01:00
Florian Müllner
11b3ed276b notificationDaemon: Close calendar when opening app
Just like we leave the overview when activating a notification,
the calendar popup should be closed - after all, the only case
where the calendar is open when a notification's default action
is activated is the user clicking an entry in the message list's
notification section.

https://bugzilla.gnome.org/show_bug.cgi?id=744817
2015-02-20 17:39:26 +01:00
Florian Müllner
65a5baa902 messageTray: Make Notification._onClicked handler public
When we will start to show notifications in the date drop-down, we
will not use the actual notification actor, but construct our own UI
based on Calendar.Message. This is similar to what we already do in
the lock screen, except that in this case clicking the notification
should activate the default action.
So rename the existing _onClicked() method to activate() to make it
clear that such use is acceptable. While not strictly necessary, also
rename the corresponding signal to match.

https://bugzilla.gnome.org/show_bug.cgi?id=744817
2015-02-20 17:39:25 +01:00
Florian Müllner
f4301147bb notificationDaemon: Remove support for action-icons
This capability was only really useful for media players, and with
music notifications no longer being special, we can simplify a bit
by removing support for it.

https://bugzilla.gnome.org/show_bug.cgi?id=744815
2015-02-20 01:53:00 +01:00
Florian Müllner
ea9e5bc52c messageTray: Remove support for Music notifications
Music is no longer a special type of notification according
to the design. If we want to resurrect the functionality, we
can reimplement it with a dedicated API like MPRIS rather
than piggy-bagging on the notification system.

https://bugzilla.gnome.org/show_bug.cgi?id=744815
2015-02-20 01:52:13 +01:00
Florian Müllner
f08e2b72d2 messageTray: Remove support for images in notifications
The design says they are no longer a thing.

https://bugzilla.gnome.org/show_bug.cgi?id=744815
2015-02-20 01:50:01 +01:00