summaryrefslogtreecommitdiff
path: root/src/ui/ui.c
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2024-04-08 12:23:57 -0400
committerlukefromdc <[email protected]>2024-06-18 17:04:23 -0400
commit96a4b36b9feca559a512fe26cb7359178f1577cc (patch)
tree78d14df3c6b3d20b237b2f5193828c7ee3f3ee3a /src/ui/ui.c
parentcb83a91ed03c9e5ab2a1d8b932ffac3ba49e9fbb (diff)
downloadmarco-96a4b36b9feca559a512fe26cb7359178f1577cc.tar.bz2
marco-96a4b36b9feca559a512fe26cb7359178f1577cc.tar.xz
window: Parse _BAMF_DESKTOP_FILE propertyiconcache-use-gdesktopapp
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.
Diffstat (limited to 'src/ui/ui.c')
-rw-r--r--src/ui/ui.c18
1 files changed, 7 insertions, 11 deletions
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