Dunst
Lightweight notification daemon
Loading...
Searching...
No Matches
notification.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause */
10
11#ifndef DUNST_NOTIFICATION_H
12#define DUNST_NOTIFICATION_H
13
14#include <glib.h>
15#include <stdbool.h>
16#include <pango/pango-layout.h>
17#include <cairo.h>
18
19#include "markup.h"
20#include "draw.h"
21
22#define DUNST_NOTIF_MAX_CHARS 50000
23
24enum icon_position {
25 ICON_LEFT,
26 ICON_RIGHT,
27 ICON_TOP,
28 ICON_OFF
29};
30
37
39enum urgency {
40 URG_NONE = -1,
41 URG_MIN = 0,
42 URG_LOW = 0,
45 URG_MAX = 2,
46};
47
48typedef struct _notification_private NotificationPrivate;
49
51 struct color frame;
52 struct color bg;
53 struct color fg;
54 struct gradient *highlight;
55};
56
58 NotificationPrivate *priv;
59 gint id;
60 char *dbus_client;
61 bool dbus_valid;
62
63 // We keep the original notification properties here when it is modified
64 struct rule *original;
65
66 char *appname;
67 char *summary;
68 char *body;
69 char *category;
71 enum urgency urgency;
72 int override_pause_level;
73
74 cairo_surface_t *icon;
75 char *icon_id;
77 gint64 icon_time;
78 char *iconname;
80 char *icon_path;
86
87 gint64 start;
88 gint64 timestamp;
89 gint64 timeout;
90 gint64 dbus_timeout;
91 int locked;
92 PangoAlignment progress_bar_alignment;
93
94 GHashTable *actions;
96
97 enum markup_mode markup;
98 char *format;
99 char **scripts;
100 int script_count;
101 struct notification_colors colors;
102
103 char *stack_tag;
104
105 /* Hints */
110
111 /* internal */
115 int displayed_height;
118 guint8 marked_for_closure;
120 bool word_wrap;
121 PangoEllipsizeMode ellipsize;
122 PangoAlignment alignment;
123 bool hide_text;
124
125 /* derived fields */
126 char *msg;
128 char *urls;
129};
130
142
147
151void notification_ref(struct notification *n);
152
159void notification_init(struct notification *n);
160
166void notification_unref(struct notification *n);
167
171int notification_cmp(const struct notification *a, const struct notification *b);
172
177int notification_cmp_data(const void *va, const void *vb, void *data);
178
179bool notification_is_duplicate(const struct notification *a, const struct notification *b);
180
181bool notification_is_locked(struct notification *n);
182
183struct notification *notification_lock(struct notification *n);
184
185struct notification *notification_unlock(struct notification *n);
186
195void notification_transfer_icon(struct notification *from, struct notification *to);
196
205void notification_icon_replace_path(struct notification *n, const char *new_icon);
206
214void notification_icon_replace_data(struct notification *n, GVariant *new_icon);
215
216void notification_replace_format(struct notification *n, const char *format);
217
230void notification_print(const struct notification *n);
231
239void notification_replace_single_field(char **haystack,
240 char **needle,
241 const char *replacement,
242 enum markup_mode markup_mode);
243
244void notification_update_text_to_render(struct notification *n);
245
252
257void notification_open_url(struct notification *n);
258
265
274
275const char *notification_urgency_to_string(const enum urgency urgency);
276
284
285void notification_keep_original(struct notification *n);
286
287#endif
Layout and render notifications.
Markup handling for notifications body.
void notification_do_action(struct notification *n)
If the notification has an action named n->default_action_name or there is only one action and n->def...
void notification_ref(struct notification *n)
Increase the reference counter of the notification.
int notification_cmp_data(const void *va, const void *vb, void *data)
Wrapper for notification_cmp to match glib's compare functions signature.
int notification_cmp(const struct notification *a, const struct notification *b)
Helper function to compare two given notifications.
void notification_invalidate_actions(struct notification *n)
Remove all client action data from the notification.
void notification_open_url(struct notification *n)
If the notification has exactly one url, invoke it.
urgency
Representing the urgencies according to the notification spec.
@ URG_NONE
Urgency not set (invalid)
@ URG_NORM
Normal urgency.
@ URG_MIN
Minimum value, useful for boundary checking.
@ URG_CRIT
Critical urgency.
@ URG_LOW
Low urgency.
@ URG_MAX
Maximum value, useful for boundary checking.
void notification_run_script(struct notification *n)
Run the script associated with the given notification.
gint notification_refcount_get(struct notification *n)
Retrieve the current reference count of the notification.
void notification_icon_replace_path(struct notification *n, const char *new_icon)
Replace the current notification's icon with the icon specified by path.
void notification_init(struct notification *n)
Sanitize values of notification, apply all matching rules and generate derived fields.
void notification_transfer_icon(struct notification *from, struct notification *to)
Transfer the image surface of from to to.
void notification_open_context_menu(struct notification *n)
Open the context menu for the notification.
void notification_replace_single_field(char **haystack, char **needle, const char *replacement, enum markup_mode markup_mode)
Replace the two chars where **needle points with a quoted "replacement", according to the markup sett...
void notification_print(const struct notification *n)
print a human readable representation of the given notification to stdout.
void notification_unref(struct notification *n)
Decrease the reference counter of the notification.
const char * enum_to_string_fullscreen(enum behavior_fullscreen in)
Return the string representation for fullscreen behavior.
struct notification * notification_create(void)
Create notification struct and initialise all fields with either.
behavior_fullscreen
@ FS_SHOW
Show the message when in fullscreen mode.
@ FS_PUSHBACK
When entering fullscreen mode, push the notification back to waiting.
@ FS_DELAY
Delay the notification until leaving fullscreen mode.
@ FS_NULL
Invalid value.
void notification_icon_replace_data(struct notification *n, GVariant *new_icon)
Replace the current notification's icon with the raw icon given in the GVariant.
Definition draw.h:48
char * stack_tag
stack notifications by tag
char * icon_path
Full path to the notification's icon.
bool receiving_raw_icon
Still waiting for raw icon to be received.
PangoAlignment progress_bar_alignment
Horizontal alignment of the progress bar.
int min_icon_size
Minimum icon size.
bool script_run
Has the script been executed already?
char * desktop_entry
The desktop entry hint sent via every GApplication.
enum icon_position icon_position
Icon position (enum left,right,top,off).
char * msg
formatted message
int locked
If non-zero the notification is locked.
char * iconname
plain icon information (may be a path or just a name) as recieved from dbus.
int skip_display
insert notification into history, skipping initial waiting and display
int progress
percentage (-1: undefined)
gint64 icon_time
Time of reception of the icon (or opening of the file in case of a path)
int max_icon_size
Maximum icon size.
int history_ignore
push to history or free directly
cairo_surface_t * icon
The raw cached icon data used to draw.
guint8 marked_for_removal
If set, the notification is marked for removal in history.
gint64 timestamp
arrival time (in milliseconds)
char * text_to_render
formatted message (with age and action indicators)
char * urls
urllist delimited by '\n'
bool first_render
markup has been rendered before?
char * icon_id
Plain icon information, which acts as the icon's id.
enum behavior_fullscreen fullscreen
The instruction what to do with it, when desktop enters fullscreen.
bool redisplayed
has been displayed before?
gint64 start
begin of current display (in milliseconds)
bool transient
timeout albeit user is idle
char * default_icon_name
The icon that is used when no other icon is available.
char * default_action_name
The name of the action to be invoked on do_action.
gint64 timeout
time to display (in milliseconds)
gint64 dbus_timeout
time to display (in milliseconds) (set by dbus)
int dup_count
amount of duplicate notifications stacked onto this
Definition rules.h:20