Execplugin: add pango markup option
This commit is contained in:
parent
ad50d32f54
commit
17f94205b4
9 changed files with 32 additions and 12 deletions
|
@ -310,7 +310,8 @@ gboolean resize_battery(void *obj)
|
||||||
buf_bat_percentage,
|
buf_bat_percentage,
|
||||||
strlen(buf_bat_percentage),
|
strlen(buf_bat_percentage),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE);
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
FALSE);
|
||||||
get_text_size2(bat2_font_desc,
|
get_text_size2(bat2_font_desc,
|
||||||
&bat_time_height_ink,
|
&bat_time_height_ink,
|
||||||
&bat_time_height,
|
&bat_time_height,
|
||||||
|
@ -320,7 +321,8 @@ gboolean resize_battery(void *obj)
|
||||||
buf_bat_time,
|
buf_bat_time,
|
||||||
strlen(buf_bat_time),
|
strlen(buf_bat_time),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE);
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
if (panel_horizontal) {
|
if (panel_horizontal) {
|
||||||
int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width;
|
int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width;
|
||||||
|
|
|
@ -254,7 +254,8 @@ gboolean resize_clock(void *obj)
|
||||||
buf_time,
|
buf_time,
|
||||||
strlen(buf_time),
|
strlen(buf_time),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE);
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
FALSE);
|
||||||
if (time2_format) {
|
if (time2_format) {
|
||||||
strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone));
|
strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone));
|
||||||
get_text_size2(time2_font_desc,
|
get_text_size2(time2_font_desc,
|
||||||
|
@ -266,7 +267,8 @@ gboolean resize_clock(void *obj)
|
||||||
buf_date,
|
buf_date,
|
||||||
strlen(buf_date),
|
strlen(buf_date),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE);
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (panel_horizontal) {
|
if (panel_horizontal) {
|
||||||
|
|
|
@ -531,6 +531,9 @@ void add_entry(char *key, char *value)
|
||||||
} else if (strcmp(key, "execp_continuous") == 0) {
|
} else if (strcmp(key, "execp_continuous") == 0) {
|
||||||
Execp *execp = get_or_create_last_execp();
|
Execp *execp = get_or_create_last_execp();
|
||||||
execp->backend->continuous = atoi(value);
|
execp->backend->continuous = atoi(value);
|
||||||
|
} else if (strcmp(key, "execp_markup") == 0) {
|
||||||
|
Execp *execp = get_or_create_last_execp();
|
||||||
|
execp->backend->has_markup = atoi(value);
|
||||||
} else if (strcmp(key, "execp_cache_icon") == 0) {
|
} else if (strcmp(key, "execp_cache_icon") == 0) {
|
||||||
Execp *execp = get_or_create_last_execp();
|
Execp *execp = get_or_create_last_execp();
|
||||||
execp->backend->cache_icon = atoi(value);
|
execp->backend->cache_icon = atoi(value);
|
||||||
|
|
|
@ -246,7 +246,10 @@ void draw_execp(void *obj, cairo_t *c)
|
||||||
pango_layout_set_alignment(layout, execp->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT);
|
pango_layout_set_alignment(layout, execp->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT);
|
||||||
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
|
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
|
||||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
|
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
|
||||||
|
if (!execp->backend->has_markup)
|
||||||
pango_layout_set_text(layout, execp->backend->text, strlen(execp->backend->text));
|
pango_layout_set_text(layout, execp->backend->text, strlen(execp->backend->text));
|
||||||
|
else
|
||||||
|
pango_layout_set_markup(layout, execp->backend->text, strlen(execp->backend->text));
|
||||||
|
|
||||||
pango_cairo_update_layout(c, layout);
|
pango_cairo_update_layout(c, layout);
|
||||||
draw_text(layout,
|
draw_text(layout,
|
||||||
|
@ -295,7 +298,8 @@ gboolean resize_execp(void *obj)
|
||||||
execp->backend->text,
|
execp->backend->text,
|
||||||
strlen(execp->backend->text),
|
strlen(execp->backend->text),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE);
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
execp->backend->has_markup);
|
||||||
} else {
|
} else {
|
||||||
get_text_size2(execp->backend->font_desc,
|
get_text_size2(execp->backend->font_desc,
|
||||||
&txt_height_ink,
|
&txt_height_ink,
|
||||||
|
@ -309,7 +313,8 @@ gboolean resize_execp(void *obj)
|
||||||
execp->backend->text,
|
execp->backend->text,
|
||||||
strlen(execp->backend->text),
|
strlen(execp->backend->text),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE);
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
execp->backend->has_markup);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
|
|
@ -32,6 +32,7 @@ typedef struct ExecpBackend {
|
||||||
PangoFontDescription *font_desc;
|
PangoFontDescription *font_desc;
|
||||||
Color font_color;
|
Color font_color;
|
||||||
int continuous;
|
int continuous;
|
||||||
|
gboolean has_markup;
|
||||||
char *lclick_command;
|
char *lclick_command;
|
||||||
char *mclick_command;
|
char *mclick_command;
|
||||||
char *rclick_command;
|
char *rclick_command;
|
||||||
|
|
|
@ -255,7 +255,8 @@ void init_taskbar_panel(void *p)
|
||||||
"TAjpg",
|
"TAjpg",
|
||||||
5,
|
5,
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_END);
|
PANGO_ELLIPSIZE_END,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
if (!panel->g_task.maximum_width && panel_horizontal)
|
if (!panel->g_task.maximum_width && panel_horizontal)
|
||||||
panel->g_task.maximum_width = server.monitor[panel->monitor].width;
|
panel->g_task.maximum_width = server.monitor[panel->monitor].width;
|
||||||
|
|
|
@ -152,7 +152,8 @@ gboolean resize_taskbarname(void *obj)
|
||||||
taskbar_name->name,
|
taskbar_name->name,
|
||||||
strlen(taskbar_name->name),
|
strlen(taskbar_name->name),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE);
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
if (panel_horizontal) {
|
if (panel_horizontal) {
|
||||||
int new_size = name_width + (2 * (taskbar_name->area.paddingxlr + taskbar_name->area.bg->border.width));
|
int new_size = name_width + (2 * (taskbar_name->area.paddingxlr + taskbar_name->area.bg->border.width));
|
||||||
|
|
|
@ -573,7 +573,8 @@ void get_text_size2(PangoFontDescription *font,
|
||||||
char *text,
|
char *text,
|
||||||
int len,
|
int len,
|
||||||
PangoWrapMode wrap,
|
PangoWrapMode wrap,
|
||||||
PangoEllipsizeMode ellipsis)
|
PangoEllipsizeMode ellipsis,
|
||||||
|
gboolean markup)
|
||||||
{
|
{
|
||||||
PangoRectangle rect_ink, rect;
|
PangoRectangle rect_ink, rect;
|
||||||
|
|
||||||
|
@ -588,7 +589,10 @@ void get_text_size2(PangoFontDescription *font,
|
||||||
pango_layout_set_wrap(layout, wrap);
|
pango_layout_set_wrap(layout, wrap);
|
||||||
pango_layout_set_ellipsize(layout, ellipsis);
|
pango_layout_set_ellipsize(layout, ellipsis);
|
||||||
pango_layout_set_font_description(layout, font);
|
pango_layout_set_font_description(layout, font);
|
||||||
|
if (!markup)
|
||||||
pango_layout_set_text(layout, text, len);
|
pango_layout_set_text(layout, text, len);
|
||||||
|
else
|
||||||
|
pango_layout_set_markup(layout, text, len);
|
||||||
|
|
||||||
pango_layout_get_pixel_extents(layout, &rect_ink, &rect);
|
pango_layout_get_pixel_extents(layout, &rect_ink, &rect);
|
||||||
*height_ink = rect_ink.height;
|
*height_ink = rect_ink.height;
|
||||||
|
|
|
@ -87,7 +87,8 @@ void get_text_size2(PangoFontDescription *font,
|
||||||
char *text,
|
char *text,
|
||||||
int len,
|
int len,
|
||||||
PangoWrapMode wrap,
|
PangoWrapMode wrap,
|
||||||
PangoEllipsizeMode ellipsis);
|
PangoEllipsizeMode ellipsis,
|
||||||
|
gboolean markup);
|
||||||
|
|
||||||
void draw_text(PangoLayout *layout, cairo_t *c, int posx, int posy, Color *color, int font_shadow);
|
void draw_text(PangoLayout *layout, cairo_t *c, int posx, int posy, Color *color, int font_shadow);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue