[gtk/matthiasc/for-master: 3/6] gtk-demo: Improve an error message




commit 4f5e3b7b0d5144cbd87ebe0f5b5ab08b5d6818a0
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Aug 8 12:51:31 2020 -0400

    gtk-demo: Improve an error message
    
    Be more helpful when we can't do syntax highlighting.

 demos/gtk-demo/main.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c
index b14e3b0909..d3f65220d0 100644
--- a/demos/gtk-demo/main.c
+++ b/demos/gtk-demo/main.c
@@ -239,7 +239,6 @@ fontify_text (const char *format,
               const char *text)
 {
   GSubprocess *subprocess;
-  static gboolean warned = FALSE;
   GBytes *stdin_buf;
   GBytes *stdout_buf = NULL;
   GBytes *stderr_buf = NULL;
@@ -259,11 +258,19 @@ fontify_text (const char *format,
 
   if (!subprocess)
     {
-      if (!warned)
+      if (g_error_matches (error, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT))
         {
-          g_warning ("%s", error->message);
-          warned = TRUE;
+          static gboolean warned = FALSE;
+
+          if (!warned)
+            {
+              warned = TRUE;
+              g_message ("For syntax highlighting, install the “highlight” program");
+            }
         }
+      else
+        g_warning ("%s", error->message);
+
       g_clear_error (&error);
 
       return NULL;


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