app: log actions upon activation before emitting "selected" signal
In GimpAction, instead of connecting the action-history log function to the action's "activate" signal as a user-provided handler, call it directly from the default handler. In subclasses of GimpAction, chain to the parent's activate() function before emitting the "selected" signal, so that we always log the action in the history before responding to it. This allows us to avoid the hack in commit6544ce4301
. (cherry picked from commit114d49510f
)
This commit is contained in:
@ -348,29 +348,18 @@ gimp_action_history_is_excluded_action (const gchar *action_name)
|
||||
g_strcmp0 (action_name, "filters-reshow") == 0);
|
||||
}
|
||||
|
||||
/* Callback run on the `activate` signal of an action.
|
||||
* It allows us to log all used action.
|
||||
/* Called whenever a GimpAction is activated.
|
||||
* It allows us to log all used actions.
|
||||
*/
|
||||
void
|
||||
gimp_action_history_activate_callback (GtkAction *action,
|
||||
gpointer user_data)
|
||||
gimp_action_history_action_activated (GtkAction *action)
|
||||
{
|
||||
GimpGuiConfig *config;
|
||||
const gchar *action_name;
|
||||
GList *link;
|
||||
GimpActionHistoryItem *item;
|
||||
|
||||
/* we can get here after gimp_action_history_exit() has been called, if
|
||||
* gimp_exit() was called during the execution of a temporary procedure,
|
||||
* which was executed in response to a GimpProcedureAction, such as a script-
|
||||
* fu script (temporary procedures run a nested mainloop, during which
|
||||
* anything can happen.) the GimpProcedureAction's "selected" signal, in
|
||||
* response to which the procedure is run, is emitted before any user-
|
||||
* provided "activate" handlers are invoked, and so this function will be
|
||||
* called *after* the procedure returns.
|
||||
*/
|
||||
if (! history.gimp)
|
||||
return;
|
||||
g_return_if_fail (history.gimp != NULL);
|
||||
|
||||
config = GIMP_GUI_CONFIG (history.gimp->config);
|
||||
|
||||
|
@ -40,8 +40,7 @@ GList * gimp_action_history_search (Gimp *gimp,
|
||||
gboolean gimp_action_history_is_blacklisted_action (const gchar *action_name);
|
||||
gboolean gimp_action_history_is_excluded_action (const gchar *action_name);
|
||||
|
||||
void gimp_action_history_activate_callback (GtkAction *action,
|
||||
gpointer user_data);
|
||||
void gimp_action_history_action_activated (GtkAction *action);
|
||||
|
||||
|
||||
#endif /* __GIMP_ACTION_HISTORY_H__ */
|
||||
|
@ -56,7 +56,6 @@ enum
|
||||
};
|
||||
|
||||
|
||||
static void gimp_action_constructed (GObject *object);
|
||||
static void gimp_action_finalize (GObject *object);
|
||||
static void gimp_action_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@ -67,6 +66,7 @@ static void gimp_action_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_action_activate (GtkAction *action);
|
||||
static void gimp_action_connect_proxy (GtkAction *action,
|
||||
GtkWidget *proxy);
|
||||
static void gimp_action_set_proxy (GimpAction *action,
|
||||
@ -90,11 +90,11 @@ gimp_action_class_init (GimpActionClass *klass)
|
||||
GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
|
||||
GimpRGB black;
|
||||
|
||||
object_class->constructed = gimp_action_constructed;
|
||||
object_class->finalize = gimp_action_finalize;
|
||||
object_class->set_property = gimp_action_set_property;
|
||||
object_class->get_property = gimp_action_get_property;
|
||||
|
||||
action_class->activate = gimp_action_activate;
|
||||
action_class->connect_proxy = gimp_action_connect_proxy;
|
||||
|
||||
gimp_rgba_set (&black, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
|
||||
@ -144,16 +144,6 @@ gimp_action_init (GimpAction *action)
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_constructed (GObject *object)
|
||||
{
|
||||
GimpAction *action = GIMP_ACTION (object);
|
||||
|
||||
g_signal_connect (action, "activate",
|
||||
(GCallback) gimp_action_history_activate_callback,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_finalize (GObject *object)
|
||||
{
|
||||
@ -261,6 +251,15 @@ gimp_action_set_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_activate (GtkAction *action)
|
||||
{
|
||||
if (GTK_ACTION_CLASS (parent_class)->activate)
|
||||
GTK_ACTION_CLASS (parent_class)->activate (action);
|
||||
|
||||
gimp_action_history_action_activated (action);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_connect_proxy (GtkAction *action,
|
||||
GtkWidget *proxy)
|
||||
|
@ -170,6 +170,8 @@ gimp_enum_action_activate (GtkAction *action)
|
||||
{
|
||||
GimpEnumAction *enum_action = GIMP_ENUM_ACTION (action);
|
||||
|
||||
GTK_ACTION_CLASS (parent_class)->activate (action);
|
||||
|
||||
gimp_enum_action_selected (enum_action, enum_action->value);
|
||||
}
|
||||
|
||||
|
@ -160,6 +160,8 @@ gimp_procedure_action_activate (GtkAction *action)
|
||||
{
|
||||
GimpProcedureAction *procedure_action = GIMP_PROCEDURE_ACTION (action);
|
||||
|
||||
GTK_ACTION_CLASS (parent_class)->activate (action);
|
||||
|
||||
/* Not all actions have procedures associated with them, for example
|
||||
* unused "filters-recent-[N]" actions, so check for NULL before we
|
||||
* invoke the action
|
||||
|
@ -175,6 +175,8 @@ gimp_string_action_activate (GtkAction *action)
|
||||
{
|
||||
GimpStringAction *string_action = GIMP_STRING_ACTION (action);
|
||||
|
||||
GTK_ACTION_CLASS (parent_class)->activate (action);
|
||||
|
||||
gimp_string_action_selected (string_action, string_action->value);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user