[gtk/mjog/mute-actionhelper-null-target-warning] actionhelper: Mute warnings for actions with null targets



commit 9e4878d606cc2180b75016892ed6f9ffa9b12d1b
Author: Michael Gratton <mike vee net>
Date:   Wed Oct 30 16:02:12 2019 +1100

    actionhelper: Mute warnings for actions with null targets
    
    There's currently no way for actions parameterised with a target to be
    disabled on a per-target basis, except by setting the target to be
    null. This causes actionhelper to mark the associated widget as
    insensitive as desired, but also print a warning about the target's
    type being invalid.
    
    This patch mutes the warning only in case the target is null, if the
    target is otherwise the incorrect type then the warning will still be
    printed.

 gtk/gtkactionhelper.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkactionhelper.c b/gtk/gtkactionhelper.c
index c5f4356b2b..8e4fa8fa06 100644
--- a/gtk/gtkactionhelper.c
+++ b/gtk/gtkactionhelper.c
@@ -147,12 +147,18 @@ gtk_action_helper_action_added (GtkActionHelper    *helper,
 
   if (!helper->can_activate)
     {
-      g_warning ("%s: action %s can't be activated due to parameter type mismatch "
-                 "(parameter type %s, target type %s)",
-                 "actionhelper",
-                 helper->action_name,
-                 parameter_type ? g_variant_type_peek_string (parameter_type) : "NULL",
-                 helper->target ? g_variant_get_type_string (helper->target) : "NULL");
+      /* If target is null, just treat it as being disabled, otherwise
+         warn about the incorrect type. */
+      if (helper->target != NULL)
+        {
+          g_warning ("%s: action %s can't be activated due to parameter type mismatch "
+                     "(parameter type %s, target type %s)",
+                     "actionhelper",
+                     helper->action_name,
+                     parameter_type ? g_variant_type_peek_string (parameter_type) : "NULL",
+                     g_variant_get_type_string (helper->target));
+        }
+
       return;
     }
 


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