From 808d6d5989532570abc14f52d7445015c51cbc77 Mon Sep 17 00:00:00 2001 From: scorpion-26 Date: Thu, 2 May 2024 11:15:26 +0200 Subject: [PATCH] SNI: Fall back to Title when ToolTip isn't set This adds a way to filter items, which don't have a nice object path nor a tooltip. https://github.com/scorpion-26/gBar/issues/92#issuecomment-2089845752 --- src/SNI.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/SNI.cpp b/src/SNI.cpp index 53e134a..13cef59 100644 --- a/src/SNI.cpp +++ b/src/SNI.cpp @@ -11,6 +11,7 @@ #include #include +#include #include namespace SNI @@ -152,10 +153,31 @@ namespace SNI { LOG("SNI: Error querying tooltip"); } - LOG("SNI: Title: " << data->item.tooltip); + LOG("SNI: Tooltip: " << data->item.tooltip); g_variant_unref(tooltip); } + if (data->item.tooltip.empty()) + { + LOG("SNI: No tooltip found, using title as tooltip"); + // No tooltip, use title as tooltip + GVariant* title = getProperty("Title"); + if (title) + { + const gchar* titleStr = g_variant_get_string(title, nullptr); + if (titleStr != nullptr) + { + data->item.tooltip = titleStr; + } + else + { + LOG("SNI: Error querying title"); + } + LOG("SNI: Fallback tooltip: " << data->item.tooltip); + g_variant_unref(title); + } + } + // Query menu GVariant* menuPath = getProperty("Menu"); if (menuPath)