mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 09:33:39 +01:00
Icons: split detection code
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef FF_INCLUDED_detection_icons
|
||||
#define FF_INCLUDED_detection_icons
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
const char* ffDetectIcons(const FFinstance* instance, FFstrbuf* result);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "icons.h"
|
||||
#include "common/parsing.h"
|
||||
#include "detection/gtk_qt/gtk_qt.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
const char* ffDetectIcons(const FFinstance* instance, FFstrbuf* result)
|
||||
{
|
||||
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
|
||||
|
||||
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0)
|
||||
return "Icons aren't supported in TTY";
|
||||
|
||||
const FFstrbuf* plasma = &ffDetectQt(instance)->icons;
|
||||
const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->icons;
|
||||
const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->icons;
|
||||
const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->icons;
|
||||
|
||||
if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
|
||||
return "No icons could be found";
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY gtkPretty;
|
||||
ffStrbufInit(>kPretty);
|
||||
ffParseGTK(>kPretty, gtk2, gtk3, gtk4);
|
||||
|
||||
if(plasma->length > 0)
|
||||
{
|
||||
ffStrbufAppend(result, plasma);
|
||||
ffStrbufAppendS(result, " [QT]");
|
||||
|
||||
if(gtkPretty.length > 0)
|
||||
ffStrbufAppendS(result, ", ");
|
||||
}
|
||||
ffStrbufAppend(result, >kPretty);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "icons.h"
|
||||
|
||||
const char* ffDetectIcons(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_UNUSED FFstrbuf* result)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
Reference in New Issue
Block a user