fonts-cmds.c 5.47 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
2 3
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7 8 9 10 11 12 13 14
 * (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
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17
 */

18
/* NOTE: This file is auto-generated by pdbgen.pl. */
19 20 21

#include "config.h"

22
#include <gegl.h>
23 24 25 26

#include "pdb-types.h"

#include "core/gimp.h"
27
#include "core/gimpcontainer-filter.h"
28
#include "core/gimpcontainer.h"
29
#include "core/gimpparamspecs.h"
30
#include "text/gimp-fonts.h"
31

32 33
#include "gimppdb.h"
#include "gimpprocedure.h"
34
#include "internal-procs.h"
35

36

37
static GValueArray *
38 39 40 41 42 43
fonts_refresh_invoker (GimpProcedure      *procedure,
                       Gimp               *gimp,
                       GimpContext        *context,
                       GimpProgress       *progress,
                       const GValueArray  *args,
                       GError            **error)
44 45
{
  gimp_fonts_load (gimp);
46

47
  return gimp_procedure_get_return_values (procedure, TRUE, NULL);
48 49
}

50
static GValueArray *
51 52 53 54 55 56
fonts_get_list_invoker (GimpProcedure      *procedure,
                        Gimp               *gimp,
                        GimpContext        *context,
                        GimpProgress       *progress,
                        const GValueArray  *args,
                        GError            **error)
57
{
58
  gboolean success = TRUE;
59
  GValueArray *return_vals;
60
  const gchar *filter;
61
  gint32 num_fonts = 0;
62
  gchar **font_list = NULL;
63

64
  filter = g_value_get_string (&args->values[0]);
65

66
  if (success)
67 68 69 70
    {
      font_list = gimp_container_get_filtered_name_array (gimp->fonts,
                                                          filter, &num_fonts);
    }
71

72 73
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
74 75 76

  if (success)
    {
77 78
      g_value_set_int (&return_vals->values[1], num_fonts);
      gimp_value_take_stringarray (&return_vals->values[2], font_list, num_fonts);
79
    }
80

81
  return return_vals;
82 83
}

84
void
85
register_fonts_procs (GimpPDB *pdb)
86
{
87 88 89 90 91
  GimpProcedure *procedure;

  /*
   * gimp-fonts-refresh
   */
92
  procedure = gimp_procedure_new (fonts_refresh_invoker);
93 94
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-fonts-refresh");
95 96 97 98 99 100 101 102
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-fonts-refresh",
                                     "Refresh current fonts. This function always succeeds.",
                                     "This procedure retrieves all fonts currently in the user's font path and updates the font dialogs accordingly.",
                                     "Sven Neumann <sven@gimp.org>",
                                     "Sven Neumann",
                                     "2003",
                                     NULL);
103
  gimp_pdb_register_procedure (pdb, procedure);
104
  g_object_unref (procedure);
105 106 107 108

  /*
   * gimp-fonts-get-list
   */
109
  procedure = gimp_procedure_new (fonts_get_list_invoker);
110 111
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-fonts-get-list");
112 113 114 115 116 117 118 119 120 121 122 123
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-fonts-get-list",
                                     "Retrieve the list of loaded fonts.",
                                     "This procedure returns a list of the fonts that are currently available.",
                                     "Sven Neumann <sven@gimp.org>",
                                     "Sven Neumann",
                                     "2003",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("filter",
                                                       "filter",
                                                       "An optional regular expression used to filter the list",
124
                                                       FALSE, TRUE, FALSE,
125 126 127 128 129 130 131 132 133 134 135 136 137
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("num-fonts",
                                                          "num fonts",
                                                          "The number of available fonts",
                                                          0, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string_array ("font-list",
                                                                 "font list",
                                                                 "The list of font names",
                                                                 GIMP_PARAM_READWRITE));
138
  gimp_pdb_register_procedure (pdb, procedure);
139
  g_object_unref (procedure);
140
}