Better debug messages for actions

Unify the debug messages between actionhelper and menutracker,
and add some more context to some of them.
This commit is contained in:
Matthias Clasen 2016-03-11 12:19:47 -05:00
parent baaa0637bf
commit 63b03ce836
2 changed files with 32 additions and 29 deletions

View File

@ -138,7 +138,7 @@ gtk_action_helper_action_added (GtkActionHelper *helper,
GVariant *state,
gboolean should_emit_signals)
{
GTK_NOTE(ACTIONS, g_message("actionhelper: %s added", helper->action_name));
GTK_NOTE(ACTIONS, g_message("%s: action %s added", "actionhelper", helper->action_name));
/* we can only activate if we have the correct type of parameter */
helper->can_activate = (helper->target == NULL && parameter_type == NULL) ||
@ -147,19 +147,20 @@ gtk_action_helper_action_added (GtkActionHelper *helper,
if (!helper->can_activate)
{
GTK_NOTE(ACTIONS, g_message("actionhelper: %s found, but disabled due to parameter type mismatch",
helper->action_name));
GTK_NOTE(ACTIONS, g_message ("%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"));
return;
}
GTK_NOTE(ACTIONS, g_message ("actionhelper: %s can be activated", helper->action_name));
GTK_NOTE(ACTIONS, g_message ("%s: %s can be activated", "actionhelper", helper->action_name));
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));
GTK_NOTE(ACTIONS, g_message ("%s: action %s is %s", "actionhelper", helper->action_name, enabled ? "enabled" : "disabled"));
if (helper->target != NULL && state != NULL)
{
@ -191,7 +192,7 @@ gtk_action_helper_action_added (GtkActionHelper *helper,
static void
gtk_action_helper_action_removed (GtkActionHelper *helper)
{
GTK_NOTE(ACTIONS, g_message ("actionhelper: %s was removed", helper->action_name));
GTK_NOTE(ACTIONS, g_message ("%s: action %s was removed", "actionhelper", helper->action_name));
if (!helper->can_activate)
return;
@ -215,7 +216,7 @@ static void
gtk_action_helper_action_enabled_changed (GtkActionHelper *helper,
gboolean enabled)
{
GTK_NOTE(ACTIONS, g_message ("actionhelper: %s enabled changed: %d", helper->action_name, enabled));
GTK_NOTE(ACTIONS, g_message ("%s: action %s: enabled changed to %d", "actionhelper", helper->action_name, enabled));
if (!helper->can_activate)
return;
@ -233,7 +234,7 @@ gtk_action_helper_action_state_changed (GtkActionHelper *helper,
{
gboolean was_active;
GTK_NOTE(ACTIONS, g_message ("actionhelper: %s state changed", helper->action_name));
GTK_NOTE(ACTIONS, g_message ("%s: %s state changed", "actionhelper", helper->action_name));
if (!helper->can_activate)
return;
@ -416,8 +417,9 @@ gtk_action_helper_set_action_name (GtkActionHelper *helper,
GTK_NOTE(ACTIONS,
if (action_name == NULL || !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));
g_message ("%s: action name %s doesn't look like 'app.' or 'win.'; "
"it is unlikely to work",
"actionhelper", action_name));
if (helper->action_name)
{
@ -442,7 +444,7 @@ gtk_action_helper_set_action_name (GtkActionHelper *helper,
if (g_action_group_query_action (G_ACTION_GROUP (helper->action_context), helper->action_name,
&enabled, &parameter_type, NULL, NULL, &state))
{
GTK_NOTE(ACTIONS, g_message ("actionhelper: %s existed from the start", helper->action_name));
GTK_NOTE(ACTIONS, g_message ("%s: action %s existed from the start", "actionhelper", helper->action_name));
gtk_action_helper_action_added (helper, enabled, parameter_type, state, FALSE);
@ -451,7 +453,7 @@ gtk_action_helper_set_action_name (GtkActionHelper *helper,
}
else
{
GTK_NOTE(ACTIONS, g_message ("actionhelper: %s missing from the start", helper->action_name));
GTK_NOTE(ACTIONS, g_message ("%s: action %s missing from the start", "actionhelper", helper->action_name));
helper->enabled = FALSE;
}

View File

@ -298,7 +298,7 @@ gtk_menu_tracker_item_action_added (GtkActionObserver *observer,
GtkMenuTrackerItem *self = GTK_MENU_TRACKER_ITEM (observer);
GVariant *action_target;
GTK_NOTE(ACTIONS, g_message("menutracker: %s added", action_name));
GTK_NOTE(ACTIONS, g_message ("menutracker: action %s added", action_name));
action_target = g_menu_item_get_attribute_value (self->item, G_MENU_ATTRIBUTE_TARGET, NULL);
@ -308,21 +308,22 @@ gtk_menu_tracker_item_action_added (GtkActionObserver *observer,
if (!self->can_activate)
{
GTK_NOTE(ACTIONS, g_message("menutracker: %s found, but disabled due to parameter type mismatch", action_name));
GTK_NOTE(ACTIONS, g_message ("menutracker: action %s can't be activated due to parameter type mismatch "
"(parameter type %s, target type %s)",
action_name,
parameter_type ? g_variant_type_peek_string (parameter_type) : "NULL",
action_target ? g_variant_get_type_string (action_target) : "NULL"));
if (action_target)
g_variant_unref (action_target);
return;
}
GTK_NOTE(ACTIONS, g_message ("menutracker: %s can be activated", action_name));
GTK_NOTE(ACTIONS, g_message ("menutracker: action %s can be activated", action_name));
self->sensitive = enabled;
if (!enabled)
GTK_NOTE(ACTIONS, g_message("menutracker: %s found, but disabled due to disabled action", action_name));
else
GTK_NOTE(ACTIONS, g_message("menutracker: %s found and enabled", action_name));
GTK_NOTE(ACTIONS, g_message ("menutracker: action %s is %s", action_name, enabled ? "enabled" : "disabled"));
if (action_target != NULL && state != NULL)
{
@ -367,7 +368,7 @@ gtk_menu_tracker_item_action_enabled_changed (GtkActionObserver *observer,
{
GtkMenuTrackerItem *self = GTK_MENU_TRACKER_ITEM (observer);
GTK_NOTE(ACTIONS, g_message ("menutracker: %s enabled changed: %d", action_name, enabled));
GTK_NOTE(ACTIONS, g_message ("menutracker: action %s: enabled changed to %d", action_name, enabled));
if (!self->can_activate)
return;
@ -392,7 +393,7 @@ gtk_menu_tracker_item_action_state_changed (GtkActionObserver *observer,
GVariant *action_target;
gboolean was_toggled;
GTK_NOTE(ACTIONS, g_message ("menutracker: %s state changed", action_name));
GTK_NOTE(ACTIONS, g_message ("menutracker: action %s: state changed", action_name));
if (!self->can_activate)
return;
@ -425,7 +426,7 @@ gtk_menu_tracker_item_action_removed (GtkActionObserver *observer,
gboolean was_sensitive, was_toggled;
GtkMenuTrackerItemRole old_role;
GTK_NOTE(ACTIONS, g_message ("menutracker: %s was removed", action_name));
GTK_NOTE(ACTIONS, g_message ("menutracker: action %s was removed", action_name));
if (!self->can_activate)
return;
@ -540,8 +541,8 @@ _gtk_menu_tracker_item_new (GtkActionObservable *observable,
GTK_NOTE(ACTIONS,
if (!strchr (action_name, '.'))
g_message ("menutracker: action name %s doesn't look like 'app.' or 'win.' "
"which means that it will probably not work properly.", action_name));
g_message ("menutracker: action name %s doesn't look like 'app.' or 'win.'; "
"it is unlikely to work", action_name));
state = NULL;
@ -550,12 +551,12 @@ _gtk_menu_tracker_item_new (GtkActionObservable *observable,
if (found)
{
GTK_NOTE(ACTIONS, g_message ("menutracker: %s existed from the start", action_name));
GTK_NOTE(ACTIONS, g_message ("menutracker: action %s existed from the start", action_name));
gtk_menu_tracker_item_action_added (GTK_ACTION_OBSERVER (self), observable, NULL, parameter_type, enabled, state);
}
else
{
GTK_NOTE(ACTIONS, g_message ("menutracker: %s missing from the start", action_name));
GTK_NOTE(ACTIONS, g_message ("menutracker: action %s missing from the start", action_name));
gtk_menu_tracker_item_update_visibility (self);
}