#include "i3-nagbar.h"
typedef struct {
- char *label;
+ i3String *label;
char *action;
int16_t x;
uint16_t width;
static xcb_gcontext_t pixmap_gc;
static xcb_rectangle_t rect = { 0, 0, 600, 20 };
static i3Font font;
-static char *prompt;
+static i3String *prompt;
static button_t *buttons;
static int buttoncnt;
/* restore font color */
set_font_colors(pixmap_gc, color_text, color_background);
- draw_text(prompt, strlen(prompt), false, pixmap, pixmap_gc,
+ draw_text((char *)i3string_as_ucs2(prompt), i3string_get_num_glyphs(prompt), true, pixmap, pixmap_gc,
4 + 4, 4 + 4, rect.width - 4 - 4);
/* render close button */
values[0] = color_text;
values[1] = color_button_background;
set_font_colors(pixmap_gc, color_text, color_button_background);
- draw_text(buttons[c].label, strlen(buttons[c].label), false, pixmap, pixmap_gc,
+ draw_text((char *)i3string_as_ucs2(buttons[c].label), i3string_get_num_glyphs(buttons[c].label), true, pixmap, pixmap_gc,
y - w - line_width + 6, 4 + 3, rect.width - y + w + line_width - 6);
y -= w;
char *options_string = "b:f:m:t:vh";
- prompt = sstrdup("Please do not run this program.");
+ prompt = i3string_from_utf8("Please do not run this program.");
while ((o = getopt_long(argc, argv, options_string, long_options, &option_index)) != -1) {
switch (o) {
pattern = sstrdup(optarg);
break;
case 'm':
- FREE(prompt);
- prompt = sstrdup(optarg);
+ i3string_free(prompt);
+ prompt = i3string_from_utf8(optarg);
break;
case 't':
bar_type = (strcasecmp(optarg, "warning") == 0 ? TYPE_WARNING : TYPE_ERROR);
return 0;
case 'b':
buttons = realloc(buttons, sizeof(button_t) * (buttoncnt + 1));
- buttons[buttoncnt].label = optarg;
+ buttons[buttoncnt].label = i3string_from_utf8(optarg);
buttons[buttoncnt].action = argv[optind];
printf("button with label *%s* and action *%s*\n",
- buttons[buttoncnt].label,
+ i3string_as_utf8(buttons[buttoncnt].label),
buttons[buttoncnt].action);
buttoncnt++;
printf("now %d buttons\n", buttoncnt);