Lfb.Event¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
The Application id to use for this event |
||
r/en |
The reason why the feedbacks ended |
||
r/w/co |
The name of the event triggering the feedback |
||
r/w/en |
Feedback profile to use for this event |
||
r/w/en |
Whether to flags this event as important |
||
r/en |
The event’s state |
||
r/w |
When the event should timeout |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted when all feedbacks triggered by the event have ended. |
Fields¶
- Inherited:
Class Details¶
- class Lfb.Event(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
An event triggering feedback to the user
Lfb.Event
represents an event that should trigger audio, haptic and/or visual feedback to the user by triggering feedback on a feedback daemon. Valid event names are specified in the Event naming specification.One event can trigger multiple feedbacks at once (e.g. audio and haptic feedback). This is determined by the feedback theme in use (which is not under the appliction’s control) and the active feedback profile (see [func`Lfb`.set_feedback_profile].
After initializing the library via [func`Lfb`.init] feedback can be triggered like:
- ``c
g_autoptr (GError) err = NULL; LfbEvent *event = lfb_event_new (“message-new-instant”); lfb_event_set_timeout (event, 0); if (!lfb_event_trigger_feedback (event, &err))
g_warning (“Failed to trigger feedback: %s”, err->message);
When all feedback for this event has ended the [signal`LfbEvent`:py:func:::feedback-ended<Lfb.Event.signals.feedback_ended>] signal is emitted. If you want to end the feedback ahead of time use [method`LfbEvent`.end_feedback]:
- ``c
- if (!lfb_event_end_feedback (event, &err))
g_warning (“Failed to end feedback: %s”, err->message);
Since these methods involve DBus calls there are asynchronous variants available, e.g. [method`LfbEvent`.trigger_feedback_async]:
```c static void on_feedback_triggered (
Lfb.Event
*event,Gio.AsyncResult
*res,object
unused) { g_autoptr (GLib.Error
) err =None
; if (!:obj:Lfb.Event.trigger_feedback_finish (event, res, &err)) { g_warning (“Failed to trigger feedback for %s: %s”,Lfb.Event.get_event
(event), err->message); } }static void my_function () {
Lfb.Event
*event =Lfb.Event.new
(“message-new-instant”);Lfb.Event.trigger_feedback_async
(event,None
, (Gio.AsyncReadyCallback
)on_feedback_triggered,None
); } ```- classmethod new(event)¶
-
Creates a new [class`Lfb`.Event] based on the given event name. See [property`Lfb`.Event:event] for details.
- end_feedback()¶
-
Tells the feedback server to end all feedback for the given event as soon as possible.
- end_feedback_async(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
to cancel the operation orNone
.callback (
Gio.AsyncReadyCallback
orNone
) – AGio.AsyncReadyCallback
to call when the request is satisfied orNone
.
Tells the feedback server to end all feedback for the given event as soon as possible.
- end_feedback_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – Result object passed to the callback of [method`LfbEvent`.end_feedback_async]- Raises:
- Returns:
True
if ending the feedbacks was successful- Return type:
Finish an async operation started by
Lfb.Event.end_feedback_async
. You must call this function in the callback to free memory and receive any errors which occurred.This does not mean that the feedbacks finished right away. Connect to the [signal LfbEvent
::feedback-ended
] signal for this.
- get_app_id()¶
-
Returns the app-id for this event. If no app-id has been explicitly set,
None
is returned. The event uses the app-id returned by [func`Lfb`.get_app_id] in this case.
- get_end_reason()¶
- Returns:
The reason why feedback ended.
- Return type:
Get the reason why the feadback ended.
- get_event()¶
- Returns:
The event name
- Return type:
Get the event’s name according to the event naming spec.
- get_feedback_profile()¶
-
Gets the set feedback profile. If no profile was set it returns
None
. The event uses the system wide profile in this case.
- get_important()¶
-
Gets the set feedback profile. If no profile was set it returns
None
. The event uses the system wide profile in this case.
- get_state()¶
- Returns:
The state of the feedback triggered by event.
- Return type:
Get the current event state (e.g. if triggered feeedback is currently running.
- get_timeout()¶
- Returns:
The event timeout in milliseconds
- Return type:
Get the currently set timeout.
- set_app_id(app_id)¶
- Parameters:
app_id (
str
) – The application id to use
Tells the feedback server to use the given application id for this event when it is submitted. The server might ignore this request. This can be used by notification daemons to honor per application settings automatically.
The functions is usually not used by applications.
A value of
None
(the default) lets the server pick the profile.
- set_feedback_profile(profile)¶
- Parameters:
profile (
str
) – The feedback profile to use
Tells the feedback server to use the given feedback profile for this event when it is submitted. The server might ignore this request. Valid profile names and their ‘noisiness’ are specified in the Feedback theme specification.
A value of
None
(the default) lets the server pick the profile.
- set_important(important)¶
- Parameters:
important (
bool
) – Whether to flag this event as important
Tells the feedback server that the sender deems this to be an important event. A feedback server might allow the sender to override the current feedback level when this is set.
- set_timeout(timeout)¶
- Parameters:
timeout (
int
) – The timeout
Tells the feedback server to end feedack after #timeout seconds. The value -1 indicates to not set a timeout and let feedbacks stop on their own while 0 indicates to loop all feedbacks endlessly. They must be stopped via [method`LfbEvent`.end_feedback] in this case.
It is an error to change the timeout after the feedback has been triggered via [method`LfbEvent`.trigger_feedback].
- trigger_feedback()¶
-
Tells the feedback server to provide proper feedback for the give event to the user.
- trigger_feedback_async(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
to cancel the operation orNone
.callback (
Gio.AsyncReadyCallback
orNone
) – AGio.AsyncReadyCallback
to call when the request is satisfied orNone
.
Tells the feedback server to provide proper feedback for the give event to the user. This is the sync version of [method`LfbEvent`.trigger_feedback].
- trigger_feedback_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – Result object passed to the callback of [method`LfbEvent`.trigger_feedback_async]- Raises:
- Returns:
True
if triggering the feedbacks was successful- Return type:
Finish an async operation started by [method`LfbEvent`.trigger_feedback_async]. You must call this function in the callback to free memory and receive any errors which occurred.
Signal Details¶
Property Details¶
- Lfb.Event.props.app_id¶
- Name:
app-id
- Type:
- Default Value:
- Flags:
The application id to use for the event. [method`LfbEvent`.set_feedback_profile] for details.
- Lfb.Event.props.end_reason¶
- Name:
end-reason
- Type:
- Default Value:
- Flags:
The reason why the feedbacks ended
- Lfb.Event.props.event¶
- Name:
event
- Type:
- Default Value:
- Flags:
The type of event from the Event naming spec, e.g. ‘message-new-instant’.
- Lfb.Event.props.feedback_profile¶
- Name:
feedback-profile
- Type:
- Default Value:
- Flags:
The name of the feedback profile to use for this event. See [method`LfbEvent`.set_feedback_profile] for details.
- Lfb.Event.props.important¶
- Name:
important
- Type:
- Default Value:
- Flags:
Whether to flag this event as important. [method`LfbEvent`.set_important] for details.
- Lfb.Event.props.state¶
- Name:
state
- Type:
- Default Value:
- Flags:
The event’s state
- Lfb.Event.props.timeout¶
-
How long feedback should be provided in seconds. The special value %-1 uses the natural length of each feedback while %0 plays each feedback in a loop until ended explicitly via e.g. [method`LfbEvent`.end_feedback].