Lfb.Event

g GObject.Object GObject.Object Lfb.Event Lfb.Event GObject.Object->Lfb.Event

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (event)

end_feedback ()

end_feedback_async (cancellable, callback, *user_data)

end_feedback_finish (res)

get_app_id ()

get_end_reason ()

get_event ()

get_feedback_profile ()

get_state ()

get_timeout ()

set_app_id (app_id)

set_feedback_profile (profile)

set_timeout (timeout)

trigger_feedback ()

trigger_feedback_async (cancellable, callback, *user_data)

trigger_feedback_finish (res)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

app-id

str

r/w/en

The Application id to use for this event

end-reason

Lfb.EventEndReason

r/en

The reason why the feedbacks ended

event

str

r/w/co

The name of the event triggering the feedback

feedback-profile

str

r/w/en

Feedback profile to use for this event

state

Lfb.EventState

r/en

The event’s state

timeout

int

r/w

When the event should timeout

Signals

Inherited:

GObject.Object (1)

Name

Short Description

feedback-ended

Emitted when all feedbacks triggered by the event have ended.

Fields

Inherited:

GObject.Object (1)

Class Details

class Lfb.Event(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Lfb.EventClass

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)
Parameters:

event (str) – The event’s name.

Returns:

The [class`Lfb`.Event].

Return type:

Lfb.Event

Creates a new [class`Lfb`.Event] based on the given event name. See [property`Lfb`.Event:event] for details.

end_feedback()
Raises:

GLib.Error

Returns:

True if successful. On error, this will return False and set error.

Return type:

bool

Tells the feedback server to end all feedback for the given event as soon as possible.

end_feedback_async(cancellable, callback, *user_data)
Parameters:

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:

GLib.Error

Returns:

True if ending the feedbacks was successful

Return type:

bool

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 set app-id for this event or None.

Return type:

str

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:

Lfb.EventEndReason

Get the reason why the feadback ended.

get_event()
Returns:

The event name

Return type:

str

Get the event’s name according to the event naming spec.

get_feedback_profile()
Returns:

The set feedback profile to use for this event or None.

Return type:

str

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:

Lfb.EventState

Get the current event state (e.g. if triggered feeedback is currently running.

get_timeout()
Returns:

The event timeout in milliseconds

Return type:

int

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_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()
Raises:

GLib.Error

Returns:

True if successful. On error, this will return False and set error.

Return type:

bool

Tells the feedback server to provide proper feedback for the give event to the user.

trigger_feedback_async(cancellable, callback, *user_data)
Parameters:

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:

GLib.Error

Returns:

True if triggering the feedbacks was successful

Return type:

bool

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

Lfb.Event.signals.feedback_ended(event)
Signal Name:

feedback-ended

Flags:

RUN_LAST

Parameters:

event (Lfb.Event) – The object which received the signal

Emitted when all feedbacks triggered by the event have ended.

Property Details

Lfb.Event.props.app_id
Name:

app-id

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The application id to use for the event. [method`LfbEvent`.set_feedback_profile] for details.

Lfb.Event.props.end_reason
Name:

end-reason

Type:

Lfb.EventEndReason

Default Value:

Lfb.EventEndReason.NATURAL

Flags:

READABLE, EXPLICIT_NOTIFY

The reason why the feedbacks ended

Lfb.Event.props.event
Name:

event

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The type of event from the Event naming spec, e.g. ‘message-new-instant’.

Lfb.Event.props.feedback_profile
Name:

feedback-profile

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The name of the feedback profile to use for this event. See [method`LfbEvent`.set_feedback_profile] for details.

Lfb.Event.props.state
Name:

state

Type:

Lfb.EventState

Default Value:

Lfb.EventState.NONE

Flags:

READABLE, EXPLICIT_NOTIFY

The event’s state

Lfb.Event.props.timeout
Name:

timeout

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE

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].