From 0acc96d9f1963b78374307ec563868dce2619697 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 4 Sep 2003 12:02:31 +0000 Subject: [PATCH] added new function gimp_container_get_name_array(). 2003-09-04 Sven Neumann * app/core/gimpcontainer.[ch]: added new function gimp_container_get_name_array(). * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/palettes.pdb * tools/pdbgen/pdb/paths.pdb * tools/pdbgen/pdb/patterns.pdb: use the new GimpContainer function instead of duplicating this code over and over again. * app/pdb/brushes_cmds.c * app/pdb/gradients_cmds.c * app/pdb/palettes_cmds.c * app/pdb/paths_cmds.c * app/pdb/patterns_cmds.c * libgimp/gimpgradients_pdb.c: regenerated. * tools/pdbgen/Makefile.am * tools/pdbgen/pdb/fonts.pdb: added new file that defines a simple PDB API for fonts. * tools/pdbgen/groups.pl * app/pdb/Makefile.am * app/pdb/fonts_cmds.c * app/pdb/internal_procs.c * libgimp/gimp_pdb.h * libgimp/gimpfonts_pdb.[ch]: (re)generated. --- ChangeLog | 30 +++++++++ app/core/gimpcontainer.c | 37 ++++++++++- app/core/gimpcontainer.h | 5 +- app/pdb/Makefile.am | 1 + app/pdb/brushes_cmds.c | 26 ++------ app/pdb/fonts_cmds.c | 115 +++++++++++++++++++++++++++++++++ app/pdb/gradients_cmds.c | 28 ++------ app/pdb/internal_procs.c | 66 ++++++++++--------- app/pdb/palettes_cmds.c | 26 ++------ app/pdb/paths_cmds.c | 24 +------ app/pdb/patterns_cmds.c | 26 ++------ libgimp/gimp_pdb.h | 1 + libgimp/gimpfonts_pdb.c | 92 ++++++++++++++++++++++++++ libgimp/gimpfonts_pdb.h | 38 +++++++++++ libgimp/gimpgradients_pdb.c | 8 +-- tools/pdbgen/Makefile.am | 1 + tools/pdbgen/groups.pl | 1 + tools/pdbgen/pdb/brushes.pdb | 21 +----- tools/pdbgen/pdb/fonts.pdb | 70 ++++++++++++++++++++ tools/pdbgen/pdb/gradients.pdb | 24 ++----- tools/pdbgen/pdb/palettes.pdb | 21 +----- tools/pdbgen/pdb/paths.pdb | 26 +------- tools/pdbgen/pdb/patterns.pdb | 21 +----- 23 files changed, 468 insertions(+), 240 deletions(-) create mode 100644 app/pdb/fonts_cmds.c create mode 100644 libgimp/gimpfonts_pdb.c create mode 100644 libgimp/gimpfonts_pdb.h create mode 100644 tools/pdbgen/pdb/fonts.pdb diff --git a/ChangeLog b/ChangeLog index f9ef659723..b1d0a55fff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,33 @@ +2003-09-04 Sven Neumann + + * app/core/gimpcontainer.[ch]: added new function + gimp_container_get_name_array(). + + * tools/pdbgen/pdb/brushes.pdb + * tools/pdbgen/pdb/gradients.pdb + * tools/pdbgen/pdb/palettes.pdb + * tools/pdbgen/pdb/paths.pdb + * tools/pdbgen/pdb/patterns.pdb: use the new GimpContainer function + instead of duplicating this code over and over again. + + * app/pdb/brushes_cmds.c + * app/pdb/gradients_cmds.c + * app/pdb/palettes_cmds.c + * app/pdb/paths_cmds.c + * app/pdb/patterns_cmds.c + * libgimp/gimpgradients_pdb.c: regenerated. + + * tools/pdbgen/Makefile.am + * tools/pdbgen/pdb/fonts.pdb: added new file that defines a simple + PDB API for fonts. + + * tools/pdbgen/groups.pl + * app/pdb/Makefile.am + * app/pdb/fonts_cmds.c + * app/pdb/internal_procs.c + * libgimp/gimp_pdb.h + * libgimp/gimpfonts_pdb.[ch]: (re)generated. + 2003-09-04 Simon Budig * app/vectors/gimpbezierstroke.c: Changed the direct dragging diff --git a/app/core/gimpcontainer.c b/app/core/gimpcontainer.c index c23bcc3761..636f3c4905 100644 --- a/app/core/gimpcontainer.c +++ b/app/core/gimpcontainer.c @@ -789,8 +789,8 @@ gimp_container_clear (GimpContainer *container) } gboolean -gimp_container_have (GimpContainer *container, - GimpObject *object) +gimp_container_have (const GimpContainer *container, + GimpObject *object) { g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE); @@ -852,6 +852,39 @@ gimp_container_get_child_index (const GimpContainer *container, object); } +static void +gimp_container_get_name_array_foreach_func (GimpObject *object, + gchar ***names) +{ + gchar **name = *names; + + *name = g_strdup (gimp_object_get_name (object)); + + *names++; +} + +gchar ** +gimp_container_get_name_array (const GimpContainer *container, + gint *length) +{ + gchar **names; + + g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL); + g_return_val_if_fail (length != NULL, NULL); + + *length = gimp_container_num_children (container); + if (*length == 0) + return NULL; + + names = g_new (gchar *, *length); + + GIMP_CONTAINER_GET_CLASS (container)->foreach (container, + (GFunc) gimp_container_get_name_array_foreach_func, + &names); + + return names; +} + static void gimp_container_add_handler_foreach_func (GimpObject *object, GimpContainerHandler *handler) diff --git a/app/core/gimpcontainer.h b/app/core/gimpcontainer.h index 99dbfb5094..ddb5f2a347 100644 --- a/app/core/gimpcontainer.h +++ b/app/core/gimpcontainer.h @@ -103,7 +103,7 @@ void gimp_container_thaw (GimpContainer *container); gboolean gimp_container_frozen (GimpContainer *container); void gimp_container_clear (GimpContainer *container); -gboolean gimp_container_have (GimpContainer *container, +gboolean gimp_container_have (const GimpContainer *container, GimpObject *object); void gimp_container_foreach (GimpContainer *container, GFunc func, @@ -116,6 +116,9 @@ GimpObject * gimp_container_get_child_by_index (const GimpContainer *container, gint gimp_container_get_child_index (const GimpContainer *container, const GimpObject *object); +gchar ** gimp_container_get_name_array (const GimpContainer *container, + gint *length); + GQuark gimp_container_add_handler (GimpContainer *container, const gchar *signame, GCallback callback, diff --git a/app/pdb/Makefile.am b/app/pdb/Makefile.am index 146fd4992e..cae62e8661 100644 --- a/app/pdb/Makefile.am +++ b/app/pdb/Makefile.am @@ -18,6 +18,7 @@ libapppdb_a_SOURCES = \ fileops_cmds.c \ floating_sel_cmds.c \ font_select_cmds.c \ + fonts_cmds.c \ gimprc_cmds.c \ gradient_select_cmds.c \ gradients_cmds.c \ diff --git a/app/pdb/brushes_cmds.c b/app/pdb/brushes_cmds.c index 91d696fda7..aaeadfb28e 100644 --- a/app/pdb/brushes_cmds.c +++ b/app/pdb/brushes_cmds.c @@ -102,30 +102,16 @@ static Argument * brushes_get_list_invoker (Gimp *gimp, Argument *args) { - gboolean success = TRUE; Argument *return_args; - gchar **brushes; - GList *list; - int i = 0; + gint32 num_brushes; + gchar **brush_list; - brushes = g_new (char *, gimp->brush_factory->container->num_children); + brush_list = gimp_container_get_name_array (gimp->brush_factory->container, &num_brushes); - for (list = GIMP_LIST (gimp->brush_factory->container)->list; - list; - list = g_list_next (list)) - { - brushes[i++] = g_strdup (GIMP_OBJECT (list->data)->name); - } + return_args = procedural_db_return_args (&brushes_get_list_proc, TRUE); - success = (i > 0); - - return_args = procedural_db_return_args (&brushes_get_list_proc, success); - - if (success) - { - return_args[1].value.pdb_int = gimp->brush_factory->container->num_children; - return_args[2].value.pdb_pointer = brushes; - } + return_args[1].value.pdb_int = num_brushes; + return_args[2].value.pdb_pointer = brush_list; return return_args; } diff --git a/app/pdb/fonts_cmds.c b/app/pdb/fonts_cmds.c new file mode 100644 index 0000000000..864063a1c7 --- /dev/null +++ b/app/pdb/fonts_cmds.c @@ -0,0 +1,115 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995-2003 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. + */ + +/* NOTE: This file is autogenerated by pdbgen.pl. */ + +#include "config.h" + + +#include + +#include "libgimpbase/gimpbasetypes.h" + +#include "pdb-types.h" +#include "procedural_db.h" + +#include "core/gimp.h" +#include "core/gimpcontainer.h" +#include "text/gimpfonts.h" + +static ProcRecord fonts_refresh_proc; +static ProcRecord fonts_get_list_proc; + +void +register_fonts_procs (Gimp *gimp) +{ + procedural_db_register (gimp, &fonts_refresh_proc); + procedural_db_register (gimp, &fonts_get_list_proc); +} + +static Argument * +fonts_refresh_invoker (Gimp *gimp, + Argument *args) +{ + gimp_fonts_load (gimp); + return procedural_db_return_args (&fonts_refresh_proc, TRUE); +} + +static ProcRecord fonts_refresh_proc = +{ + "gimp_fonts_refresh", + "Refresh current fonts.", + "This procedure retrieves all fonts currently in the user's font path and updates the font dialogs accordingly.", + "Sven Neumann", + "Sven Neumann", + "2003", + GIMP_INTERNAL, + 0, + NULL, + 0, + NULL, + { { fonts_refresh_invoker } } +}; + +static Argument * +fonts_get_list_invoker (Gimp *gimp, + Argument *args) +{ + Argument *return_args; + gint32 num_fonts; + gchar **font_list; + + font_list = gimp_container_get_name_array (gimp->fonts, &num_fonts); + + return_args = procedural_db_return_args (&fonts_get_list_proc, TRUE); + + return_args[1].value.pdb_int = num_fonts; + return_args[2].value.pdb_pointer = font_list; + + return return_args; +} + +static ProcArg fonts_get_list_outargs[] = +{ + { + GIMP_PDB_INT32, + "num_fonts", + "The number of available fonts" + }, + { + GIMP_PDB_STRINGARRAY, + "font_list", + "The list of font names" + } +}; + +static ProcRecord fonts_get_list_proc = +{ + "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 Neumann", + "2003", + GIMP_INTERNAL, + 0, + NULL, + 2, + fonts_get_list_outargs, + { { fonts_get_list_invoker } } +}; diff --git a/app/pdb/gradients_cmds.c b/app/pdb/gradients_cmds.c index ba646383c1..8c768edbdf 100644 --- a/app/pdb/gradients_cmds.c +++ b/app/pdb/gradients_cmds.c @@ -85,30 +85,16 @@ static Argument * gradients_get_list_invoker (Gimp *gimp, Argument *args) { - gboolean success = TRUE; Argument *return_args; - gchar **gradients; - GList *list; - gint i = 0; + gint32 num_gradients; + gchar **gradient_list; - gradients = g_new (gchar *, gimp->gradient_factory->container->num_children); + gradient_list = gimp_container_get_name_array (gimp->gradient_factory->container, &num_gradients); - for (list = GIMP_LIST (gimp->gradient_factory->container)->list; - list; - list = g_list_next (list)) - { - gradients[i++] = g_strdup (GIMP_OBJECT (list->data)->name); - } + return_args = procedural_db_return_args (&gradients_get_list_proc, TRUE); - success = (i > 0); - - return_args = procedural_db_return_args (&gradients_get_list_proc, success); - - if (success) - { - return_args[1].value.pdb_int = gimp->gradient_factory->container->num_children; - return_args[2].value.pdb_pointer = gradients; - } + return_args[1].value.pdb_int = num_gradients; + return_args[2].value.pdb_pointer = gradient_list; return return_args; } @@ -122,7 +108,7 @@ static ProcArg gradients_get_list_outargs[] = }, { GIMP_PDB_STRINGARRAY, - "gradient_names", + "gradient_list", "The list of gradient names" } }; diff --git a/app/pdb/internal_procs.c b/app/pdb/internal_procs.c index a26b6eefe8..6352f05712 100644 --- a/app/pdb/internal_procs.c +++ b/app/pdb/internal_procs.c @@ -41,6 +41,7 @@ void register_edit_procs (Gimp *gimp); void register_fileops_procs (Gimp *gimp); void register_floating_sel_procs (Gimp *gimp); void register_font_select_procs (Gimp *gimp); +void register_fonts_procs (Gimp *gimp); void register_gimprc_procs (Gimp *gimp); void register_gradient_select_procs (Gimp *gimp); void register_gradients_procs (Gimp *gimp); @@ -68,7 +69,7 @@ void register_transform_tools_procs (Gimp *gimp); void register_undo_procs (Gimp *gimp); void register_unit_procs (Gimp *gimp); -/* 345 procedures registered total */ +/* 347 procedures registered total */ void internal_procs_init (Gimp *gimp, @@ -83,106 +84,109 @@ internal_procs_init (Gimp *gimp, (* status_callback) (NULL, _("Brushes"), 0.009); register_brushes_procs (gimp); - (* status_callback) (NULL, _("Channel"), 0.041); + (* status_callback) (NULL, _("Channel"), 0.04); register_channel_procs (gimp); - (* status_callback) (NULL, _("Color"), 0.087); + (* status_callback) (NULL, _("Color"), 0.086); register_color_procs (gimp); - (* status_callback) (NULL, _("Convert"), 0.125); + (* status_callback) (NULL, _("Convert"), 0.124); register_convert_procs (gimp); (* status_callback) (NULL, _("Display procedures"), 0.133); register_display_procs (gimp); - (* status_callback) (NULL, _("Drawable procedures"), 0.145); + (* status_callback) (NULL, _("Drawable procedures"), 0.144); register_drawable_procs (gimp); - (* status_callback) (NULL, _("Edit procedures"), 0.212); + (* status_callback) (NULL, _("Edit procedures"), 0.21); register_edit_procs (gimp); - (* status_callback) (NULL, _("File Operations"), 0.229); + (* status_callback) (NULL, _("File Operations"), 0.228); register_fileops_procs (gimp); - (* status_callback) (NULL, _("Floating selections"), 0.252); + (* status_callback) (NULL, _("Floating selections"), 0.251); register_floating_sel_procs (gimp); - (* status_callback) (NULL, _("Font UI"), 0.27); + (* status_callback) (NULL, _("Font UI"), 0.268); register_font_select_procs (gimp); - (* status_callback) (NULL, _("Gimprc procedures"), 0.278); + (* status_callback) (NULL, _("Fonts"), 0.277); + register_fonts_procs (gimp); + + (* status_callback) (NULL, _("Gimprc procedures"), 0.282); register_gimprc_procs (gimp); - (* status_callback) (NULL, _("Gradient UI"), 0.29); + (* status_callback) (NULL, _("Gradient UI"), 0.294); register_gradient_select_procs (gimp); - (* status_callback) (NULL, _("Gradients"), 0.299); + (* status_callback) (NULL, _("Gradients"), 0.303); register_gradients_procs (gimp); - (* status_callback) (NULL, _("Guide procedures"), 0.319); + (* status_callback) (NULL, _("Guide procedures"), 0.323); register_guides_procs (gimp); - (* status_callback) (NULL, _("Help procedures"), 0.336); + (* status_callback) (NULL, _("Help procedures"), 0.34); register_help_procs (gimp); - (* status_callback) (NULL, _("Image"), 0.339); + (* status_callback) (NULL, _("Image"), 0.343); register_image_procs (gimp); - (* status_callback) (NULL, _("Layer"), 0.525); + (* status_callback) (NULL, _("Layer"), 0.527); register_layer_procs (gimp); - (* status_callback) (NULL, _("Message procedures"), 0.617); + (* status_callback) (NULL, _("Message procedures"), 0.62); register_message_procs (gimp); - (* status_callback) (NULL, _("Miscellaneous"), 0.626); + (* status_callback) (NULL, _("Miscellaneous"), 0.628); register_misc_procs (gimp); - (* status_callback) (NULL, _("Misc Tool procedures"), 0.632); + (* status_callback) (NULL, _("Misc Tool procedures"), 0.634); register_misc_tools_procs (gimp); - (* status_callback) (NULL, _("Paint Tool procedures"), 0.641); + (* status_callback) (NULL, _("Paint Tool procedures"), 0.643); register_paint_tools_procs (gimp); - (* status_callback) (NULL, _("Palette"), 0.684); + (* status_callback) (NULL, _("Palette"), 0.686); register_palette_procs (gimp); - (* status_callback) (NULL, _("Palette UI"), 0.701); + (* status_callback) (NULL, _("Palette UI"), 0.703); register_palette_select_procs (gimp); - (* status_callback) (NULL, _("Palettes"), 0.71); + (* status_callback) (NULL, _("Palettes"), 0.712); register_palettes_procs (gimp); - (* status_callback) (NULL, _("Parasite procedures"), 0.725); + (* status_callback) (NULL, _("Parasite procedures"), 0.726); register_parasite_procs (gimp); - (* status_callback) (NULL, _("Paths"), 0.759); + (* status_callback) (NULL, _("Paths"), 0.761); register_paths_procs (gimp); - (* status_callback) (NULL, _("Pattern UI"), 0.8); + (* status_callback) (NULL, _("Pattern UI"), 0.801); register_pattern_select_procs (gimp); - (* status_callback) (NULL, _("Patterns"), 0.809); + (* status_callback) (NULL, _("Patterns"), 0.81); register_patterns_procs (gimp); - (* status_callback) (NULL, _("Plug-in"), 0.823); + (* status_callback) (NULL, _("Plug-in"), 0.824); register_plug_in_procs (gimp); (* status_callback) (NULL, _("Procedural database"), 0.841); register_procedural_db_procs (gimp); - (* status_callback) (NULL, _("Image mask"), 0.864); + (* status_callback) (NULL, _("Image mask"), 0.865); register_selection_procs (gimp); (* status_callback) (NULL, _("Selection Tool procedures"), 0.916); register_selection_tools_procs (gimp); - (* status_callback) (NULL, _("Text procedures"), 0.93); + (* status_callback) (NULL, _("Text procedures"), 0.931); register_text_tool_procs (gimp); (* status_callback) (NULL, _("Transform Tool procedures"), 0.942); register_transform_tools_procs (gimp); - (* status_callback) (NULL, _("Undo"), 0.959); + (* status_callback) (NULL, _("Undo"), 0.96); register_undo_procs (gimp); (* status_callback) (NULL, _("Units"), 0.965); diff --git a/app/pdb/palettes_cmds.c b/app/pdb/palettes_cmds.c index 5c137c6593..a5456cd09a 100644 --- a/app/pdb/palettes_cmds.c +++ b/app/pdb/palettes_cmds.c @@ -91,30 +91,16 @@ static Argument * palettes_get_list_invoker (Gimp *gimp, Argument *args) { - gboolean success = TRUE; Argument *return_args; - gchar **palettes; - GList *list; - gint i = 0; + gint32 num_palettes; + gchar **palette_list; - palettes = g_new (gchar *, gimp->palette_factory->container->num_children); + palette_list = gimp_container_get_name_array (gimp->palette_factory->container, &num_palettes); - for (list = GIMP_LIST (gimp->palette_factory->container)->list; - list; - list = g_list_next (list)) - { - palettes[i++] = g_strdup (GIMP_OBJECT (list->data)->name); - } + return_args = procedural_db_return_args (&palettes_get_list_proc, TRUE); - success = (i > 0); - - return_args = procedural_db_return_args (&palettes_get_list_proc, success); - - if (success) - { - return_args[1].value.pdb_int = gimp->palette_factory->container->num_children; - return_args[2].value.pdb_pointer = palettes; - } + return_args[1].value.pdb_int = num_palettes; + return_args[2].value.pdb_pointer = palette_list; return return_args; } diff --git a/app/pdb/paths_cmds.c b/app/pdb/paths_cmds.c index 807120ef8a..37ff7f8bb3 100644 --- a/app/pdb/paths_cmds.c +++ b/app/pdb/paths_cmds.c @@ -82,33 +82,15 @@ path_list_invoker (Gimp *gimp, gboolean success = TRUE; Argument *return_args; GimpImage *gimage; - gint32 num_paths = 0; - gchar **path_list = NULL; + gint32 num_paths; + gchar **path_list; gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); if (! GIMP_IS_IMAGE (gimage)) success = FALSE; if (success) - { - num_paths = gimp_container_num_children (gimage->vectors); - - if (num_paths > 0) - { - gint count = 0; - GList *list; - - path_list = g_new (gchar *, num_paths); - - for (list = GIMP_LIST (gimage->vectors)->list; - list; - list = g_list_next (list)) - { - path_list[count++] = - g_strdup (gimp_object_get_name (GIMP_OBJECT (list->data))); - } - } - } + path_list = gimp_container_get_name_array (gimage->vectors, &num_paths); return_args = procedural_db_return_args (&path_list_proc, success); diff --git a/app/pdb/patterns_cmds.c b/app/pdb/patterns_cmds.c index fe03ee721f..3ac7db16fa 100644 --- a/app/pdb/patterns_cmds.c +++ b/app/pdb/patterns_cmds.c @@ -81,30 +81,16 @@ static Argument * patterns_get_list_invoker (Gimp *gimp, Argument *args) { - gboolean success = TRUE; Argument *return_args; - gchar **patterns; - GList *list; - gint i = 0; + gint32 num_patterns; + gchar **pattern_list; - patterns = g_new (gchar *, gimp->pattern_factory->container->num_children); + pattern_list = gimp_container_get_name_array (gimp->pattern_factory->container, &num_patterns); - for (list = GIMP_LIST (gimp->pattern_factory->container)->list; - list; - list = g_list_next (list)) - { - patterns[i++] = g_strdup (GIMP_OBJECT (list->data)->name); - } + return_args = procedural_db_return_args (&patterns_get_list_proc, TRUE); - success = (i > 0); - - return_args = procedural_db_return_args (&patterns_get_list_proc, success); - - if (success) - { - return_args[1].value.pdb_int = gimp->pattern_factory->container->num_children; - return_args[2].value.pdb_pointer = patterns; - } + return_args[1].value.pdb_int = num_patterns; + return_args[2].value.pdb_pointer = pattern_list; return return_args; } diff --git a/libgimp/gimp_pdb.h b/libgimp/gimp_pdb.h index 61b2f9ffa2..73aad257e2 100644 --- a/libgimp/gimp_pdb.h +++ b/libgimp/gimp_pdb.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/libgimp/gimpfonts_pdb.c b/libgimp/gimpfonts_pdb.c new file mode 100644 index 0000000000..34f237dde5 --- /dev/null +++ b/libgimp/gimpfonts_pdb.c @@ -0,0 +1,92 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball + * + * gimpfonts_pdb.c + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* NOTE: This file is autogenerated by pdbgen.pl */ + +#include "config.h" + +#include "gimp.h" + +/** + * gimp_fonts_refresh: + * + * Refresh current fonts. + * + * This procedure retrieves all fonts currently in the user's font path + * and updates the font dialogs accordingly. + * + * Returns: TRUE on success. + */ +gboolean +gimp_fonts_refresh (void) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_fonts_refresh", + &nreturn_vals, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + +/** + * gimp_fonts_get_list: + * @num_fonts: The number of available fonts. + * + * Retrieve the list of loaded fonts. + * + * This procedure returns a list of the fonts that are currently + * available. + * + * Returns: The list of font names. + */ +gchar ** +gimp_fonts_get_list (gint *num_fonts) +{ + GimpParam *return_vals; + gint nreturn_vals; + gchar **font_list = NULL; + gint i; + + return_vals = gimp_run_procedure ("gimp_fonts_get_list", + &nreturn_vals, + GIMP_PDB_END); + + *num_fonts = 0; + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + { + *num_fonts = return_vals[1].data.d_int32; + font_list = g_new (gchar *, *num_fonts); + for (i = 0; i < *num_fonts; i++) + font_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]); + } + + gimp_destroy_params (return_vals, nreturn_vals); + + return font_list; +} diff --git a/libgimp/gimpfonts_pdb.h b/libgimp/gimpfonts_pdb.h new file mode 100644 index 0000000000..4d9c096177 --- /dev/null +++ b/libgimp/gimpfonts_pdb.h @@ -0,0 +1,38 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball + * + * gimpfonts_pdb.h + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* NOTE: This file is autogenerated by pdbgen.pl */ + +#ifndef __GIMP_FONTS_PDB_H__ +#define __GIMP_FONTS_PDB_H__ + +G_BEGIN_DECLS + +/* For information look into the C source or the html documentation */ + + +gboolean gimp_fonts_refresh (void); +gchar** gimp_fonts_get_list (gint *num_fonts); + + +G_END_DECLS + +#endif /* __GIMP_FONTS_PDB_H__ */ diff --git a/libgimp/gimpgradients_pdb.c b/libgimp/gimpgradients_pdb.c index 4d65964d42..272f7074a0 100644 --- a/libgimp/gimpgradients_pdb.c +++ b/libgimp/gimpgradients_pdb.c @@ -72,7 +72,7 @@ gimp_gradients_get_list (gint *num_gradients) { GimpParam *return_vals; gint nreturn_vals; - gchar **gradient_names = NULL; + gchar **gradient_list = NULL; gint i; return_vals = gimp_run_procedure ("gimp_gradients_get_list", @@ -84,14 +84,14 @@ gimp_gradients_get_list (gint *num_gradients) if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) { *num_gradients = return_vals[1].data.d_int32; - gradient_names = g_new (gchar *, *num_gradients); + gradient_list = g_new (gchar *, *num_gradients); for (i = 0; i < *num_gradients; i++) - gradient_names[i] = g_strdup (return_vals[2].data.d_stringarray[i]); + gradient_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]); } gimp_destroy_params (return_vals, nreturn_vals); - return gradient_names; + return gradient_list; } /** diff --git a/tools/pdbgen/Makefile.am b/tools/pdbgen/Makefile.am index a93e9eaa0a..f1fa784cc0 100644 --- a/tools/pdbgen/Makefile.am +++ b/tools/pdbgen/Makefile.am @@ -13,6 +13,7 @@ pdb_sources = \ pdb/fileops.pdb \ pdb/floating_sel.pdb \ pdb/font_select.pdb \ + pdb/fonts.pdb \ pdb/gimprc.pdb \ pdb/gradient_select.pdb \ pdb/gradients.pdb \ diff --git a/tools/pdbgen/groups.pl b/tools/pdbgen/groups.pl index 7bf8f3c59e..3b8755d16c 100644 --- a/tools/pdbgen/groups.pl +++ b/tools/pdbgen/groups.pl @@ -11,6 +11,7 @@ fileops floating_sel font_select + fonts gimprc gradient_select gradients diff --git a/tools/pdbgen/pdb/brushes.pdb b/tools/pdbgen/pdb/brushes.pdb index d2600a2a11..29414d87f4 100644 --- a/tools/pdbgen/pdb/brushes.pdb +++ b/tools/pdbgen/pdb/brushes.pdb @@ -104,29 +104,12 @@ HELP @outargs = ( { name => 'brush_list', type => 'stringarray', desc => 'The list of brush names', - alias => 'brushes', array => { name => 'num_brushes', - desc => 'The number of brushes in the brush list', - alias => 'gimp->brush_factory->container->num_children', - no_declare => 1 } } + desc => 'The number of brushes in the brush list' } } ); %invoke = ( - vars => [ 'GList *list', 'int i = 0' ], - code => <<'CODE' -{ - brushes = g_new (char *, gimp->brush_factory->container->num_children); - - for (list = GIMP_LIST (gimp->brush_factory->container)->list; - list; - list = g_list_next (list)) - { - brushes[i++] = g_strdup (GIMP_OBJECT (list->data)->name); - } - - success = (i > 0); -} -CODE + code => 'brush_list = gimp_container_get_name_array (gimp->brush_factory->container, &num_brushes);' ); } diff --git a/tools/pdbgen/pdb/fonts.pdb b/tools/pdbgen/pdb/fonts.pdb new file mode 100644 index 0000000000..06286bef74 --- /dev/null +++ b/tools/pdbgen/pdb/fonts.pdb @@ -0,0 +1,70 @@ +# 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. + +# "Perlized" from C source by Manish Singh + +sub pdb_misc { + $author = $copyright = 'Sven Neumann'; + $date = '2003'; +} + +# The defs + +sub fonts_refresh { + $blurb = 'Refresh current fonts.'; + + $help = <<'HELP'; +This procedure retrieves all fonts currently in the user's font path +and updates the font dialogs accordingly. +HELP + + &pdb_misc; + + %invoke = ( + code => 'gimp_fonts_load (gimp);' + ); +} + +sub fonts_get_list { + $blurb = 'Retrieve the list of loaded fonts.'; + + $help = <<'HELP'; +This procedure returns a list of the fonts that are currently available. +HELP + + &pdb_misc; + + @outargs = ( + { name => 'font_list', type => 'stringarray', + desc => 'The list of font names', + array => { name => 'num_fonts', + desc => 'The number of available fonts' } } + ); + + %invoke = ( + code => 'font_list = gimp_container_get_name_array (gimp->fonts, &num_fonts);' + ); +} + +@headers = qw("core/gimp.h" "core/gimpcontainer.h" "text/gimpfonts.h"); + +@procs = qw(fonts_refresh fonts_get_list); +%exports = (app => [@procs], lib => [@procs]); + +$desc = 'Fonts'; + +1; diff --git a/tools/pdbgen/pdb/gradients.pdb b/tools/pdbgen/pdb/gradients.pdb index bdcf55477e..f1f9479171 100644 --- a/tools/pdbgen/pdb/gradients.pdb +++ b/tools/pdbgen/pdb/gradients.pdb @@ -57,30 +57,14 @@ HELP &pdb_misc; @outargs = ( - { name => 'gradient_names', type => 'stringarray', - desc => 'The list of gradient names', alias => 'gradients', + { name => 'gradient_list', type => 'stringarray', + desc => 'The list of gradient names', array => { name => 'num_gradients', - desc => 'The number of loaded gradients', - alias => 'gimp->gradient_factory->container->num_children', - no_declare => 1 } } + desc => 'The number of loaded gradients' } } ); %invoke = ( - vars => [ 'GList *list', 'gint i = 0' ], - code => <<'CODE' -{ - gradients = g_new (gchar *, gimp->gradient_factory->container->num_children); - - for (list = GIMP_LIST (gimp->gradient_factory->container)->list; - list; - list = g_list_next (list)) - { - gradients[i++] = g_strdup (GIMP_OBJECT (list->data)->name); - } - - success = (i > 0); -} -CODE + code => 'gradient_list = gimp_container_get_name_array (gimp->gradient_factory->container, &num_gradients);' ); } diff --git a/tools/pdbgen/pdb/palettes.pdb b/tools/pdbgen/pdb/palettes.pdb index 5598e712ea..0808a03bba 100644 --- a/tools/pdbgen/pdb/palettes.pdb +++ b/tools/pdbgen/pdb/palettes.pdb @@ -100,29 +100,12 @@ HELP @outargs = ( { name => 'palette_list', type => 'stringarray', desc => 'The list of palette names', - alias => 'palettes', array => { name => 'num_palettes', - desc => 'The number of palettes in the list', - alias => 'gimp->palette_factory->container->num_children', - no_declare => 1 } } + desc => 'The number of palettes in the list' } } ); %invoke = ( - vars => [ 'GList *list', 'gint i = 0' ], - code => <<'CODE' -{ - palettes = g_new (gchar *, gimp->palette_factory->container->num_children); - - for (list = GIMP_LIST (gimp->palette_factory->container)->list; - list; - list = g_list_next (list)) - { - palettes[i++] = g_strdup (GIMP_OBJECT (list->data)->name); - } - - success = (i > 0); -} -CODE + code => 'palette_list = gimp_container_get_name_array (gimp->palette_factory->container, &num_palettes);' ); } diff --git a/tools/pdbgen/pdb/paths.pdb b/tools/pdbgen/pdb/paths.pdb index 4ea1449858..ddb6492af0 100644 --- a/tools/pdbgen/pdb/paths.pdb +++ b/tools/pdbgen/pdb/paths.pdb @@ -37,34 +37,14 @@ HELP $inargs[0]->{desc} = 'The ID of the image to list the paths from'; @outargs = ( - { name => 'path_list', type => 'stringarray', init => 1, + { name => 'path_list', type => 'stringarray', desc => 'List of the paths belonging to this image', - array => { name => 'num_paths', init => 1, + array => { name => 'num_paths', desc => 'The number of paths returned' } } ); %invoke = ( - code => <<'CODE' -{ - num_paths = gimp_container_num_children (gimage->vectors); - - if (num_paths > 0) - { - gint count = 0; - GList *list; - - path_list = g_new (gchar *, num_paths); - - for (list = GIMP_LIST (gimage->vectors)->list; - list; - list = g_list_next (list)) - { - path_list[count++] = - g_strdup (gimp_object_get_name (GIMP_OBJECT (list->data))); - } - } -} -CODE + code => 'path_list = gimp_container_get_name_array (gimage->vectors, &num_paths);' ); } diff --git a/tools/pdbgen/pdb/patterns.pdb b/tools/pdbgen/pdb/patterns.pdb index 84940e2787..dd019224e3 100644 --- a/tools/pdbgen/pdb/patterns.pdb +++ b/tools/pdbgen/pdb/patterns.pdb @@ -82,29 +82,12 @@ HELP @outargs = ( { name => 'pattern_list', type => 'stringarray', desc => 'The list of pattern names', - alias => 'patterns', array => { name => 'num_patterns', - desc => 'The number of patterns in the pattern list', - alias => 'gimp->pattern_factory->container->num_children', - no_declare => 1 } } + desc => 'The number of patterns in the pattern list' } } ); %invoke = ( - vars => [ 'GList *list', 'gint i = 0' ], - code => <<'CODE' -{ - patterns = g_new (gchar *, gimp->pattern_factory->container->num_children); - - for (list = GIMP_LIST (gimp->pattern_factory->container)->list; - list; - list = g_list_next (list)) - { - patterns[i++] = g_strdup (GIMP_OBJECT (list->data)->name); - } - - success = (i > 0); -} -CODE + code => 'pattern_list = gimp_container_get_name_array (gimp->pattern_factory->container, &num_patterns);' ); }