plasma color theme detection

This commit is contained in:
Linus Dierheimer
2021-04-09 19:21:56 +02:00
parent 2b55a14c16
commit 0ed54eddc4
9 changed files with 159 additions and 36 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
void ffPrintFont(FFinstance* instance)
{
FFstrbuf* plasma;
ffCalculatePlasma(instance, NULL, NULL, &plasma);
ffCalculatePlasma(instance, NULL, NULL, NULL, &plasma);
FFstrbuf* gtk2;
ffCalculateGTK2(instance, NULL, NULL, &gtk2);
+1 -1
View File
@@ -3,7 +3,7 @@
void ffPrintIcons(FFinstance* instance)
{
FFstrbuf* plasma;
ffCalculatePlasma(instance, NULL, &plasma, NULL);
ffCalculatePlasma(instance, NULL, NULL, &plasma, NULL);
FFstrbuf* gtk2;
ffCalculateGTK2(instance, NULL, &gtk2, NULL);
+44 -7
View File
@@ -2,8 +2,9 @@
void ffPrintTheme(FFinstance* instance)
{
FFstrbuf* plasma;
ffCalculatePlasma(instance, &plasma, NULL, NULL);
FFstrbuf* plasmaTheme;
FFstrbuf* plasmaColor;
ffCalculatePlasma(instance, &plasmaTheme, &plasmaColor, NULL, NULL);
FFstrbuf* gtk2;
ffCalculateGTK2(instance, &gtk2, NULL, NULL);
@@ -14,12 +15,20 @@ void ffPrintTheme(FFinstance* instance)
FFstrbuf* gtk4;
ffCalculateGTK4(instance, &gtk4, NULL, NULL);
if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
if(plasmaTheme->length == 0 && plasmaColor->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
{
ffPrintError(instance, &instance->config.themeKey, "Theme", "No themes found");
return;
}
FF_STRBUF_CREATE(plasmaColorPretty);
if(ffStrbufStartsWithIgnCase(plasmaColor, plasmaTheme))
ffStrbufAppendNS(&plasmaColorPretty, plasmaColor->length - plasmaTheme->length, &plasmaColor->chars[plasmaTheme->length]);
else
ffStrbufAppend(&plasmaColorPretty, plasmaColor);
ffStrbufTrim(&plasmaColorPretty, ' ');
FF_STRBUF_CREATE(gtkPretty);
ffGetGtkPretty(&gtkPretty, gtk2, gtk3, gtk4);
@@ -27,9 +36,32 @@ void ffPrintTheme(FFinstance* instance)
{
ffPrintLogoAndKey(instance, &instance->config.themeKey, "Theme");
if(plasma->length > 0)
if(plasmaTheme->length > 0)
{
ffStrbufWriteTo(plasmaTheme, stdout);
if(plasmaColor->length > 0)
{
fputs(" (", stdout);
if(plasmaColorPretty.length > 0)
ffStrbufWriteTo(&plasmaColorPretty, stdout);
else
ffStrbufWriteTo(plasmaColor, stdout);
putchar(')');
}
}
else if(plasmaColor->length > 0)
{
if(plasmaColorPretty.length > 0)
ffStrbufWriteTo(&plasmaColorPretty, stdout);
else
ffStrbufWriteTo(plasmaColor, stdout);
}
if(plasmaTheme->length > 0 || plasmaColor->length > 0)
{
ffStrbufWriteTo(plasma, stdout);
fputs(" [Plasma]", stdout);
if(gtkPretty.length > 0)
@@ -40,12 +72,17 @@ void ffPrintTheme(FFinstance* instance)
}
else
{
ffPrintFormatString(instance, &instance->config.themeKey, "Theme", &instance->config.themeFormat, 5,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, plasma},
ffPrintFormatString(instance, &instance->config.themeKey, "Theme", &instance->config.themeFormat, 7,
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, plasmaTheme},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, plasmaColor},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &plasmaColorPretty},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, gtk2},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, gtk3},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, gtk4},
(FFformatarg){FF_FORMAT_ARG_TYPE_STRBUF, &gtkPretty}
);
}
ffStrbufDestroy(&plasmaColorPretty);
ffStrbufDestroy(&gtkPretty);
}