From cfe93425582d4dc3148bbeee43e6f07360b51aea Mon Sep 17 00:00:00 2001
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
Date: Wed, 3 Jan 2018 16:30:58 +0900
Subject: [PATCH 4/4] CPU: reflect panel font size configuration
ref: https://bugzilla.redhat.com/show_bug.cgi?id=1261464
To archive this, API to access LXPanel pointer must provide
to get font size.
---
plugins/thermal/thermal.c | 19 ++++++++++++++++---
src/panel.c | 8 ++++++++
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/plugins/thermal/thermal.c b/plugins/thermal/thermal.c
index 41bcfb1..b0d3d88 100644
--- a/plugins/thermal/thermal.c
+++ b/plugins/thermal/thermal.c
@@ -258,12 +258,24 @@ static gint get_critical(thermal *th)
return min;
}
+static int get_font_size(LXPanel *p, GtkWidget *label)
+{
+ int font_size = panel_get_font_size(p);
+ if (font_size < 0)
+ {
+ GtkStyle *style = gtk_widget_get_style(label);
+ font_size = pango_font_description_get_size(style->font_desc) / PANGO_SCALE;
+ }
+ return font_size;
+}
+
static void
update_display(thermal *th)
{
- char buffer [60];
+ char buffer [80];
int i;
int temp;
+ int font_size;
GdkColor color;
gchar *separator;
@@ -279,8 +291,9 @@ update_display(thermal *th)
lxpanel_draw_label_text(th->panel, th->namew, "NA", TRUE, 1, TRUE);
else
{
- snprintf(buffer, sizeof(buffer), "<span color=\"#%06x\"><b>%02d</b></span>",
- gcolor2rgb24(&color), temp);
+ font_size = get_font_size(th->panel, th->namew);
+ snprintf(buffer, sizeof(buffer), "<span font_desc=\"%d\" color=\"#%06x\"><b>%02d</b></span>",
+ font_size, gcolor2rgb24(&color), temp);
gtk_label_set_markup (GTK_LABEL(th->namew), buffer) ;
}
diff --git a/src/panel.c b/src/panel.c
index 38f5a49..3359ffa 100644
--- a/src/panel.c
+++ b/src/panel.c
@@ -2037,6 +2037,14 @@ gint panel_get_height(LXPanel *panel)
return panel->priv->height;
}
+gint panel_get_font_size(LXPanel *panel)
+{
+ if (panel->priv->usefontsize)
+ return panel->priv->fontsize;
+ else
+ return -1;
+}
+
Window panel_get_xwindow(LXPanel *panel)
{
return panel->priv->topxwin;
--
2.14.3