Plugin text label aligned to ceiling?

Discussion on LXDE releases and Development. This forum is not the best way to contact the developers, please use the Development mailing list and Sourceforge to interact with them.
Locked
Maddy
Posts: 1
Joined: Sun Nov 29, 2020 6:35 am

Plugin text label aligned to ceiling?

Post by Maddy »

I just wrote my first two lxpanel plugins using https://github.com/olignyf/raspberry-pi-showip/ as a base and simply modifying it for my needs.

Platform:
Raspberry Pi OS Buster
LXPanel 0.10.0

The attached screenshot shows the second to last panel item is aligned to the ceiling while the last one is not.

Both plugins update the label identically:
Temperature (temp.c):

Code: Select all

static void update_display(Temp *pPlugin)
{
    char output[16];
    char faren[16];
    exec("vcgencmd measure_temp | sed 's/temp=\\([0-9]\\+\\)\\.[0-9]\\+.C/\\1°C/'",output,16);
    float far = atoi(output);
    far *= 9.f/5.f;
    far += 32;
    snprintf(faren,16,"%.1f°F",far);
    lxpanel_draw_label_text(pPlugin->panel, pPlugin->gLabel, output, TRUE, 1, TRUE);
    gtk_widget_set_tooltip_text(pPlugin->gLabel, faren);
}
Battery (gpiobatt.c):

Code: Select all

static void update_display(Batt *pPlugin)
{
    char output[16];
    exec("python /home/pi/x750status.py",output,16);
    char percent[16];
    char voltage[16];
    for (int i = 0;i < 16;++i)
    {
        if (output[i] == ' ')
        {
            percent[i] = '%';
            percent[++i] = '\0';
            strcpy(voltage,output+i);
            voltage[4] = 'V';
            voltage[5] = '\0';
            break;
        }
        percent[i] = output[i];
    }
    lxpanel_draw_label_text(pPlugin->panel, pPlugin->gLabel, percent, TRUE, 1, TRUE);
    gtk_widget_set_tooltip_text(pPlugin->gLabel, voltage);
}
Yet when temp.c does it, it is off center and I am very confused as to why..

Full sources:
temp.c https://hastebin.com/utorokorix.cpp
gpiobatt.c https://hastebin.com/izugadimuz.cpp
Attachments
2020-11-28-222340_1024x600_scrot.png
2020-11-28-222340_1024x600_scrot.png (14.79 KiB) Viewed 9174 times
drooly
Posts: 791
Joined: Mon Apr 08, 2013 6:45 am

Re: Plugin text label aligned to ceiling?

Post by drooly »

Obviously you need to compare what is different between the two.
The actual output (last 2 lines of code) seems identical, so the (content of the) variables themselves must differ.
I don't understand much C or CPP, but I can see differences in how the relevant variables are filled with content.
Maybe you should use snprintf for the temperature, too?
Locked