add all procedures that take an image paramter to the history of last-used

2006-08-08  Sven Neumann  <sven@gimp.org>

	* app/actions/plug-in-commands.c (plug_in_run_cmd_callback): add
	all procedures that take an image paramter to the history of
	last-used procedures. Fixes bug #348243.
	(plug_in_repeat_cmd_callback): use
plug_in_collect_drawable_args()
	to construct the procedure arguments.

	* app/actions/plug-in-actions.c
	* app/plug-in/gimppluginmanager.[ch]: renamed "last_plug_ins" to
	"history"; it's actually a list of procedures.
This commit is contained in:
Sven Neumann 2006-08-08 15:36:16 +00:00 committed by Sven Neumann
parent 75c54265ae
commit b65fa0215d
5 changed files with 77 additions and 76 deletions

View file

@ -1,3 +1,15 @@
2006-08-08 Sven Neumann <sven@gimp.org>
* app/actions/plug-in-commands.c (plug_in_run_cmd_callback): add
all procedures that take an image paramter to the history of
last-used procedures. Fixes bug #348243.
(plug_in_repeat_cmd_callback): use plug_in_collect_drawable_args()
to construct the procedure arguments.
* app/actions/plug-in-actions.c
* app/plug-in/gimppluginmanager.[ch]: renamed "last_plug_ins" to
"history"; it's actually a list of procedures.
2006-08-08 Sven Neumann <sven@gimp.org>
* tools/pdbgen/pdb/drawable.pdb: changed limits in

View file

@ -68,7 +68,7 @@ static void plug_in_actions_menu_path_added (GimpPlugInProcedure *proc,
static void plug_in_actions_add_proc (GimpActionGroup *group,
GimpPlugInProcedure *proc);
static void plug_in_actions_last_changed (GimpPlugInManager *manager,
static void plug_in_actions_history_changed (GimpPlugInManager *manager,
GimpActionGroup *group);
static gboolean plug_in_actions_check_translation (const gchar *original,
const gchar *translated);
@ -220,12 +220,11 @@ plug_in_actions_setup (GimpActionGroup *group)
g_free (entries);
g_signal_connect_object (group->gimp->plug_in_manager,
"last-plug-ins-changed",
G_CALLBACK (plug_in_actions_last_changed),
g_signal_connect_object (group->gimp->plug_in_manager, "history-changed",
G_CALLBACK (plug_in_actions_history_changed),
group, 0);
plug_in_actions_last_changed (group->gimp->plug_in_manager, group);
plug_in_actions_history_changed (group->gimp->plug_in_manager, group);
}
void
@ -234,7 +233,7 @@ plug_in_actions_update (GimpActionGroup *group,
{
GimpImage *image = action_data_get_image (data);
GimpPlugInManager *manager;
GimpImageType type = -1;
GimpImageType type = -1;
GSList *list;
gint i;
@ -258,8 +257,7 @@ plug_in_actions_update (GimpActionGroup *group,
! proc->prefixes &&
! proc->magics)
{
gboolean sensitive = gimp_plug_in_procedure_get_sensitive (proc,
type);
gboolean sensitive = gimp_plug_in_procedure_get_sensitive (proc, type);
gimp_action_group_set_action_sensitive (group,
GIMP_OBJECT (proc)->name,
@ -267,9 +265,8 @@ plug_in_actions_update (GimpActionGroup *group,
}
}
if (manager->last_plug_ins &&
gimp_plug_in_procedure_get_sensitive (manager->last_plug_ins->data,
type))
if (manager->history &&
gimp_plug_in_procedure_get_sensitive (manager->history->data, type))
{
gimp_action_group_set_action_sensitive (group, "plug-in-repeat", TRUE);
gimp_action_group_set_action_sensitive (group, "plug-in-reshow", TRUE);
@ -280,7 +277,7 @@ plug_in_actions_update (GimpActionGroup *group,
gimp_action_group_set_action_sensitive (group, "plug-in-reshow", FALSE);
}
for (list = manager->last_plug_ins, i = 0; list; list = list->next, i++)
for (list = manager->history, i = 0; list; list = list->next, i++)
{
GimpPlugInProcedure *proc = list->data;
gchar *name = g_strdup_printf ("plug-in-recent-%02d",
@ -506,17 +503,17 @@ plug_in_actions_add_proc (GimpActionGroup *group,
}
static void
plug_in_actions_last_changed (GimpPlugInManager *manager,
GimpActionGroup *group)
plug_in_actions_history_changed (GimpPlugInManager *manager,
GimpActionGroup *group)
{
GSList *list;
const gchar *progname;
const gchar *domain;
gint i;
if (manager->last_plug_ins)
if (manager->history)
{
GimpPlugInProcedure *proc = manager->last_plug_ins->data;
GimpPlugInProcedure *proc = manager->history->data;
gchar *label;
gchar *repeat;
gchar *reshow;
@ -546,7 +543,7 @@ plug_in_actions_last_changed (GimpPlugInManager *manager,
_("Re-Show Last"));
}
for (list = manager->last_plug_ins, i = 0; list; list = list->next, i++)
for (list = manager->history, i = 0; list; list = list->next, i++)
{
GtkAction *action;
GimpPlugInProcedure *proc = list->data;

View file

@ -156,16 +156,11 @@ plug_in_run_cmd_callback (GtkAction *action,
}
else
{
GimpImage *image;
display = action_data_get_display (data);
if (display)
image = display->image;
else
image = NULL;
n_args = plug_in_collect_drawable_args (action, image,
n_args = plug_in_collect_drawable_args (action,
display ?
display->image : NULL,
args, n_args);
}
break;
@ -185,13 +180,11 @@ plug_in_run_cmd_callback (GtkAction *action,
GIMP_PROGRESS (display), args,
GIMP_OBJECT (display));
/* remember only "standard" plug-ins */
if (procedure->proc_type == GIMP_PLUGIN &&
procedure->num_args >= 3 &&
GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[1]) &&
GIMP_IS_PARAM_SPEC_DRAWABLE_ID (procedure->args[2]))
/* remember only image plug-ins */
if (procedure->num_args >= 2 &&
GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[1]))
{
gimp_plug_in_manager_set_last_plug_in (gimp->plug_in_manager, proc);
gimp_plug_in_manager_set_last_proc (gimp->plug_in_manager, proc);
}
}
@ -206,37 +199,36 @@ plug_in_repeat_cmd_callback (GtkAction *action,
GimpProcedure *procedure;
Gimp *gimp;
GimpDisplay *display;
GimpDrawable *drawable;
gboolean interactive = TRUE;
return_if_no_gimp (gimp, data);
return_if_no_display (display, data);
drawable = gimp_image_active_drawable (display->image);
if (! drawable)
return;
if (strcmp (gtk_action_get_name (action), "plug-in-repeat") == 0)
interactive = FALSE;
procedure = g_slist_nth_data (gimp->plug_in_manager->last_plug_ins, value);
procedure = g_slist_nth_data (gimp->plug_in_manager->history, value);
if (procedure)
{
GValueArray *args = gimp_procedure_get_arguments (procedure);
gint n_args;
g_value_set_int (&args->values[0],
interactive ?
GIMP_RUN_INTERACTIVE : GIMP_RUN_WITH_LAST_VALS);
gimp_value_set_image (&args->values[1], display->image);
gimp_value_set_drawable (&args->values[2], drawable);
g_value_set_int (&args->values[0],
interactive ?
GIMP_RUN_INTERACTIVE : GIMP_RUN_WITH_LAST_VALS);
gimp_value_array_truncate (args, 3);
n_args = plug_in_collect_drawable_args (action, display->image, args, 1);
/* run the plug-in procedure */
gimp_procedure_execute_async (procedure, gimp,
gimp_get_user_context (gimp),
GIMP_PROGRESS (display), args,
GIMP_OBJECT (display));
if (n_args >= 1)
{
gimp_value_array_truncate (args, n_args);
/* run the plug-in procedure */
gimp_procedure_execute_async (procedure, gimp,
gimp_get_user_context (gimp),
GIMP_PROGRESS (display), args,
GIMP_OBJECT (display));
}
g_value_array_free (args);
}

View file

@ -62,7 +62,7 @@ enum
PLUG_IN_OPENED,
PLUG_IN_CLOSED,
MENU_BRANCH_ADDED,
LAST_PLUG_INS_CHANGED,
HISTORY_CHANGED,
LAST_SIGNAL
};
@ -132,12 +132,12 @@ gimp_plug_in_manager_class_init (GimpPlugInManagerClass *klass)
G_TYPE_STRING,
G_TYPE_STRING);
manager_signals[LAST_PLUG_INS_CHANGED] =
g_signal_new ("last-plug-ins-changed",
manager_signals[HISTORY_CHANGED] =
g_signal_new ("history-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GimpPlugInManagerClass,
last_plug_ins_changed),
history_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@ -162,7 +162,7 @@ gimp_plug_in_manager_init (GimpPlugInManager *manager)
manager->current_plug_in = NULL;
manager->open_plug_ins = NULL;
manager->plug_in_stack = NULL;
manager->last_plug_ins = NULL;
manager->history = NULL;
manager->shm = NULL;
manager->interpreter_db = gimp_interpreter_db_new ();
@ -196,10 +196,10 @@ gimp_plug_in_manager_finalize (GObject *object)
manager->plug_in_procedures = NULL;
}
if (manager->last_plug_ins)
if (manager->history)
{
g_slist_free (manager->last_plug_ins);
manager->last_plug_ins = NULL;
g_slist_free (manager->history);
manager->history = NULL;
}
if (manager->shm)
@ -684,14 +684,15 @@ gimp_plug_in_manager_remove_temp_proc (GimpPlugInManager *manager,
manager->plug_in_procedures = g_slist_remove (manager->plug_in_procedures,
procedure);
gimp_pdb_unregister_procedure (manager->gimp->pdb, GIMP_PROCEDURE (procedure));
gimp_pdb_unregister_procedure (manager->gimp->pdb,
GIMP_PROCEDURE (procedure));
g_object_unref (procedure);
}
void
gimp_plug_in_manager_set_last_plug_in (GimpPlugInManager *manager,
GimpPlugInProcedure *procedure)
gimp_plug_in_manager_set_last_proc (GimpPlugInManager *manager,
GimpPlugInProcedure *procedure)
{
GSList *list;
gint history_size;
@ -700,19 +701,18 @@ gimp_plug_in_manager_set_last_plug_in (GimpPlugInManager *manager,
history_size = MAX (1, manager->gimp->config->plug_in_history_size);
manager->last_plug_ins = g_slist_remove (manager->last_plug_ins, procedure);
manager->last_plug_ins = g_slist_prepend (manager->last_plug_ins, procedure);
manager->history = g_slist_remove (manager->history, procedure);
manager->history = g_slist_prepend (manager->history, procedure);
list = g_slist_nth (manager->last_plug_ins, history_size);
list = g_slist_nth (manager->history, history_size);
if (list)
{
manager->last_plug_ins = g_slist_remove_link (manager->last_plug_ins,
list);
manager->history = g_slist_remove_link (manager->history, list);
g_slist_free (list);
}
g_signal_emit (manager, manager_signals[LAST_PLUG_INS_CHANGED], 0);
g_signal_emit (manager, manager_signals[HISTORY_CHANGED], 0);
}
void

View file

@ -55,7 +55,7 @@ struct _GimpPlugInManager
GimpPlugIn *current_plug_in;
GSList *open_plug_ins;
GSList *plug_in_stack;
GSList *last_plug_ins;
GSList *history;
GimpPlugInShm *shm;
GimpInterpreterDB *interpreter_db;
@ -68,16 +68,16 @@ struct _GimpPlugInManagerClass
{
GimpObjectClass parent_class;
void (* plug_in_opened) (GimpPlugInManager *manager,
GimpPlugIn *plug_in);
void (* plug_in_closed) (GimpPlugInManager *manager,
GimpPlugIn *plug_in);
void (* plug_in_opened) (GimpPlugInManager *manager,
GimpPlugIn *plug_in);
void (* plug_in_closed) (GimpPlugInManager *manager,
GimpPlugIn *plug_in);
void (* menu_branch_added) (GimpPlugInManager *manager,
const gchar *prog_name,
const gchar *menu_path,
const gchar *menu_label);
void (* last_plug_ins_changed) (GimpPlugInManager *manager);
void (* menu_branch_added) (GimpPlugInManager *manager,
const gchar *prog_name,
const gchar *menu_path,
const gchar *menu_label);
void (* history_changed) (GimpPlugInManager *manager);
};
@ -109,7 +109,7 @@ void gimp_plug_in_manager_add_open_plug_in (GimpPlugInManager *manager,
void gimp_plug_in_manager_remove_open_plug_in (GimpPlugInManager *manager,
GimpPlugIn *plug_in);
void gimp_plug_in_manager_set_last_plug_in (GimpPlugInManager *manager,
void gimp_plug_in_manager_set_last_proc (GimpPlugInManager *manager,
GimpPlugInProcedure *procedure);
void gimp_plug_in_manager_plug_in_push (GimpPlugInManager *manager,