[gimp/gimp-2-10] app: log actions upon activation before emitting "selected" signal
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: log actions upon activation before emitting "selected" signal
- Date: Fri, 6 Jul 2018 04:09:09 +0000 (UTC)
commit 4f20255675584a4b78a454765037cae2e2e62c96
Author: Ell <ell_se yahoo com>
Date: Fri Jul 6 00:00:16 2018 -0400
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
6544ce4301fa43636b4c282c7b4815e18fd653d1.
(cherry picked from commit 114d49510f2031e00aafafb6c4666b5213d0d0cf)
app/widgets/gimpaction-history.c | 19 ++++---------------
app/widgets/gimpaction-history.h | 3 +--
app/widgets/gimpaction.c | 23 +++++++++++------------
app/widgets/gimpenumaction.c | 2 ++
app/widgets/gimpprocedureaction.c | 2 ++
app/widgets/gimpstringaction.c | 2 ++
6 files changed, 22 insertions(+), 29 deletions(-)
---
diff --git a/app/widgets/gimpaction-history.c b/app/widgets/gimpaction-history.c
index e94aedc8a6..d693917386 100644
--- a/app/widgets/gimpaction-history.c
+++ b/app/widgets/gimpaction-history.c
@@ -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);
diff --git a/app/widgets/gimpaction-history.h b/app/widgets/gimpaction-history.h
index dc3cb1f8a3..26ca1a9ee9 100644
--- a/app/widgets/gimpaction-history.h
+++ b/app/widgets/gimpaction-history.h
@@ -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__ */
diff --git a/app/widgets/gimpaction.c b/app/widgets/gimpaction.c
index 0fe98c1212..cb209d81f0 100644
--- a/app/widgets/gimpaction.c
+++ b/app/widgets/gimpaction.c
@@ -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)
diff --git a/app/widgets/gimpenumaction.c b/app/widgets/gimpenumaction.c
index ba89aa27bb..f0b3db5af4 100644
--- a/app/widgets/gimpenumaction.c
+++ b/app/widgets/gimpenumaction.c
@@ -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);
}
diff --git a/app/widgets/gimpprocedureaction.c b/app/widgets/gimpprocedureaction.c
index da53b5f184..38d0afa809 100644
--- a/app/widgets/gimpprocedureaction.c
+++ b/app/widgets/gimpprocedureaction.c
@@ -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
diff --git a/app/widgets/gimpstringaction.c b/app/widgets/gimpstringaction.c
index a5f1cb97e5..d8cb1e2944 100644
--- a/app/widgets/gimpstringaction.c
+++ b/app/widgets/gimpstringaction.c
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]