global results are now stored in state

This commit is contained in:
Linus Dierheimer
2021-04-16 20:22:38 +02:00
parent 86abc05cd4
commit 7b65316483
14 changed files with 255 additions and 299 deletions
+18 -29
View File
@@ -5,65 +5,54 @@
void ffPrintTheme(FFinstance* instance)
{
FFstrbuf* plasmaTheme;
FFstrbuf* plasmaColor;
ffCalculatePlasma(instance, &plasmaTheme, &plasmaColor, NULL, NULL);
ffCalculatePlasmaAndGtk(instance);
FFstrbuf* gtk2;
ffCalculateGTK2(instance, &gtk2, NULL, NULL);
FFstrbuf* gtk3;
ffCalculateGTK3(instance, &gtk3, NULL, NULL);
FFstrbuf* gtk4;
ffCalculateGTK4(instance, &gtk4, NULL, NULL);
if(plasmaTheme->length == 0 && plasmaColor->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
if(instance->state.plasma.widgetStyle.length == 0 && instance->state.plasma.colorScheme.length == 0 && instance->state.gtk2.theme.length == 0 && instance->state.gtk3.theme.length == 0 && instance->state.gtk4.theme.length == 0)
{
ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &instance->config.themeKey, &instance->config.themeFormat, FF_THEME_NUM_FORMAT_ARGS, "No themes found");
return;
}
FF_STRBUF_CREATE(plasmaColorPretty);
if(ffStrbufStartsWithIgnCase(plasmaColor, plasmaTheme))
ffStrbufAppendNS(&plasmaColorPretty, plasmaColor->length - plasmaTheme->length, &plasmaColor->chars[plasmaTheme->length]);
if(ffStrbufStartsWithIgnCase(&instance->state.plasma.colorScheme, &instance->state.plasma.widgetStyle))
ffStrbufAppendNS(&plasmaColorPretty, instance->state.plasma.colorScheme.length - instance->state.plasma.widgetStyle.length, &instance->state.plasma.colorScheme.chars[instance->state.plasma.widgetStyle.length]);
else
ffStrbufAppend(&plasmaColorPretty, plasmaColor);
ffStrbufAppend(&plasmaColorPretty, &instance->state.plasma.colorScheme);
ffStrbufTrim(&plasmaColorPretty, ' ');
FF_STRBUF_CREATE(gtkPretty);
ffGetGtkPretty(&gtkPretty, gtk2, gtk3, gtk4);
ffGetGtkPretty(&gtkPretty, &instance->state.gtk2.theme, &instance->state.gtk3.theme, &instance->state.gtk4.theme);
if(instance->config.themeFormat.length == 0)
{
ffPrintLogoAndKey(instance, FF_THEME_MODULE_NAME, 0, &instance->config.themeKey);
if(plasmaTheme->length > 0)
if(instance->state.plasma.widgetStyle.length > 0)
{
ffStrbufWriteTo(plasmaTheme, stdout);
ffStrbufWriteTo(&instance->state.plasma.widgetStyle, stdout);
if(plasmaColor->length > 0)
if(instance->state.plasma.colorScheme.length > 0)
{
fputs(" (", stdout);
if(plasmaColorPretty.length > 0)
ffStrbufWriteTo(&plasmaColorPretty, stdout);
else
ffStrbufWriteTo(plasmaColor, stdout);
ffStrbufWriteTo(&instance->state.plasma.colorScheme, stdout);
putchar(')');
}
}
else if(plasmaColor->length > 0)
else if(instance->state.plasma.colorScheme.length > 0)
{
if(plasmaColorPretty.length > 0)
ffStrbufWriteTo(&plasmaColorPretty, stdout);
else
ffStrbufWriteTo(plasmaColor, stdout);
ffStrbufWriteTo(&instance->state.plasma.colorScheme, stdout);
}
if(plasmaTheme->length > 0 || plasmaColor->length > 0)
if(instance->state.plasma.widgetStyle.length > 0 || instance->state.plasma.colorScheme.length > 0)
{
fputs(" [Plasma]", stdout);
@@ -76,12 +65,12 @@ void ffPrintTheme(FFinstance* instance)
else
{
ffPrintFormatString(instance, FF_THEME_MODULE_NAME, 0, &instance->config.themeKey, &instance->config.themeFormat, NULL, FF_THEME_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, plasmaTheme},
{FF_FORMAT_ARG_TYPE_STRBUF, plasmaColor},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.plasma.widgetStyle},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.plasma.colorScheme},
{FF_FORMAT_ARG_TYPE_STRBUF, &plasmaColorPretty},
{FF_FORMAT_ARG_TYPE_STRBUF, gtk2},
{FF_FORMAT_ARG_TYPE_STRBUF, gtk3},
{FF_FORMAT_ARG_TYPE_STRBUF, gtk4},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk2.theme},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk3.theme},
{FF_FORMAT_ARG_TYPE_STRBUF, &instance->state.gtk4.theme},
{FF_FORMAT_ARG_TYPE_STRBUF, &gtkPretty}
});
}