From 96a4b36b9feca559a512fe26cb7359178f1577cc Mon Sep 17 00:00:00 2001 From: Victor Kareh Date: Mon, 8 Apr 2024 12:23:57 -0400 Subject: window: Parse _BAMF_DESKTOP_FILE property In systems with bamfdaemon running, windows get this property for finding the dekstop spec file of an application. This can be used to find the defined icon for any application window that reports this attribute and provider much better icon matching. --- src/ui/ui.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/ui/ui.c') diff --git a/src/ui/ui.c b/src/ui/ui.c index 3c32c909..00500c03 100644 --- a/src/ui/ui.c +++ b/src/ui/ui.c @@ -650,7 +650,7 @@ meta_ui_get_default_mini_icon (MetaUI *ui) } static GdkPixbuf * -load_window_icon_from_app (char *app_id, int size, int scale) +load_window_icon_from_desktop_id (char *desktop_id, int size, int scale) { GtkIconTheme *theme = gtk_icon_theme_get_default (); GdkPixbuf *pixbuf = NULL; @@ -659,17 +659,13 @@ load_window_icon_from_app (char *app_id, int size, int scale) GIcon *gicon; GtkIconInfo *icon_info; - /* Generate a desktop ID the GTK Application ID name (e.g. org.mate.Caja.desktop). */ - gchar *desktop_id = g_strconcat(app_id, ".desktop", NULL); - - if (desktop_id == NULL) + if (desktop_id == NULL || !g_str_has_suffix (desktop_id, ".desktop")) return NULL; - /* Now that we have the desktop file ID, we extract the icon from it and render it */ info = g_desktop_app_info_new (desktop_id); - g_free(desktop_id); if (info == NULL) return NULL; + gicon = g_app_info_get_icon (G_APP_INFO (info)); icon_info = gtk_icon_theme_lookup_by_gicon_for_scale (theme, gicon, size, scale, GTK_ICON_LOOKUP_FORCE_SIZE); if (icon_info) @@ -682,7 +678,7 @@ load_window_icon_from_app (char *app_id, int size, int scale) } GdkPixbuf* -meta_ui_get_window_icon_from_app (MetaUI *ui, char *name) +meta_ui_get_window_icon_from_desktop_id (MetaUI *ui, char *desktop_id) { int scale; int size; @@ -690,11 +686,11 @@ meta_ui_get_window_icon_from_app (MetaUI *ui, char *name) scale = gtk_widget_get_scale_factor (GTK_WIDGET (ui->frames)); size = meta_prefs_get_icon_size() / scale; - return load_window_icon_from_app (name, size, scale); + return load_window_icon_from_desktop_id (desktop_id, size, scale); } GdkPixbuf* -meta_ui_get_mini_icon_from_app (MetaUI *ui, char *name) +meta_ui_get_mini_icon_from_desktop_id (MetaUI *ui, char *desktop_id) { int scale; int size; @@ -702,7 +698,7 @@ meta_ui_get_mini_icon_from_app (MetaUI *ui, char *name) scale = gtk_widget_get_scale_factor (GTK_WIDGET (ui->frames)); size = META_MINI_ICON_WIDTH / scale; - return load_window_icon_from_app (name, size, scale); + return load_window_icon_from_desktop_id (desktop_id, size, scale); } gboolean -- cgit v1.2.1