diff --git a/src/bar.c b/src/bar.c index 25376eb..b2e7cc0 100644 --- a/src/bar.c +++ b/src/bar.c @@ -285,7 +285,6 @@ void bar_refresh(struct bar *bar) if (has_batt) { char batt[255]; snprintf(batt, sizeof(batt), "%' '3d%%", percent); - struct bar_line batt_line = bar_prepare_line(g_bar_manager.t_font, batt, g_bar_manager.foreground_color); CGPoint p_pos = bar_align_line(bar, batt_line, ALIGN_RIGHT, ALIGN_CENTER); p_pos.x = time_line_pos - 40; diff --git a/src/bar_manager.c b/src/bar_manager.c index 1b70b52..4e73010 100644 --- a/src/bar_manager.c +++ b/src/bar_manager.c @@ -28,66 +28,35 @@ void bar_manager_set_text_font(struct bar_manager *bar_manager, char *font_strin CFRelease(bar_manager->t_font); } - if (bar_manager->space_underline.line) { - bar_destroy_line(bar_manager->space_underline); - } - - if (bar_manager->power_underline.line) { - bar_destroy_line(bar_manager->power_underline); - } - - if (bar_manager->clock_underline.line) { - bar_destroy_line(bar_manager->clock_underline); - } - if (font_string != bar_manager->t_font_prop) { - if (bar_manager->t_font_prop) { - free(bar_manager->t_font_prop); - } + if (bar_manager->t_font_prop) { + free(bar_manager->t_font_prop); + } - bar_manager->t_font_prop = font_string; + bar_manager->t_font_prop = font_string; } bar_manager->t_font = bar_create_font(bar_manager->t_font_prop); - bar_manager->space_underline = bar_prepare_line(bar_manager->t_font, "______", rgba_color_from_hex(0xffd4d232)); - bar_manager->power_underline = bar_prepare_line(bar_manager->t_font, "__________", rgba_color_from_hex(0xffd75f5f)); - - time_t rawtime; - time(&rawtime); - struct tm *timeinfo = localtime(&rawtime); - if (timeinfo) { - char time[255]; - strftime(time, sizeof(time), g_bar_manager._clock_format, timeinfo); - char underline[255] = {0}; - - for (int i = 0; i < strlen(time) + 4; ++i) - underline[i] = '_'; - - bar_manager->clock_underline = bar_prepare_line(bar_manager->t_font, underline, rgba_color_from_hex(0xff458588)); - } - else - bar_manager->clock_underline = bar_prepare_line(bar_manager->t_font, "__________", rgba_color_from_hex(0xff458588)); - bar_manager_refresh(bar_manager); } void bar_manager_set_icon_font(struct bar_manager *bar_manager, char *font_string) { - if (bar_manager->i_font) { - CFRelease(bar_manager->i_font); + if (bar_manager->i_font) { + CFRelease(bar_manager->i_font); + } + + if (font_string != bar_manager->i_font_prop) { + if (bar_manager->i_font_prop) { + free(bar_manager->i_font_prop); } - if (font_string != bar_manager->i_font_prop) { - if (bar_manager->i_font_prop) { - free(bar_manager->i_font_prop); - } + bar_manager->i_font_prop = font_string; + } - bar_manager->i_font_prop = font_string; - } - - bar_manager->i_font = bar_create_font(bar_manager->i_font_prop); - if (bar_manager->_space_icon_strip) bar_manager_set_space_strip(bar_manager, bar_manager->_space_icon_strip); - if (bar_manager->_power_icon_strip) bar_manager_set_power_strip(bar_manager, bar_manager->_power_icon_strip); + bar_manager->i_font = bar_create_font(bar_manager->i_font_prop); + if (bar_manager->_space_icon_strip) bar_manager_set_space_strip(bar_manager, bar_manager->_space_icon_strip); + if (bar_manager->_power_icon_strip) bar_manager_set_power_strip(bar_manager, bar_manager->_power_icon_strip); if (bar_manager->_clock_icon) bar_manager_set_clock_icon(bar_manager, bar_manager->_clock_icon); if (bar_manager->_space_icon) bar_manager_set_space_icon(bar_manager, bar_manager->_space_icon); bar_manager_refresh(bar_manager); diff --git a/src/bar_manager.h b/src/bar_manager.h index 0d9b4f8..62048fb 100644 --- a/src/bar_manager.h +++ b/src/bar_manager.h @@ -23,9 +23,6 @@ struct bar_manager struct bar_line clock_icon; struct bar_line battr_icon; struct bar_line power_icon; - struct bar_line space_underline; - struct bar_line power_underline; - struct bar_line clock_underline; }; void bar_manager_set_foreground_color(struct bar_manager *bar_manager, uint32_t color);