Skip to content

Commit

Permalink
Reformat icon_position enum
Browse files Browse the repository at this point in the history
  • Loading branch information
bebehei committed Sep 16, 2018
1 parent 2a5fe93 commit c5d5528
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ static struct colored_layout *layout_init_shared(cairo_t *c, const struct notifi
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);
} else {
cl->icon = NULL;
Expand Down Expand Up @@ -515,10 +515,10 @@ static void render_content(cairo_t *c, struct colored_layout *cl, int width)
int 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,
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);
} else {
cairo_move_to(c, settings.h_padding, settings.padding);
Expand All @@ -535,9 +535,9 @@ static void render_content(cairo_t *c, struct colored_layout *cl, int width)
image_x,
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;
} else if (settings.icon_position == icons_right){
} else if (settings.icon_position == ICON_RIGHT){
image_x = width - settings.h_padding - image_width;
} else {
LOG_E("Tried to draw icon but icon position is not valid. %s:%d", __FILE__, __LINE__);
Expand Down
4 changes: 2 additions & 2 deletions src/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
//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))
return false;

return strcmp(a->appname, b->appname) == 0
&& strcmp(a->summary, b->summary) == 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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,11 @@ void load_settings(char *cmdline_config_path)

if (strlen(c) > 0) {
if (strcmp(c, "left") == 0)
settings.icon_position = icons_left;
settings.icon_position = ICON_LEFT;
else if (strcmp(c, "right") == 0)
settings.icon_position = icons_right;
settings.icon_position = ICON_RIGHT;
else if (strcmp(c, "off") == 0)
settings.icon_position = icons_off;
settings.icon_position = ICON_OFF;
else
LOG_W("Unknown icon position: '%s'", c);
g_free(c);
Expand Down
4 changes: 2 additions & 2 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

enum alignment { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT };
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 follow_mode { FOLLOW_NONE, FOLLOW_MOUSE, FOLLOW_KEYBOARD };
enum markup_mode { MARKUP_NULL, MARKUP_NO, MARKUP_STRIP, MARKUP_FULL };
Expand Down Expand Up @@ -75,7 +75,7 @@ struct settings {
char *dmenu;
char **dmenu_cmd;
char *browser;
enum icon_position_t icon_position;
enum icon_position icon_position;
int max_icon_size;
char *icon_path;
enum follow_mode f_mode;
Expand Down
8 changes: 4 additions & 4 deletions test/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ TEST test_notification_is_duplicate(void *notifications)
ASSERT(notification_is_duplicate(a, b));

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";

settings.icon_position = icons_off;
settings.icon_position = ICON_OFF;
ASSERT(notification_is_duplicate(a, b));
//Setting pointer to a random value since we are checking for null
b->raw_icon = (struct raw_image*)0xff;
ASSERT(notification_is_duplicate(a, b));
b->raw_icon = NULL;

settings.icon_position = icons_left;
settings.icon_position = ICON_LEFT;
ASSERT_FALSE(notification_is_duplicate(a, b));
b->raw_icon = (struct raw_image*)0xff;
ASSERT_FALSE(notification_is_duplicate(a, b));
b->raw_icon = NULL;

settings.icon_position = icons_right;
settings.icon_position = ICON_RIGHT;
ASSERT_FALSE(notification_is_duplicate(a, b));
b->raw_icon = (struct raw_image*)0xff;
ASSERT_FALSE(notification_is_duplicate(a, b));
Expand Down

0 comments on commit c5d5528

Please sign in to comment.