Reformat icon_position enum
This commit is contained in:
parent
2a5fe938f6
commit
c5d552856f
10
src/draw.c
10
src/draw.c
@ -270,7 +270,7 @@ static struct colored_layout *layout_init_shared(cairo_t *c, const struct notifi
|
|||||||
pango_layout_set_ellipsize(cl->l, ellipsize);
|
pango_layout_set_ellipsize(cl->l, ellipsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.icon_position != icons_off) {
|
if (settings.icon_position != ICON_OFF) {
|
||||||
cl->icon = icon_get_for_notification(n);
|
cl->icon = icon_get_for_notification(n);
|
||||||
} else {
|
} else {
|
||||||
cl->icon = NULL;
|
cl->icon = NULL;
|
||||||
@ -515,10 +515,10 @@ static void render_content(cairo_t *c, struct colored_layout *cl, int width)
|
|||||||
int h_text;
|
int h_text;
|
||||||
pango_layout_get_pixel_size(cl->l, NULL, &h_text);
|
pango_layout_get_pixel_size(cl->l, NULL, &h_text);
|
||||||
|
|
||||||
if (cl->icon && settings.icon_position == icons_left) {
|
if (cl->icon && settings.icon_position == ICON_LEFT) {
|
||||||
cairo_move_to(c, cairo_image_surface_get_width(cl->icon) + 2 * settings.h_padding,
|
cairo_move_to(c, cairo_image_surface_get_width(cl->icon) + 2 * settings.h_padding,
|
||||||
settings.padding + h/2 - h_text/2);
|
settings.padding + h/2 - h_text/2);
|
||||||
} else if (cl->icon && settings.icon_position == icons_right) {
|
} else if (cl->icon && settings.icon_position == ICON_RIGHT) {
|
||||||
cairo_move_to(c, settings.h_padding, settings.padding + h/2 - h_text/2);
|
cairo_move_to(c, settings.h_padding, settings.padding + h/2 - h_text/2);
|
||||||
} else {
|
} else {
|
||||||
cairo_move_to(c, settings.h_padding, settings.padding);
|
cairo_move_to(c, settings.h_padding, settings.padding);
|
||||||
@ -535,9 +535,9 @@ static void render_content(cairo_t *c, struct colored_layout *cl, int width)
|
|||||||
image_x,
|
image_x,
|
||||||
image_y = settings.padding + h/2 - image_height/2;
|
image_y = settings.padding + h/2 - image_height/2;
|
||||||
|
|
||||||
if (settings.icon_position == icons_left) {
|
if (settings.icon_position == ICON_LEFT) {
|
||||||
image_x = settings.h_padding;
|
image_x = settings.h_padding;
|
||||||
} else if (settings.icon_position == icons_right){
|
} else if (settings.icon_position == ICON_RIGHT){
|
||||||
image_x = width - settings.h_padding - image_width;
|
image_x = width - settings.h_padding - image_width;
|
||||||
} else {
|
} else {
|
||||||
LOG_E("Tried to draw icon but icon position is not valid. %s:%d", __FILE__, __LINE__);
|
LOG_E("Tried to draw icon but icon position is not valid. %s:%d", __FILE__, __LINE__);
|
||||||
|
@ -174,14 +174,14 @@ int notification_cmp_data(const void *va, const void *vb, void *data)
|
|||||||
int notification_is_duplicate(const struct notification *a, const struct notification *b)
|
int notification_is_duplicate(const struct notification *a, const struct notification *b)
|
||||||
{
|
{
|
||||||
//Comparing raw icons is not supported, assume they are not identical
|
//Comparing raw icons is not supported, assume they are not identical
|
||||||
if (settings.icon_position != icons_off
|
if (settings.icon_position != ICON_OFF
|
||||||
&& (a->raw_icon || b->raw_icon))
|
&& (a->raw_icon || b->raw_icon))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return strcmp(a->appname, b->appname) == 0
|
return strcmp(a->appname, b->appname) == 0
|
||||||
&& strcmp(a->summary, b->summary) == 0
|
&& strcmp(a->summary, b->summary) == 0
|
||||||
&& strcmp(a->body, b->body) == 0
|
&& strcmp(a->body, b->body) == 0
|
||||||
&& (settings.icon_position != icons_off ? strcmp(a->icon, b->icon) == 0 : 1)
|
&& (settings.icon_position != ICON_OFF ? strcmp(a->icon, b->icon) == 0 : 1)
|
||||||
&& a->urgency == b->urgency;
|
&& a->urgency == b->urgency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,11 +457,11 @@ void load_settings(char *cmdline_config_path)
|
|||||||
|
|
||||||
if (strlen(c) > 0) {
|
if (strlen(c) > 0) {
|
||||||
if (strcmp(c, "left") == 0)
|
if (strcmp(c, "left") == 0)
|
||||||
settings.icon_position = icons_left;
|
settings.icon_position = ICON_LEFT;
|
||||||
else if (strcmp(c, "right") == 0)
|
else if (strcmp(c, "right") == 0)
|
||||||
settings.icon_position = icons_right;
|
settings.icon_position = ICON_RIGHT;
|
||||||
else if (strcmp(c, "off") == 0)
|
else if (strcmp(c, "off") == 0)
|
||||||
settings.icon_position = icons_off;
|
settings.icon_position = ICON_OFF;
|
||||||
else
|
else
|
||||||
LOG_W("Unknown icon position: '%s'", c);
|
LOG_W("Unknown icon position: '%s'", c);
|
||||||
g_free(c);
|
g_free(c);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
enum alignment { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT };
|
enum alignment { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT };
|
||||||
enum ellipsize { start, middle, end };
|
enum ellipsize { start, middle, end };
|
||||||
enum icon_position_t { icons_left, icons_right, icons_off };
|
enum icon_position { ICON_LEFT, ICON_RIGHT, ICON_OFF };
|
||||||
enum separator_color { SEP_FOREGROUND, SEP_AUTO, SEP_FRAME, SEP_CUSTOM };
|
enum separator_color { SEP_FOREGROUND, SEP_AUTO, SEP_FRAME, SEP_CUSTOM };
|
||||||
enum follow_mode { FOLLOW_NONE, FOLLOW_MOUSE, FOLLOW_KEYBOARD };
|
enum follow_mode { FOLLOW_NONE, FOLLOW_MOUSE, FOLLOW_KEYBOARD };
|
||||||
enum markup_mode { MARKUP_NULL, MARKUP_NO, MARKUP_STRIP, MARKUP_FULL };
|
enum markup_mode { MARKUP_NULL, MARKUP_NO, MARKUP_STRIP, MARKUP_FULL };
|
||||||
@ -75,7 +75,7 @@ struct settings {
|
|||||||
char *dmenu;
|
char *dmenu;
|
||||||
char **dmenu_cmd;
|
char **dmenu_cmd;
|
||||||
char *browser;
|
char *browser;
|
||||||
enum icon_position_t icon_position;
|
enum icon_position icon_position;
|
||||||
int max_icon_size;
|
int max_icon_size;
|
||||||
char *icon_path;
|
char *icon_path;
|
||||||
enum follow_mode f_mode;
|
enum follow_mode f_mode;
|
||||||
|
@ -33,24 +33,24 @@ TEST test_notification_is_duplicate(void *notifications)
|
|||||||
ASSERT(notification_is_duplicate(a, b));
|
ASSERT(notification_is_duplicate(a, b));
|
||||||
|
|
||||||
char *tmp = b->icon;
|
char *tmp = b->icon;
|
||||||
enum icon_position_t icon_setting_tmp = settings.icon_position;
|
enum icon_position icon_setting_tmp = settings.icon_position;
|
||||||
|
|
||||||
b->icon = "Test1";
|
b->icon = "Test1";
|
||||||
|
|
||||||
settings.icon_position = icons_off;
|
settings.icon_position = ICON_OFF;
|
||||||
ASSERT(notification_is_duplicate(a, b));
|
ASSERT(notification_is_duplicate(a, b));
|
||||||
//Setting pointer to a random value since we are checking for null
|
//Setting pointer to a random value since we are checking for null
|
||||||
b->raw_icon = (struct raw_image*)0xff;
|
b->raw_icon = (struct raw_image*)0xff;
|
||||||
ASSERT(notification_is_duplicate(a, b));
|
ASSERT(notification_is_duplicate(a, b));
|
||||||
b->raw_icon = NULL;
|
b->raw_icon = NULL;
|
||||||
|
|
||||||
settings.icon_position = icons_left;
|
settings.icon_position = ICON_LEFT;
|
||||||
ASSERT_FALSE(notification_is_duplicate(a, b));
|
ASSERT_FALSE(notification_is_duplicate(a, b));
|
||||||
b->raw_icon = (struct raw_image*)0xff;
|
b->raw_icon = (struct raw_image*)0xff;
|
||||||
ASSERT_FALSE(notification_is_duplicate(a, b));
|
ASSERT_FALSE(notification_is_duplicate(a, b));
|
||||||
b->raw_icon = NULL;
|
b->raw_icon = NULL;
|
||||||
|
|
||||||
settings.icon_position = icons_right;
|
settings.icon_position = ICON_RIGHT;
|
||||||
ASSERT_FALSE(notification_is_duplicate(a, b));
|
ASSERT_FALSE(notification_is_duplicate(a, b));
|
||||||
b->raw_icon = (struct raw_image*)0xff;
|
b->raw_icon = (struct raw_image*)0xff;
|
||||||
ASSERT_FALSE(notification_is_duplicate(a, b));
|
ASSERT_FALSE(notification_is_duplicate(a, b));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user