mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-22 03:02:49 +00:00
SNI: Allow absolute path for icons
Even though this is non-standard behavior, some apps still do this (e.g. spotube) Fixes: https://github.com/scorpion-26/gBar/issues/92
This commit is contained in:
parent
808d6d5989
commit
3147ff21d8
1 changed files with 23 additions and 7 deletions
30
src/SNI.cpp
30
src/SNI.cpp
|
@ -228,15 +228,31 @@ namespace SNI
|
||||||
}
|
}
|
||||||
if (iconName != "")
|
if (iconName != "")
|
||||||
{
|
{
|
||||||
GError* err = nullptr;
|
GdkPixbuf* pixbuf = nullptr;
|
||||||
GtkIconTheme* defaultTheme = gtk_icon_theme_get_default();
|
if (std::filesystem::path(iconName).is_absolute())
|
||||||
GdkPixbuf* pixbuf = gtk_icon_theme_load_icon(defaultTheme, iconName.c_str(), 64, GTK_ICON_LOOKUP_FORCE_SVG, &err);
|
|
||||||
if (err)
|
|
||||||
{
|
{
|
||||||
LOG("SNI: gtk_icon_theme_load_icon failed: " << err->message);
|
// The icon name is an absolute path. This is not according to spec, but some apps (e.g. Spotube) still do it this way.
|
||||||
g_error_free(err);
|
LOG("SNI: Warning: IconName shouldn't be a full path!");
|
||||||
|
GError* err = nullptr;
|
||||||
|
pixbuf = gdk_pixbuf_new_from_file(iconName.c_str(), &err);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
LOG("SNI: gdk_pixbuf_new_from_file failed: " << err->message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (pixbuf)
|
else
|
||||||
|
{
|
||||||
|
GError* err = nullptr;
|
||||||
|
GtkIconTheme* defaultTheme = gtk_icon_theme_get_default();
|
||||||
|
pixbuf = gtk_icon_theme_load_icon(defaultTheme, iconName.c_str(), 64, GTK_ICON_LOOKUP_FORCE_SVG, &err);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
LOG("SNI: gtk_icon_theme_load_icon failed: " << err->message);
|
||||||
|
g_error_free(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pixbuf)
|
||||||
{
|
{
|
||||||
LOG("SNI: Creating icon from \"" << iconName << "\"");
|
LOG("SNI: Creating icon from \"" << iconName << "\"");
|
||||||
data->item.pixbuf = pixbuf;
|
data->item.pixbuf = pixbuf;
|
||||||
|
|
Loading…
Reference in a new issue