2001-12-19 08:13:16 +08: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-05-18 17:04:12 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2001-12-19 08:13:16 +08:00
|
|
|
#include <glib-object.h>
|
2004-05-19 05:19:43 +08:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2001-12-19 08:13:16 +08:00
|
|
|
|
2004-02-03 21:02:18 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
2001-12-19 08:13:16 +08:00
|
|
|
#include "plug-in-types.h"
|
|
|
|
|
2004-02-03 21:02:18 +08:00
|
|
|
#include "core/gimp.h"
|
|
|
|
|
2003-01-18 02:07:37 +08:00
|
|
|
#include "plug-in.h"
|
2004-02-03 21:02:18 +08:00
|
|
|
#include "plug-ins.h"
|
2001-12-19 08:13:16 +08:00
|
|
|
#include "plug-in-proc.h"
|
|
|
|
|
2004-02-03 21:02:18 +08:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
2001-12-19 08:13:16 +08:00
|
|
|
|
2003-01-18 02:07:37 +08:00
|
|
|
PlugInProcDef *
|
|
|
|
plug_in_proc_def_new (void)
|
2001-12-19 08:13:16 +08:00
|
|
|
{
|
2004-05-19 05:19:43 +08:00
|
|
|
PlugInProcDef *proc_def = g_new0 (PlugInProcDef, 1);
|
|
|
|
|
|
|
|
proc_def->icon_data_length = -1;
|
|
|
|
|
|
|
|
return proc_def;
|
2001-12-19 08:13:16 +08:00
|
|
|
}
|
2001-12-28 01:58:30 +08:00
|
|
|
|
|
|
|
void
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in_proc_def_free (PlugInProcDef *proc_def)
|
2001-12-28 01:58:30 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_if_fail (proc_def != NULL);
|
|
|
|
|
|
|
|
g_free (proc_def->db_info.name);
|
|
|
|
g_free (proc_def->db_info.blurb);
|
|
|
|
g_free (proc_def->db_info.help);
|
|
|
|
g_free (proc_def->db_info.author);
|
|
|
|
g_free (proc_def->db_info.copyright);
|
|
|
|
g_free (proc_def->db_info.date);
|
|
|
|
|
|
|
|
for (i = 0; i < proc_def->db_info.num_args; i++)
|
|
|
|
{
|
|
|
|
g_free (proc_def->db_info.args[i].name);
|
|
|
|
g_free (proc_def->db_info.args[i].description);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < proc_def->db_info.num_values; i++)
|
|
|
|
{
|
|
|
|
g_free (proc_def->db_info.values[i].name);
|
|
|
|
g_free (proc_def->db_info.values[i].description);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (proc_def->db_info.args);
|
|
|
|
g_free (proc_def->db_info.values);
|
|
|
|
|
|
|
|
g_free (proc_def->prog);
|
2004-05-07 08:30:24 +08:00
|
|
|
g_free (proc_def->menu_label);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
|
|
|
g_list_foreach (proc_def->menu_paths, (GFunc) g_free, NULL);
|
|
|
|
g_list_free (proc_def->menu_paths);
|
|
|
|
|
2004-05-19 05:19:43 +08:00
|
|
|
g_free (proc_def->icon_data);
|
|
|
|
g_free (proc_def->image_types);
|
|
|
|
|
2001-12-28 01:58:30 +08:00
|
|
|
g_free (proc_def->extensions);
|
|
|
|
g_free (proc_def->prefixes);
|
|
|
|
g_free (proc_def->magics);
|
2004-05-14 08:01:11 +08:00
|
|
|
g_free (proc_def->mime_type);
|
2004-05-19 05:19:43 +08:00
|
|
|
|
|
|
|
g_slist_foreach (proc_def->extensions_list, (GFunc) g_free, NULL);
|
|
|
|
g_slist_free (proc_def->extensions_list);
|
|
|
|
|
|
|
|
g_slist_foreach (proc_def->prefixes_list, (GFunc) g_free, NULL);
|
|
|
|
g_slist_free (proc_def->prefixes_list);
|
|
|
|
|
|
|
|
g_slist_foreach (proc_def->magics_list, (GFunc) g_free, NULL);
|
|
|
|
g_slist_free (proc_def->magics_list);
|
2001-12-28 01:58:30 +08:00
|
|
|
|
2003-01-18 02:07:37 +08:00
|
|
|
g_free (proc_def);
|
|
|
|
}
|
|
|
|
|
2004-02-03 21:02:18 +08:00
|
|
|
const ProcRecord *
|
|
|
|
plug_in_proc_def_get_proc (const PlugInProcDef *proc_def)
|
2003-01-18 02:07:37 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (proc_def != NULL, NULL);
|
|
|
|
|
|
|
|
return &proc_def->db_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
const gchar *
|
2004-02-03 21:02:18 +08:00
|
|
|
plug_in_proc_def_get_progname (const PlugInProcDef *proc_def)
|
2003-01-18 02:07:37 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (proc_def != NULL, NULL);
|
|
|
|
|
|
|
|
switch (proc_def->db_info.proc_type)
|
|
|
|
{
|
|
|
|
case GIMP_PLUGIN:
|
|
|
|
case GIMP_EXTENSION:
|
|
|
|
return proc_def->prog;
|
|
|
|
|
|
|
|
case GIMP_TEMPORARY:
|
2003-02-11 09:21:21 +08:00
|
|
|
return ((PlugIn *) proc_def->db_info.exec_method.temporary.plug_in)->prog;
|
2003-01-18 02:07:37 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2001-12-28 01:58:30 +08:00
|
|
|
}
|
2003-08-26 00:28:46 +08:00
|
|
|
|
2004-05-18 17:04:12 +08:00
|
|
|
gchar *
|
|
|
|
plug_in_proc_def_get_label (const PlugInProcDef *proc_def,
|
|
|
|
const gchar *locale_domain)
|
|
|
|
{
|
|
|
|
const gchar *path;
|
|
|
|
gchar *stripped;
|
|
|
|
gchar *ellipses;
|
|
|
|
gchar *label;
|
|
|
|
|
|
|
|
g_return_val_if_fail (proc_def != NULL, NULL);
|
|
|
|
|
|
|
|
if (proc_def->menu_label)
|
|
|
|
path = dgettext (locale_domain, proc_def->menu_label);
|
|
|
|
else if (proc_def->menu_paths)
|
|
|
|
path = dgettext (locale_domain, proc_def->menu_paths->data);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
stripped = gimp_strip_uline (path);
|
|
|
|
|
|
|
|
if (proc_def->menu_label)
|
|
|
|
label = g_strdup (stripped);
|
|
|
|
else
|
|
|
|
label = g_path_get_basename (stripped);
|
|
|
|
|
|
|
|
g_free (stripped);
|
|
|
|
|
|
|
|
ellipses = strstr (label, "...");
|
|
|
|
|
|
|
|
if (ellipses && ellipses == (label + strlen (label) - 3))
|
|
|
|
*ellipses = '\0';
|
|
|
|
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
2004-05-19 05:19:43 +08:00
|
|
|
const gchar *
|
|
|
|
plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (proc_def != NULL, NULL);
|
|
|
|
|
|
|
|
switch (proc_def->icon_type)
|
|
|
|
{
|
|
|
|
case GIMP_ICON_TYPE_STOCK_ID:
|
|
|
|
return proc_def->icon_data;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkPixbuf *
|
|
|
|
plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def)
|
|
|
|
{
|
|
|
|
GdkPixbuf *pixbuf = NULL;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (proc_def != NULL, NULL);
|
|
|
|
|
|
|
|
switch (proc_def->icon_type)
|
|
|
|
{
|
|
|
|
case GIMP_ICON_TYPE_INLINE_PIXBUF:
|
|
|
|
pixbuf = gdk_pixbuf_new_from_inline (proc_def->icon_data_length,
|
|
|
|
proc_def->icon_data, TRUE, &error);
|
|
|
|
if (! pixbuf)
|
|
|
|
{
|
|
|
|
g_printerr (error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ICON_TYPE_IMAGE_FILE:
|
|
|
|
pixbuf = gdk_pixbuf_new_from_file (proc_def->icon_data, &error);
|
|
|
|
if (! pixbuf)
|
|
|
|
{
|
|
|
|
g_printerr (error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pixbuf;
|
|
|
|
}
|
|
|
|
|
2003-08-26 00:28:46 +08:00
|
|
|
gchar *
|
2004-02-03 21:02:18 +08:00
|
|
|
plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
|
|
|
|
const gchar *help_domain)
|
2003-08-26 00:28:46 +08:00
|
|
|
{
|
2003-08-26 23:12:47 +08:00
|
|
|
gchar *help_id;
|
|
|
|
gchar *p;
|
2003-08-26 00:28:46 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (proc_def != NULL, NULL);
|
|
|
|
|
2003-08-26 23:12:47 +08:00
|
|
|
help_id = g_strdup (proc_def->db_info.name);
|
2003-08-26 00:28:46 +08:00
|
|
|
|
2003-08-26 23:12:47 +08:00
|
|
|
for (p = help_id; p && *p; p++)
|
|
|
|
if (*p == '_')
|
|
|
|
*p = '-';
|
2003-08-26 00:28:46 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
if (help_domain)
|
2003-08-26 23:12:47 +08:00
|
|
|
{
|
2003-08-29 02:49:11 +08:00
|
|
|
gchar *domain_and_id;
|
2003-08-26 23:12:47 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
domain_and_id = g_strconcat (help_domain, "?", help_id, NULL);
|
2003-08-26 23:12:47 +08:00
|
|
|
g_free (help_id);
|
2003-08-26 00:28:46 +08:00
|
|
|
|
2003-08-29 02:49:11 +08:00
|
|
|
return domain_and_id;
|
2003-08-26 23:12:47 +08:00
|
|
|
}
|
2003-08-26 00:28:46 +08:00
|
|
|
|
|
|
|
return help_id;
|
|
|
|
}
|
2004-08-08 18:53:19 +08:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
plug_in_proc_def_get_sensitive (const PlugInProcDef *proc_def,
|
|
|
|
GimpImageType image_type)
|
|
|
|
{
|
|
|
|
gboolean sensitive;
|
|
|
|
|
|
|
|
g_return_val_if_fail (proc_def != NULL, FALSE);
|
|
|
|
|
|
|
|
switch (image_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sensitive ? TRUE : FALSE;
|
|
|
|
}
|