app/config/gimpcoreconfig.[ch] app/config/gimprc-blurbs.h keep a history

2006-02-20  Sven Neumann  <sven@gimp.org>

	* app/config/gimpcoreconfig.[ch]
	* app/config/gimprc-blurbs.h
	* app/core/gimp.[ch]: keep a history of recently used plug-ins.

	* app/plug-in/plug-in-run.[ch] (plug_in_repeat): pass an index
	into the plug-in history.

	* app/actions/plug-in-actions.c
	* app/actions/plug-in-commands.c
	* app/menus/plug-in-menus.c
	* menus/image-menu.xml.in: added a submenu with recently used
	plug-ins to the Filters menu. Fixes bug #148855.
This commit is contained in:
Sven Neumann 2006-02-20 16:38:09 +00:00 committed by Sven Neumann
parent fd02e97a4f
commit d833630ad8
16 changed files with 241 additions and 53 deletions

View File

@ -1,3 +1,18 @@
2006-02-20 Sven Neumann <sven@gimp.org>
* app/config/gimpcoreconfig.[ch]
* app/config/gimprc-blurbs.h
* app/core/gimp.[ch]: keep a history of recently used plug-ins.
* app/plug-in/plug-in-run.[ch] (plug_in_repeat): pass an index
into the plug-in history.
* app/actions/plug-in-actions.c
* app/actions/plug-in-commands.c
* app/menus/plug-in-menus.c
* menus/image-menu.xml.in: added a submenu with recently used
plug-ins to the Filters menu. Fixes bug #148855.
2006-02-20 Sven Neumann <sven@gimp.org>
* app/tools/gimpmagnifytool.c: renamed to Zoom tool.

View File

@ -27,6 +27,8 @@
#include "actions-types.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
@ -60,6 +62,7 @@ static void plug_in_actions_build_path (GimpActionGroup *group,
static GimpActionEntry plug_in_actions[] =
{
{ "plug-in-menu", NULL, N_("Filte_rs") },
{ "plug-in-recent-menu", NULL, N_("Recently Used") },
{ "plug-in-blur-menu", NULL, N_("_Blur") },
{ "plug-in-noise-menu", NULL, N_("_Noise") },
{ "plug-in-edge-detect-menu", NULL, N_("Edge-De_tect") },
@ -87,12 +90,12 @@ static GimpEnumActionEntry plug_in_repeat_actions[] =
{
{ "plug-in-repeat", GTK_STOCK_EXECUTE,
N_("Re_peat Last"), "<control>F", NULL,
FALSE, FALSE,
0, FALSE,
GIMP_HELP_FILTER_REPEAT },
{ "plug-in-reshow", GIMP_STOCK_RESHOW_FILTER,
N_("R_e-Show Last"), "<control><shift>F", NULL,
TRUE, FALSE,
0, FALSE,
GIMP_HELP_FILTER_RESHOW }
};
@ -102,7 +105,10 @@ static GimpEnumActionEntry plug_in_repeat_actions[] =
void
plug_in_actions_setup (GimpActionGroup *group)
{
GSList *list;
GimpEnumActionEntry *entries;
GSList *list;
gint n_entries;
gint i;
gimp_action_group_add_actions (group,
plug_in_actions,
@ -141,7 +147,35 @@ plug_in_actions_setup (GimpActionGroup *group)
}
}
g_signal_connect_object (group->gimp, "last-plug-in-changed",
n_entries = group->gimp->config->plug_in_history_size;
entries = g_new0 (GimpEnumActionEntry, n_entries);
for (i = 0; i < n_entries; i++)
{
entries[i].name = g_strdup_printf ("plug-in-recent-%02d",
i + 1);
entries[i].stock_id = GIMP_STOCK_RESHOW_FILTER;
entries[i].label = NULL;
entries[i].tooltip = NULL;
entries[i].value = i;
entries[i].value_variable = FALSE;
entries[i].help_id = GIMP_HELP_FILTER_RESHOW;
entries[i].accelerator = "";
}
gimp_action_group_add_enum_actions (group, entries, n_entries,
G_CALLBACK (plug_in_repeat_cmd_callback));
for (i = 0; i < n_entries; i++)
{
gimp_action_group_set_action_visible (group, entries[i].name, FALSE);
g_free ((gchar *) entries[i].name);
}
g_free (entries);
g_signal_connect_object (group->gimp, "last-plug-ins-changed",
G_CALLBACK (plug_in_actions_last_changed),
group, 0);
@ -155,6 +189,7 @@ plug_in_actions_update (GimpActionGroup *group,
GimpImage *gimage = action_data_get_image (data);
GimpImageType type = -1;
GSList *list;
gint i;
if (gimage)
{
@ -184,8 +219,8 @@ plug_in_actions_update (GimpActionGroup *group,
}
}
if (group->gimp->last_plug_in &&
plug_in_proc_def_get_sensitive (group->gimp->last_plug_in, type))
if (group->gimp->last_plug_ins &&
plug_in_proc_def_get_sensitive (group->gimp->last_plug_ins->data, type))
{
gimp_action_group_set_action_sensitive (group, "plug-in-repeat", TRUE);
gimp_action_group_set_action_sensitive (group, "plug-in-reshow", TRUE);
@ -195,6 +230,19 @@ plug_in_actions_update (GimpActionGroup *group,
gimp_action_group_set_action_sensitive (group, "plug-in-repeat", FALSE);
gimp_action_group_set_action_sensitive (group, "plug-in-reshow", FALSE);
}
for (list = group->gimp->last_plug_ins, i = 0; list; list = list->next, i++)
{
PlugInProcDef *proc_def = list->data;
gchar *name = g_strdup_printf ("plug-in-recent-%02d", i + 1);
gboolean sensitive;
sensitive = plug_in_proc_def_get_sensitive (proc_def, type);
gimp_action_group_set_action_sensitive (group, name, sensitive);
g_free (name);
}
}
void
@ -374,11 +422,14 @@ static void
plug_in_actions_last_changed (Gimp *gimp,
GimpActionGroup *group)
{
if (gimp->last_plug_in)
GSList *list;
const gchar *progname;
const gchar *domain;
gint i;
if (gimp->last_plug_ins)
{
PlugInProcDef *proc_def = gimp->last_plug_in;
const gchar *progname;
const gchar *domain;
PlugInProcDef *proc_def = gimp->last_plug_ins->data;
gchar *label;
gchar *repeat;
gchar *reshow;
@ -407,7 +458,44 @@ plug_in_actions_last_changed (Gimp *gimp,
_("Re-Show Last"));
}
/* update sensitivity of the "plug-in-repeat" and "plug-in-reshow" actions */
for (list = gimp->last_plug_ins, i = 0; list; list = list->next, i++)
{
GtkAction *action;
PlugInProcDef *proc_def = list->data;
gchar *name = g_strdup_printf ("plug-in-recent-%02d", i + 1);
gchar *label;
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), name);
g_free (name);
progname = plug_in_proc_def_get_progname (proc_def);
domain = plug_ins_locale_domain (gimp, progname, NULL);
label = plug_in_proc_def_get_label (proc_def, domain);
g_object_set (action,
"label", label,
"visible", TRUE,
"stock-id", plug_in_proc_def_get_stock_id (proc_def),
NULL);
g_free (label);
}
for (; i < gimp->config->plug_in_history_size; i++)
{
GtkAction *action;
gchar *name = g_strdup_printf ("plug-in-recent-%02d", i + 1);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), name);
g_free (name);
g_object_set (action,
"visible", FALSE,
NULL);
}
/* update sensitivity of the actions */
plug_in_actions_update (group, gimp);
}

View File

@ -18,6 +18,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
@ -157,7 +159,7 @@ plug_in_repeat_cmd_callback (GtkAction *action,
{
GimpDisplay *gdisp;
GimpDrawable *drawable;
gboolean interactive;
gboolean interactive = TRUE;
gdisp = action_data_get_display (data);
if (! gdisp)
@ -167,9 +169,10 @@ plug_in_repeat_cmd_callback (GtkAction *action,
if (! drawable)
return;
interactive = value ? TRUE : FALSE;
if (strcmp (gtk_action_get_name (action), "plug-in-repeat") == 0)
interactive = FALSE;
plug_in_repeat (gdisp->gimage->gimp,
plug_in_repeat (gdisp->gimage->gimp, value,
gimp_get_user_context (gdisp->gimage->gimp),
GIMP_PROGRESS (gdisp),
gimp_display_get_ID (gdisp),

View File

@ -79,6 +79,7 @@ enum
PROP_UNDO_LEVELS,
PROP_UNDO_SIZE,
PROP_UNDO_PREVIEW_SIZE,
PROP_PLUG_IN_HISTORY_SIZE,
PROP_PLUGINRC_PATH,
PROP_LAYER_PREVIEWS,
PROP_LAYER_PREVIEW_SIZE,
@ -298,6 +299,12 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
GIMP_VIEW_SIZE_LARGE,
GIMP_PARAM_STATIC_STRINGS |
GIMP_CONFIG_PARAM_RESTART);
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_PLUG_IN_HISTORY_SIZE,
"plug-in-history-size",
PLUG_IN_HISTORY_SIZE_BLURB,
0, 256, 10,
GIMP_PARAM_STATIC_STRINGS |
GIMP_CONFIG_PARAM_RESTART);
GIMP_CONFIG_INSTALL_PROP_PATH (object_class,
PROP_PLUGINRC_PATH,
"pluginrc-path", PLUGINRC_PATH_BLURB,
@ -519,6 +526,9 @@ gimp_core_config_set_property (GObject *object,
gimp_config_sync (g_value_get_object (value),
G_OBJECT (core_config->default_grid), 0);
break;
case PROP_PLUG_IN_HISTORY_SIZE:
core_config->plug_in_history_size = g_value_get_int (value);
break;
case PROP_UNDO_LEVELS:
core_config->levels_of_undo = g_value_get_int (value);
break;
@ -656,6 +666,9 @@ gimp_core_config_get_property (GObject *object,
case PROP_DEFAULT_GRID:
g_value_set_object (value, core_config->default_grid);
break;
case PROP_PLUG_IN_HISTORY_SIZE:
g_value_set_int (value, core_config->plug_in_history_size);
break;
case PROP_UNDO_LEVELS:
g_value_set_int (value, core_config->levels_of_undo);
break;

View File

@ -70,6 +70,7 @@ struct _GimpCoreConfig
gint levels_of_undo;
guint64 undo_size;
GimpViewSize undo_preview_size;
gint plug_in_history_size;
gchar *plug_in_rc_path;
gboolean layer_previews;
GimpViewSize layer_preview_size;

View File

@ -236,6 +236,9 @@ N_("When enabled, the X server is queried for the mouse's current position " \
"be slower. Perversely, on some X servers enabling this option results " \
"in faster painting.")
#define PLUG_IN_HISTORY_SIZE_BLURB \
"How many recently used plug-ins to keep on the Filters menu."
#define PLUG_IN_PATH_BLURB \
"Sets the plug-in search path."

View File

@ -79,7 +79,7 @@ enum
RESTORE,
EXIT,
BUFFER_CHANGED,
LAST_PLUG_IN_CHANGED,
LAST_PLUG_INS_CHANGED,
LAST_SIGNAL
};
@ -157,11 +157,11 @@ gimp_class_init (GimpClass *klass)
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gimp_signals[LAST_PLUG_IN_CHANGED] =
g_signal_new ("last-plug-in-changed",
gimp_signals[LAST_PLUG_INS_CHANGED] =
g_signal_new ("last-plug-ins-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GimpClass, last_plug_in_changed),
G_STRUCT_OFFSET (GimpClass, last_plug_ins_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@ -290,6 +290,12 @@ gimp_finalize (GObject *object)
gimp_contexts_exit (gimp);
if (gimp->last_plug_ins)
{
g_slist_free (gimp->last_plug_ins);
gimp->last_plug_ins = NULL;
}
if (gimp->image_new_last_template)
{
g_object_unref (gimp->image_new_last_template);
@ -913,11 +919,25 @@ void
gimp_set_last_plug_in (Gimp *gimp,
PlugInProcDef *proc_def)
{
GSList *list;
gint history_size;
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp->last_plug_in = proc_def;
history_size = MAX (1, gimp->config->plug_in_history_size);
g_signal_emit (gimp, gimp_signals[LAST_PLUG_IN_CHANGED], 0);
gimp->last_plug_ins = g_slist_remove (gimp->last_plug_ins, proc_def);
gimp->last_plug_ins = g_slist_prepend (gimp->last_plug_ins, proc_def);
list = g_slist_nth (gimp->last_plug_ins, history_size);
if (list)
{
gimp->last_plug_ins = g_slist_remove_link (gimp->last_plug_ins, list);
g_slist_free (list);
}
g_signal_emit (gimp, gimp_signals[LAST_PLUG_INS_CHANGED], 0);
}
GimpImage *

View File

@ -80,7 +80,7 @@ struct _Gimp
PlugIn *current_plug_in;
GSList *open_plug_ins;
GSList *plug_in_stack;
PlugInProcDef *last_plug_in;
GSList *last_plug_ins;
PlugInShm *plug_in_shm;
GimpInterpreterDB *interpreter_db;
@ -140,15 +140,15 @@ struct _GimpClass
{
GimpObjectClass parent_class;
void (* initialize) (Gimp *gimp,
GimpInitStatusFunc status_callback);
void (* restore) (Gimp *gimp,
GimpInitStatusFunc status_callback);
gboolean (* exit) (Gimp *gimp,
gboolean force);
void (* initialize) (Gimp *gimp,
GimpInitStatusFunc status_callback);
void (* restore) (Gimp *gimp,
GimpInitStatusFunc status_callback);
gboolean (* exit) (Gimp *gimp,
gboolean force);
void (* buffer_changed) (Gimp *gimp);
void (* last_plug_in_changed) (Gimp *gimp);
void (* buffer_changed) (Gimp *gimp);
void (* last_plug_ins_changed) (Gimp *gimp);
};

View File

@ -26,6 +26,8 @@
#include "menus-types.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "plug-in/plug-ins.h"
@ -117,12 +119,37 @@ void
plug_in_menus_setup (GimpUIManager *manager,
const gchar *ui_path)
{
GTree *menu_entries;
GSList *list;
GtkUIManager *ui_manager;
GTree *menu_entries;
GSList *list;
guint merge_id;
gint i;
g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
g_return_if_fail (ui_path != NULL);
ui_manager = GTK_UI_MANAGER (manager);
merge_id = gtk_ui_manager_new_merge_id (ui_manager);
for (i = 0; i < manager->gimp->config->plug_in_history_size; i++)
{
gchar *action_name;
gchar *action_path;
action_name = g_strdup_printf ("plug-in-recent-%02d", i + 1);
action_path = g_strdup_printf ("%s/Filters/Recently Used/Plug-Ins",
ui_path);
gtk_ui_manager_add_ui (ui_manager, merge_id,
action_path, action_name, action_name,
GTK_UI_MANAGER_MENUITEM,
FALSE);
g_free (action_name);
g_free (action_path);
}
menu_entries = g_tree_new_full ((GCompareDataFunc) strcmp, NULL,
g_free, g_free);

View File

@ -196,6 +196,7 @@ plug_in_run (Gimp *gimp,
void
plug_in_repeat (Gimp *gimp,
gint index,
GimpContext *context,
GimpProgress *progress,
gint display_ID,
@ -203,21 +204,25 @@ plug_in_repeat (Gimp *gimp,
gint drawable_ID,
gboolean with_interface)
{
Argument *args;
gint i;
PlugInProcDef *proc_def;
Argument *args;
gint i;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (index >= 0);
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
if (gimp->last_plug_in)
proc_def = g_slist_nth_data (gimp->last_plug_ins, index);
if (proc_def)
{
/* construct the procedures arguments */
args = g_new (Argument, 3);
/* initialize the first three argument types */
for (i = 0; i < 3; i++)
args[i].arg_type = gimp->last_plug_in->db_info.args[i].arg_type;
args[i].arg_type = proc_def->db_info.args[i].arg_type;
/* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ?
@ -226,7 +231,7 @@ plug_in_repeat (Gimp *gimp,
args[2].value.pdb_int = drawable_ID;
/* run the plug-in procedure */
plug_in_run (gimp, context, progress, &gimp->last_plug_in->db_info,
plug_in_run (gimp, context, progress, &proc_def->db_info,
args, 3, FALSE, TRUE, display_ID);
g_free (args);

View File

@ -34,10 +34,11 @@ Argument * plug_in_run (Gimp *gimp,
gboolean destroy_return_vals,
gint gdisp_ID);
/* Run the last plug-in again with the same arguments. Extensions
* are exempt from this "privelege".
/* Run one of the last plug-ins from the plug-in history again with
* the same arguments. Extensions are exempt from this "privelege".
*/
void plug_in_repeat (Gimp *gimp,
gint index,
GimpContext *context,
GimpProgress *progress,
gint display_ID,

View File

@ -196,6 +196,7 @@ plug_in_run (Gimp *gimp,
void
plug_in_repeat (Gimp *gimp,
gint index,
GimpContext *context,
GimpProgress *progress,
gint display_ID,
@ -203,21 +204,25 @@ plug_in_repeat (Gimp *gimp,
gint drawable_ID,
gboolean with_interface)
{
Argument *args;
gint i;
PlugInProcDef *proc_def;
Argument *args;
gint i;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (index >= 0);
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
if (gimp->last_plug_in)
proc_def = g_slist_nth_data (gimp->last_plug_ins, index);
if (proc_def)
{
/* construct the procedures arguments */
args = g_new (Argument, 3);
/* initialize the first three argument types */
for (i = 0; i < 3; i++)
args[i].arg_type = gimp->last_plug_in->db_info.args[i].arg_type;
args[i].arg_type = proc_def->db_info.args[i].arg_type;
/* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ?
@ -226,7 +231,7 @@ plug_in_repeat (Gimp *gimp,
args[2].value.pdb_int = drawable_ID;
/* run the plug-in procedure */
plug_in_run (gimp, context, progress, &gimp->last_plug_in->db_info,
plug_in_run (gimp, context, progress, &proc_def->db_info,
args, 3, FALSE, TRUE, display_ID);
g_free (args);

View File

@ -34,10 +34,11 @@ Argument * plug_in_run (Gimp *gimp,
gboolean destroy_return_vals,
gint gdisp_ID);
/* Run the last plug-in again with the same arguments. Extensions
* are exempt from this "privelege".
/* Run one of the last plug-ins from the plug-in history again with
* the same arguments. Extensions are exempt from this "privelege".
*/
void plug_in_repeat (Gimp *gimp,
gint index,
GimpContext *context,
GimpProgress *progress,
gint display_ID,

View File

@ -196,6 +196,7 @@ plug_in_run (Gimp *gimp,
void
plug_in_repeat (Gimp *gimp,
gint index,
GimpContext *context,
GimpProgress *progress,
gint display_ID,
@ -203,21 +204,25 @@ plug_in_repeat (Gimp *gimp,
gint drawable_ID,
gboolean with_interface)
{
Argument *args;
gint i;
PlugInProcDef *proc_def;
Argument *args;
gint i;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (index >= 0);
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
if (gimp->last_plug_in)
proc_def = g_slist_nth_data (gimp->last_plug_ins, index);
if (proc_def)
{
/* construct the procedures arguments */
args = g_new (Argument, 3);
/* initialize the first three argument types */
for (i = 0; i < 3; i++)
args[i].arg_type = gimp->last_plug_in->db_info.args[i].arg_type;
args[i].arg_type = proc_def->db_info.args[i].arg_type;
/* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ?
@ -226,7 +231,7 @@ plug_in_repeat (Gimp *gimp,
args[2].value.pdb_int = drawable_ID;
/* run the plug-in procedure */
plug_in_run (gimp, context, progress, &gimp->last_plug_in->db_info,
plug_in_run (gimp, context, progress, &proc_def->db_info,
args, 3, FALSE, TRUE, display_ID);
g_free (args);

View File

@ -34,10 +34,11 @@ Argument * plug_in_run (Gimp *gimp,
gboolean destroy_return_vals,
gint gdisp_ID);
/* Run the last plug-in again with the same arguments. Extensions
* are exempt from this "privelege".
/* Run one of the last plug-ins from the plug-in history again with
* the same arguments. Extensions are exempt from this "privelege".
*/
void plug_in_repeat (Gimp *gimp,
gint index,
GimpContext *context,
GimpProgress *progress,
gint display_ID,

View File

@ -529,7 +529,7 @@
<menu action="plug-in-menu" name="Filters">
<menuitem action="plug-in-repeat" />
<menuitem action="plug-in-reshow" />
<menu action="plug-in-repeat-recent-menu" name="Repeat">
<menu action="plug-in-recent-menu" name="Recently Used">
<placeholder name="Plug-Ins" />
</menu>
<menuitem action="plug-in-reset-all" />