mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-21 18:52: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
20
src/SNI.cpp
20
src/SNI.cpp
|
@ -227,16 +227,32 @@ namespace SNI
|
|||
}
|
||||
}
|
||||
if (iconName != "")
|
||||
{
|
||||
GdkPixbuf* pixbuf = nullptr;
|
||||
if (std::filesystem::path(iconName).is_absolute())
|
||||
{
|
||||
// The icon name is an absolute path. This is not according to spec, but some apps (e.g. Spotube) still do it this way.
|
||||
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
|
||||
{
|
||||
GError* err = nullptr;
|
||||
GtkIconTheme* defaultTheme = gtk_icon_theme_get_default();
|
||||
GdkPixbuf* pixbuf = gtk_icon_theme_load_icon(defaultTheme, iconName.c_str(), 64, GTK_ICON_LOOKUP_FORCE_SVG, &err);
|
||||
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);
|
||||
}
|
||||
else if (pixbuf)
|
||||
}
|
||||
|
||||
if (pixbuf)
|
||||
{
|
||||
LOG("SNI: Creating icon from \"" << iconName << "\"");
|
||||
data->item.pixbuf = pixbuf;
|
||||
|
|
Loading…
Reference in a new issue