summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Gratton <mike@vee.net>2019-10-30 16:02:12 +1100
committerMichael Gratton <mike@vee.net>2019-10-30 16:17:03 +1100
commit9e4878d606cc2180b75016892ed6f9ffa9b12d1b (patch)
treebf78c1e7f3bc97adeda780c6c4a3f40f3e49b1e5
parent9dd8652a6617d14a83815e2e13266b34b07d84d0 (diff)
downloadgtk+-mjog/mute-actionhelper-null-target-warning.tar.gz
actionhelper: Mute warnings for actions with null targetsmjog/mute-actionhelper-null-target-warning
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.
-rw-r--r--gtk/gtkactionhelper.c18
1 files 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;
}