app: GtkAction -> GAction madness part two
Change all action callbacks so they can be invoked by a GAction:
- add GimpActionCallback typedef:
void (* cb) (GimpAction*, GVariant*, gpointer)
- change all action callbacks to the GimpActionCallback signature
- add "gimp-activate" and "gimp-change-state" signals to GimpAction,
with the same signature as the resp. GAction signals
- remove all other custom action signals and only use the new
GimpAction signals
- pass around appropriate GVariants containing booleans, int32,
strings
- badly hack around to force a GimpProcedure pointer into a
uint64 variant
- remove all G_CALLBACK() casts from all action callbacks,
they all have the same signature now
(cherry picked from commit 3b6b3fc189
)
This commit is contained in:
@ -25,20 +25,13 @@
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimpmarshal.h"
|
||||
|
||||
#include "pdb/gimpprocedure.h"
|
||||
|
||||
#include "gimpaction.h"
|
||||
#include "gimpaction-history.h"
|
||||
#include "gimpprocedureaction.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
SELECTED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
@ -66,8 +59,6 @@ G_DEFINE_TYPE (GimpProcedureAction, gimp_procedure_action,
|
||||
|
||||
#define parent_class gimp_procedure_action_parent_class
|
||||
|
||||
static guint action_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
|
||||
static void
|
||||
gimp_procedure_action_class_init (GimpProcedureActionClass *klass)
|
||||
@ -87,16 +78,6 @@ gimp_procedure_action_class_init (GimpProcedureActionClass *klass)
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_PROCEDURE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
|
||||
action_signals[SELECTED] =
|
||||
g_signal_new ("selected",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpProcedureActionClass, selected),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1,
|
||||
GIMP_TYPE_PROCEDURE);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -161,15 +142,19 @@ 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
|
||||
*/
|
||||
if (procedure_action->procedure)
|
||||
gimp_procedure_action_selected (procedure_action,
|
||||
procedure_action->procedure);
|
||||
{
|
||||
gsize hack = GPOINTER_TO_SIZE (procedure_action->procedure);
|
||||
|
||||
gimp_action_emit_activate (GIMP_ACTION (action),
|
||||
g_variant_new_uint64 (hack));
|
||||
|
||||
gimp_action_history_action_activated (GIMP_ACTION (action));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -241,12 +226,3 @@ gimp_procedure_action_new (const gchar *name,
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_procedure_action_selected (GimpProcedureAction *action,
|
||||
GimpProcedure *procedure)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_PROCEDURE_ACTION (action));
|
||||
|
||||
g_signal_emit (action, action_signals[SELECTED], 0, procedure);
|
||||
}
|
||||
|
Reference in New Issue
Block a user