app: rename GimpPlugInAction to GimpProcedureAction

and make the filter history keep around a list of GimpProcedures
instead of GimpPlugInProcedures. Still WIP and unfinished...
This commit is contained in:
Michael Natterer 2015-12-31 17:05:35 +01:00
parent 050229cb45
commit e0ab721361
16 changed files with 247 additions and 245 deletions

View File

@ -528,9 +528,9 @@ static const GimpEnumActionEntry filters_repeat_actions[] =
void void
filters_actions_setup (GimpActionGroup *group) filters_actions_setup (GimpActionGroup *group)
{ {
GimpPlugInActionEntry *entries; GimpProcedureActionEntry *entries;
gint n_entries; gint n_entries;
gint i; gint i;
gimp_action_group_add_actions (group, "filters-action", gimp_action_group_add_actions (group, "filters-action",
filters_menu_actions, filters_menu_actions,
@ -560,7 +560,7 @@ filters_actions_setup (GimpActionGroup *group)
n_entries = gimp_filter_history_size (group->gimp); n_entries = gimp_filter_history_size (group->gimp);
entries = g_new0 (GimpPlugInActionEntry, n_entries); entries = g_new0 (GimpProcedureActionEntry, n_entries);
for (i = 0; i < n_entries; i++) for (i = 0; i < n_entries; i++)
{ {
@ -573,8 +573,8 @@ filters_actions_setup (GimpActionGroup *group)
entries[i].help_id = GIMP_HELP_FILTER_RESHOW; entries[i].help_id = GIMP_HELP_FILTER_RESHOW;
} }
gimp_action_group_add_plug_in_actions (group, entries, n_entries, gimp_action_group_add_procedure_actions (group, entries, n_entries,
G_CALLBACK (filters_history_cmd_callback)); G_CALLBACK (filters_history_cmd_callback));
for (i = 0; i < n_entries; i++) for (i = 0; i < n_entries; i++)
{ {
@ -713,10 +713,11 @@ filters_actions_update (GimpActionGroup *group,
#undef SET_SENSITIVE #undef SET_SENSITIVE
{ {
GimpPlugInProcedure *proc = gimp_filter_history_nth (group->gimp, 0); GimpProcedure *proc = gimp_filter_history_nth (group->gimp, 0);
gint i; gint i;
if (proc && gimp_plug_in_procedure_get_sensitive (proc, drawable)) /* FIXME history */
if (proc && gimp_plug_in_procedure_get_sensitive (GIMP_PLUG_IN_PROCEDURE (proc), drawable))
{ {
gimp_action_group_set_action_sensitive (group, "filters-repeat", TRUE); gimp_action_group_set_action_sensitive (group, "filters-repeat", TRUE);
gimp_action_group_set_action_sensitive (group, "filters-reshow", TRUE); gimp_action_group_set_action_sensitive (group, "filters-reshow", TRUE);
@ -734,7 +735,8 @@ filters_actions_update (GimpActionGroup *group,
proc = gimp_filter_history_nth (group->gimp, i); proc = gimp_filter_history_nth (group->gimp, i);
sensitive = gimp_plug_in_procedure_get_sensitive (proc, drawable); /* FIXME history */
sensitive = gimp_plug_in_procedure_get_sensitive (GIMP_PLUG_IN_PROCEDURE (proc), drawable);
gimp_action_group_set_action_sensitive (group, name, sensitive); gimp_action_group_set_action_sensitive (group, name, sensitive);
@ -767,9 +769,9 @@ static void
filters_actions_history_changed (Gimp *gimp, filters_actions_history_changed (Gimp *gimp,
GimpActionGroup *group) GimpActionGroup *group)
{ {
GimpPlugInProcedure *proc; GimpProcedure *proc;
GimpActionGroup *plug_in_group; GimpActionGroup *plug_in_group;
gint i; gint i;
plug_in_group = filters_actions_get_plug_in_group (group); plug_in_group = filters_actions_get_plug_in_group (group);
@ -782,7 +784,8 @@ filters_actions_history_changed (Gimp *gimp,
gchar *reshow; gchar *reshow;
gboolean sensitive = FALSE; gboolean sensitive = FALSE;
label = gimp_plug_in_procedure_get_label (proc); /* FIXME history */
label = gimp_plug_in_procedure_get_label (GIMP_PLUG_IN_PROCEDURE (proc));
/* copy the sensitivity of the plug-in procedure's actual action /* copy the sensitivity of the plug-in procedure's actual action
* instead of calling filters_actions_update() because doing the * instead of calling filters_actions_update() because doing the
@ -836,14 +839,15 @@ filters_actions_history_changed (Gimp *gimp,
proc = gimp_filter_history_nth (gimp, i); proc = gimp_filter_history_nth (gimp, i);
if (proc->menu_label) /* FIXME history */
if (GIMP_PLUG_IN_PROCEDURE (proc)->menu_label)
{ {
label = dgettext (gimp_plug_in_procedure_get_locale_domain (proc), label = dgettext (gimp_plug_in_procedure_get_locale_domain (GIMP_PLUG_IN_PROCEDURE (proc)),
proc->menu_label); GIMP_PLUG_IN_PROCEDURE (proc)->menu_label);
} }
else else
{ {
label = gimp_plug_in_procedure_get_label (proc); label = gimp_plug_in_procedure_get_label (GIMP_PLUG_IN_PROCEDURE (proc));
} }
/* see comment above */ /* see comment above */
@ -861,8 +865,8 @@ filters_actions_history_changed (Gimp *gimp,
"sensitive", sensitive, "sensitive", sensitive,
"procedure", proc, "procedure", proc,
"label", label, "label", label,
"icon-name", gimp_plug_in_procedure_get_icon_name (proc), "icon-name", gimp_plug_in_procedure_get_icon_name (GIMP_PLUG_IN_PROCEDURE (proc)),
"tooltip", gimp_plug_in_procedure_get_blurb (proc), "tooltip", gimp_plug_in_procedure_get_blurb (GIMP_PLUG_IN_PROCEDURE (proc)),
NULL); NULL);
} }

View File

@ -103,10 +103,10 @@ filters_repeat_cmd_callback (GtkAction *action,
gint value, gint value,
gpointer data) gpointer data)
{ {
GimpPlugInProcedure *procedure; GimpProcedure *procedure;
Gimp *gimp; Gimp *gimp;
GimpDisplay *display; GimpDisplay *display;
GimpRunMode run_mode; GimpRunMode run_mode;
return_if_no_gimp (gimp, data); return_if_no_gimp (gimp, data);
return_if_no_display (display, data); return_if_no_display (display, data);
@ -119,12 +119,12 @@ filters_repeat_cmd_callback (GtkAction *action,
GimpValueArray *args; GimpValueArray *args;
gint n_args; gint n_args;
args = gimp_procedure_get_arguments (GIMP_PROCEDURE (procedure)); args = gimp_procedure_get_arguments (procedure);
g_value_set_int (gimp_value_array_index (args, 0), run_mode); g_value_set_int (gimp_value_array_index (args, 0), run_mode);
n_args = plug_in_collect_display_args (action, display, n_args = plug_in_collect_display_args (action, display,
GIMP_PROCEDURE (procedure)->args, procedure->args,
args, 1); args, 1);
plug_in_procedure_execute (procedure, gimp, display, args, n_args); plug_in_procedure_execute (procedure, gimp, display, args, n_args);
@ -134,9 +134,9 @@ filters_repeat_cmd_callback (GtkAction *action,
} }
void void
filters_history_cmd_callback (GtkAction *action, filters_history_cmd_callback (GtkAction *action,
GimpPlugInProcedure *procedure, GimpProcedure *procedure,
gpointer data) gpointer data)
{ {
Gimp *gimp; Gimp *gimp;
GimpDisplay *display; GimpDisplay *display;
@ -145,12 +145,12 @@ filters_history_cmd_callback (GtkAction *action,
return_if_no_gimp (gimp, data); return_if_no_gimp (gimp, data);
return_if_no_display (display, data); return_if_no_display (display, data);
args = gimp_procedure_get_arguments (GIMP_PROCEDURE (procedure)); args = gimp_procedure_get_arguments (procedure);
g_value_set_int (gimp_value_array_index (args, 0), GIMP_RUN_INTERACTIVE); g_value_set_int (gimp_value_array_index (args, 0), GIMP_RUN_INTERACTIVE);
n_args = plug_in_collect_display_args (action, display, n_args = plug_in_collect_display_args (action, display,
GIMP_PROCEDURE (procedure)->args, procedure->args,
args, 1); args, 1);
plug_in_procedure_execute (procedure, gimp, display, args, n_args); plug_in_procedure_execute (procedure, gimp, display, args, n_args);

View File

@ -19,16 +19,16 @@
#define __FILTERS_COMMANDS_H__ #define __FILTERS_COMMANDS_H__
void filters_filter_cmd_callback (GtkAction *action, void filters_filter_cmd_callback (GtkAction *action,
const gchar *operation, const gchar *operation,
gpointer data); gpointer data);
void filters_repeat_cmd_callback (GtkAction *action, void filters_repeat_cmd_callback (GtkAction *action,
gint value, gint value,
gpointer data); gpointer data);
void filters_history_cmd_callback (GtkAction *action, void filters_history_cmd_callback (GtkAction *action,
GimpPlugInProcedure *proc, GimpProcedure *procedure,
gpointer data); gpointer data);
#endif /* __FILTERS_COMMANDS_H__ */ #endif /* __FILTERS_COMMANDS_H__ */

View File

@ -284,11 +284,11 @@ static void
plug_in_actions_add_proc (GimpActionGroup *group, plug_in_actions_add_proc (GimpActionGroup *group,
GimpPlugInProcedure *proc) GimpPlugInProcedure *proc)
{ {
GimpPlugInActionEntry entry; GimpProcedureActionEntry entry;
const gchar *locale_domain; const gchar *locale_domain;
const gchar *label; const gchar *label;
gchar *path_original = NULL; gchar *path_original = NULL;
gchar *path_translated = NULL; gchar *path_translated = NULL;
locale_domain = gimp_plug_in_procedure_get_locale_domain (proc); locale_domain = gimp_plug_in_procedure_get_locale_domain (proc);
@ -337,7 +337,7 @@ plug_in_actions_add_proc (GimpActionGroup *group,
entry.label = label; entry.label = label;
entry.accelerator = NULL; entry.accelerator = NULL;
entry.tooltip = gimp_plug_in_procedure_get_blurb (proc); entry.tooltip = gimp_plug_in_procedure_get_blurb (proc);
entry.procedure = proc; entry.procedure = GIMP_PROCEDURE (proc);
entry.help_id = gimp_plug_in_procedure_get_help_id (proc); entry.help_id = gimp_plug_in_procedure_get_help_id (proc);
#if 0 #if 0
@ -345,8 +345,8 @@ plug_in_actions_add_proc (GimpActionGroup *group,
gimp_object_get_name (proc), label); gimp_object_get_name (proc), label);
#endif #endif
gimp_action_group_add_plug_in_actions (group, &entry, 1, gimp_action_group_add_procedure_actions (group, &entry, 1,
G_CALLBACK (plug_in_run_cmd_callback)); G_CALLBACK (plug_in_run_cmd_callback));
g_free ((gchar *) entry.help_id); g_free ((gchar *) entry.help_id);

View File

@ -64,7 +64,7 @@
/* local function prototypes */ /* local function prototypes */
#if 0 #if 0
static void plug_in_procedure_execute (GimpPlugInProcedure *procedure, static void plug_in_procedure_execute (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpDisplay *display, GimpDisplay *display,
GimpValueArray *args, GimpValueArray *args,
@ -102,11 +102,10 @@ static void plug_in_reset_all_response (GtkWidget *dialog,
/* public functions */ /* public functions */
void void
plug_in_run_cmd_callback (GtkAction *action, plug_in_run_cmd_callback (GtkAction *action,
GimpPlugInProcedure *proc, GimpProcedure *procedure,
gpointer data) gpointer data)
{ {
GimpProcedure *procedure = GIMP_PROCEDURE (proc);
Gimp *gimp; Gimp *gimp;
GimpValueArray *args; GimpValueArray *args;
gint n_args = 0; gint n_args = 0;
@ -192,7 +191,7 @@ plug_in_run_cmd_callback (GtkAction *action,
} }
if (n_args >= 1) if (n_args >= 1)
plug_in_procedure_execute (proc, gimp, display, args, n_args); plug_in_procedure_execute (procedure, gimp, display, args, n_args);
gimp_value_array_unref (args); gimp_value_array_unref (args);
} }
@ -235,18 +234,18 @@ plug_in_reset_all_cmd_callback (GtkAction *action,
/* FIXME history */ /* FIXME history */
void void
plug_in_procedure_execute (GimpPlugInProcedure *procedure, plug_in_procedure_execute (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpDisplay *display, GimpDisplay *display,
GimpValueArray *args, GimpValueArray *args,
gint n_args) gint n_args)
{ {
GError *error = NULL; GError *error = NULL;
gimp_value_array_truncate (args, n_args); gimp_value_array_truncate (args, n_args);
/* run the plug-in procedure */ /* run the plug-in procedure */
gimp_procedure_execute_async (GIMP_PROCEDURE (procedure), gimp, gimp_procedure_execute_async (procedure, gimp,
gimp_get_user_context (gimp), gimp_get_user_context (gimp),
GIMP_PROGRESS (display), args, GIMP_PROGRESS (display), args,
GIMP_OBJECT (display), &error); GIMP_OBJECT (display), &error);
@ -261,8 +260,8 @@ plug_in_procedure_execute (GimpPlugInProcedure *procedure,
else else
{ {
/* remember only image plug-ins */ /* remember only image plug-ins */
if (GIMP_PROCEDURE (procedure)->num_args >= 2 && if (procedure->num_args >= 2 &&
GIMP_IS_PARAM_SPEC_IMAGE_ID (GIMP_PROCEDURE (procedure)->args[1])) GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[1]))
{ {
gimp_filter_history_add (gimp, procedure); gimp_filter_history_add (gimp, procedure);
} }

View File

@ -19,20 +19,20 @@
#define __PLUG_IN_COMMANDS_H__ #define __PLUG_IN_COMMANDS_H__
void plug_in_run_cmd_callback (GtkAction *action, void plug_in_run_cmd_callback (GtkAction *action,
GimpPlugInProcedure *proc, GimpProcedure *proc,
gpointer data); gpointer data);
void plug_in_reset_all_cmd_callback (GtkAction *action, void plug_in_reset_all_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
/* FIXME history */ /* FIXME history */
void plug_in_procedure_execute (GimpPlugInProcedure *procedure, void plug_in_procedure_execute (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpDisplay *display, GimpDisplay *display,
GimpValueArray *args, GimpValueArray *args,
gint n_args); gint n_args);
gint plug_in_collect_display_args (GtkAction *action, gint plug_in_collect_display_args (GtkAction *action,
GimpDisplay *display, GimpDisplay *display,
GParamSpec **pspecs, GParamSpec **pspecs,

View File

@ -30,11 +30,10 @@
#include "gimp.h" #include "gimp.h"
#include "gimp-filter-history.h" #include "gimp-filter-history.h"
#include "plug-in/gimppluginmanager.h" #include "pdb/gimpprocedure.h"
#include "plug-in/gimppluginprocedure.h"
guint gint
gimp_filter_history_size (Gimp *gimp) gimp_filter_history_size (Gimp *gimp)
{ {
g_return_val_if_fail (GIMP_IS_GIMP (gimp), 0); g_return_val_if_fail (GIMP_IS_GIMP (gimp), 0);
@ -42,7 +41,7 @@ gimp_filter_history_size (Gimp *gimp)
return MAX (1, gimp->config->filter_history_size); return MAX (1, gimp->config->filter_history_size);
} }
guint gint
gimp_filter_history_length (Gimp *gimp) gimp_filter_history_length (Gimp *gimp)
{ {
g_return_val_if_fail (GIMP_IS_GIMP (gimp), 0); g_return_val_if_fail (GIMP_IS_GIMP (gimp), 0);
@ -50,7 +49,7 @@ gimp_filter_history_length (Gimp *gimp)
return g_list_length (gimp->filter_history); return g_list_length (gimp->filter_history);
} }
GimpPlugInProcedure * GimpProcedure *
gimp_filter_history_nth (Gimp *gimp, gimp_filter_history_nth (Gimp *gimp,
gint n) gint n)
{ {
@ -60,14 +59,14 @@ gimp_filter_history_nth (Gimp *gimp,
} }
void void
gimp_filter_history_add (Gimp *gimp, gimp_filter_history_add (Gimp *gimp,
GimpPlugInProcedure *procedure) GimpProcedure *procedure)
{ {
GList *link; GList *link;
gint history_size; gint history_size;
g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (procedure)); g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
/* return early if the procedure is already at the top */ /* return early if the procedure is already at the top */
if (gimp->filter_history && gimp->filter_history->data == procedure) if (gimp->filter_history && gimp->filter_history->data == procedure)
@ -101,13 +100,13 @@ gimp_filter_history_add (Gimp *gimp,
} }
void void
gimp_filter_history_remove (Gimp *gimp, gimp_filter_history_remove (Gimp *gimp,
GimpPlugInProcedure *procedure) GimpProcedure *procedure)
{ {
GList *link; GList *link;
g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (procedure)); g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
link = g_list_find (gimp->filter_history, procedure); link = g_list_find (gimp->filter_history, procedure);
@ -133,5 +132,3 @@ gimp_filter_history_clear (Gimp *gimp)
gimp_filter_history_changed (gimp); gimp_filter_history_changed (gimp);
} }
} }

View File

@ -21,15 +21,15 @@
#define __GIMP_FILTER_HISTORY_H__ #define __GIMP_FILTER_HISTORY_H__
guint gimp_filter_history_size (Gimp *gimp); gint gimp_filter_history_size (Gimp *gimp);
guint gimp_filter_history_length (Gimp *gimp); gint gimp_filter_history_length (Gimp *gimp);
GimpPlugInProcedure * gimp_filter_history_nth (Gimp *gimp, GimpProcedure * gimp_filter_history_nth (Gimp *gimp,
gint n); gint n);
void gimp_filter_history_add (Gimp *gimp, void gimp_filter_history_add (Gimp *gimp,
GimpPlugInProcedure *procedure); GimpProcedure *procedure);
void gimp_filter_history_remove (Gimp *gimp, void gimp_filter_history_remove (Gimp *gimp,
GimpPlugInProcedure *procedure); GimpProcedure *procedure);
void gimp_filter_history_clear (Gimp *gimp); void gimp_filter_history_clear (Gimp *gimp);
#endif /* __GIMP_FILTER_HISTORY_H__ */ #endif /* __GIMP_FILTER_HISTORY_H__ */

View File

@ -337,7 +337,7 @@ gimp_plug_in_manager_add_procedure (GimpPlugInManager *manager,
manager->export_procs = g_slist_remove (manager->export_procs, tmp_proc); manager->export_procs = g_slist_remove (manager->export_procs, tmp_proc);
/* and from the history */ /* and from the history */
gimp_filter_history_remove (manager->gimp, tmp_proc); gimp_filter_history_remove (manager->gimp, GIMP_PROCEDURE (tmp_proc));
g_object_unref (tmp_proc); g_object_unref (tmp_proc);
@ -373,7 +373,7 @@ gimp_plug_in_manager_remove_temp_proc (GimpPlugInManager *manager,
procedure); procedure);
gimp_filter_history_remove (manager->gimp, gimp_filter_history_remove (manager->gimp,
GIMP_PLUG_IN_PROCEDURE (procedure)); GIMP_PROCEDURE (procedure));
gimp_pdb_unregister_procedure (manager->gimp->pdb, gimp_pdb_unregister_procedure (manager->gimp->pdb,
GIMP_PROCEDURE (procedure)); GIMP_PROCEDURE (procedure));

View File

@ -278,14 +278,14 @@ libappwidgets_a_sources = \
gimppickablepopup.h \ gimppickablepopup.h \
gimppixbuf.c \ gimppixbuf.c \
gimppixbuf.h \ gimppixbuf.h \
gimppluginaction.c \
gimppluginaction.h \
gimppolar.c \ gimppolar.c \
gimppolar.h \ gimppolar.h \
gimppopup.c \ gimppopup.c \
gimppopup.h \ gimppopup.h \
gimpprefsbox.c \ gimpprefsbox.c \
gimpprefsbox.h \ gimpprefsbox.h \
gimpprocedureaction.c \
gimpprocedureaction.h \
gimpprogressbox.c \ gimpprogressbox.c \
gimpprogressbox.h \ gimpprogressbox.h \
gimpprogressdialog.c \ gimpprogressdialog.c \

View File

@ -35,7 +35,7 @@
#include "gimpactiongroup.h" #include "gimpactiongroup.h"
#include "gimpaction.h" #include "gimpaction.h"
#include "gimpenumaction.h" #include "gimpenumaction.h"
#include "gimppluginaction.h" #include "gimpprocedureaction.h"
#include "gimpradioaction.h" #include "gimpradioaction.h"
#include "gimpstringaction.h" #include "gimpstringaction.h"
#include "gimptoggleaction.h" #include "gimptoggleaction.h"
@ -636,10 +636,10 @@ gimp_action_group_add_string_actions (GimpActionGroup *group,
} }
void void
gimp_action_group_add_plug_in_actions (GimpActionGroup *group, gimp_action_group_add_procedure_actions (GimpActionGroup *group,
const GimpPlugInActionEntry *entries, const GimpProcedureActionEntry *entries,
guint n_entries, guint n_entries,
GCallback callback) GCallback callback)
{ {
gint i; gint i;
@ -647,16 +647,16 @@ gimp_action_group_add_plug_in_actions (GimpActionGroup *group,
for (i = 0; i < n_entries; i++) for (i = 0; i < n_entries; i++)
{ {
GimpPlugInAction *action; GimpProcedureAction *action;
if (! gimp_action_group_check_unique_action (group, entries[i].name)) if (! gimp_action_group_check_unique_action (group, entries[i].name))
continue; continue;
action = gimp_plug_in_action_new (entries[i].name, action = gimp_procedure_action_new (entries[i].name,
entries[i].label, entries[i].label,
entries[i].tooltip, entries[i].tooltip,
entries[i].icon_name, entries[i].icon_name,
entries[i].procedure); entries[i].procedure);
if (callback) if (callback)
g_signal_connect (action, "selected", g_signal_connect (action, "selected",

View File

@ -118,16 +118,16 @@ struct _GimpStringActionEntry
const gchar *help_id; const gchar *help_id;
}; };
struct _GimpPlugInActionEntry struct _GimpProcedureActionEntry
{ {
const gchar *name; const gchar *name;
const gchar *icon_name; const gchar *icon_name;
const gchar *label; const gchar *label;
const gchar *accelerator; const gchar *accelerator;
const gchar *tooltip; const gchar *tooltip;
GimpPlugInProcedure *procedure; GimpProcedure *procedure;
const gchar *help_id; const gchar *help_id;
}; };
@ -170,8 +170,8 @@ void gimp_action_group_add_string_actions (GimpActionGroup *grou
const GimpStringActionEntry *entries, const GimpStringActionEntry *entries,
guint n_entries, guint n_entries,
GCallback callback); GCallback callback);
void gimp_action_group_add_plug_in_actions (GimpActionGroup *group, void gimp_action_group_add_procedure_actions(GimpActionGroup *group,
const GimpPlugInActionEntry *entries, const GimpProcedureActionEntry *entries,
guint n_entries, guint n_entries,
GCallback callback); GCallback callback);

View File

@ -1,65 +0,0 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimppluginaction.h
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_PLUG_IN_ACTION_H__
#define __GIMP_PLUG_IN_ACTION_H__
#include "gimpaction.h"
#define GIMP_TYPE_PLUG_IN_ACTION (gimp_plug_in_action_get_type ())
#define GIMP_PLUG_IN_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PLUG_IN_ACTION, GimpPlugInAction))
#define GIMP_PLUG_IN_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PLUG_IN_ACTION, GimpPlugInActionClass))
#define GIMP_IS_PLUG_IN_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PLUG_IN_ACTION))
#define GIMP_IS_PLUG_IN_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GIMP_TYPE_PLUG_IN_ACTION))
#define GIMP_PLUG_IN_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GIMP_TYPE_PLUG_IN_ACTION, GimpPlugInActionClass))
typedef struct _GimpPlugInActionClass GimpPlugInActionClass;
struct _GimpPlugInAction
{
GimpAction parent_instance;
GimpPlugInProcedure *procedure;
};
struct _GimpPlugInActionClass
{
GimpActionClass parent_class;
void (* selected) (GimpPlugInAction *action,
GimpPlugInProcedure *proc);
};
GType gimp_plug_in_action_get_type (void) G_GNUC_CONST;
GimpPlugInAction * gimp_plug_in_action_new (const gchar *name,
const gchar *label,
const gchar *tooltip,
const gchar *icon_name,
GimpPlugInProcedure *procedure);
void gimp_plug_in_action_selected (GimpPlugInAction *action,
GimpPlugInProcedure *procedure);
#endif /* __GIMP_PLUG_IN_ACTION_H__ */

View File

@ -1,8 +1,8 @@
/* GIMP - The GNU Image Manipulation Program /* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis * Copyright (C) 1995 Spencer Kimball and Peter Mattis
* *
* gimppluginaction.c * gimpprocedureaction.c
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org> * Copyright (C) 2004-2016 Michael Natterer <mitch@gimp.org>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,9 +26,9 @@
#include "core/gimpmarshal.h" #include "core/gimpmarshal.h"
#include "plug-in/gimppluginprocedure.h" #include "plug-in/gimppluginprocedure.h" /* FIXME history */
#include "gimppluginaction.h" #include "gimpprocedureaction.h"
enum enum
@ -44,68 +44,68 @@ enum
}; };
static void gimp_plug_in_action_finalize (GObject *object); static void gimp_procedure_action_finalize (GObject *object);
static void gimp_plug_in_action_set_property (GObject *object, static void gimp_procedure_action_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gimp_plug_in_action_get_property (GObject *object, static void gimp_procedure_action_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gimp_plug_in_action_activate (GtkAction *action); static void gimp_procedure_action_activate (GtkAction *action);
static void gimp_plug_in_action_connect_proxy (GtkAction *action, static void gimp_procedure_action_connect_proxy (GtkAction *action,
GtkWidget *proxy); GtkWidget *proxy);
G_DEFINE_TYPE (GimpPlugInAction, gimp_plug_in_action, GIMP_TYPE_ACTION) G_DEFINE_TYPE (GimpProcedureAction, gimp_procedure_action, GIMP_TYPE_ACTION)
#define parent_class gimp_plug_in_action_parent_class #define parent_class gimp_procedure_action_parent_class
static guint action_signals[LAST_SIGNAL] = { 0 }; static guint action_signals[LAST_SIGNAL] = { 0 };
static void static void
gimp_plug_in_action_class_init (GimpPlugInActionClass *klass) gimp_procedure_action_class_init (GimpProcedureActionClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkActionClass *action_class = GTK_ACTION_CLASS (klass); GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
object_class->finalize = gimp_plug_in_action_finalize; object_class->finalize = gimp_procedure_action_finalize;
object_class->set_property = gimp_plug_in_action_set_property; object_class->set_property = gimp_procedure_action_set_property;
object_class->get_property = gimp_plug_in_action_get_property; object_class->get_property = gimp_procedure_action_get_property;
action_class->activate = gimp_plug_in_action_activate; action_class->activate = gimp_procedure_action_activate;
action_class->connect_proxy = gimp_plug_in_action_connect_proxy; action_class->connect_proxy = gimp_procedure_action_connect_proxy;
g_object_class_install_property (object_class, PROP_PROCEDURE, g_object_class_install_property (object_class, PROP_PROCEDURE,
g_param_spec_object ("procedure", g_param_spec_object ("procedure",
NULL, NULL, NULL, NULL,
GIMP_TYPE_PLUG_IN_PROCEDURE, GIMP_TYPE_PROCEDURE,
GIMP_PARAM_READWRITE)); GIMP_PARAM_READWRITE));
action_signals[SELECTED] = action_signals[SELECTED] =
g_signal_new ("selected", g_signal_new ("selected",
G_TYPE_FROM_CLASS (klass), G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpPlugInActionClass, selected), G_STRUCT_OFFSET (GimpProcedureActionClass, selected),
NULL, NULL, NULL, NULL,
gimp_marshal_VOID__OBJECT, gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
GIMP_TYPE_PLUG_IN_PROCEDURE); GIMP_TYPE_PROCEDURE);
} }
static void static void
gimp_plug_in_action_init (GimpPlugInAction *action) gimp_procedure_action_init (GimpProcedureAction *action)
{ {
action->procedure = NULL; action->procedure = NULL;
} }
static void static void
gimp_plug_in_action_finalize (GObject *object) gimp_procedure_action_finalize (GObject *object)
{ {
GimpPlugInAction *action = GIMP_PLUG_IN_ACTION (object); GimpProcedureAction *action = GIMP_PROCEDURE_ACTION (object);
if (action->procedure) if (action->procedure)
{ {
@ -117,12 +117,12 @@ gimp_plug_in_action_finalize (GObject *object)
} }
static void static void
gimp_plug_in_action_get_property (GObject *object, gimp_procedure_action_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpPlugInAction *action = GIMP_PLUG_IN_ACTION (object); GimpProcedureAction *action = GIMP_PROCEDURE_ACTION (object);
switch (prop_id) switch (prop_id)
{ {
@ -137,12 +137,12 @@ gimp_plug_in_action_get_property (GObject *object,
} }
static void static void
gimp_plug_in_action_set_property (GObject *object, gimp_procedure_action_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GimpPlugInAction *action = GIMP_PLUG_IN_ACTION (object); GimpProcedureAction *action = GIMP_PROCEDURE_ACTION (object);
switch (prop_id) switch (prop_id)
{ {
@ -159,31 +159,33 @@ gimp_plug_in_action_set_property (GObject *object,
} }
static void static void
gimp_plug_in_action_activate (GtkAction *action) gimp_procedure_action_activate (GtkAction *action)
{ {
GimpPlugInAction *plug_in_action = GIMP_PLUG_IN_ACTION (action); GimpProcedureAction *procedure_action = GIMP_PROCEDURE_ACTION (action);
/* Not all actions have procedures associated with them, for example /* Not all actions have procedures associated with them, for example
* unused "plug-in-recent-[N]" actions, so check for NULL before we * unused "plug-in-recent-[N]" actions, so check for NULL before we
* invoke the plug-in action * invoke the action
*/ */
if (plug_in_action->procedure) if (procedure_action->procedure)
gimp_plug_in_action_selected (plug_in_action, plug_in_action->procedure); gimp_procedure_action_selected (procedure_action,
procedure_action->procedure);
} }
static void static void
gimp_plug_in_action_connect_proxy (GtkAction *action, gimp_procedure_action_connect_proxy (GtkAction *action,
GtkWidget *proxy) GtkWidget *proxy)
{ {
GimpPlugInAction *plug_in_action = GIMP_PLUG_IN_ACTION (action); GimpProcedureAction *procedure_action = GIMP_PROCEDURE_ACTION (action);
GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy); GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);
if (GTK_IS_IMAGE_MENU_ITEM (proxy) && plug_in_action->procedure) if (GTK_IS_IMAGE_MENU_ITEM (proxy) && procedure_action->procedure)
{ {
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
pixbuf = gimp_plug_in_procedure_get_pixbuf (plug_in_action->procedure); /* FIXME history */
pixbuf = gimp_plug_in_procedure_get_pixbuf (GIMP_PLUG_IN_PROCEDURE (procedure_action->procedure));
if (pixbuf) if (pixbuf)
{ {
@ -216,14 +218,14 @@ gimp_plug_in_action_connect_proxy (GtkAction *action,
/* public functions */ /* public functions */
GimpPlugInAction * GimpProcedureAction *
gimp_plug_in_action_new (const gchar *name, gimp_procedure_action_new (const gchar *name,
const gchar *label, const gchar *label,
const gchar *tooltip, const gchar *tooltip,
const gchar *icon_name, const gchar *icon_name,
GimpPlugInProcedure *procedure) GimpProcedure *procedure)
{ {
return g_object_new (GIMP_TYPE_PLUG_IN_ACTION, return g_object_new (GIMP_TYPE_PROCEDURE_ACTION,
"name", name, "name", name,
"label", label, "label", label,
"tooltip", tooltip, "tooltip", tooltip,
@ -233,10 +235,10 @@ gimp_plug_in_action_new (const gchar *name,
} }
void void
gimp_plug_in_action_selected (GimpPlugInAction *action, gimp_procedure_action_selected (GimpProcedureAction *action,
GimpPlugInProcedure *procedure) GimpProcedure *procedure)
{ {
g_return_if_fail (GIMP_IS_PLUG_IN_ACTION (action)); g_return_if_fail (GIMP_IS_PROCEDURE_ACTION (action));
g_signal_emit (action, action_signals[SELECTED], 0, procedure); g_signal_emit (action, action_signals[SELECTED], 0, procedure);
} }

View File

@ -0,0 +1,65 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpprocedureaction.h
* Copyright (C) 2004-2016 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_PROCEDURE_ACTION_H__
#define __GIMP_PROCEDURE_ACTION_H__
#include "gimpaction.h"
#define GIMP_TYPE_PROCEDURE_ACTION (gimp_procedure_action_get_type ())
#define GIMP_PROCEDURE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PROCEDURE_ACTION, GimpProcedureAction))
#define GIMP_PROCEDURE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PROCEDURE_ACTION, GimpProcedureActionClass))
#define GIMP_IS_PROCEDURE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PROCEDURE_ACTION))
#define GIMP_IS_PROCEDURE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GIMP_TYPE_PROCEDURE_ACTION))
#define GIMP_PROCEDURE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GIMP_TYPE_PROCEDURE_ACTION, GimpProcedureActionClass))
typedef struct _GimpProcedureActionClass GimpProcedureActionClass;
struct _GimpProcedureAction
{
GimpAction parent_instance;
GimpProcedure *procedure;
};
struct _GimpProcedureActionClass
{
GimpActionClass parent_class;
void (* selected) (GimpProcedureAction *action,
GimpProcedure *procedure);
};
GType gimp_procedure_action_get_type (void) G_GNUC_CONST;
GimpProcedureAction * gimp_procedure_action_new (const gchar *name,
const gchar *label,
const gchar *tooltip,
const gchar *icon_name,
GimpProcedure *procedure);
void gimp_procedure_action_selected (GimpProcedureAction *action,
GimpProcedure *procedure);
#endif /* __GIMP_PROCEDURE_ACTION_H__ */

View File

@ -125,7 +125,7 @@ typedef struct _GimpActionFactory GimpActionFactory;
typedef struct _GimpActionGroup GimpActionGroup; typedef struct _GimpActionGroup GimpActionGroup;
typedef struct _GimpEnumAction GimpEnumAction; typedef struct _GimpEnumAction GimpEnumAction;
typedef struct _GimpMenuFactory GimpMenuFactory; typedef struct _GimpMenuFactory GimpMenuFactory;
typedef struct _GimpPlugInAction GimpPlugInAction; typedef struct _GimpProcedureAction GimpProcedureAction;
typedef struct _GimpStringAction GimpStringAction; typedef struct _GimpStringAction GimpStringAction;
typedef struct _GimpUIManager GimpUIManager; typedef struct _GimpUIManager GimpUIManager;
@ -265,7 +265,7 @@ typedef struct _GimpSessionManaged GimpSessionManaged;
typedef struct _GimpActionEntry GimpActionEntry; typedef struct _GimpActionEntry GimpActionEntry;
typedef struct _GimpEnumActionEntry GimpEnumActionEntry; typedef struct _GimpEnumActionEntry GimpEnumActionEntry;
typedef struct _GimpPlugInActionEntry GimpPlugInActionEntry; typedef struct _GimpProcedureActionEntry GimpProcedureActionEntry;
typedef struct _GimpRadioActionEntry GimpRadioActionEntry; typedef struct _GimpRadioActionEntry GimpRadioActionEntry;
typedef struct _GimpStringActionEntry GimpStringActionEntry; typedef struct _GimpStringActionEntry GimpStringActionEntry;
typedef struct _GimpToggleActionEntry GimpToggleActionEntry; typedef struct _GimpToggleActionEntry GimpToggleActionEntry;