markup
This commit is contained in:
parent
bcc0c6621f
commit
0d8be7dccf
@ -1,6 +1,7 @@
|
||||
/* see example dunstrc for additional explanations about these options */
|
||||
|
||||
char *font = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*";
|
||||
bool allow_markup = false;
|
||||
char *normbgcolor = "#1793D1";
|
||||
char *normfgcolor = "#DDDDDD";
|
||||
char *critbgcolor = "#ffaaaa";
|
||||
|
11
dunstrc
11
dunstrc
@ -1,6 +1,16 @@
|
||||
[global]
|
||||
font = Monospace-10
|
||||
|
||||
# allow a small subset of html markup:
|
||||
# <b>bold</b>
|
||||
# <i>italic</i>
|
||||
# <s>strikethrough<s/>
|
||||
# <u>underline</u>
|
||||
#
|
||||
# for a complete reference see http://developer.gnome.org/pango/stable/PangoMarkupFormat.html
|
||||
# If markup is not allowed, those tags will be stripped out of the message.
|
||||
allow_markup = yes
|
||||
|
||||
# The format of the message. Possible variables are:
|
||||
# %a appname
|
||||
# %s summary
|
||||
@ -8,6 +18,7 @@
|
||||
# %i iconname (including its path)
|
||||
# %I iconname (without its path)
|
||||
# %p progress value if set ([ 0%] to [100%]) or nothing
|
||||
# Markup is allowed
|
||||
format = "%s\n%b"
|
||||
|
||||
# Sort messages by urgency
|
||||
|
@ -251,6 +251,7 @@ int notification_init(notification * n, int id)
|
||||
n->msg = string_replace("%p", "", n->msg);
|
||||
}
|
||||
|
||||
if (!settings.allow_markup)
|
||||
n->msg = notification_fix_markup(n->msg);
|
||||
|
||||
while (strstr(n->msg, "\\n") != NULL)
|
||||
|
@ -59,6 +59,9 @@ void load_settings(char *cmdline_config_path)
|
||||
settings.font =
|
||||
option_get_string("global", "font", "-fn", font,
|
||||
"The font dunst should use.");
|
||||
settings.allow_markup =
|
||||
option_get_bool("global", "allow_markup", "-markup", allow_markup,
|
||||
"Allow markups.");
|
||||
settings.format =
|
||||
option_get_string("global", "format", "-format", format,
|
||||
"The format template for the notifictions");
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
typedef struct _settings {
|
||||
bool print_notifications;
|
||||
bool allow_markup;
|
||||
char *font;
|
||||
char *normbgcolor;
|
||||
char *normfgcolor;
|
||||
|
14
x.c
14
x.c
@ -37,6 +37,8 @@ typedef struct _colored_layout {
|
||||
PangoLayout *l;
|
||||
color_t fg;
|
||||
color_t bg;
|
||||
char *text;
|
||||
PangoAttrList *attr;
|
||||
} colored_layout;
|
||||
|
||||
cairo_ctx_t cairo_ctx;
|
||||
@ -161,6 +163,7 @@ static void free_colored_layout(void *data)
|
||||
{
|
||||
colored_layout *cl = data;
|
||||
g_object_unref(cl->l);
|
||||
g_free(cl->text);
|
||||
}
|
||||
|
||||
colored_layout *r_create_layout_from_notification(cairo_t *c, notification *n)
|
||||
@ -180,7 +183,18 @@ colored_layout *r_create_layout_from_notification(cairo_t *c, notification *n)
|
||||
}
|
||||
r_setup_pango_layout(cl->l, width);
|
||||
|
||||
/* markup */
|
||||
bool success = pango_parse_markup(n->text_to_render, -1, 0, &(cl->attr), &(cl->text), NULL, NULL);
|
||||
|
||||
if (success) {
|
||||
pango_layout_set_text(cl->l, cl->text, -1);
|
||||
pango_layout_set_attributes(cl->l, cl->attr);
|
||||
} else {
|
||||
cl->text = NULL;
|
||||
cl->attr = NULL;
|
||||
pango_layout_set_text(cl->l, n->text_to_render, -1);
|
||||
printf("Error parsing markup\n");
|
||||
}
|
||||
|
||||
pango_layout_get_pixel_size(cl->l, NULL, &(n->displayed_height));
|
||||
n->displayed_height += 2 * settings.padding;
|
||||
|
Loading…
x
Reference in New Issue
Block a user