Commit Graph

37 Commits

Author SHA1 Message Date
mergify[bot] aa7c7c80ee
Merge pull request #2881 from psychon/dead_code
Remove some dead code
2019-09-23 16:40:19 +00:00
Uli Schlachter 1adeef18a2 Fix some typos (#2880)
Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-09-23 18:39:12 +02:00
Uli Schlachter fb151c3340 Remove some dead code in notification:reset_timeout()
This code is inside an "if new_timeout and [something else]". Thus, it
only executes when new_timeout is "truthy". Thus, "new_timeout or
[whatever]" will always evaluate to "new_timeout".

This commit removes that tiny bit of dead code.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2019-09-21 13:43:35 +02:00
Emmanuel Lepage Vallee 1bd2c1977e notification: Add an `append_actions` method.
The name is self explanatory, it adds more actions to a notification.

One of the use case is adding a snooze/reming_me action. Another one
is "mute similar notifications".
2019-08-03 01:45:22 -04:00
Emmanuel Lepage Vallee e524f93baa notification.action: Allow actions to be shared by multiple notification
The reason is that if actions are provided by rules, only one instance
exist. It was a mistake to couple actions with their notifications. It
could not work reliably and has to be removed.

The commit also change the notification action storage to be a copy
instead of the original table. This allows to append actions (not part
of this commit) without risking adding them to the wrong notification.

**WARNING** This break an unreleased API by removing the `notification`
property of an action.
2019-08-03 01:45:22 -04:00
Emmanuel Lepage Vallee f8cbb54913 naughty: Expose 3 previously internal properties.
* app_name: To be used in filters when no clients are found.
 * max_width: Allow to set it from the rules, it might be different
    when a `widget_template` is used.
 * widget_template: Now it can be set from the rules without further
    boilerplate code.
2019-08-03 01:45:22 -04:00
Emmanuel Lepage Vallee 78c616c358 notification: Allow nil to be set to the timeout to rmeove it 2019-08-03 01:45:22 -04:00
Emmanuel Lepage Vallee 84ae41422f notification: Prevent the timer to be started early in the constructor.
Otherwise the timer will be started before the preset is applied.
2019-08-03 01:45:22 -04:00
Emmanuel Lepage Vallee c36d35756f naughty: Begin to deprecate the presets.
The old preset code had a primitive implementation of the rule API
used in `naughty.dbus`. Now that `gears.matcher` is extracted from
`awful.rules`, it is possible to share the code.

The first step is to only enable the old API when the new
`request::preset` isn't connected. This is the same way the legacy
popup is only enabled when nothing is connected to `request::display`.
2019-08-03 01:45:22 -04:00
Emmanuel Lepage Vallee e076bc664e naughty: Bump the SPEC version compliance to v1.2.
* action icons
 * persistence
 * residence
 * categories
 * animated icons
 * more ways to get icons

In addition, the commit also tries its best to attach notifications to
objects using various dubious semi compliant hints or the DBus PID. It
works often enough to be useful.
2019-08-03 01:45:22 -04:00
Emmanuel Lepage Vallee 620241e056 doc: Fix the type of naughty.notification.id.
Copy/paste error.
2019-08-03 01:45:22 -04:00
Emmanuel Lepage Vallee bec4de5fab naughty: Auto-reset the timeout when notifications are modified.
This is configurable globally or per-notification. When it is
replaced over dbus, it has a new timeout and *that* should be the
new timeout (starting when the notification is replaced).

Closes #2821
2019-07-11 01:01:38 -04:00
Emmanuel Lepage Vallee 11ef560c5c naughty: Un-document naughty.notification.replaces_id.
It doesn't and cannot exists within `naughty.notification()` since it is
a constructor and that's way too late.

Ref #2816
2019-07-11 00:06:24 -04:00
Emmanuel Lepage Vallee 4df8120acb notification: Set the ID earlier.
Otherwise the signals were sent and the widgets created before the ID
was set. This makes some attempt at detecting updated notifications
error prone.
2019-07-09 01:25:00 -04:00
Emmanuel Lepage Vallee 1b4d667b67 doc: Update to the newer doc conventions. 2019-06-08 18:56:08 -04:00
Emmanuel Lepage Vallee 90396f33e7 doc: Tag the callback properties as deprecated.
They exists to comply with the old `naughty.notify` API. They should not
be used for new code.
2019-06-08 18:56:08 -04:00
Emmanuel Lepage Vallee 5261165be4 doc: Add many more examples to naughty.notification
Also document the `test` property as deprecated. It exists because the
older API (`naughty.notify`) had it. It exists on purpose in the
rewrite, it cannot just be removed even if it was never in a release.
2019-06-08 18:56:08 -04:00
Emmanuel Lepage Vallee 4aaf6ea730 naughty: Only enable the legacy mode when there is no other handlers.
It was called legacy for a reason, it is meant to be used only when the
rc.lua doesn't have the newer notification section.
2019-06-08 18:56:08 -04:00
Emmanuel Lepage Vallee d956b5411b naughty: Initialize the action `notification` property 2019-06-08 18:56:08 -04:00
Emmanuel Lepage Vallee fded165e41 doc: Document how to select different shapes based on the content. 2019-06-08 18:56:08 -04:00
Emmanuel Lepage Vallee 9acc452b1e naughty: Set an action table even if the notification has none.
Less `if` in the code.
2019-06-08 18:56:08 -04:00
Emmanuel Lepage Vallee 7bf1a276ef naughty: Use cleaner code to update the legacy actions.
The old code surprisingly worked, but reading this again, better
make some changes.
2019-06-08 18:56:08 -04:00
Emmanuel Lepage Vallee 90a29f92eb doc: Fix all the property, theme and field types. 2019-06-08 18:14:14 -04:00
Emmanuel Lepage Vallee 11d7a614d9 doc: Add a constructor stereotype for everything.
This forces the constructor functions to be at the top of the API
documentation rather than in a random position.
2019-06-08 18:13:42 -04:00
Emmanuel Lepage Vallee 63ca0f0d8f doc: Use an explicit @method stereotype for all methods.
ldoc has a magical `@classmod` module type which tries to detect
what is a method and what is a static function. It fails about as
often as it works. This commit makes everything explicit to remove
such issues.

Fixes #2640
Ref #1373
2019-06-08 18:13:42 -04:00
Emmanuel Lepage Vallee 9d0c2200b2 doc: Add a section for the important classes.
The choice is very subjective, but at least they stand out.
2019-06-08 18:13:28 -04:00
Michael Beaumont 9e2a544ba3 naughty: Add position "middle" to center notifications in screen (#2775)
Signed-off-by: Michael Beaumont <mjboamail@gmail.com>
2019-06-08 16:10:14 -04:00
Anton Bulakh 8493fd1829
Add forgotten nil-check to `notification.reset_timeout`
When you call `reset_timeout` on a notification with 0 timeout and thus no timer, a nil field error occures.
(can be tested with `awesome-client 'require"naughty".notification{message="TEST",timeout=0}:reset_timeout()'`)
Everywhere else in similar places (even at the beginning of the `reset_timeout`) the `self.timer` field is checked so i guess it was just forgotten there.
2019-03-11 20:45:31 +02:00
Emmanuel Lepage Vallee b0cf594de5 naughty: Set a default reason in `:destroy()`.
Fix #2713
2019-03-03 16:24:17 -05:00
Emmanuel Lepage Vallee 347d87418b naughty: Always have an id.
Fixes #2678
2019-02-22 11:47:46 -05:00
Emmanuel Lepage Vallée dd3c270819
Print a warning when trying to destroy the same notification multiple time. (#2662)
* notification: Print a warning when destroying more than once.

* doc: Fix a copy paste issue.
2019-02-17 12:36:02 -05:00
Emmanuel Lepage Vallee 1b567cc06a notification: Rename text to message
There is many "text" and the default text is the title, not the body.
2019-02-16 15:26:38 -05:00
Emmanuel Lepage Vallee faa553e47c notification: Allow to pause automatic expiration.
When the mouse is over or a keyboard driven menu is open, avoid
unexpected expiration to mess with the current notifications.

This commit also improve the `suspended` behavior to correctly
emit some signals.
2019-02-16 15:26:38 -05:00
Emmanuel Lepage Vallee 6d5d016a2a naughty: Turn actions into object.
The current API is non-compliant with the 1.0 spec and cannot represent
the v1.2 spec at all. The pair of name and callback fails to represent
the explicit ordering and cannot support the icons cleanly.

Plus to support the keyboard navigation use case, the notification
action need to be able to get some sort of focus state. Having an
object makes this easy.
2019-02-16 15:26:38 -05:00
Emmanuel Lepage Vallee 29cef2d615 notification: Add a new destroyed reason for "lack of space".
they were previously silently dismissed.
2019-02-16 15:26:38 -05:00
Emmanuel Lepage Vallee c691a0842b notification: Prevent Lua errors from causing unlimited timer events.
It now runs user defined code, so it can happen. Extra safety is
required.
2019-02-16 15:26:38 -05:00
Emmanuel Lepage Vallee 9df77e5c76 naughty: Move the notification object into its own file.
Mostly for the documentation, but also as the new base upon which
to build the modular notification GUI.
2019-02-16 15:25:10 -05:00