Merge pull request #810 from GuessWhatBBQ/master

Adding a config variable that adds extra space between the notification icon and text
This commit is contained in:
fwSmit 2021-01-27 11:12:13 +01:00 committed by GitHub
commit 22d108f53e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 8 deletions

View File

@ -54,6 +54,7 @@ struct settings defaults = {
.separator_height = 2, /* height of the separator line between two notifications */ .separator_height = 2, /* height of the separator line between two notifications */
.padding = 0, .padding = 0,
.h_padding = 0, /* horizontal padding */ .h_padding = 0, /* horizontal padding */
.text_icon_padding = 0, /* padding between icon and text*/
.sep_color = {SEP_AUTO}, /* SEP_AUTO, SEP_FOREGROUND, SEP_FRAME, SEP_CUSTOM */ .sep_color = {SEP_AUTO}, /* SEP_AUTO, SEP_FOREGROUND, SEP_FRAME, SEP_CUSTOM */
.frame_width = 0, .frame_width = 0,

View File

@ -219,6 +219,23 @@ in the vertical axis
The distance in pixels from the content to the border of the window The distance in pixels from the content to the border of the window
in the horizontal axis in the horizontal axis
=item B<text_icon_padding> (default: 0)
The distance in pixels from the text to the icon (or vice versa)
in the horizontal axis.
Setting this to a non-zero value overwrites any padding that horizontal_padding was adding between the notification text and icon.
So for example setting
text_icon_padding=10
horizontal_padding=10
is equivalent to
text_icon_padding=0
horizontal_padding=10
=item B<frame_width> (default: 0) =item B<frame_width> (default: 0)
Defines width in pixels of frame around the notification window. Set to 0 to Defines width in pixels of frame around the notification window. Set to 0 to

View File

@ -76,6 +76,9 @@
# Horizontal padding. # Horizontal padding.
horizontal_padding = 8 horizontal_padding = 8
# Padding between text and icon.
text_icon_padding = 0
# Defines width in pixels of frame around the notification window. # Defines width in pixels of frame around the notification window.
# Set to 0 to disable. # Set to 0 to disable.
frame_width = 3 frame_width = 3

View File

@ -179,6 +179,15 @@ static bool have_dynamic_width(void)
return (settings.geometry.width_set && settings.geometry.w == 0); return (settings.geometry.width_set && settings.geometry.w == 0);
} }
static int get_text_icon_padding()
{
if (settings.text_icon_padding) {
return settings.text_icon_padding;
} else {
return settings.h_padding;
}
}
static bool have_progress_bar(const struct notification *n) static bool have_progress_bar(const struct notification *n)
{ {
return (n->progress >= 0 && settings.progress_bar == true); return (n->progress >= 0 && settings.progress_bar == true);
@ -241,7 +250,9 @@ static struct dimensions calculate_dimensions(GSList *layouts)
w = dim.w; w = dim.w;
w -= 2 * settings.h_padding; w -= 2 * settings.h_padding;
w -= 2 * settings.frame_width; w -= 2 * settings.frame_width;
if (cl->icon) w -= cairo_image_surface_get_width(cl->icon) + settings.h_padding; if (cl->icon) {
w -= cairo_image_surface_get_width(cl->icon) + get_text_icon_padding();
}
layout_setup_pango(cl->l, w); layout_setup_pango(cl->l, w);
/* re-read information */ /* re-read information */
@ -335,7 +346,9 @@ static struct colored_layout *layout_init_shared(cairo_t *c, const struct notifi
} else { } else {
width -= 2 * settings.h_padding; width -= 2 * settings.h_padding;
width -= 2 * settings.frame_width; width -= 2 * settings.frame_width;
if (cl->icon) width -= cairo_image_surface_get_width(cl->icon) + settings.h_padding; if (cl->icon) {
width -= cairo_image_surface_get_width(cl->icon) + get_text_icon_padding();
}
layout_setup_pango(cl->l, width); layout_setup_pango(cl->l, width);
} }
@ -621,7 +634,7 @@ static void render_content(cairo_t *c, struct colored_layout *cl, int width)
// icon position // icon position
if (settings.icon_position == ICON_LEFT) { if (settings.icon_position == ICON_LEFT) {
text_x = cairo_image_surface_get_width(cl->icon) + 2 * settings.h_padding; text_x = cairo_image_surface_get_width(cl->icon) + settings.h_padding + get_text_icon_padding();
} // else ICON_RIGHT } // else ICON_RIGHT
} }
cairo_move_to(c, text_x, text_y); cairo_move_to(c, text_x, text_y);

View File

@ -370,6 +370,12 @@ void load_settings(char *cmdline_config_path)
"horizontal padding" "horizontal padding"
); );
settings.text_icon_padding = option_get_int(
"global",
"text_icon_padding", "-text_icon_padding", defaults.text_icon_padding,
"Padding between text and icon"
);
settings.transparency = option_get_int( settings.transparency = option_get_int(
"global", "global",
"transparency", "-transparency", defaults.transparency, "transparency", "-transparency", defaults.transparency,

View File

@ -81,6 +81,7 @@ struct settings {
int separator_height; int separator_height;
int padding; int padding;
int h_padding; int h_padding;
int text_icon_padding;
struct separator_color_data sep_color; struct separator_color_data sep_color;
int frame_width; int frame_width;
char *frame_color; char *frame_color;