[gtk/icon-fallback] Add logging for icon fallback




commit 6f8240805617c2c772c4d298dc692ac831d22013
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Mar 25 17:26:15 2021 -0400

    Add logging for icon fallback
    
    Add GTK_DEBUG=iconfallback which prints out what icon names
    we fall back to image-missing for.

 gtk/gtkdebug.h     | 1 +
 gtk/gtkicontheme.c | 5 +++++
 gtk/gtkmain.c      | 1 +
 3 files changed, 7 insertions(+)
---
diff --git a/gtk/gtkdebug.h b/gtk/gtkdebug.h
index ac85014d74..4a10c96cff 100644
--- a/gtk/gtkdebug.h
+++ b/gtk/gtkdebug.h
@@ -53,6 +53,7 @@ typedef enum {
   GTK_DEBUG_CONSTRAINTS     = 1 << 15,
   GTK_DEBUG_BUILDER_OBJECTS = 1 << 16,
   GTK_DEBUG_A11Y            = 1 << 17,
+  GTK_DEBUG_ICONFALLBACK    = 1 << 18,
 } GtkDebugFlags;
 
 #ifdef G_ENABLE_DEBUG
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index ef1e70a0b2..7486457e17 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -2269,6 +2269,11 @@ real_choose_icon (GtkIconTheme      *self,
   /* Fall back to missing icon */
   if (icon == NULL)
     {
+      GTK_NOTE(ICONFALLBACK, {
+        char *s = g_strjoinv (", ", (char **)icon_names);
+        g_message ("No icon found for: %s", s);
+        g_free (s);
+      });
       icon = icon_paintable_new ("image-missing", size, scale);
       icon->filename = g_strdup (IMAGE_MISSING_RESOURCE_PATH);
       icon->is_resource = TRUE;
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 02c37b045e..27dea0f007 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -197,6 +197,7 @@ static const GdkDebugKey gtk_debug_keys[] = {
   { "touchscreen", GTK_DEBUG_TOUCHSCREEN, "Pretend the pointer is a touchscreen" },
   { "snapshot", GTK_DEBUG_SNAPSHOT, "Generate debug render nodes" },
   { "accessibility", GTK_DEBUG_A11Y, "Information about accessibility state changes" },
+  { "iconfallback", GTK_DEBUG_ICONFALLBACK, "Information about icon fallback" },
 };
 
 /* This checks to see if the process is running suid or sgid


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]