Class

LfbEvent

Description [src]

final class Lfb.Event : GObject.Object {
  /* No available fields */
}

An event triggering feedback to the user

LfbEvent 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 lfb_set_feedback_profile()().

After initializing the library via lfb_init()() feedback can be triggered like:

  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 LfbEvent::feedback-ended signal is emitted. If you want to end the feedback ahead of time use lfb_event_end_feedback()():

  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. lfb_event_trigger_feedback_async()():

  static void
  on_feedback_triggered (LfbEvent      *event,
                         GAsyncResult  *res,
                         gpointer      unused)
  {
     g_autoptr (GError) err = NULL;
     if (!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 ()
  {
    LfbEvent *event = lfb_event_new ("message-new-instant");
    lfb_event_trigger_feedback_async (event, NULL,
                                     (GAsyncReadyCallback)on_feedback_triggered,
                                     NULL);
  }

Hierarchy

hierarchy this LfbEvent ancestor_0 GObject ancestor_0--this

Ancestors

Constructors

lfb_event_new

Creates a new LfbEvent based on the given event name. See LfbEvent:event for details.

Instance methods

lfb_event_end_feedback

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

lfb_event_end_feedback_async

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

lfb_event_end_feedback_finish

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.

lfb_event_get_end_reason

Get the reason why the feadback ended.

lfb_event_get_event

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

lfb_event_get_feedback_profile
No description available.

lfb_event_get_state

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

lfb_event_get_timeout

Get the currently set timeout.

lfb_event_set_feedback_profile

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.

lfb_event_set_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 lfb_event_end_feedback()() in this case.

lfb_event_trigger_feedback

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

lfb_event_trigger_feedback_async

Tells the feedback server to provide proper feedback for the give event to the user. This is the sync version of lfb_event_trigger_feedback()().

lfb_event_trigger_feedback_finish

Finish an async operation started by lfb_event_trigger_feedback_async()(). You must call this function in the callback to free memory and receive any errors which occurred.

Methods inherited from GObject (43)

Please see GObject for a full list of methods.

Properties

Lfb.Event:end-reason
No description available.

Lfb.Event:event

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

Lfb.Event:feedback-profile

The name of the feedback profile to use for this event. See lfb_event_set_feedback_profile()() for details.

Lfb.Event:state
No description available.

Lfb.Event: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. lfb_event_end_feedback()().

Signals

Lfb.Event::feedback-ended

Emitted when all feedbacks triggered by the event have ended.

Signals inherited from GObject (1)
GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Class structure

struct LfbEventClass {
  GObjectClass parent_class;
  
}
No description available.
Class members
parent_class: GObjectClass
No description available.