mirror of https://github.com/GNOME/gimp.git
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 commit
6544ce4301
.
This commit is contained in:
parent
b4aece8a27
commit
114d49510f
|
@ -348,29 +348,18 @@ gimp_action_history_is_excluded_action (const gchar *action_name)
|
||||||
g_strcmp0 (action_name, "filters-reshow") == 0);
|
g_strcmp0 (action_name, "filters-reshow") == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callback run on the `activate` signal of an action.
|
/* Called whenever a GimpAction is activated.
|
||||||
* It allows us to log all used action.
|
* It allows us to log all used actions.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gimp_action_history_activate_callback (GtkAction *action,
|
gimp_action_history_action_activated (GtkAction *action)
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
GimpGuiConfig *config;
|
GimpGuiConfig *config;
|
||||||
const gchar *action_name;
|
const gchar *action_name;
|
||||||
GList *link;
|
GList *link;
|
||||||
GimpActionHistoryItem *item;
|
GimpActionHistoryItem *item;
|
||||||
|
|
||||||
/* we can get here after gimp_action_history_exit() has been called, if
|
g_return_if_fail (history.gimp != NULL);
|
||||||
* 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;
|
|
||||||
|
|
||||||
config = GIMP_GUI_CONFIG (history.gimp->config);
|
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_blacklisted_action (const gchar *action_name);
|
||||||
gboolean gimp_action_history_is_excluded_action (const gchar *action_name);
|
gboolean gimp_action_history_is_excluded_action (const gchar *action_name);
|
||||||
|
|
||||||
void gimp_action_history_activate_callback (GtkAction *action,
|
void gimp_action_history_action_activated (GtkAction *action);
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_ACTION_HISTORY_H__ */
|
#endif /* __GIMP_ACTION_HISTORY_H__ */
|
||||||
|
|
|
@ -57,7 +57,6 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void gimp_action_constructed (GObject *object);
|
|
||||||
static void gimp_action_finalize (GObject *object);
|
static void gimp_action_finalize (GObject *object);
|
||||||
static void gimp_action_set_property (GObject *object,
|
static void gimp_action_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
|
@ -68,6 +67,7 @@ static void gimp_action_get_property (GObject *object,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec);
|
GParamSpec *pspec);
|
||||||
|
|
||||||
|
static void gimp_action_activate (GtkAction *action);
|
||||||
static void gimp_action_connect_proxy (GtkAction *action,
|
static void gimp_action_connect_proxy (GtkAction *action,
|
||||||
GtkWidget *proxy);
|
GtkWidget *proxy);
|
||||||
static void gimp_action_set_proxy (GimpAction *action,
|
static void gimp_action_set_proxy (GimpAction *action,
|
||||||
|
@ -91,11 +91,11 @@ gimp_action_class_init (GimpActionClass *klass)
|
||||||
GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
|
GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
|
||||||
GimpRGB black;
|
GimpRGB black;
|
||||||
|
|
||||||
object_class->constructed = gimp_action_constructed;
|
|
||||||
object_class->finalize = gimp_action_finalize;
|
object_class->finalize = gimp_action_finalize;
|
||||||
object_class->set_property = gimp_action_set_property;
|
object_class->set_property = gimp_action_set_property;
|
||||||
object_class->get_property = gimp_action_get_property;
|
object_class->get_property = gimp_action_get_property;
|
||||||
|
|
||||||
|
action_class->activate = gimp_action_activate;
|
||||||
action_class->connect_proxy = gimp_action_connect_proxy;
|
action_class->connect_proxy = gimp_action_connect_proxy;
|
||||||
|
|
||||||
gimp_rgba_set (&black, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
|
gimp_rgba_set (&black, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
|
||||||
|
@ -145,16 +145,6 @@ gimp_action_init (GimpAction *action)
|
||||||
NULL);
|
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
|
static void
|
||||||
gimp_action_finalize (GObject *object)
|
gimp_action_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
|
@ -262,6 +252,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
|
static void
|
||||||
gimp_action_connect_proxy (GtkAction *action,
|
gimp_action_connect_proxy (GtkAction *action,
|
||||||
GtkWidget *proxy)
|
GtkWidget *proxy)
|
||||||
|
|
|
@ -170,6 +170,8 @@ gimp_enum_action_activate (GtkAction *action)
|
||||||
{
|
{
|
||||||
GimpEnumAction *enum_action = GIMP_ENUM_ACTION (action);
|
GimpEnumAction *enum_action = GIMP_ENUM_ACTION (action);
|
||||||
|
|
||||||
|
GTK_ACTION_CLASS (parent_class)->activate (action);
|
||||||
|
|
||||||
gimp_enum_action_selected (enum_action, enum_action->value);
|
gimp_enum_action_selected (enum_action, enum_action->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,8 @@ gimp_procedure_action_activate (GtkAction *action)
|
||||||
{
|
{
|
||||||
GimpProcedureAction *procedure_action = GIMP_PROCEDURE_ACTION (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
|
/* Not all actions have procedures associated with them, for example
|
||||||
* unused "filters-recent-[N]" actions, so check for NULL before we
|
* unused "filters-recent-[N]" actions, so check for NULL before we
|
||||||
* invoke the action
|
* invoke the action
|
||||||
|
|
|
@ -175,6 +175,8 @@ gimp_string_action_activate (GtkAction *action)
|
||||||
{
|
{
|
||||||
GimpStringAction *string_action = GIMP_STRING_ACTION (action);
|
GimpStringAction *string_action = GIMP_STRING_ACTION (action);
|
||||||
|
|
||||||
|
GTK_ACTION_CLASS (parent_class)->activate (action);
|
||||||
|
|
||||||
gimp_string_action_selected (string_action, string_action->value);
|
gimp_string_action_selected (string_action, string_action->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue