2004-04-20 13:25:55 +00:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* 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 2 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2004-04-20 23:04:50 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2004-04-20 13:25:55 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2004-04-20 23:04:50 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2004-04-20 13:25:55 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "actions-types.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2004-04-26 15:01:00 +00:00
|
|
|
#include "core/gimpdrawable.h"
|
2004-04-20 13:25:55 +00:00
|
|
|
#include "core/gimpimage.h"
|
2004-04-20 23:04:50 +00:00
|
|
|
|
|
|
|
#include "pdb/procedural_db.h"
|
2004-04-20 13:25:55 +00:00
|
|
|
|
|
|
|
#include "plug-in/plug-ins.h"
|
2004-04-20 23:04:50 +00:00
|
|
|
#include "plug-in/plug-in-proc.h"
|
2004-04-20 13:25:55 +00:00
|
|
|
|
|
|
|
#include "widgets/gimpactiongroup.h"
|
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
|
2004-05-03 14:03:51 +00:00
|
|
|
#include "actions.h"
|
2004-04-20 13:25:55 +00:00
|
|
|
#include "plug-in-actions.h"
|
|
|
|
#include "plug-in-commands.h"
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2004-04-27 12:28:27 +00:00
|
|
|
/* local function prototypes */
|
|
|
|
|
|
|
|
static void plug_in_actions_build_path (GimpActionGroup *group,
|
|
|
|
const gchar *path_original,
|
|
|
|
const gchar *path_translated);
|
|
|
|
|
|
|
|
|
|
|
|
/* private variables */
|
|
|
|
|
2004-04-20 13:25:55 +00:00
|
|
|
static GimpActionEntry plug_in_actions[] =
|
|
|
|
{
|
2004-04-26 15:01:00 +00:00
|
|
|
{ "plug-in-menu", NULL, N_("Filte_rs") },
|
2004-04-20 13:25:55 +00:00
|
|
|
{ "plug-in-blur-menu", NULL, N_("_Blur") },
|
|
|
|
{ "plug-in-colors-menu", NULL, N_("_Colors") },
|
|
|
|
{ "plug-in-colors-map-menu", NULL, N_("Ma_p") },
|
|
|
|
{ "plug-in-noise-menu", NULL, N_("_Noise") },
|
2004-04-21 10:55:45 +00:00
|
|
|
{ "plug-in-edge-detect-menu", NULL, N_("Edge-De_tect") },
|
2004-04-20 13:25:55 +00:00
|
|
|
{ "plug-in-enhance-menu", NULL, N_("En_hance") },
|
|
|
|
{ "plug-in-generic-menu", NULL, N_("_Generic") },
|
|
|
|
{ "plug-in-glass-effects-menu", NULL, N_("Gla_ss Effects") },
|
|
|
|
{ "plug-in-light-effects-menu", NULL, N_("_Light Effects") },
|
|
|
|
{ "plug-in-distorts-menu", NULL, N_("_Distorts") },
|
|
|
|
{ "plug-in-artistic-menu", NULL, N_("_Artistic") },
|
|
|
|
{ "plug-in-map-menu", NULL, N_("_Map") },
|
|
|
|
{ "plug-in-render-menu", NULL, N_("_Render") },
|
|
|
|
{ "plug-in-render-clouds-menu", NULL, N_("_Clouds") },
|
|
|
|
{ "plug-in-render-nature-menu", NULL, N_("_Nature") },
|
|
|
|
{ "plug-in-render-pattern-menu", NULL, N_("_Pattern") },
|
|
|
|
{ "plug-in-web-menu", NULL, N_("_Web") },
|
|
|
|
{ "plug-in-animation-menu", NULL, N_("An_imation") },
|
|
|
|
{ "plug-in-combine-menu", NULL, N_("C_ombine") },
|
|
|
|
{ "plug-in-toys-menu", NULL, N_("To_ys") }
|
|
|
|
};
|
|
|
|
|
|
|
|
static GimpEnumActionEntry plug_in_repeat_actions[] =
|
|
|
|
{
|
|
|
|
{ "plug-in-repeat", GTK_STOCK_EXECUTE,
|
|
|
|
N_("Repeat Last"), "<control>F", NULL,
|
|
|
|
FALSE,
|
|
|
|
GIMP_HELP_FILTER_REPEAT },
|
|
|
|
|
|
|
|
{ "plug-in-reshow", GIMP_STOCK_RESHOW_FILTER,
|
|
|
|
N_("Re-Show Last"), "<control><shift>F", NULL,
|
|
|
|
TRUE,
|
|
|
|
GIMP_HELP_FILTER_RESHOW }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-04-20 23:04:50 +00:00
|
|
|
/* public functions */
|
|
|
|
|
2004-04-20 13:25:55 +00:00
|
|
|
void
|
2004-04-27 13:55:26 +00:00
|
|
|
plug_in_actions_setup (GimpActionGroup *group)
|
2004-04-20 13:25:55 +00:00
|
|
|
{
|
2004-04-26 15:01:00 +00:00
|
|
|
GSList *list;
|
2004-04-20 23:04:50 +00:00
|
|
|
|
2004-04-20 13:25:55 +00:00
|
|
|
gimp_action_group_add_actions (group,
|
|
|
|
plug_in_actions,
|
2004-04-27 13:55:26 +00:00
|
|
|
G_N_ELEMENTS (plug_in_actions));
|
2004-04-20 13:25:55 +00:00
|
|
|
|
|
|
|
gimp_action_group_add_enum_actions (group,
|
|
|
|
plug_in_repeat_actions,
|
|
|
|
G_N_ELEMENTS (plug_in_repeat_actions),
|
2004-04-27 13:55:26 +00:00
|
|
|
G_CALLBACK (plug_in_repeat_cmd_callback));
|
2004-04-20 23:04:50 +00:00
|
|
|
|
2004-04-26 15:01:00 +00:00
|
|
|
for (list = group->gimp->plug_in_proc_defs;
|
|
|
|
list;
|
|
|
|
list = g_slist_next (list))
|
2004-04-20 23:04:50 +00:00
|
|
|
{
|
2004-04-26 15:01:00 +00:00
|
|
|
PlugInProcDef *proc_def = list->data;
|
2004-04-20 23:04:50 +00:00
|
|
|
|
|
|
|
if (proc_def->prog &&
|
2004-05-06 13:51:56 +00:00
|
|
|
proc_def->menu_paths &&
|
2004-04-20 23:04:50 +00:00
|
|
|
! proc_def->extensions &&
|
|
|
|
! proc_def->prefixes &&
|
|
|
|
! proc_def->magics)
|
|
|
|
{
|
2004-04-26 15:01:00 +00:00
|
|
|
plug_in_actions_add_proc (group, proc_def);
|
2004-04-20 23:04:50 +00:00
|
|
|
}
|
|
|
|
}
|
2004-04-20 13:25:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
plug_in_actions_update (GimpActionGroup *group,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-05-03 14:03:51 +00:00
|
|
|
GimpImage *gimage;
|
2004-04-26 15:01:00 +00:00
|
|
|
GimpImageType type = -1;
|
2004-04-27 12:28:27 +00:00
|
|
|
GSList *list;
|
2004-04-26 15:01:00 +00:00
|
|
|
|
2004-05-03 14:03:51 +00:00
|
|
|
gimage = action_data_get_image (data);
|
2004-04-26 15:01:00 +00:00
|
|
|
|
|
|
|
if (gimage)
|
|
|
|
{
|
|
|
|
GimpDrawable *drawable = gimp_image_active_drawable (gimage);
|
|
|
|
|
|
|
|
type = gimp_drawable_type (drawable);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (list = group->gimp->plug_in_proc_defs;
|
|
|
|
list;
|
|
|
|
list = g_slist_next (list))
|
|
|
|
{
|
|
|
|
PlugInProcDef *proc_def = list->data;
|
|
|
|
|
2004-05-06 13:51:56 +00:00
|
|
|
if (proc_def->menu_paths &&
|
2004-04-26 15:01:00 +00:00
|
|
|
proc_def->image_types_val &&
|
|
|
|
! proc_def->extensions &&
|
|
|
|
! proc_def->prefixes &&
|
|
|
|
! proc_def->magics)
|
|
|
|
{
|
|
|
|
gboolean sensitive;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case GIMP_RGB_IMAGE:
|
|
|
|
sensitive = proc_def->image_types_val & PLUG_IN_RGB_IMAGE;
|
|
|
|
break;
|
|
|
|
case GIMP_RGBA_IMAGE:
|
|
|
|
sensitive = proc_def->image_types_val & PLUG_IN_RGBA_IMAGE;
|
|
|
|
break;
|
|
|
|
case GIMP_GRAY_IMAGE:
|
|
|
|
sensitive = proc_def->image_types_val & PLUG_IN_GRAY_IMAGE;
|
|
|
|
break;
|
|
|
|
case GIMP_GRAYA_IMAGE:
|
|
|
|
sensitive = proc_def->image_types_val & PLUG_IN_GRAYA_IMAGE;
|
|
|
|
break;
|
|
|
|
case GIMP_INDEXED_IMAGE:
|
|
|
|
sensitive = proc_def->image_types_val & PLUG_IN_INDEXED_IMAGE;
|
|
|
|
break;
|
|
|
|
case GIMP_INDEXEDA_IMAGE:
|
|
|
|
sensitive = proc_def->image_types_val & PLUG_IN_INDEXEDA_IMAGE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sensitive = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_action_group_set_action_sensitive (group,
|
|
|
|
proc_def->db_info.name,
|
|
|
|
sensitive);
|
|
|
|
|
|
|
|
if (group->gimp->last_plug_in &&
|
|
|
|
group->gimp->last_plug_in == &proc_def->db_info)
|
|
|
|
{
|
|
|
|
const gchar *progname;
|
|
|
|
const gchar *path;
|
|
|
|
gchar *stripped;
|
|
|
|
gchar *basename;
|
|
|
|
gchar *ellipses;
|
|
|
|
gchar *repeat;
|
|
|
|
gchar *reshow;
|
|
|
|
|
|
|
|
progname = plug_in_proc_def_get_progname (proc_def);
|
|
|
|
|
|
|
|
path = dgettext (plug_ins_locale_domain (group->gimp,
|
|
|
|
progname, NULL),
|
2004-05-06 13:51:56 +00:00
|
|
|
proc_def->menu_paths->data);
|
2004-04-26 15:01:00 +00:00
|
|
|
|
|
|
|
stripped = gimp_strip_uline (path);
|
|
|
|
basename = g_path_get_basename (stripped);
|
|
|
|
|
|
|
|
g_free (stripped);
|
|
|
|
|
|
|
|
ellipses = strstr (basename, "...");
|
|
|
|
|
|
|
|
if (ellipses && ellipses == (basename + strlen (basename) - 3))
|
|
|
|
*ellipses = '\0';
|
|
|
|
|
|
|
|
repeat = g_strdup_printf (_("Re_peat \"%s\""), basename);
|
|
|
|
reshow = g_strdup_printf (_("R_e-show \"%s\""), basename);
|
|
|
|
|
|
|
|
g_free (basename);
|
|
|
|
|
|
|
|
gimp_action_group_set_action_label (group, "plug-in-repeat",
|
|
|
|
repeat);
|
|
|
|
gimp_action_group_set_action_label (group, "plug-in-reshow",
|
|
|
|
reshow);
|
|
|
|
|
|
|
|
g_free (repeat);
|
|
|
|
g_free (reshow);
|
|
|
|
|
|
|
|
gimp_action_group_set_action_sensitive (group, "plug-in-repeat",
|
|
|
|
TRUE);
|
|
|
|
gimp_action_group_set_action_sensitive (group, "plug-in-reshow",
|
|
|
|
TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! group->gimp->last_plug_in)
|
|
|
|
{
|
|
|
|
gimp_action_group_set_action_label (group, "plug-in-repeat",
|
|
|
|
_("Repeat Last"));
|
|
|
|
gimp_action_group_set_action_label (group, "plug-in-reshow",
|
|
|
|
_("Re-Show Last"));
|
|
|
|
|
|
|
|
gimp_action_group_set_action_sensitive (group, "plug-in-repeat", FALSE);
|
|
|
|
gimp_action_group_set_action_sensitive (group, "plug-in-reshow", FALSE);
|
|
|
|
}
|
2004-04-20 13:25:55 +00:00
|
|
|
}
|
2004-04-20 23:04:50 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
plug_in_actions_add_proc (GimpActionGroup *group,
|
2004-04-26 15:01:00 +00:00
|
|
|
PlugInProcDef *proc_def)
|
2004-04-20 23:04:50 +00:00
|
|
|
{
|
2004-04-27 12:28:27 +00:00
|
|
|
const gchar *progname;
|
|
|
|
const gchar *locale_domain;
|
|
|
|
const gchar *help_domain;
|
|
|
|
gchar *path_original;
|
|
|
|
gchar *path_translated;
|
|
|
|
gchar *help_id;
|
|
|
|
gchar *p1, *p2;
|
2004-04-20 23:04:50 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
g_return_if_fail (proc_def != NULL);
|
|
|
|
|
2004-04-26 15:01:00 +00:00
|
|
|
progname = plug_in_proc_def_get_progname (proc_def);
|
|
|
|
|
|
|
|
locale_domain = plug_ins_locale_domain (group->gimp, progname, NULL);
|
|
|
|
help_domain = plug_ins_help_domain (group->gimp, progname, NULL);
|
|
|
|
|
2004-04-20 23:04:50 +00:00
|
|
|
help_id = plug_in_proc_def_get_help_id (proc_def, help_domain);
|
|
|
|
|
2004-05-06 13:51:56 +00:00
|
|
|
path_original = g_strdup (proc_def->menu_paths->data);
|
2004-04-27 12:28:27 +00:00
|
|
|
path_translated = g_strdup (dgettext (locale_domain, path_original));
|
|
|
|
|
|
|
|
p1 = strrchr (path_original, '/');
|
|
|
|
p2 = strrchr (path_translated, '/');
|
|
|
|
|
|
|
|
if (p1 && p2)
|
|
|
|
{
|
2004-05-02 08:56:07 +00:00
|
|
|
GimpPlugInActionEntry entry;
|
|
|
|
gchar *label;
|
2004-04-27 12:28:27 +00:00
|
|
|
|
|
|
|
label = p2 + 1;
|
|
|
|
|
2004-05-02 08:56:07 +00:00
|
|
|
entry.name = proc_def->db_info.name;
|
|
|
|
entry.stock_id = NULL;
|
|
|
|
entry.label = label;
|
|
|
|
entry.accelerator = proc_def->accelerator;
|
|
|
|
entry.tooltip = NULL;
|
|
|
|
entry.proc_def = proc_def;
|
|
|
|
entry.help_id = help_id;
|
|
|
|
|
2004-04-29 12:52:29 +00:00
|
|
|
#if 0
|
2004-04-27 12:28:27 +00:00
|
|
|
g_print ("adding plug-in action '%s' (%s)\n",
|
|
|
|
proc_def->db_info.name, label);
|
2004-04-29 12:52:29 +00:00
|
|
|
#endif
|
2004-04-26 15:01:00 +00:00
|
|
|
|
2004-05-02 08:56:07 +00:00
|
|
|
gimp_action_group_add_plug_in_actions (group, &entry, 1,
|
|
|
|
G_CALLBACK (plug_in_run_cmd_callback));
|
2004-04-26 15:01:00 +00:00
|
|
|
|
2004-04-27 12:28:27 +00:00
|
|
|
*p1 = '\0';
|
|
|
|
*p2 = '\0';
|
|
|
|
|
|
|
|
plug_in_actions_build_path (group, path_original, path_translated);
|
|
|
|
}
|
2004-05-02 08:56:07 +00:00
|
|
|
|
2004-05-05 15:34:11 +00:00
|
|
|
g_free (path_original);
|
|
|
|
g_free (path_translated);
|
|
|
|
|
2004-05-02 08:56:07 +00:00
|
|
|
g_free (help_id);
|
2004-04-20 23:04:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
plug_in_actions_remove_proc (GimpActionGroup *group,
|
|
|
|
PlugInProcDef *proc_def)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
|
|
|
g_return_if_fail (proc_def != NULL);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
|
|
|
|
proc_def->db_info.name);
|
|
|
|
|
|
|
|
if (action)
|
2004-04-26 15:01:00 +00:00
|
|
|
{
|
2004-04-29 12:52:29 +00:00
|
|
|
#if 0
|
2004-04-26 15:01:00 +00:00
|
|
|
g_print ("removing plug-in action '%s'\n",
|
|
|
|
proc_def->db_info.name);
|
2004-04-29 12:52:29 +00:00
|
|
|
#endif
|
2004-04-20 23:04:50 +00:00
|
|
|
|
2004-04-26 15:01:00 +00:00
|
|
|
gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
|
|
|
|
}
|
2004-04-20 23:04:50 +00:00
|
|
|
}
|
2004-04-27 12:28:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
plug_in_actions_build_path (GimpActionGroup *group,
|
|
|
|
const gchar *path_original,
|
|
|
|
const gchar *path_translated)
|
|
|
|
{
|
|
|
|
GHashTable *path_table;
|
|
|
|
gchar *p1, *p2;
|
|
|
|
|
|
|
|
path_table = g_object_get_data (G_OBJECT (group), "plug-in-path-table");
|
|
|
|
|
|
|
|
if (! path_table)
|
|
|
|
{
|
|
|
|
path_table = g_hash_table_new_full (g_str_hash, g_str_equal,
|
|
|
|
g_free, NULL);
|
|
|
|
|
|
|
|
g_object_set_data_full (G_OBJECT (group), "plug-in-path-table",
|
|
|
|
path_table,
|
|
|
|
(GDestroyNotify) g_hash_table_destroy);
|
|
|
|
}
|
|
|
|
|
|
|
|
p1 = strrchr (path_original, '/');
|
|
|
|
p2 = strrchr (path_translated, '/');
|
|
|
|
|
|
|
|
if (p1 && p2 && ! g_hash_table_lookup (path_table, path_original))
|
|
|
|
{
|
|
|
|
gchar *copy_original = g_strdup (path_original);
|
|
|
|
gchar *copy_translated = g_strdup (path_translated);
|
|
|
|
gchar *label;
|
|
|
|
GtkAction *action;
|
|
|
|
|
|
|
|
label = p2 + 1;
|
|
|
|
|
2004-04-29 12:52:29 +00:00
|
|
|
#if 0
|
2004-04-27 12:28:27 +00:00
|
|
|
g_print ("adding plug-in submenu '%s' (%s)\n",
|
|
|
|
path_original, label);
|
2004-04-29 12:52:29 +00:00
|
|
|
#endif
|
2004-04-27 12:28:27 +00:00
|
|
|
|
|
|
|
action = gtk_action_new (path_original, label, NULL, NULL);
|
|
|
|
gtk_action_group_add_action (GTK_ACTION_GROUP (group), action);
|
|
|
|
g_object_unref (action);
|
|
|
|
|
|
|
|
g_hash_table_insert (path_table, g_strdup (path_original), action);
|
|
|
|
|
|
|
|
p1 = strrchr (copy_original, '/');
|
|
|
|
p2 = strrchr (copy_translated, '/');
|
|
|
|
|
|
|
|
*p1 = '\0';
|
|
|
|
*p2 = '\0';
|
|
|
|
|
|
|
|
plug_in_actions_build_path (group, copy_original, copy_translated);
|
|
|
|
|
|
|
|
g_free (copy_original);
|
|
|
|
g_free (copy_translated);
|
|
|
|
}
|
|
|
|
}
|