mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-21 18:52:49 +00:00
SNI: Add tooltip
This commit is contained in:
parent
6bd5a450b1
commit
25912c7e35
1 changed files with 19 additions and 0 deletions
19
src/SNI.cpp
19
src/SNI.cpp
|
@ -26,6 +26,8 @@ namespace SNI
|
|||
size_t w;
|
||||
size_t h;
|
||||
uint8_t* iconData = nullptr;
|
||||
|
||||
std::string tooltip;
|
||||
};
|
||||
std::vector<Item> items;
|
||||
|
||||
|
@ -164,6 +166,22 @@ namespace SNI
|
|||
memcpy(item.iconData, pixels, width * height * 4);
|
||||
stbi_image_free(pixels);
|
||||
}
|
||||
|
||||
// Query tooltip(Steam e.g. doesn't have one)
|
||||
GVariant* tooltip = getProperty("ToolTip");
|
||||
if (tooltip)
|
||||
{
|
||||
GVariant* tooltipVar;
|
||||
g_variant_get_child(tooltip, 0, "v", &tooltipVar);
|
||||
const gchar* title;
|
||||
// Both telegram and discord only set the "title" component
|
||||
g_variant_get_child(tooltipVar, 2, "s", &title);
|
||||
item.tooltip = title;
|
||||
LOG("SNI: Title: " << item.tooltip);
|
||||
g_variant_unref(tooltip);
|
||||
g_variant_unref(tooltipVar);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -250,6 +268,7 @@ namespace SNI
|
|||
auto texture = Widget::Create<Texture>();
|
||||
texture->SetHorizontalTransform({0, true, Alignment::Fill});
|
||||
texture->SetBuf(item.w, item.h, item.iconData);
|
||||
texture->SetTooltip(item.tooltip);
|
||||
iconBox->AddChild(std::move(texture));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue