diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-04-17 11:35:22 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-04-17 11:36:03 -0400 |
commit | 84fae94ab9ca7fd148c786d224c49205a212882e (patch) | |
tree | d3d3e8a16f96e400ee07cc44e2f9110195bea02a /swaybar | |
parent | Merge pull request #590 from mikkeloscar/i686-warnings (diff) | |
download | sway-84fae94ab9ca7fd148c786d224c49205a212882e.tar.gz sway-84fae94ab9ca7fd148c786d224c49205a212882e.tar.zst sway-84fae94ab9ca7fd148c786d224c49205a212882e.zip |
Flesh out pango markup implementation
Diffstat (limited to 'swaybar')
-rw-r--r-- | swaybar/render.c | 13 | ||||
-rw-r--r-- | swaybar/status_line.c | 7 |
2 files changed, 13 insertions, 7 deletions
diff --git a/swaybar/render.c b/swaybar/render.c index fff47ab0..3eb824fe 100644 --- a/swaybar/render.c +++ b/swaybar/render.c | |||
@@ -136,7 +136,7 @@ static void render_block(struct window *window, struct config *config, struct st | |||
136 | 136 | ||
137 | cairo_move_to(window->cairo, offset, margin); | 137 | cairo_move_to(window->cairo, offset, margin); |
138 | cairo_set_source_u32(window->cairo, block->color); | 138 | cairo_set_source_u32(window->cairo, block->color); |
139 | pango_printf(window->cairo, window->font, "%s", block->full_text); | 139 | pango_printf(window->cairo, window->font, block->markup, "%s", block->full_text); |
140 | 140 | ||
141 | pos += width; | 141 | pos += width; |
142 | 142 | ||
@@ -159,7 +159,7 @@ static void render_block(struct window *window, struct config *config, struct st | |||
159 | if (config->sep_symbol) { | 159 | if (config->sep_symbol) { |
160 | offset = pos + (block->separator_block_width - sep_width) / 2; | 160 | offset = pos + (block->separator_block_width - sep_width) / 2; |
161 | cairo_move_to(window->cairo, offset, margin); | 161 | cairo_move_to(window->cairo, offset, margin); |
162 | pango_printf(window->cairo, window->font, "%s", config->sep_symbol); | 162 | pango_printf(window->cairo, window->font, false, "%s", config->sep_symbol); |
163 | } else { | 163 | } else { |
164 | cairo_set_line_width(window->cairo, 1); | 164 | cairo_set_line_width(window->cairo, 1); |
165 | cairo_move_to(window->cairo, pos + block->separator_block_width/2, | 165 | cairo_move_to(window->cairo, pos + block->separator_block_width/2, |
@@ -228,7 +228,7 @@ static void render_workspace_button(struct window *window, struct config *config | |||
228 | // text | 228 | // text |
229 | cairo_set_source_u32(window->cairo, box_colors.text); | 229 | cairo_set_source_u32(window->cairo, box_colors.text); |
230 | cairo_move_to(window->cairo, (int)*x + ws_horizontal_padding, margin); | 230 | cairo_move_to(window->cairo, (int)*x + ws_horizontal_padding, margin); |
231 | pango_printf(window->cairo, window->font, "%s", name); | 231 | pango_printf(window->cairo, window->font, false, "%s", name); |
232 | 232 | ||
233 | *x += width + ws_horizontal_padding * 2 + ws_spacing; | 233 | *x += width + ws_horizontal_padding * 2 + ws_spacing; |
234 | 234 | ||
@@ -254,7 +254,7 @@ static void render_binding_mode_indicator(struct window *window, struct config * | |||
254 | // text | 254 | // text |
255 | cairo_set_source_u32(window->cairo, config->colors.binding_mode.text); | 255 | cairo_set_source_u32(window->cairo, config->colors.binding_mode.text); |
256 | cairo_move_to(window->cairo, (int)pos + ws_horizontal_padding, margin); | 256 | cairo_move_to(window->cairo, (int)pos + ws_horizontal_padding, margin); |
257 | pango_printf(window->cairo, window->font, "%s", config->mode); | 257 | pango_printf(window->cairo, window->font, false, "%s", config->mode); |
258 | } | 258 | } |
259 | 259 | ||
260 | void render(struct output *output, struct config *config, struct status_line *line) { | 260 | void render(struct output *output, struct config *config, struct status_line *line) { |
@@ -280,7 +280,7 @@ void render(struct output *output, struct config *config, struct status_line *li | |||
280 | if (line->protocol == TEXT) { | 280 | if (line->protocol == TEXT) { |
281 | get_text_size(window->cairo, window->font, &width, &height, "%s", line->text_line); | 281 | get_text_size(window->cairo, window->font, &width, &height, "%s", line->text_line); |
282 | cairo_move_to(cairo, window->width - margin - width, margin); | 282 | cairo_move_to(cairo, window->width - margin - width, margin); |
283 | pango_printf(window->cairo, window->font, "%s", line->text_line); | 283 | pango_printf(window->cairo, window->font, true, "%s", line->text_line); |
284 | } else if (line->protocol == I3BAR && line->block_line) { | 284 | } else if (line->protocol == I3BAR && line->block_line) { |
285 | double pos = window->width - 0.5; | 285 | double pos = window->width - 0.5; |
286 | bool edge = true; | 286 | bool edge = true; |
@@ -312,7 +312,8 @@ void render(struct output *output, struct config *config, struct status_line *li | |||
312 | 312 | ||
313 | void set_window_height(struct window *window, int height) { | 313 | void set_window_height(struct window *window, int height) { |
314 | int text_width, text_height; | 314 | int text_width, text_height; |
315 | get_text_size(window->cairo, window->font, &text_width, &text_height, "Test string for measuring purposes"); | 315 | get_text_size(window->cairo, window->font, &text_width, &text_height, false, |
316 | "Test string for measuring purposes"); | ||
316 | if (height > 0) { | 317 | if (height > 0) { |
317 | margin = (height - text_height) / 2; | 318 | margin = (height - text_height) / 2; |
318 | ws_vertical_padding = margin - 1.5; | 319 | ws_vertical_padding = margin - 1.5; |
diff --git a/swaybar/status_line.c b/swaybar/status_line.c index ba6de6a1..63db702f 100644 --- a/swaybar/status_line.c +++ b/swaybar/status_line.c | |||
@@ -71,7 +71,7 @@ static void parse_json(struct bar *bar, const char *text) { | |||
71 | json_object *full_text, *short_text, *color, *min_width, *align, *urgent; | 71 | json_object *full_text, *short_text, *color, *min_width, *align, *urgent; |
72 | json_object *name, *instance, *separator, *separator_block_width; | 72 | json_object *name, *instance, *separator, *separator_block_width; |
73 | json_object *background, *border, *border_top, *border_bottom; | 73 | json_object *background, *border, *border_top, *border_bottom; |
74 | json_object *border_left, *border_right; | 74 | json_object *border_left, *border_right, *markup; |
75 | 75 | ||
76 | json_object *json = json_object_array_get_idx(results, i); | 76 | json_object *json = json_object_array_get_idx(results, i); |
77 | if (!json) { | 77 | if (!json) { |
@@ -86,6 +86,7 @@ static void parse_json(struct bar *bar, const char *text) { | |||
86 | json_object_object_get_ex(json, "urgent", &urgent); | 86 | json_object_object_get_ex(json, "urgent", &urgent); |
87 | json_object_object_get_ex(json, "name", &name); | 87 | json_object_object_get_ex(json, "name", &name); |
88 | json_object_object_get_ex(json, "instance", &instance); | 88 | json_object_object_get_ex(json, "instance", &instance); |
89 | json_object_object_get_ex(json, "markup", &markup); | ||
89 | json_object_object_get_ex(json, "separator", &separator); | 90 | json_object_object_get_ex(json, "separator", &separator); |
90 | json_object_object_get_ex(json, "separator_block_width", &separator_block_width); | 91 | json_object_object_get_ex(json, "separator_block_width", &separator_block_width); |
91 | json_object_object_get_ex(json, "background", &background); | 92 | json_object_object_get_ex(json, "background", &background); |
@@ -139,6 +140,10 @@ static void parse_json(struct bar *bar, const char *text) { | |||
139 | new->instance = strdup(json_object_get_string(instance)); | 140 | new->instance = strdup(json_object_get_string(instance)); |
140 | } | 141 | } |
141 | 142 | ||
143 | if (markup) { | ||
144 | new->markup = json_object_get_boolean(markup); | ||
145 | } | ||
146 | |||
142 | if (separator) { | 147 | if (separator) { |
143 | new->separator = json_object_get_int(separator); | 148 | new->separator = json_object_get_int(separator); |
144 | } else { | 149 | } else { |