home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / app / brush_select_cmds.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-02-23  |  7.8 KB  |  317 lines

  1. /* The GIMP -- an image manipulation program
  2.  * Copyright (C) 1995-2000 Spencer Kimball and Peter Mattis
  3.  *
  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 2 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17.  */
  18.  
  19. /* NOTE: This file is autogenerated by pdbgen.pl. */
  20.  
  21. #include "procedural_db.h"
  22.  
  23. #include <string.h>
  24.  
  25. #include "apptypes.h"
  26. #include "brush_select.h"
  27. #include "gimpbrushlist.h"
  28.  
  29. static ProcRecord brushes_popup_proc;
  30. static ProcRecord brushes_close_popup_proc;
  31. static ProcRecord brushes_set_popup_proc;
  32.  
  33. void
  34. register_brush_select_procs (void)
  35. {
  36.   procedural_db_register (&brushes_popup_proc);
  37.   procedural_db_register (&brushes_close_popup_proc);
  38.   procedural_db_register (&brushes_set_popup_proc);
  39. }
  40.  
  41. static BrushSelect *
  42. brush_get_brushselect (gchar *name)
  43. {
  44.   GSList *list;
  45.   BrushSelect *bsp;
  46.  
  47.   for (list = brush_active_dialogs; list; list = g_slist_next (list))
  48.     {
  49.       bsp = (BrushSelect *) list->data;
  50.  
  51.       if (bsp->callback_name && !strcmp (name, bsp->callback_name))
  52.     return bsp;
  53.     }
  54.  
  55.   return NULL;
  56. }
  57.  
  58. static Argument *
  59. brushes_popup_invoker (Argument *args)
  60. {
  61.   gboolean success = TRUE;
  62.   gchar *name;
  63.   gchar *title;
  64.   gchar *brush;
  65.   gdouble opacity;
  66.   gint32 spacing;
  67.   gint32 paint_mode;
  68.   ProcRecord *prec;
  69.   BrushSelect *newdialog;
  70.  
  71.   name = (gchar *) args[0].value.pdb_pointer;
  72.   if (name == NULL)
  73.     success = FALSE;
  74.  
  75.   title = (gchar *) args[1].value.pdb_pointer;
  76.   if (title == NULL)
  77.     success = FALSE;
  78.  
  79.   brush = (gchar *) args[2].value.pdb_pointer;
  80.  
  81.   opacity = args[3].value.pdb_float;
  82.  
  83.   spacing = args[4].value.pdb_int;
  84.  
  85.   paint_mode = args[5].value.pdb_int;
  86.   if (paint_mode < NORMAL_MODE || paint_mode > DIVIDE_MODE)
  87.     success = FALSE;
  88.  
  89.   if (success)
  90.     {
  91.       if ((prec = procedural_db_lookup (name)))
  92.     {
  93.       if (brush && strlen (brush))
  94.         newdialog = brush_select_new (title, brush, opacity, spacing,
  95.                       paint_mode);
  96.       else
  97.         newdialog = brush_select_new (title, NULL, 0.0, 0, 0);
  98.     
  99.       /* The callback procedure to run when brush changes */
  100.       newdialog->callback_name = g_strdup (name);
  101.     }
  102.       else
  103.     success = FALSE;
  104.     }
  105.  
  106.   return procedural_db_return_args (&brushes_popup_proc, success);
  107. }
  108.  
  109. static ProcArg brushes_popup_inargs[] =
  110. {
  111.   {
  112.     PDB_STRING,
  113.     "brush_callback",
  114.     "The callback PDB proc to call when brush selection is made"
  115.   },
  116.   {
  117.     PDB_STRING,
  118.     "popup_title",
  119.     "Title to give the brush popup window"
  120.   },
  121.   {
  122.     PDB_STRING,
  123.     "initial_brush",
  124.     "The name of the brush to set as the first selected"
  125.   },
  126.   {
  127.     PDB_FLOAT,
  128.     "opacity",
  129.     "The initial opacity of the brush"
  130.   },
  131.   {
  132.     PDB_INT32,
  133.     "spacing",
  134.     "The initial spacing of the brush (if < 0 then use brush default spacing)"
  135.   },
  136.   {
  137.     PDB_INT32,
  138.     "paint_mode",
  139.     "The initial paint mode: { NORMAL_MODE (0), DISSOLVE_MODE (1), BEHIND_MODE (2), MULTIPLY_MODE (3), SCREEN_MODE (4), OVERLAY_MODE (5), DIFFERENCE_MODE (6), ADDITION_MODE (7), SUBTRACT_MODE (8), DARKEN_ONLY_MODE (9), LIGHTEN_ONLY_MODE (10), HUE_MODE (11), SATURATION_MODE (12), COLOR_MODE (13), VALUE_MODE (14), DIVIDE_MODE (15) }"
  140.   }
  141. };
  142.  
  143. static ProcRecord brushes_popup_proc =
  144. {
  145.   "gimp_brushes_popup",
  146.   "Invokes the Gimp brush selection.",
  147.   "This procedure popups the brush selection dialog.",
  148.   "Andy Thomas",
  149.   "Andy Thomas",
  150.   "1998",
  151.   PDB_INTERNAL,
  152.   6,
  153.   brushes_popup_inargs,
  154.   0,
  155.   NULL,
  156.   { { brushes_popup_invoker } }
  157. };
  158.  
  159. static Argument *
  160. brushes_close_popup_invoker (Argument *args)
  161. {
  162.   gboolean success = TRUE;
  163.   gchar *name;
  164.   ProcRecord *prec;
  165.   BrushSelect *bsp;
  166.  
  167.   name = (gchar *) args[0].value.pdb_pointer;
  168.   if (name == NULL)
  169.     success = FALSE;
  170.  
  171.   if (success)
  172.     {
  173.       if ((prec = procedural_db_lookup (name)) &&
  174.       (bsp = brush_get_brushselect (name)))
  175.     {
  176.       if (GTK_WIDGET_VISIBLE (bsp->shell))
  177.         gtk_widget_hide (bsp->shell);
  178.     
  179.       /* Free memory if poping down dialog which is not the main one */
  180.       if (bsp != brush_select_dialog)
  181.         {
  182.           gtk_widget_destroy (bsp->shell);
  183.           brush_select_free (bsp);
  184.         }
  185.     }
  186.       else
  187.     success = FALSE;
  188.     }
  189.  
  190.   return procedural_db_return_args (&brushes_close_popup_proc, success);
  191. }
  192.  
  193. static ProcArg brushes_close_popup_inargs[] =
  194. {
  195.   {
  196.     PDB_STRING,
  197.     "brush_callback",
  198.     "The name of the callback registered for this popup"
  199.   }
  200. };
  201.  
  202. static ProcRecord brushes_close_popup_proc =
  203. {
  204.   "gimp_brushes_close_popup",
  205.   "Popdown the Gimp brush selection.",
  206.   "This procedure closes an opened brush selection dialog.",
  207.   "Andy Thomas",
  208.   "Andy Thomas",
  209.   "1998",
  210.   PDB_INTERNAL,
  211.   1,
  212.   brushes_close_popup_inargs,
  213.   0,
  214.   NULL,
  215.   { { brushes_close_popup_invoker } }
  216. };
  217.  
  218. static Argument *
  219. brushes_set_popup_invoker (Argument *args)
  220. {
  221.   gboolean success = TRUE;
  222.   gchar *name;
  223.   gchar *brush_name;
  224.   gdouble opacity;
  225.   gint32 spacing;
  226.   gint32 paint_mode;
  227.   ProcRecord *prec;
  228.   BrushSelect *bsp;
  229.  
  230.   name = (gchar *) args[0].value.pdb_pointer;
  231.   if (name == NULL)
  232.     success = FALSE;
  233.  
  234.   brush_name = (gchar *) args[1].value.pdb_pointer;
  235.   if (brush_name == NULL)
  236.     success = FALSE;
  237.  
  238.   opacity = args[2].value.pdb_float;
  239.  
  240.   spacing = args[3].value.pdb_int;
  241.  
  242.   paint_mode = args[4].value.pdb_int;
  243.   if (paint_mode < NORMAL_MODE || paint_mode > DIVIDE_MODE)
  244.     success = FALSE;
  245.  
  246.   if (success)
  247.     {
  248.       if ((prec = procedural_db_lookup (name)) &&
  249.       (bsp = brush_get_brushselect (name)))
  250.     {
  251.       GimpBrush *active = gimp_brush_list_get_brush (brush_list, brush_name);
  252.     
  253.       if (active)
  254.         {
  255.           /* Updating the context updates the widgets as well */
  256.     
  257.           gimp_context_set_brush (bsp->context, active);
  258.           gimp_context_set_opacity (bsp->context, opacity);
  259.           gimp_context_set_paint_mode (bsp->context, paint_mode);
  260.     
  261.           gtk_adjustment_set_value (GTK_ADJUSTMENT (bsp->spacing_data), spacing);
  262.         }
  263.       else
  264.         success = FALSE;
  265.     }
  266.       else
  267.     success = FALSE;
  268.     }
  269.  
  270.   return procedural_db_return_args (&brushes_set_popup_proc, success);
  271. }
  272.  
  273. static ProcArg brushes_set_popup_inargs[] =
  274. {
  275.   {
  276.     PDB_STRING,
  277.     "brush_callback",
  278.     "The name of the callback registered for this popup"
  279.   },
  280.   {
  281.     PDB_STRING,
  282.     "brush_name",
  283.     "The name of the brush to set as selected"
  284.   },
  285.   {
  286.     PDB_FLOAT,
  287.     "opacity",
  288.     "The initial opacity of the brush"
  289.   },
  290.   {
  291.     PDB_INT32,
  292.     "spacing",
  293.     "The initial spacing of the brush (if < 0 then use brush default spacing)"
  294.   },
  295.   {
  296.     PDB_INT32,
  297.     "paint_mode",
  298.     "The initial paint mode: { NORMAL_MODE (0), DISSOLVE_MODE (1), BEHIND_MODE (2), MULTIPLY_MODE (3), SCREEN_MODE (4), OVERLAY_MODE (5), DIFFERENCE_MODE (6), ADDITION_MODE (7), SUBTRACT_MODE (8), DARKEN_ONLY_MODE (9), LIGHTEN_ONLY_MODE (10), HUE_MODE (11), SATURATION_MODE (12), COLOR_MODE (13), VALUE_MODE (14), DIVIDE_MODE (15) }"
  299.   }
  300. };
  301.  
  302. static ProcRecord brushes_set_popup_proc =
  303. {
  304.   "gimp_brushes_set_popup",
  305.   "Sets the current brush selection in a popup.",
  306.   "Sets the current brush selection in a popup.",
  307.   "Andy Thomas",
  308.   "Andy Thomas",
  309.   "1998",
  310.   PDB_INTERNAL,
  311.   5,
  312.   brushes_set_popup_inargs,
  313.   0,
  314.   NULL,
  315.   { { brushes_set_popup_invoker } }
  316. };
  317.