Dunst
Lightweight notification daemon
Loading...
Searching...
No Matches
queues.h File Reference

Queues for history, waiting and displayed notifications. More...

#include "dbus.h"
#include "dunst.h"
#include "notification.h"
+ Include dependency graph for queues.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void queues_init (void)
 Initialise necessary queues.
 
GList * queues_get_displayed (void)
 Receive the current list of displayed notifications.
 
GList * queues_get_history (void)
 Recieve the list of all notifications encountered.
 
struct notificationqueues_get_head_waiting (void)
 Get the highest notification in line.
 
unsigned int queues_length_waiting (void)
 Returns the current amount of notifications, which are waiting to get displayed.
 
unsigned int queues_length_displayed (void)
 Returns the current amount of notifications, which are shown in the UI.
 
unsigned int queues_length_history (void)
 Returns the current amount of notifications, which are already in history.
 
int queues_notification_insert (struct notification *n)
 Insert a fully initialized notification into queues.
 
bool queues_notification_replace_id (struct notification *new)
 Replace the notification which matches the id field of the new notification.
 
void queues_notification_close_id (gint id, enum reason reason)
 Close the notification that has n->id == id.
 
void queues_notification_close (struct notification *n, enum reason reason)
 Close the given notification.
 
void queues_notification_remove (struct notification *n, enum reason reason)
 Remove the given notification from all queues.
 
void queues_notification_remove_id (gint id, enum reason reason)
 Remove the notification that has n->id == id.
 
guint queues_history_clear (void)
 Removes all notifications from history Returns the number of removed notifications.
 
void queues_history_pop (void)
 Pushes the latest notification of history to the displayed queue and removes it from history.
 
void queues_history_pop_by_id (gint id)
 Pushes the latest notification found in the history buffer identified by it's assigned id.
 
void queues_history_push (struct notification *n)
 Push a single notification to history The given notification has to be removed its queue.
 
void queues_history_push_all (void)
 Push all waiting and displayed notifications to history.
 
bool queues_history_remove_by_id (gint id)
 Removes an notification identified by the given id from the history.
 
void queues_update (struct dunst_status status, gint64 time)
 Move inserted notifications from waiting queue to displayed queue and show them.
 
gint64 queues_get_next_datachange (gint64 time)
 Calculate the distance to the next event, when an element in the queues changes.
 
struct notificationqueues_get_by_id (gint id)
 Get the notification which has the given id in the displayed and waiting queue or NULL if not found.
 
void queues_reapply_all_rules (void)
 Reapply all rules to the queue (used when reloading configs)
 
void queues_teardown (void)
 Remove all notifications from all list and free the notifications.
 

Detailed Description

Queues for history, waiting and displayed notifications.

License
BSD-3-Clause

Every method requires to have executed queues_init() at the start.

A read only representation of the queue with the current notifications can get acquired by calling queues_get_displayed().

When ending the program or resetting the queues, tear down the stack with queues_teardown(). (And reinit with queues_init() if needed.)

Definition in file queues.h.

Function Documentation

◆ queues_get_by_id()

struct notification * queues_get_by_id ( gint id)

Get the notification which has the given id in the displayed and waiting queue or NULL if not found.

Parameters
idthe id searched for.
Returns
the id notification or NULL

Definition at line 662 of file queues.c.

◆ queues_get_displayed()

GList * queues_get_displayed ( void )

Receive the current list of displayed notifications.

Returns
read only list of notifications

Definition at line 41 of file queues.c.

◆ queues_get_head_waiting()

struct notification * queues_get_head_waiting ( void )

Get the highest notification in line.

Returns
the first notification in waiting
Return values
NULLif waiting is empty

Definition at line 47 of file queues.c.

◆ queues_get_history()

GList * queues_get_history ( void )

Recieve the list of all notifications encountered.

Returns
read only list of notifications

Definition at line 73 of file queues.c.

◆ queues_get_next_datachange()

gint64 queues_get_next_datachange ( gint64 time)

Calculate the distance to the next event, when an element in the queues changes.

Parameters
timethe current time
Returns
the timestamp of the next event in the queue, which forces an update visible to the user. This may be:
  • notification hits timeout
  • notification's age second changes
  • notification's age threshold is hit

Definition at line 620 of file queues.c.

◆ queues_history_clear()

guint queues_history_clear ( void )

Removes all notifications from history Returns the number of removed notifications.

Definition at line 400 of file queues.c.

◆ queues_history_pop()

void queues_history_pop ( void )

Pushes the latest notification of history to the displayed queue and removes it from history.

Definition at line 409 of file queues.c.

◆ queues_history_pop_by_id()

void queues_history_pop_by_id ( gint id)

Pushes the latest notification found in the history buffer identified by it's assigned id.

Definition at line 421 of file queues.c.

◆ queues_history_push()

void queues_history_push ( struct notification * n)

Push a single notification to history The given notification has to be removed its queue.

Parameters
n(transfer full) The notification to push to history

Definition at line 449 of file queues.c.

◆ queues_history_push_all()

void queues_history_push_all ( void )

Push all waiting and displayed notifications to history.

Definition at line 465 of file queues.c.

◆ queues_history_remove_by_id()

bool queues_history_remove_by_id ( gint id)

Removes an notification identified by the given id from the history.

Definition at line 477 of file queues.c.

◆ queues_init()

void queues_init ( void )

Initialise necessary queues.

Precondition
Do not call consecutively to avoid memory leaks or assure to have queues_teardown() executed before

Definition at line 33 of file queues.c.

◆ queues_length_displayed()

unsigned int queues_length_displayed ( void )

Returns the current amount of notifications, which are shown in the UI.

Definition at line 61 of file queues.c.

◆ queues_length_history()

unsigned int queues_length_history ( void )

Returns the current amount of notifications, which are already in history.

Definition at line 67 of file queues.c.

◆ queues_length_waiting()

unsigned int queues_length_waiting ( void )

Returns the current amount of notifications, which are waiting to get displayed.

Definition at line 55 of file queues.c.

◆ queues_notification_close()

void queues_notification_close ( struct notification * n,
enum reason reason )

Close the given notification.

See also
queues_notification_close_id()
Parameters
n(transfer full) The notification to close
reasonThe reason to close

Definition at line 380 of file queues.c.

◆ queues_notification_close_id()

void queues_notification_close_id ( gint id,
enum reason reason )

Close the notification that has n->id == id.

Sends a signal and pushes the selected notification automatically to history.

Parameters
idThe id of the notification to close
reasonThe reason to close
Postcondition
Call wake_up() to synchronize the queues with the UI (which closes the notification on screen)

Definition at line 354 of file queues.c.

◆ queues_notification_insert()

int queues_notification_insert ( struct notification * n)

Insert a fully initialized notification into queues.

Respects stack_duplicates, and notification replacement

Parameters
nthe notification to insert
  • If n->id != 0, n replaces notification n with id n->id
  • If n->id == 0, n gets a new id assigned
Returns
The new value of n->id
Return values
0if the notification was dismissed and freed

Definition at line 169 of file queues.c.

◆ queues_notification_remove()

void queues_notification_remove ( struct notification * n,
enum reason reason )

Remove the given notification from all queues.

Sends a signal and removes the selected notification from all queues.

Parameters
n(transfer full) The notification to remove
reasonThe reason to remove

Definition at line 386 of file queues.c.

◆ queues_notification_remove_id()

void queues_notification_remove_id ( gint id,
enum reason reason )

Remove the notification that has n->id == id.

Sends a signal and removes the selected notification from all queues.

Parameters
idThe id of the notification to remove
reasonThe reason to remove
Postcondition
Call wake_up() to synchronize the queues with the UI (which closes the notification on screen)

◆ queues_notification_replace_id()

bool queues_notification_replace_id ( struct notification * new)

Replace the notification which matches the id field of the new notification.

The given notification is inserted right in the same position as the old notification.

Parameters
newreplacement for the old notification
Return values
trueif a matching notification has been found and is replaced
falseotherwise

Definition at line 328 of file queues.c.

◆ queues_reapply_all_rules()

void queues_reapply_all_rules ( void )

Reapply all rules to the queue (used when reloading configs)

Definition at line 679 of file queues.c.

◆ queues_teardown()

void queues_teardown ( void )

Remove all notifications from all list and free the notifications.

Precondition
At least one time queues_init() called

Definition at line 706 of file queues.c.

◆ queues_update()

void queues_update ( struct dunst_status status,
gint64 time )

Move inserted notifications from waiting queue to displayed queue and show them.

In displayed queue, the amount of elements is limited to the amount set via queues_displayed_limit()

Postcondition
Call wake_up() to synchronize the queues with the UI (which closes old and shows new notifications on screen)
Parameters
statusthe current status of dunst
timethe current time

Definition at line 501 of file queues.c.