Skip to content

Commit

Permalink
Revert "notifications: Try to guess app id if getting from hints fails (
Browse files Browse the repository at this point in the history
#479)"

This reverts commit bfee2a0.
  • Loading branch information
fossfreedom committed Oct 18, 2023
1 parent d0ef7db commit e0a7aba
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions src/lib/notification.vala
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,15 @@
category = variant.get_string();
}

// Try to set the application ID and app info
// Set the application ID and app info
if ((variant = hints.lookup("desktop-entry")) != null && variant.is_of_type(VariantType.STRING)) {
app_id = variant.get_string();
app_id.replace(".desktop", "");
app_info = new DesktopAppInfo("%s.desktop".printf(app_id));
}

// Because following specs is a lost art, sometimes the desktop-entry
// value does not correspond to the desktop file. So, try to best-guess
// the desktop id instead.
if (app_info == null) {
app_id = app_name.replace(" ", "-").down();
app_info = new DesktopAppInfo("%s.desktop".printf(app_id));
}

// Make sure we have the best app name
if (app_info != null) {
app_name = app_info.get_string("Name") ?? app_name;
if (app_info != null) app_name = app_info.get_string("Name") ?? app_name;
}

// Try to get the application's image
app_image = get_appinfo_image(Gtk.IconSize.DND, app_id.down());

bool image_found = false;
Expand Down Expand Up @@ -267,13 +255,9 @@

private Gtk.Image? get_appinfo_image(Gtk.IconSize size, string? fallback) {
if (app_info == null) {
var theme = Gtk.IconTheme.get_default();

if (!theme.has_icon(fallback)) {
return null;
}

return new Gtk.Image.from_icon_name(fallback, size);
var fallback_image = new Gtk.Image.from_icon_name(fallback, size);
var invalid_image = (fallback_image == null) || (fallback_image.icon_name == null) || (fallback_image.icon_name == "image-missing") || (fallback_image.icon_name == "");
return invalid_image ? null : fallback_image;
}

var app_icon_name = app_info.get_string("Icon"); // Use the Icon from the respective DesktopAppInfo or fallback to generic applications-internet
Expand All @@ -288,4 +272,4 @@
return null;
}
}
}
}

0 comments on commit e0a7aba

Please sign in to comment.