gimppluginprocedure.c 3.07 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* 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"

#include <glib-object.h>

#include "plug-in-types.h"

25
#include "plug-in.h"
26
27
28
#include "plug-in-proc.h"


29
30
PlugInProcDef *
plug_in_proc_def_new (void)
31
{
32
  PlugInProcDef *proc_def;
33

34
35
36
  proc_def = g_new0 (PlugInProcDef, 1);

  return proc_def;
37
}
38
39

void
40
plug_in_proc_def_free (PlugInProcDef *proc_def)
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{
  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);
  g_free (proc_def->menu_path);
  g_free (proc_def->accelerator);
  g_free (proc_def->extensions);
  g_free (proc_def->prefixes);
  g_free (proc_def->magics);
  g_free (proc_def->image_types);

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  g_free (proc_def);
}

ProcRecord * 
plug_in_proc_def_get_proc (PlugInProcDef *proc_def)
{
  g_return_val_if_fail (proc_def != NULL, NULL);

  return &proc_def->db_info;
}

const gchar *
plug_in_proc_def_get_progname (PlugInProcDef *proc_def)
{
  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:
99
      return ((PlugIn *) proc_def->db_info.exec_method.temporary.plug_in)->prog;
100
101
102
103
104
105

    default:
      break;
    }

  return NULL;
106
}
107
108

gchar *
Michael Natterer's avatar
Michael Natterer committed
109
plug_in_proc_def_get_help_id (PlugInProcDef *proc_def,
110
                              const gchar   *help_domain)
111
{
Michael Natterer's avatar
Michael Natterer committed
112
113
  gchar *help_id;
  gchar *p;
114
115
116

  g_return_val_if_fail (proc_def != NULL, NULL);

Michael Natterer's avatar
Michael Natterer committed
117
  help_id = g_strdup (proc_def->db_info.name);
118

Michael Natterer's avatar
Michael Natterer committed
119
120
121
  for (p = help_id; p && *p; p++)
    if (*p == '_')
      *p = '-';
122

123
  if (help_domain)
Michael Natterer's avatar
Michael Natterer committed
124
    {
125
      gchar *domain_and_id;
Michael Natterer's avatar
Michael Natterer committed
126

127
      domain_and_id = g_strconcat (help_domain, "?", help_id, NULL);
Michael Natterer's avatar
Michael Natterer committed
128
      g_free (help_id);
129

130
      return domain_and_id;
Michael Natterer's avatar
Michael Natterer committed
131
    }
132
133
134

  return help_id;
}