Commit 16e02850 authored by Allison Karlitskaya's avatar Allison Karlitskaya Committed by Matthias Clasen

GtkActionHelper: add some debugging output

Introduce a new debug category "actions" and write some messages from
GtkActionHelper about if we can find the actions or not.

We will probably soon want to add some similar messages to
GtkMenuTrackerItem.

https://bugzilla.gnome.org/show_bug.cgi?id=733965
parent 785c9f5e
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "gtkwidget.h" #include "gtkwidget.h"
#include "gtkwidgetprivate.h" #include "gtkwidgetprivate.h"
#include "gtkdebug.h"
#include <string.h> #include <string.h>
...@@ -121,16 +122,29 @@ gtk_action_helper_action_added (GtkActionHelper *helper, ...@@ -121,16 +122,29 @@ gtk_action_helper_action_added (GtkActionHelper *helper,
GVariant *state, GVariant *state,
gboolean should_emit_signals) gboolean should_emit_signals)
{ {
GTK_NOTE(ACTIONS, g_message("actionhelper: %s added", helper->action_name));
/* we can only activate if we have the correct type of parameter */ /* we can only activate if we have the correct type of parameter */
helper->can_activate = (helper->target == NULL && parameter_type == NULL) || helper->can_activate = (helper->target == NULL && parameter_type == NULL) ||
(helper->target != NULL && parameter_type != NULL && (helper->target != NULL && parameter_type != NULL &&
g_variant_is_of_type (helper->target, parameter_type)); g_variant_is_of_type (helper->target, parameter_type));
if (!helper->can_activate) if (!helper->can_activate)
return; {
GTK_NOTE(ACTIONS, g_message("actionhelper: %s found, but disabled due to parameter type mismatch",
helper->action_name));
return;
}
GTK_NOTE(ACTIONS, g_message ("actionhelper: %s can be activated", helper->action_name));
helper->enabled = enabled; helper->enabled = enabled;
if (!enabled)
GTK_NOTE(ACTIONS, g_message("actionhelper: %s found, but disabled due to disabled action", helper->action_name));
else
GTK_NOTE(ACTIONS, g_message("actionhelper: %s found and enabled", helper->action_name));
if (helper->target != NULL && state != NULL) if (helper->target != NULL && state != NULL)
helper->active = g_variant_equal (state, helper->target); helper->active = g_variant_equal (state, helper->target);
...@@ -150,6 +164,8 @@ gtk_action_helper_action_added (GtkActionHelper *helper, ...@@ -150,6 +164,8 @@ gtk_action_helper_action_added (GtkActionHelper *helper,
static void static void
gtk_action_helper_action_removed (GtkActionHelper *helper) gtk_action_helper_action_removed (GtkActionHelper *helper)
{ {
GTK_NOTE(ACTIONS, g_message ("actionhelper: %s was removed", helper->action_name));
if (!helper->can_activate) if (!helper->can_activate)
return; return;
...@@ -172,6 +188,8 @@ static void ...@@ -172,6 +188,8 @@ static void
gtk_action_helper_action_enabled_changed (GtkActionHelper *helper, gtk_action_helper_action_enabled_changed (GtkActionHelper *helper,
gboolean enabled) gboolean enabled)
{ {
GTK_NOTE(ACTIONS, g_message ("actionhelper: %s enabled changed: %d", helper->action_name, enabled));
if (!helper->can_activate) if (!helper->can_activate)
return; return;
...@@ -188,6 +206,8 @@ gtk_action_helper_action_state_changed (GtkActionHelper *helper, ...@@ -188,6 +206,8 @@ gtk_action_helper_action_state_changed (GtkActionHelper *helper,
{ {
gboolean was_active; gboolean was_active;
GTK_NOTE(ACTIONS, g_message ("actionhelper: %s state changed", helper->action_name));
if (!helper->can_activate) if (!helper->can_activate)
return; return;
...@@ -359,6 +379,11 @@ gtk_action_helper_set_action_name (GtkActionHelper *helper, ...@@ -359,6 +379,11 @@ gtk_action_helper_set_action_name (GtkActionHelper *helper,
if (g_strcmp0 (action_name, helper->action_name) == 0) if (g_strcmp0 (action_name, helper->action_name) == 0)
return; return;
GTK_NOTE(ACTIONS,
if (!strchr (action_name, '.'))
g_message ("actionhelper: action name %s doesn't look like 'app.' or 'win.' "
"which means that it will probably not work properly.", action_name));
if (helper->action_name) if (helper->action_name)
{ {
gtk_action_observable_unregister_observer (GTK_ACTION_OBSERVABLE (helper->action_context), gtk_action_observable_unregister_observer (GTK_ACTION_OBSERVABLE (helper->action_context),
...@@ -382,13 +407,18 @@ gtk_action_helper_set_action_name (GtkActionHelper *helper, ...@@ -382,13 +407,18 @@ gtk_action_helper_set_action_name (GtkActionHelper *helper,
if (g_action_group_query_action (G_ACTION_GROUP (helper->action_context), helper->action_name, if (g_action_group_query_action (G_ACTION_GROUP (helper->action_context), helper->action_name,
&enabled, &parameter_type, NULL, NULL, &state)) &enabled, &parameter_type, NULL, NULL, &state))
{ {
GTK_NOTE(ACTIONS, g_message ("actionhelper: %s existed from the start", helper->action_name));
gtk_action_helper_action_added (helper, enabled, parameter_type, state, FALSE); gtk_action_helper_action_added (helper, enabled, parameter_type, state, FALSE);
if (state) if (state)
g_variant_unref (state); g_variant_unref (state);
} }
else else
helper->enabled = FALSE; {
GTK_NOTE(ACTIONS, g_message ("actionhelper: %s missing from the start", helper->action_name));
helper->enabled = FALSE;
}
/* Send the notifies for the properties that changed. /* Send the notifies for the properties that changed.
* *
......
...@@ -53,7 +53,8 @@ typedef enum { ...@@ -53,7 +53,8 @@ typedef enum {
GTK_DEBUG_PIXEL_CACHE = 1 << 15, GTK_DEBUG_PIXEL_CACHE = 1 << 15,
GTK_DEBUG_NO_PIXEL_CACHE = 1 << 16, GTK_DEBUG_NO_PIXEL_CACHE = 1 << 16,
GTK_DEBUG_INTERACTIVE = 1 << 17, GTK_DEBUG_INTERACTIVE = 1 << 17,
GTK_DEBUG_TOUCHSCREEN = 1 << 18 GTK_DEBUG_TOUCHSCREEN = 1 << 18,
GTK_DEBUG_ACTIONS = 1 << 19
} GtkDebugFlag; } GtkDebugFlag;
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
......
...@@ -178,7 +178,8 @@ static const GDebugKey gtk_debug_keys[] = { ...@@ -178,7 +178,8 @@ static const GDebugKey gtk_debug_keys[] = {
{"pixel-cache", GTK_DEBUG_PIXEL_CACHE}, {"pixel-cache", GTK_DEBUG_PIXEL_CACHE},
{"no-pixel-cache", GTK_DEBUG_NO_PIXEL_CACHE}, {"no-pixel-cache", GTK_DEBUG_NO_PIXEL_CACHE},
{"interactive", GTK_DEBUG_INTERACTIVE}, {"interactive", GTK_DEBUG_INTERACTIVE},
{"touchscreen", GTK_DEBUG_TOUCHSCREEN} {"touchscreen", GTK_DEBUG_TOUCHSCREEN},
{"actions", GTK_DEBUG_ACTIONS},
}; };
#endif /* G_ENABLE_DEBUG */ #endif /* G_ENABLE_DEBUG */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment