Ejemplo n.º 1
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[2];
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;
  GimpParasite      *parasite;
  gint32             image;
  gint32             drawable;
  gint32             orig_image;
  GimpExportReturn   export = GIMP_EXPORT_CANCEL;
  GError            *error  = NULL;

  run_mode = param[0].data.d_int32;

  INIT_I18N ();
  gegl_init (NULL, NULL);

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;

  TIFFSetWarningHandler (tiff_warning);
  TIFFSetErrorHandler (tiff_error);

  if ((strcmp (name, SAVE_PROC) == 0) ||
      (strcmp (name, SAVE2_PROC) == 0))
    {
      /* Plug-in is either file_tiff_save or file_tiff_save2 */
      image = orig_image = param[1].data.d_int32;
      drawable = param[2].data.d_int32;

      /* Do this right this time, if POSSIBLE query for parasites, otherwise
         or if there isn't one, choose the default comment from the gimprc. */

      /*  eventually export the image */
      switch (run_mode)
        {
        case GIMP_RUN_INTERACTIVE:
        case GIMP_RUN_WITH_LAST_VALS:
          gimp_ui_init (PLUG_IN_BINARY, FALSE);
          export = gimp_export_image (&image, &drawable, NULL,
                                      (GIMP_EXPORT_CAN_HANDLE_RGB |
                                       GIMP_EXPORT_CAN_HANDLE_GRAY |
                                       GIMP_EXPORT_CAN_HANDLE_INDEXED |
                                       GIMP_EXPORT_CAN_HANDLE_ALPHA ));
          if (export == GIMP_EXPORT_CANCEL)
            {
              values[0].data.d_status = GIMP_PDB_CANCEL;
              return;
            }
          break;
        default:
          break;
        }
Ejemplo n.º 2
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam values[2];
  GimpRunMode      run_mode;

  run_mode = param[0].data.d_int32;

  INIT_I18N ();

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = GIMP_PDB_CALLING_ERROR;

  if (strcmp (name, PLUG_IN_PROC) == 0)
    {
      values[0].data.d_status = GIMP_PDB_SUCCESS;

      unit_editor_dialog ();
    }
}
Ejemplo n.º 3
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam  values[1];
  gint32            image_ID;
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  INIT_I18N();

  image_ID = param[1].data.d_image;

  if (status == GIMP_PDB_SUCCESS)
    {
      gimp_progress_init (_("Guillotine"));
      guillotine (image_ID);
      gimp_displays_flush ();
    }

  values[0].data.d_status = status;
}
Ejemplo n.º 4
0
static void
run (const gchar      *name,
     gint              n_params,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[1];
  GimpRunMode        run_mode;
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;
  gint32             drawable_id;
  gint32             image_id;

  INIT_I18N ();
  gegl_init (NULL, NULL);

  *nreturn_vals = 1;
  *return_vals  = values;

  run_mode = param[0].data.d_int32;

  if (run_mode == GIMP_RUN_NONINTERACTIVE)
    {
      if (n_params != 3)
        {
          status = GIMP_PDB_CALLING_ERROR;
        }
    }

  if (status == GIMP_PDB_SUCCESS)
    {
      /*  Get the specified drawable  */
      image_id    = param[1].data.d_int32;
      drawable_id = param[2].data.d_int32;

      /*  Make sure that the drawable is gray or RGB or indexed  */
      if (gimp_drawable_is_rgb (drawable_id) ||
          gimp_drawable_is_gray (drawable_id) ||
          gimp_drawable_is_indexed (drawable_id))
        {
          gimp_progress_init (_("Zealous cropping"));

          do_zcrop (drawable_id, image_id);

          if (run_mode != GIMP_RUN_NONINTERACTIVE)
            gimp_displays_flush ();
        }
      else
        {
          status = GIMP_PDB_EXECUTION_ERROR;
        }
    }

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  gegl_exit ();
}
static void
run (const gchar      *name,
     gint              n_params,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam  values[2];
  GimpRunMode       run_mode;
  GimpPDBStatusType status    = GIMP_PDB_SUCCESS;
  gboolean          diff_only = FALSE;

  *nreturn_vals = 2;
  *return_vals  = values;

  run_mode = param[0].data.d_int32;

  INIT_I18N ();

  if (run_mode == GIMP_RUN_NONINTERACTIVE && n_params != 3)
    {
      status = GIMP_PDB_CALLING_ERROR;
    }

  /* Check the procedure name we were called with, to decide
     what needs to be done. */
  if (strcmp (name, OPTIMIZE_PROC) == 0)
    opmode = OPOPTIMIZE;
  else if (strcmp (name, OPTIMIZE_DIFF_PROC) == 0)
    {
      opmode = OPOPTIMIZE;
      diff_only = TRUE;
    }
  else if (strcmp (name, UNOPTIMIZE_PROC) == 0)
    opmode = OPUNOPTIMIZE;
  else if (strcmp (name, FIND_BACKDROP_PROC) == 0)
    opmode = OPBACKGROUND;
  else if (strcmp (name, REMOVE_BACKDROP_PROC) == 0)
    opmode = OPFOREGROUND;
  else
    g_error("GAH!!!");

  if (status == GIMP_PDB_SUCCESS)
    {
      image_id = param[1].data.d_image;

      new_image_id = do_optimizations (run_mode, diff_only);

      if (run_mode != GIMP_RUN_NONINTERACTIVE)
        gimp_displays_flush();
    }

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  values[1].type         = GIMP_PDB_IMAGE;
  values[1].data.d_image = new_image_id;
}
Ejemplo n.º 6
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[1];
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;
  GimpRunMode        run_mode;
  GimpDrawable      *drawable;

  INIT_I18N ();

  run_mode = param[0].data.d_int32;
  drawable = gimp_drawable_get (param[2].data.d_int32);

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  switch (run_mode)
    {
    case GIMP_RUN_INTERACTIVE:
      gimp_get_data (HSV_NOISE_PROC, &VALS);
      if (!gimp_drawable_is_rgb (drawable->drawable_id))
        {
          g_message (_("Can only operate on RGB drawables."));
          return;
        }
      if (! scatter_hsv_dialog (drawable))
        return;
      break;

    case GIMP_RUN_NONINTERACTIVE:
      VALS.holdness            = CLAMP (param[3].data.d_int32, 1, 8);
      VALS.hue_distance        = CLAMP (param[4].data.d_int32, 0, 180);
      VALS.saturation_distance = CLAMP (param[5].data.d_int32, 0, 255);
      VALS.value_distance      = CLAMP (param[6].data.d_int32, 0, 255);
      break;

    case GIMP_RUN_WITH_LAST_VALS:
      gimp_get_data (HSV_NOISE_PROC, &VALS);
      break;
    }

  scatter_hsv (drawable);

  if (run_mode != GIMP_RUN_NONINTERACTIVE)
    gimp_displays_flush();
  if (run_mode == GIMP_RUN_INTERACTIVE && status == GIMP_PDB_SUCCESS )
    gimp_set_data (HSV_NOISE_PROC, &VALS, sizeof (ValueType));

  values[0].type = GIMP_PDB_STATUS;
  values[0].data.d_status = status;
}
Ejemplo n.º 7
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam  values[2];
  GimpPDBStatusType status = GIMP_PDB_EXECUTION_ERROR;
  GimpRunMode       run_mode;
  gint              image_id, layer_num;

  run_mode = param[0].data.d_int32;
  image_id = param[1].data.d_int32;

  INIT_I18N ();

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  switch ( run_mode )
    {
    case GIMP_RUN_INTERACTIVE:
      gimp_image_get_layers (image_id, &layer_num);
      if (layer_num < 2)
        {
          *nreturn_vals = 2;
          values[1].type          = GIMP_PDB_STRING;
          values[1].data.d_string = _("There are not enough layers to align.");
          return;
        }
      gimp_get_data (PLUG_IN_PROC, &VALS);
      VALS.grid_size = MAX (VALS.grid_size, 1);
      if (! align_layers_dialog ())
        return;
      break;

    case GIMP_RUN_NONINTERACTIVE:
      break;

    case GIMP_RUN_WITH_LAST_VALS:
      gimp_get_data (PLUG_IN_PROC, &VALS);
      break;
    }

  status = align_layers (image_id);

  if (run_mode != GIMP_RUN_NONINTERACTIVE)
    gimp_displays_flush ();
  if (run_mode == GIMP_RUN_INTERACTIVE && status == GIMP_PDB_SUCCESS)
    gimp_set_data (PLUG_IN_PROC, &VALS, sizeof (ValueType));

  values[0].type = GIMP_PDB_STATUS;
  values[0].data.d_status = status;
}
Ejemplo n.º 8
0
/* main function */
static void
run (const gchar      *name,
     gint              n_params,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[2];
  GimpRunMode        run_mode;
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;
  GimpDrawable      *drawable;

  run_mode = param[0].data.d_int32;

  INIT_I18N ();

  *nreturn_vals = 2;
  *return_vals  = values;

  if (run_mode == GIMP_RUN_NONINTERACTIVE)
    {
      if (n_params != 3)
        status = GIMP_PDB_CALLING_ERROR;
    }

  if (status == GIMP_PDB_SUCCESS)
    {
      drawable = gimp_drawable_get (param[2].data.d_drawable);
      imageID  = param[1].data.d_image;

      if (gimp_drawable_is_rgb (drawable->drawable_id) ||
          gimp_drawable_is_gray (drawable->drawable_id) ||
          gimp_drawable_is_indexed (drawable->drawable_id))
        {
          memset (hist_red, 0, sizeof (hist_red));
          memset (hist_green, 0, sizeof (hist_green));
          memset (hist_blue, 0, sizeof (hist_blue));

          gimp_tile_cache_ntiles (2 *
                                  (drawable->width / gimp_tile_width () + 1));

          analyze (drawable);

          /* show dialog after we analyzed image */
          if (run_mode != GIMP_RUN_NONINTERACTIVE)
            doDialog ();
        }
      else
        status = GIMP_PDB_EXECUTION_ERROR;

      gimp_drawable_detach (drawable);
    }

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;
  values[1].type          = GIMP_PDB_INT32;
  values[1].data.d_int32  = uniques;
}
Ejemplo n.º 9
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam  values[2];
  GimpRunMode       run_mode;
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;
  gint32            image_ID;
  GError           *error  = NULL;

  INIT_I18N ();
  gegl_init (NULL, NULL);

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;

  if (strcmp (name, LOAD_PROC) == 0)
    {
      run_mode = param[0].data.d_int32;

      image_ID = load_image (param[1].data.d_string,
                             run_mode == GIMP_RUN_INTERACTIVE, &error);

      if (image_ID != -1)
        {
          *nreturn_vals = 2;
          values[1].type = GIMP_PDB_IMAGE;
          values[1].data.d_image = image_ID;
        }
      else
        {
          status = GIMP_PDB_EXECUTION_ERROR;
        }
    }
  else
    {
      status = GIMP_PDB_CALLING_ERROR;
    }

  if (status != GIMP_PDB_SUCCESS && error)
    {
      *nreturn_vals = 2;
      values[1].type          = GIMP_PDB_STRING;
      values[1].data.d_string = error->message;
    }

  values[0].data.d_status = status;
}
Ejemplo n.º 10
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  GimpDrawable      *drawable;
  static GimpParam   values[1];
  GimpPDBStatusType  status = GIMP_PDB_EXECUTION_ERROR;
  GimpRunMode        run_mode;

  run_mode = param[0].data.d_int32;
  drawable = gimp_drawable_get (param[2].data.d_drawable);

  INIT_I18N ();

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  switch (run_mode)
    {
    case GIMP_RUN_INTERACTIVE:
      gimp_get_data (PLUG_IN_PROC, &pvals);
      /* Since a channel might be selected, we must check wheter RGB or not. */
      if (!gimp_drawable_is_rgb (drawable->drawable_id))
        {
          g_message (_("Can only operate on RGB drawables."));
          return;
        }
      if (! max_rgb_dialog (drawable))
        return;
      break;
    case GIMP_RUN_NONINTERACTIVE:
      /* You must copy the values of parameters to pvals or dialog variables. */
      pvals.max_p = param[3].data.d_int32;
      break;
    case GIMP_RUN_WITH_LAST_VALS:
      gimp_get_data (PLUG_IN_PROC, &pvals);
      break;
    }

  status = main_function (drawable, NULL);

  if (run_mode != GIMP_RUN_NONINTERACTIVE)
    gimp_displays_flush ();
  if (run_mode == GIMP_RUN_INTERACTIVE && status == GIMP_PDB_SUCCESS)
    gimp_set_data (PLUG_IN_PROC, &pvals, sizeof (ValueType));

  values[0].data.d_status = status;
}
Ejemplo n.º 11
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[1];
  GimpDrawable      *drawable;
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;
  GimpRunMode        run_mode;

  gint32 image_ID;

  INIT_I18N();

  run_mode = param[0].data.d_int32;

  /*  Get the specified drawable  */
  drawable = gimp_drawable_get (param[2].data.d_drawable);
  image_ID = param[1].data.d_image;

  /*  Make sure that the drawable is gray or RGB color  */
  if (gimp_drawable_is_rgb (drawable->drawable_id) ||
      gimp_drawable_is_gray (drawable->drawable_id))
    {
      gimp_progress_init (_("Auto-Stretching HSV"));
      gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width () + 1));
      autostretch_hsv (drawable);

      if (run_mode != GIMP_RUN_NONINTERACTIVE)
	gimp_displays_flush ();
    }
  else if (gimp_drawable_is_indexed (drawable->drawable_id))
    {
      indexed_autostretch_hsv (image_ID);

      if (run_mode != GIMP_RUN_NONINTERACTIVE)
	gimp_displays_flush ();
    }
  else
    {
      /* gimp_message ("autostretch_hsv: cannot operate on indexed color images"); */
      status = GIMP_PDB_EXECUTION_ERROR;
    }

  *nreturn_vals = 1;
  *return_vals = values;

  values[0].type = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  gimp_drawable_detach (drawable);
}
Ejemplo n.º 12
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[2];
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;
  GError            *error  = NULL;

  INIT_I18N ();
  gegl_init (NULL, NULL);

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;

  gimp_get_data (SAVE_PROC, &gtmvals);

  if (save_dialog (param[1].data.d_int32))
    {
      GeglBuffer *buffer;

      buffer = gimp_drawable_get_buffer (param[2].data.d_int32);

      if (save_image (param[3].data.d_string, buffer, &error))
        {
          gimp_set_data (SAVE_PROC, &gtmvals, sizeof (GTMValues));
        }
      else
        {
          status = GIMP_PDB_EXECUTION_ERROR;
        }

      g_object_unref (buffer);
    }
  else
    {
      status = GIMP_PDB_CANCEL;
    }

  if (status != GIMP_PDB_SUCCESS && error)
    {
      *nreturn_vals = 2;
      values[1].type          = GIMP_PDB_STRING;
      values[1].data.d_string = error->message;
    }

  values[0].data.d_status = status;
}
Ejemplo n.º 13
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam  values[1];
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;

  INIT_I18N ();

  /*  make sure all the arguments are there  */
  if (nparams == 4)
    {
      if (! gimp_help_init (param[0].data.d_int32,
                            param[1].data.d_stringarray,
                            param[2].data.d_int32,
                            param[3].data.d_stringarray))
        {
          status = GIMP_PDB_CALLING_ERROR;
        }
    }
  else
    {
      g_printerr ("help: wrong number of arguments in procedure call.\n");

      status = GIMP_PDB_CALLING_ERROR;
    }

  if (status == GIMP_PDB_SUCCESS)
    {
      main_loop = g_main_loop_new (NULL, FALSE);

      temp_proc_install ();

      gimp_extension_ack ();
      gimp_extension_enable ();

      g_main_loop_run (main_loop);

      g_main_loop_unref (main_loop);
      main_loop = NULL;

      gimp_uninstall_temp_proc (GIMP_HELP_TEMP_EXT_PROC);
    }

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  *nreturn_vals = 1;
  *return_vals  = values;
}
Ejemplo n.º 14
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam  values[2];
  GimpRunMode       run_mode;
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;
  GimpExportReturn  export = GIMP_EXPORT_CANCEL;

  run_mode = param[0].data.d_int32;

  *nreturn_vals = 1;
  *return_vals  = values;

  INIT_I18N ();

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;

  if (run_mode == GIMP_RUN_INTERACTIVE &&
      strcmp (name, SAVE_PROC) == 0)
    {
      gint32         image_ID    = param[1].data.d_int32;
      gint32         drawable_ID = param[2].data.d_int32;
      GimpParasite  *parasite;
      gchar         *x;
      GimpImageType  drawable_type = gimp_drawable_type (drawable_ID);

      gimp_get_data (SAVE_PROC, &config);
      config.prefixed_name = "gimp_image";
      config.comment       = NULL;

      config.file_name = param[3].data.d_string;
      config.alpha = (drawable_type == GIMP_RGBA_IMAGE ||
		      drawable_type == GIMP_GRAYA_IMAGE ||
		      drawable_type == GIMP_INDEXEDA_IMAGE);

      parasite = gimp_image_parasite_find (image_ID, "gimp-comment");
      if (parasite)
	{
	  config.comment = g_strndup (gimp_parasite_data (parasite),
                                      gimp_parasite_data_size (parasite));
	  gimp_parasite_free (parasite);
	}
      x = config.comment;

      gimp_ui_init (PLUG_IN_BINARY, FALSE);
      export = gimp_export_image (&image_ID, &drawable_ID, "C Source",
Ejemplo n.º 15
0
static void query ()
{
  static GParamDef args_foreach[] =
  {
    {PARAM_INT32, "run_mode", "Interactive, non-interactive"},
    {PARAM_IMAGE, "image", "Input image"},
    {PARAM_DRAWABLE, "drawable", "Input drawable (unused)"},
    {PARAM_STRING, "vidfile", "filename of the movtar video (to write)"},
    {PARAM_INT32, "dont_recode_frames", "=1: store the frames _directly_ into the movtar. "
                                 "(works only for 4:2:2 JPEG !)"},
    {PARAM_STRING, "wavfile", "optional audiodata file .wav audiodata, pass empty string if no audiodata should be included"},
    {PARAM_INT32, "auto_videoparam", "automatic or manual video parameters ?"},
    {PARAM_STRING, "videonorm", "The used videonorm is one of these 2 strings (ignored if auto_videoparam=1): "
                                "\""  "TVNORM_PAL" "\""
                                "\""  "TVNORM_NTSC"  "\""
                               },
    {PARAM_INT32, "jpeg_interlaced", "=1: store two JPEG frames, for the odd/even lines "
                                 "(ignored if auto_videoparam=1): "},
    {PARAM_STRING, "text_author", "The content of the Author field in the movtar."},
    {PARAM_STRING, "text_software", "The content of the Software field in the movtar."},
    {PARAM_STRING, "text_device", "The content of the Device field in the movtar."},
    {PARAM_STRING, "text_input", "The content of the Input field in the movtar."},
    {PARAM_STRING, "text_contclassification", "The content of the Author field in the movtar."},
    {PARAM_STRING, "text_contdescription", "The content of the Author field in the movtar."},
    {PARAM_INT32, "jpeg_quality", "the quality of the coded jpegs (0 - 100%)"}    
  };

#define NUMARGS 16

  static int nargs_foreach = sizeof(args_foreach) / sizeof(args_foreach[0]);

  static GParamDef *return_vals = NULL;
  static int nreturn_vals = 0;


  INIT_I18N();

  gimp_install_procedure(PLUGIN_NAME_MOVTAR_ENCODE,
			 "movtar encoding of anim frames",
			 _("This plugin encodes the selected range of animframes into a movtar."
			   " The (optional) audiodata must be in .wav-format (RIFF WAVEfmt )"
			   "The text information fields' content can be chosen freely."),
			 "Gernot Ziegler ([email protected])",
			 "Gernot Ziegler",
			 gap_movtar_version,
			 N_("<Image>/Video/Encode/Movtar"),
			 "RGB*, INDEXED*, GRAY*",
			 PROC_PLUG_IN,
			 nargs_foreach, nreturn_vals,
			 args_foreach, return_vals);			 
}	/* end movtar_query */
Ejemplo n.º 16
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam values[1];
  GimpRunMode      run_mode;

  run_mode = param[0].data.d_int32;

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = GIMP_PDB_SUCCESS;

  INIT_I18N ();

  switch (run_mode)
    {
    case GIMP_RUN_INTERACTIVE:
      {
        GtkWidget *dialog;

        gimp_ui_init (PLUG_IN_BINARY, FALSE);

        dialog =
          gimp_proc_browser_dialog_new (_("Procedure Browser"), PLUG_IN_BINARY,
                                        gimp_standard_help_func, PLUG_IN_PROC,

                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,

                                        NULL);

        gtk_dialog_run (GTK_DIALOG (dialog));
        gtk_widget_destroy (dialog);
      }
      break;

    case GIMP_RUN_WITH_LAST_VALS:
    case GIMP_RUN_NONINTERACTIVE:
      g_warning (PLUG_IN_PROC " allows only interactive invocation");
      values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
      break;

    default:
      break;
    }
}
Ejemplo n.º 17
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam  values[3];
  GimpRunMode       run_mode = param[0].data.d_int32;
  GimpPDBStatusType status   = GIMP_PDB_SUCCESS;

  *nreturn_vals = 3;
  *return_vals  = values;

  values[0].type              = GIMP_PDB_STATUS;
  values[0].data.d_status     = status;
  values[1].type              = GIMP_PDB_INT32;
  values[1].data.d_int32      = 0;
  values[2].type              = GIMP_PDB_INT32ARRAY;
  values[2].data.d_int32array = NULL;

  INIT_I18N();

  if (status == GIMP_PDB_SUCCESS)
    {
      GList *images;
      GList *list;
      gint   i;

      gimp_progress_init (_("Guillotine"));

      images = guillotine (param[1].data.d_image,
                           run_mode == GIMP_RUN_INTERACTIVE);

      values[1].data.d_int32      = g_list_length (images);
      values[2].data.d_int32array = g_new (gint32, values[1].data.d_int32);

      for (list = images, i = 0; list; list = g_list_next (list), i++)
        {
          values[2].data.d_int32array[i] = GPOINTER_TO_INT (list->data);
        }

      g_list_free (images);

      if (run_mode == GIMP_RUN_INTERACTIVE)
        gimp_displays_flush ();
    }

  values[0].data.d_status = status;
}
Ejemplo n.º 18
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam  values[2];
  GimpRunMode       run_mode;
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;

  INIT_I18N ();
  gegl_init (NULL, NULL);

  run_mode = param[0].data.d_int32;

  *nreturn_vals = 1;
  *return_vals  = values;
  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;

  if (strcmp (name, SAVE_PROC) == 0)
    {
      gint32           image_ID;
      gint32           drawable_ID;
      GimpExportReturn export = GIMP_EXPORT_CANCEL;

      image_ID    = param[1].data.d_int32;
      drawable_ID = param[2].data.d_int32;

      /*  eventually export the image */
      switch (run_mode)
        {
        case GIMP_RUN_INTERACTIVE:
        case GIMP_RUN_WITH_LAST_VALS:
          gimp_ui_init (PLUG_IN_BINARY, FALSE);
          export = gimp_export_image (&image_ID, &drawable_ID, NULL,
                                      GIMP_EXPORT_CAN_HANDLE_RGB |
                                      GIMP_EXPORT_CAN_HANDLE_INDEXED);
          if (export == GIMP_EXPORT_CANCEL)
            {
              values[0].data.d_status = GIMP_PDB_CANCEL;
              return;
            }
          break;

        default:
          break;
        }
Ejemplo n.º 19
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[2];
  GimpRunMode        run_mode;
  GimpPDBStatusType  status;
  gint32             image_ID;
  GError            *error = NULL;

  run_mode = param[0].data.d_int32;

  INIT_I18N ();

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;

  image_ID = param[1].data.d_int32;

  if (strcmp (name, PRINT_PROC_NAME) == 0)
    {
      status = print_image (image_ID, run_mode == GIMP_RUN_INTERACTIVE, &error);

      if (error && run_mode == GIMP_RUN_INTERACTIVE)
        {
          print_show_error (error->message);
        }
    }
  else
    {
      status = GIMP_PDB_CALLING_ERROR;
    }

  if (status != GIMP_PDB_SUCCESS && error)
    {
      *nreturn_vals = 2;
      values[1].type          = GIMP_PDB_STRING;
      values[1].data.d_string = error->message;
    }

  values[0].data.d_status = status;
}
Ejemplo n.º 20
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam  values[1];
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;

  *nreturn_vals = 1;
  *return_vals  = values;

  INIT_I18N ();

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  Current.drawable = gimp_drawable_get (param[2].data.d_drawable);
  Current.mask = gimp_drawable_get (gimp_image_get_selection (param[1].data.d_image));

  if (gimp_drawable_is_rgb (Current.drawable->drawable_id))
    {
      if (color_rotate_dialog ())
        {
          gimp_progress_init (_("Rotating the colors"));

          gimp_tile_cache_ntiles (2 * (Current.drawable->width /
                                       gimp_tile_width () + 1));
          color_rotate (Current.drawable);
          gimp_displays_flush ();
        }
      else
        {
          status = GIMP_PDB_CANCEL;
        }
    }
  else
    {
      status = GIMP_PDB_EXECUTION_ERROR;
    }

  values[0].data.d_status = status;

  if (status == GIMP_PDB_SUCCESS)
    gimp_drawable_detach (Current.drawable);
}
Ejemplo n.º 21
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam  values[2];
  GimpRunMode       run_mode;
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;
  gint              output_type = 0;
  gint32            image_ID;
  gint32            drawable_ID;
  GimpExportReturn  export = GIMP_EXPORT_CANCEL;

  INIT_I18N ();

  /* Set us up to return a status. */
  *nreturn_vals = 1;
  *return_vals  = values;
  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
  run_mode    = param[0].data.d_int32;
  image_ID    = param[1].data.d_int32;
  drawable_ID = param[2].data.d_int32;

  /*  eventually export the image */
  switch (run_mode)
    {
    case GIMP_RUN_INTERACTIVE:
    case GIMP_RUN_WITH_LAST_VALS:
      gimp_ui_init (PLUG_IN_BINARY, FALSE);

      export = gimp_export_image (&image_ID, &drawable_ID, "AA",
                                  GIMP_EXPORT_CAN_HANDLE_RGB  |
                                  GIMP_EXPORT_CAN_HANDLE_GRAY |
                                  GIMP_EXPORT_CAN_HANDLE_ALPHA);

      if (export == GIMP_EXPORT_CANCEL)
        {
          values[0].data.d_status = GIMP_PDB_CANCEL;
          return;
        }
      break;
    default:
      break;
    }
Ejemplo n.º 22
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[1];
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;
  gint32             drawable_id;
  gint               x, y, width, height;

  *nreturn_vals = 1;
  *return_vals = values;

  gegl_init (NULL, NULL);

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  INIT_I18N();

  drawable_id = param[2].data.d_drawable;

  if (gimp_drawable_mask_intersect (drawable_id, &x, &y, &width, &height))
    {
      GeglBuffer *buffer;
      GeglBuffer *shadow_buffer;

      buffer        = gimp_drawable_get_buffer (drawable_id);
      shadow_buffer = gimp_drawable_get_shadow_buffer (drawable_id);

      gegl_render_op (buffer, shadow_buffer, "gegl:invert", NULL);

      g_object_unref (shadow_buffer); /* flushes the shadow tiles */
      g_object_unref (buffer);

      gimp_drawable_merge_shadow (drawable_id, TRUE);
      gimp_drawable_update (drawable_id, x, y, width, height);
      gimp_displays_flush ();
    }

  values[0].data.d_status = status;
  gegl_exit ();
}
Ejemplo n.º 23
0
static void
query (void)
{
  /* setup for localization */
  INIT_I18N ();

  /* Arguments for CMYK Separation routines */

  static GimpParamDef args[] =
  {
    { GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
    { GIMP_PDB_STRING, "filename", "Filename" }
  };
  static gint nargs = sizeof (args) / sizeof (args[0]);
  static GimpParamDef rargs[] =
  {
    { GIMP_PDB_IMAGE, "new_image", "Separated image" }
  };
  static gint nrargs = sizeof (rargs) / sizeof (rargs[0]);

  gimp_install_procedure ("plug_in_separate_import",
                          _("Import CMYK TIFF image"),
                          _("Load the CMYK TIFF image, and generate four layers "
                            "as pseudo C/M/Y/K channels.\nTo convert to single-"
                            "layered RGB image, try to use the \"plug-in-separate"
                            "-proof\" procedure."),
                          "Yoshinori Yamakawa",
                          "Yoshinori Yamakawa",
                          "2007-2010",
                          N_("From CMYK TIFF"),
                          NULL,
                          GIMP_PLUGIN,
                          nargs, nrargs,
                          args, rargs );

  gimp_plugin_menu_register ("plug_in_separate_import",
                             gimp_major_version > 2 ||
                             (gimp_major_version == 2 && gimp_minor_version >= 6) ?
                             "<Image>/File/Create/" : "<Toolbox>/File/Acquire");

  gimp_plugin_domain_register (GETTEXT_PACKAGE, NULL);
}
Ejemplo n.º 24
0
static void
run (const gchar      *name,
     gint             nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[2];
  GimpPDBStatusType  status;
  GError            *error = NULL;

  *nreturn_vals = 1;
  *return_vals  = values;

  status   = GIMP_PDB_SUCCESS;

  INIT_I18N ();

  if (nparams == 1 &&
      param[0].data.d_string != NULL &&
      strlen (param[0].data.d_string))
    {
      if (! browser_open_url (param[0].data.d_string, &error))
        {
          status                  = GIMP_PDB_EXECUTION_ERROR;
          *nreturn_vals           = 2;
          values[1].type          = GIMP_PDB_STRING;
          values[1].data.d_string = error->message;
        }
    }
  else
    {
      status = GIMP_PDB_CALLING_ERROR;
    }

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;
}
Ejemplo n.º 25
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[1];
  GimpDrawable      *drawable;
  GimpRunMode        run_mode;
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;

  run_mode = param[0].data.d_int32;

  INIT_I18N ();

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  /*  Get the specified drawable  */
  drawable = gimp_drawable_get (param[2].data.d_drawable);

  switch (run_mode)
    {
    case GIMP_RUN_INTERACTIVE:
      /*  Possibly retrieve data  */
      gimp_get_data (PIXELIZE_PROC, &pvals);

      /*  First acquire information with a dialog  */
      if (! pixelize_dialog (drawable))
        {
          gimp_drawable_detach (drawable);
          return;
        }
      break;

    case GIMP_RUN_NONINTERACTIVE:
      /*  Make sure all the arguments are there!  */
      if ((! strcmp (name, PIXELIZE_PROC) && nparams != 4) ||
          (! strcmp (name, PIXELIZE2_PROC) && nparams != 5))
        {
          status = GIMP_PDB_CALLING_ERROR;
        }

      if (status == GIMP_PDB_SUCCESS)
        {
          pvals.pixelwidth  = (gdouble) param[3].data.d_int32;

          if (nparams == 4)
            pvals.pixelheight = pvals.pixelwidth;
          else
            pvals.pixelheight = (gdouble) param[4].data.d_int32;
        }

      if ((status == GIMP_PDB_SUCCESS) &&
          (pvals.pixelwidth <= 0 || pvals.pixelheight <= 0))
        {
          status = GIMP_PDB_CALLING_ERROR;
        }
      break;

    case GIMP_RUN_WITH_LAST_VALS:
      /*  Possibly retrieve data  */
      gimp_get_data (PIXELIZE_PROC, &pvals);
      break;

    default:
      break;
    }

  if (status == GIMP_PDB_SUCCESS)
    {
      /*  Make sure that the drawable is gray or RGB color  */
      if (gimp_drawable_is_rgb (drawable->drawable_id) ||
          gimp_drawable_is_gray (drawable->drawable_id))
        {
          gimp_progress_init (_("Pixelizing"));

          /*  set the tile cache size  */
          gimp_tile_cache_ntiles (TILE_CACHE_SIZE);

          /*  run the pixelize effect  */
          pixelize (drawable, NULL);

          if (run_mode != GIMP_RUN_NONINTERACTIVE)
            gimp_displays_flush ();

          /*  Store data  */
          if (run_mode == GIMP_RUN_INTERACTIVE)
            gimp_set_data (PIXELIZE_PROC, &pvals, sizeof (PixelizeValues));
        }
      else
        {
          /* g_message ("pixelize: cannot operate on indexed color images"); */
          status = GIMP_PDB_EXECUTION_ERROR;
        }
    }

  values[0].data.d_status = status;

  gimp_drawable_detach (drawable);
}
Ejemplo n.º 26
0
static void
plugin_run (const gchar      *name,
            gint              numof_params,
            const GimpParam  *params,
            gint             *numof_return_vals,
            GimpParam       **return_vals)
{
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;

  INIT_I18N ();

  p.run                = FALSE;
  p.run_mode           = params[0].data.d_int32;
  p.image              = params[1].data.d_image;
  p.drawable           = gimp_drawable_get(params[2].data.d_drawable);
  p.drawable_has_alpha = gimp_drawable_has_alpha(p.drawable->drawable_id);

  if (gimp_drawable_is_rgb (p.drawable->drawable_id))
    {
      switch (p.run_mode)
        {
        case GIMP_RUN_INTERACTIVE:
          params_load_from_gimp ();
          open_dialog ();
          break;

        case GIMP_RUN_NONINTERACTIVE:
          if (numof_params == 11)
            {
              p.params.tile_width       = params[3].data.d_int32;
              p.params.tile_height      = params[3].data.d_int32;
              p.params.division_x       = p.drawable->width  / p.params.tile_width;
              p.params.division_y       = p.drawable->height / p.params.tile_height;
              p.params.move_max_rate    = params[4].data.d_float;
              p.params.fractional_type  = (FractionalType)params[5].data.d_int32;
              p.params.wrap_around      = params[6].data.d_int32;
              p.params.centering        = params[7].data.d_int32;
              p.params.background_type  = (BackgroundType)params[8].data.d_int32;
              p.params.background_color = params[9].data.d_color;

              /*  FIXME:  this used to be the alpha value
                                          params[10].data.d_int32
               */
              p.run = TRUE;
            }
          else
            {
              status = GIMP_PDB_CALLING_ERROR;
            }
          break;

        case GIMP_RUN_WITH_LAST_VALS:
          params_load_from_gimp ();
          p.run = TRUE;
          break;
        }
    }
  else
    {
      status = GIMP_PDB_EXECUTION_ERROR;
    }

  if (status == GIMP_PDB_SUCCESS && p.run)
    {
      params_save_to_gimp ();

      filter ();

      if (p.run_mode != GIMP_RUN_NONINTERACTIVE)
        gimp_displays_flush ();
    }

  gimp_drawable_detach (p.drawable);

  {
    static GimpParam return_value[1];
    return_value[0].type          = GIMP_PDB_STATUS;
    return_value[0].data.d_status = status;
    *numof_return_vals            = 1;
    *return_vals                  = return_value;
  }
}
Ejemplo n.º 27
0
/*
 * run
 *
 * The plug-in is being requested to run.
 * Capture an window image.
 */
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  GimpRunMode run_mode;

  /* Initialize the return values
   * Always return at least the status to the caller.
   */
  values[0].type = GIMP_PDB_STATUS;
  values[0].data.d_status = GIMP_PDB_SUCCESS;
  *nreturn_vals = 1;
  *return_vals = values;

  /* Get the runmode from the in-parameters */
  run_mode = param[0].data.d_int32;

  INIT_I18N ();

  /* Set up the rest of the return parameters */
  values[1].type = GIMP_PDB_INT32;
  values[1].data.d_int32 = 0;

  /* Get the data from last run */
  gimp_get_data (PLUG_IN_PROC, &winsnapvals);

  /* How are we running today? */
  switch (run_mode) {
  case GIMP_RUN_INTERACTIVE:
    /* Get information from the dialog */
    if (!snap_dialog())
      return;
    break;

  case GIMP_RUN_NONINTERACTIVE:
  case GIMP_RUN_WITH_LAST_VALS:
    if (!winsnapvals.root)
      values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
    break;

  default:
    break;
  } /* switch */

  /* Do the actual window capture */
  if (winsnapvals.root)
    doRootWindowCapture();
  else
    doWindowCapture();

  /* Check to make sure we got at least one valid
   * image.
   */
  if (values[1].data.d_int32 > 0) {
    /* A window was captured.
     * Do final Interactive steps.
     */
    if (run_mode == GIMP_RUN_INTERACTIVE) {
      /* Store variable states for next run */
      gimp_set_data (PLUG_IN_PROC, &winsnapvals, sizeof(WinSnapValues));
    }

    /* Set return values */
    *nreturn_vals = 2;
  } else {
    values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
  }
}
Ejemplo n.º 28
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam  values[3];
  GimpRunMode       run_mode;
  GimpPDBStatusType status    = GIMP_PDB_SUCCESS;
  gint32            new_layer = -1;
  gint              width;
  gint              height;

  run_mode = param[0].data.d_int32;

  INIT_I18N ();

  *nreturn_vals = 3;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;
  values[1].type          = GIMP_PDB_IMAGE;
  values[2].type          = GIMP_PDB_LAYER;

  width  = gimp_drawable_width  (param[2].data.d_drawable);
  height = gimp_drawable_height (param[2].data.d_drawable);

  switch (run_mode)
    {
    case GIMP_RUN_INTERACTIVE:
      /*  Possibly retrieve data  */
      gimp_get_data (PLUG_IN_PROC, &tvals);

      /*  First acquire information with a dialog  */
      if (! tile_dialog (param[1].data.d_image,
                         param[2].data.d_drawable))
        return;
      break;

    case GIMP_RUN_NONINTERACTIVE:
      /*  Make sure all the arguments are there!  */
      if (nparams != 6)
        {
          status = GIMP_PDB_CALLING_ERROR;
        }
      else
        {
          tvals.new_width  = param[3].data.d_int32;
          tvals.new_height = param[4].data.d_int32;
          tvals.new_image  = param[5].data.d_int32 ? TRUE : FALSE;

          if (tvals.new_width < 0 || tvals.new_height < 0)
            status = GIMP_PDB_CALLING_ERROR;
        }
      break;

    case GIMP_RUN_WITH_LAST_VALS:
      /*  Possibly retrieve data  */
      gimp_get_data (PLUG_IN_PROC, &tvals);
      break;

    default:
      break;
    }

  if (status == GIMP_PDB_SUCCESS)
    {
      gimp_progress_init (_("Tiling"));

      values[1].data.d_image = tile (param[1].data.d_image,
                                     param[2].data.d_drawable,
                                     &new_layer);
      values[2].data.d_layer = new_layer;

      /*  Store data  */
      if (run_mode == GIMP_RUN_INTERACTIVE)
        gimp_set_data (PLUG_IN_PROC, &tvals, sizeof (TileVals));

      if (run_mode != GIMP_RUN_NONINTERACTIVE)
        {
          if (tvals.new_image)
            gimp_display_new (values[1].data.d_image);
          else
            gimp_displays_flush ();
        }
    }

  values[0].data.d_status = status;
}
Ejemplo n.º 29
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[2];
  GimpRunMode        run_mode;
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;
  gint32             image_ID;
  gint32             drawable_ID;

  INIT_I18N ();

  run_mode    = param[0].data.d_int32;
  image_ID    = param[1].data.d_image;
  drawable_ID = param[2].data.d_drawable;

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;

  if (strcmp (name, PLUG_IN_PROC) == 0)
    {
      switch (run_mode)
        {
        case GIMP_RUN_INTERACTIVE:
          gimp_get_data (PLUG_IN_PROC, &mail_info);
          {
            gchar *filename = gimp_image_get_filename (image_ID);

            if (filename)
              {
                gchar *basename = g_filename_display_basename (filename);

                g_strlcpy (mail_info.filename, basename, BUFFER_SIZE);
                g_free (basename);
                g_free (filename);
              }
          }

          if (! save_dialog ())
            status = GIMP_PDB_CANCEL;
          break;

        case GIMP_RUN_NONINTERACTIVE:
          /*  Make sure all the arguments are there!  */
          if (nparams < 8)
            {
              status = GIMP_PDB_CALLING_ERROR;
            }
          else
            {
              g_strlcpy (mail_info.filename,
                         param[3].data.d_string, BUFFER_SIZE);
              g_strlcpy (mail_info.receipt,
                         param[4].data.d_string, BUFFER_SIZE);
              g_strlcpy (mail_info.from,
                         param[5].data.d_string, BUFFER_SIZE);
              g_strlcpy (mail_info.subject,
                         param[6].data.d_string, BUFFER_SIZE);
              g_strlcpy (mail_info.comment,
                         param[7].data.d_string, BUFFER_SIZE);
            }
          break;

        case GIMP_RUN_WITH_LAST_VALS:
          gimp_get_data (PLUG_IN_PROC, &mail_info);
          break;

        default:
          break;
        }

      if (status == GIMP_PDB_SUCCESS)
        {
          status = save_image (mail_info.filename,
                               image_ID,
                               drawable_ID,
                               run_mode);

          if (status == GIMP_PDB_SUCCESS)
            {
              if (mesg_body)
                g_strlcpy (mail_info.comment, mesg_body, BUFFER_SIZE);

              gimp_set_data (PLUG_IN_PROC, &mail_info, sizeof (m_info));
            }
        }
    }
  else
    {
      status = GIMP_PDB_CALLING_ERROR;
    }

  values[0].data.d_status = status;
}
Ejemplo n.º 30
0
/* ---------------------------------
 * run
 * ---------------------------------
 */
static void
run(const gchar *name
   , gint n_params
   , const GimpParam *param
   , gint *nreturn_vals
   , GimpParam **return_vals)
{
  const gchar *l_env;

  static GimpParam values[2];
  GimpRunMode run_mode;
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;
  GapBlueboxGlobalParams  *bbp;

  gint32     l_rc;

  *nreturn_vals = 1;
  *return_vals = values;
  l_rc = 0;

  INIT_I18N();

  l_env = g_getenv("GAP_DEBUG");
  if(l_env != NULL)
  {
    if((*l_env != 'n') && (*l_env != 'N')) gap_debug = 1;
  }

  bbp = gap_bluebox_bbp_new(param[2].data.d_drawable);

  run_mode = param[0].data.d_int32;
  bbp->run_mode = param[0].data.d_int32;
  bbp->image_id = param[1].data.d_image;

  gimp_image_undo_group_start (bbp->image_id);

  gap_bluebox_init_default_vals(bbp);

  if(gap_debug) printf("\n\ngap_bluebox main: debug name = %s\n", name);

  if (strcmp (name, GAP_BLUEBOX_PLUGIN_NAME) == 0)
  {
      switch (run_mode)
      {
        case GIMP_RUN_INTERACTIVE:
          {
            /*  Possibly retrieve data  */
            gimp_get_data (GAP_BLUEBOX_DATA_KEY_VALS, &bbp->vals);
            l_rc = gap_bluebox_dialog(bbp);
            if(l_rc < 0)
            {
              status = GIMP_PDB_CANCEL;
            }
          }
          break;
        case GIMP_RUN_NONINTERACTIVE:
          {
            if (n_params != G_N_ELEMENTS (args_bluebox))
              {
                status = GIMP_PDB_CALLING_ERROR;
              }
            else
              {
                bbp->vals.keycolor = param[3].data.d_color;
                bbp->vals.thres_mode = param[4].data.d_int32;
                bbp->vals.thres_r = param[5].data.d_float;
                bbp->vals.thres_g = param[6].data.d_float;
                bbp->vals.thres_b = param[7].data.d_float;
                bbp->vals.thres_h = param[8].data.d_float;
                bbp->vals.thres_s = param[9].data.d_float;
                bbp->vals.thres_v = param[10].data.d_float;
                bbp->vals.thres   = param[11].data.d_float;
                bbp->vals.tolerance = param[12].data.d_float;
                bbp->vals.grow         = (gdouble)param[13].data.d_int32;
                bbp->vals.feather_edges  = param[14].data.d_int32;
                bbp->vals.feather_radius = param[15].data.d_float;
                bbp->vals.source_alpha   = param[16].data.d_float;
                bbp->vals.target_alpha   = param[17].data.d_float;

                bbp->run_flag = TRUE;
              }
          }
          break;
        case GIMP_RUN_WITH_LAST_VALS:
          {
            /*  Possibly retrieve data  */
            gimp_get_data (GAP_BLUEBOX_DATA_KEY_VALS, &bbp->vals);
            bbp->run_flag = TRUE;
          }
          break;
        default:
          break;
      }
  }

  if(status == GIMP_PDB_SUCCESS)
  {
    bbp->layer_id = bbp->drawable_id;

    l_rc = gap_bluebox_apply(bbp);
    if(l_rc < 0)
    {
      status = GIMP_PDB_EXECUTION_ERROR;
    }
    else
    {
      gimp_set_data (GAP_BLUEBOX_DATA_KEY_VALS, &bbp->vals, sizeof (bbp->vals));
    }
  }
  gimp_image_undo_group_end (bbp->image_id);

  /* ---------- return handling --------- */


  values[0].type = GIMP_PDB_STATUS;
  values[0].data.d_status = status;
}  /* end run */