home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / app / pattern_select_cmds.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-02-23  |  6.0 KB  |  258 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 "gimpcontext.h"
  26. #include "pattern_select.h"
  27.  
  28. static ProcRecord patterns_popup_proc;
  29. static ProcRecord patterns_close_popup_proc;
  30. static ProcRecord patterns_set_popup_proc;
  31.  
  32. void
  33. register_pattern_select_procs (void)
  34. {
  35.   procedural_db_register (&patterns_popup_proc);
  36.   procedural_db_register (&patterns_close_popup_proc);
  37.   procedural_db_register (&patterns_set_popup_proc);
  38. }
  39.  
  40. static PatternSelect *
  41. pattern_get_patternselect (gchar *name)
  42. {
  43.   GSList *list;
  44.   PatternSelect *psp;
  45.  
  46.   for (list = pattern_active_dialogs; list; list = g_slist_next (list))
  47.     {
  48.       psp = (PatternSelect *) list->data;
  49.       
  50.       if (psp->callback_name && !strcmp (name, psp->callback_name))
  51.     return psp;
  52.     }
  53.  
  54.   return NULL;
  55. }
  56.  
  57. static Argument *
  58. patterns_popup_invoker (Argument *args)
  59. {
  60.   gboolean success = TRUE;
  61.   gchar *name;
  62.   gchar *title;
  63.   gchar *pattern;
  64.   ProcRecord *prec;
  65.   PatternSelect *newdialog;
  66.  
  67.   name = (gchar *) args[0].value.pdb_pointer;
  68.   if (name == NULL)
  69.     success = FALSE;
  70.  
  71.   title = (gchar *) args[1].value.pdb_pointer;
  72.   if (title == NULL)
  73.     success = FALSE;
  74.  
  75.   pattern = (gchar *) args[2].value.pdb_pointer;
  76.  
  77.   if (success)
  78.     {
  79.       if ((prec = procedural_db_lookup (name)))
  80.     {
  81.       if (pattern && strlen (pattern))
  82.         newdialog = pattern_select_new (title, pattern);
  83.       else
  84.         newdialog = pattern_select_new (title, NULL);
  85.     
  86.       /* The callback procedure to run when pattern changes */
  87.       newdialog->callback_name = g_strdup (name);
  88.     }
  89.       else
  90.     success = FALSE;
  91.     }
  92.  
  93.   return procedural_db_return_args (&patterns_popup_proc, success);
  94. }
  95.  
  96. static ProcArg patterns_popup_inargs[] =
  97. {
  98.   {
  99.     PDB_STRING,
  100.     "pattern_callback",
  101.     "The callback PDB proc to call when pattern selection is made"
  102.   },
  103.   {
  104.     PDB_STRING,
  105.     "popup_title",
  106.     "Title to give the pattern popup window"
  107.   },
  108.   {
  109.     PDB_STRING,
  110.     "initial_pattern",
  111.     "The name of the pattern to set as the first selected"
  112.   }
  113. };
  114.  
  115. static ProcRecord patterns_popup_proc =
  116. {
  117.   "gimp_patterns_popup",
  118.   "Invokes the Gimp pattern selection.",
  119.   "This procedure popups the pattern selection dialog.",
  120.   "Andy Thomas",
  121.   "Andy Thomas",
  122.   "1998",
  123.   PDB_INTERNAL,
  124.   3,
  125.   patterns_popup_inargs,
  126.   0,
  127.   NULL,
  128.   { { patterns_popup_invoker } }
  129. };
  130.  
  131. static Argument *
  132. patterns_close_popup_invoker (Argument *args)
  133. {
  134.   gboolean success = TRUE;
  135.   gchar *name;
  136.   ProcRecord *prec;
  137.   PatternSelect *psp;
  138.  
  139.   name = (gchar *) args[0].value.pdb_pointer;
  140.   if (name == NULL)
  141.     success = FALSE;
  142.  
  143.   if (success)
  144.     {
  145.       if ((prec = procedural_db_lookup (name)) &&
  146.       (psp = pattern_get_patternselect (name)))
  147.     {
  148.       if (GTK_WIDGET_VISIBLE (psp->shell))
  149.         gtk_widget_hide (psp->shell);
  150.     
  151.       /* Free memory if poping down dialog which is not the main one */
  152.       if (psp != pattern_select_dialog)
  153.         {
  154.           gtk_widget_destroy (psp->shell);
  155.           pattern_select_free (psp);
  156.         }
  157.     }
  158.       else
  159.     success = FALSE;
  160.     }
  161.  
  162.   return procedural_db_return_args (&patterns_close_popup_proc, success);
  163. }
  164.  
  165. static ProcArg patterns_close_popup_inargs[] =
  166. {
  167.   {
  168.     PDB_STRING,
  169.     "pattern_callback",
  170.     "The name of the callback registered for this popup"
  171.   }
  172. };
  173.  
  174. static ProcRecord patterns_close_popup_proc =
  175. {
  176.   "gimp_patterns_close_popup",
  177.   "Popdown the Gimp pattern selection.",
  178.   "This procedure closes an opened pattern selection dialog.",
  179.   "Andy Thomas",
  180.   "Andy Thomas",
  181.   "1998",
  182.   PDB_INTERNAL,
  183.   1,
  184.   patterns_close_popup_inargs,
  185.   0,
  186.   NULL,
  187.   { { patterns_close_popup_invoker } }
  188. };
  189.  
  190. static Argument *
  191. patterns_set_popup_invoker (Argument *args)
  192. {
  193.   gboolean success = TRUE;
  194.   gchar *name;
  195.   gchar *pattern_name;
  196.   ProcRecord *prec;
  197.   PatternSelect *psp;
  198.  
  199.   name = (gchar *) args[0].value.pdb_pointer;
  200.   if (name == NULL)
  201.     success = FALSE;
  202.  
  203.   pattern_name = (gchar *) args[1].value.pdb_pointer;
  204.   if (pattern_name == NULL)
  205.     success = FALSE;
  206.  
  207.   if (success)
  208.     {
  209.       if ((prec = procedural_db_lookup (name)) &&
  210.       (psp = pattern_get_patternselect (name)))
  211.     {
  212.       GPattern *active = pattern_list_get_pattern (pattern_list, pattern_name);
  213.     
  214.       if (active)
  215.         {
  216.           /* Must alter the wigdets on screen as well */
  217.           gimp_context_set_pattern (psp->context, active);
  218.         }
  219.       else
  220.         success = FALSE;
  221.     }
  222.       else
  223.     success = FALSE;
  224.     }
  225.  
  226.   return procedural_db_return_args (&patterns_set_popup_proc, success);
  227. }
  228.  
  229. static ProcArg patterns_set_popup_inargs[] =
  230. {
  231.   {
  232.     PDB_STRING,
  233.     "pattern_callback",
  234.     "The name of the callback registered for this popup"
  235.   },
  236.   {
  237.     PDB_STRING,
  238.     "pattern_name",
  239.     "The name of the pattern to set as selected"
  240.   }
  241. };
  242.  
  243. static ProcRecord patterns_set_popup_proc =
  244. {
  245.   "gimp_patterns_set_popup",
  246.   "Sets the current pattern selection in a popup.",
  247.   "Sets the current pattern selection in a popup.",
  248.   "Andy Thomas",
  249.   "Andy Thomas",
  250.   "1998",
  251.   PDB_INTERNAL,
  252.   2,
  253.   patterns_set_popup_inargs,
  254.   0,
  255.   NULL,
  256.   { { patterns_set_popup_invoker } }
  257. };
  258.