コード例 #1
0
ファイル: gimp-cmds.c プロジェクト: jiapei100/gimp
static GimpValueArray *
get_parasite_invoker (GimpProcedure         *procedure,
                      Gimp                  *gimp,
                      GimpContext           *context,
                      GimpProgress          *progress,
                      const GimpValueArray  *args,
                      GError               **error)
{
  gboolean success = TRUE;
  GimpValueArray *return_vals;
  const gchar *name;
  GimpParasite *parasite = NULL;

  name = g_value_get_string (gimp_value_array_index (args, 0));

  if (success)
    {
      parasite = gimp_parasite_copy (gimp_parasite_find (gimp, name));

      if (! parasite)
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_boxed (gimp_value_array_index (return_vals, 1), parasite);

  return return_vals;
}
コード例 #2
0
ファイル: parasite-cmds.c プロジェクト: jdburton/gimp-osx
static GValueArray *
vectors_parasite_find_invoker (GimpProcedure      *procedure,
                               Gimp               *gimp,
                               GimpContext        *context,
                               GimpProgress       *progress,
                               const GValueArray  *args,
                               GError            **error)
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  GimpVectors *vectors;
  const gchar *name;
  GimpParasite *parasite = NULL;

  vectors = gimp_value_get_vectors (&args->values[0], gimp);
  name = g_value_get_string (&args->values[1]);

  if (success)
    {
      parasite = gimp_parasite_copy (gimp_item_parasite_find (GIMP_ITEM (vectors),
                                                              name));

      if (! parasite)
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_boxed (&return_vals->values[1], parasite);

  return return_vals;
}
コード例 #3
0
ファイル: gimpimageundo.c プロジェクト: ctrevino/gimp
static void
gimp_image_undo_constructed (GObject *object)
{
  GimpImageUndo *image_undo = GIMP_IMAGE_UNDO (object);
  GimpImage     *image;

  G_OBJECT_CLASS (parent_class)->constructed (object);

  image = GIMP_UNDO (object)->image;

  switch (GIMP_UNDO (object)->undo_type)
    {
    case GIMP_UNDO_IMAGE_TYPE:
      image_undo->base_type = gimp_image_get_base_type (image);
      break;

    case GIMP_UNDO_IMAGE_PRECISION:
      image_undo->precision = gimp_image_get_precision (image);
      break;

    case GIMP_UNDO_IMAGE_SIZE:
      image_undo->width  = gimp_image_get_width  (image);
      image_undo->height = gimp_image_get_height (image);
      break;

    case GIMP_UNDO_IMAGE_RESOLUTION:
      gimp_image_get_resolution (image,
                                 &image_undo->xresolution,
                                 &image_undo->yresolution);
      image_undo->resolution_unit = gimp_image_get_unit (image);
      break;

    case GIMP_UNDO_IMAGE_GRID:
      g_assert (GIMP_IS_GRID (image_undo->grid));
      break;

    case GIMP_UNDO_IMAGE_COLORMAP:
      image_undo->num_colors = gimp_image_get_colormap_size (image);
      image_undo->colormap   = g_memdup (gimp_image_get_colormap (image),
                                         GIMP_IMAGE_COLORMAP_SIZE);
      break;

    case GIMP_UNDO_IMAGE_METADATA:
      image_undo->metadata =
        gimp_metadata_duplicate (gimp_image_get_metadata (image));
      break;

    case GIMP_UNDO_PARASITE_ATTACH:
    case GIMP_UNDO_PARASITE_REMOVE:
      g_assert (image_undo->parasite_name != NULL);

      image_undo->parasite = gimp_parasite_copy
        (gimp_image_parasite_find (image, image_undo->parasite_name));
      break;

    default:
      g_assert_not_reached ();
    }
}
コード例 #4
0
ファイル: gimpitempropundo.c プロジェクト: LebedevRI/gimp
static void
gimp_item_prop_undo_constructed (GObject *object)
{
  GimpItemPropUndo *item_prop_undo = GIMP_ITEM_PROP_UNDO (object);
  GimpItem         *item;

  G_OBJECT_CLASS (parent_class)->constructed (object);

  item = GIMP_ITEM_UNDO (object)->item;

  switch (GIMP_UNDO (object)->undo_type)
    {
    case GIMP_UNDO_ITEM_REORDER:
      item_prop_undo->parent   = gimp_item_get_parent (item);
      item_prop_undo->position = gimp_item_get_index (item);
      break;

    case GIMP_UNDO_ITEM_RENAME:
      item_prop_undo->name = g_strdup (gimp_object_get_name (item));
      break;

    case GIMP_UNDO_ITEM_DISPLACE:
      gimp_item_get_offset (item,
                            &item_prop_undo->offset_x,
                            &item_prop_undo->offset_y);
      break;

    case GIMP_UNDO_ITEM_VISIBILITY:
      item_prop_undo->visible = gimp_item_get_visible (item);
      break;

    case GIMP_UNDO_ITEM_LINKED:
      item_prop_undo->linked = gimp_item_get_linked (item);
      break;

    case GIMP_UNDO_ITEM_COLOR_TAG:
      item_prop_undo->color_tag = gimp_item_get_color_tag (item);
      break;

    case GIMP_UNDO_ITEM_LOCK_CONTENT:
      item_prop_undo->lock_content = gimp_item_get_lock_content (item);
      break;

    case GIMP_UNDO_ITEM_LOCK_POSITION:
      item_prop_undo->lock_position = gimp_item_get_lock_position (item);
      break;

    case GIMP_UNDO_PARASITE_ATTACH:
    case GIMP_UNDO_PARASITE_REMOVE:
      g_assert (item_prop_undo->parasite_name != NULL);

      item_prop_undo->parasite = gimp_parasite_copy
        (gimp_item_parasite_find (item, item_prop_undo->parasite_name));
      break;

    default:
      g_assert_not_reached ();
    }
}
コード例 #5
0
ファイル: gimpitempropundo.c プロジェクト: jdburton/gimp-osx
static GObject *
gimp_item_prop_undo_constructor (GType                  type,
                                 guint                  n_params,
                                 GObjectConstructParam *params)
{
  GObject          *object;
  GimpItemPropUndo *item_prop_undo;
  GimpItem         *item;

  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);

  item_prop_undo = GIMP_ITEM_PROP_UNDO (object);

  item = GIMP_ITEM_UNDO (object)->item;

  switch (GIMP_UNDO (object)->undo_type)
    {
    case GIMP_UNDO_ITEM_RENAME:
      item_prop_undo->name = g_strdup (gimp_object_get_name (GIMP_OBJECT (item)));
      break;

    case GIMP_UNDO_ITEM_DISPLACE:
      gimp_item_offsets (item,
                         &item_prop_undo->offset_x,
                         &item_prop_undo->offset_y);
      break;

    case GIMP_UNDO_ITEM_VISIBILITY:
      item_prop_undo->visible = gimp_item_get_visible (item);
      break;

    case GIMP_UNDO_ITEM_LINKED:
      item_prop_undo->linked  = gimp_item_get_linked (item);
      break;

    case GIMP_UNDO_PARASITE_ATTACH:
    case GIMP_UNDO_PARASITE_REMOVE:
      g_assert (item_prop_undo->parasite_name != NULL);

      item_prop_undo->parasite = gimp_parasite_copy
        (gimp_item_parasite_find (item, item_prop_undo->parasite_name));
      break;

    default:
      g_assert_not_reached ();
    }

  return object;
}
コード例 #6
0
ファイル: gimp_pdb.c プロジェクト: AjayRamanathan/gimp
/**
 * gimp_get_parasite:
 * @name: The name of the parasite to find.
 *
 * Look up a global parasite.
 *
 * Finds and returns the global parasite that was previously attached.
 *
 * Returns: The found parasite.
 *
 * Since: GIMP 2.8
 **/
GimpParasite *
gimp_get_parasite (const gchar *name)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  GimpParasite *parasite = NULL;

  return_vals = gimp_run_procedure ("gimp-get-parasite",
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_END);

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    parasite = gimp_parasite_copy (&return_vals[1].data.d_parasite);

  gimp_destroy_params (return_vals, nreturn_vals);

  return parasite;
}
コード例 #7
0
ファイル: gimpparasitelist.c プロジェクト: Anstep/gimp
void
gimp_parasite_list_add (GimpParasiteList   *list,
                        const GimpParasite *parasite)
{
  GimpParasite *copy;

  g_return_if_fail (GIMP_IS_PARASITE_LIST (list));
  g_return_if_fail (parasite != NULL);
  g_return_if_fail (parasite->name != NULL);

  if (list->table == NULL)
    list->table = g_hash_table_new (g_str_hash, g_str_equal);

  gimp_parasite_list_remove (list, parasite->name);
  copy = gimp_parasite_copy (parasite);
  g_hash_table_insert (list->table, copy->name, copy);

  g_signal_emit (list, parasite_list_signals[ADD], 0, copy);
}
コード例 #8
0
ファイル: gimpitempropundo.c プロジェクト: LebedevRI/gimp
static void
gimp_item_prop_undo_pop (GimpUndo            *undo,
                         GimpUndoMode         undo_mode,
                         GimpUndoAccumulator *accum)
{
  GimpItemPropUndo *item_prop_undo = GIMP_ITEM_PROP_UNDO (undo);
  GimpItem         *item           = GIMP_ITEM_UNDO (undo)->item;

  GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);

  switch (undo->undo_type)
    {
    case GIMP_UNDO_ITEM_REORDER:
      {
        GimpItem *parent;
        gint      position;

        parent   = gimp_item_get_parent (item);
        position = gimp_item_get_index (item);

        gimp_item_tree_reorder_item (gimp_item_get_tree (item), item,
                                     item_prop_undo->parent,
                                     item_prop_undo->position,
                                     FALSE, NULL);

        item_prop_undo->parent   = parent;
        item_prop_undo->position = position;
      }
      break;

    case GIMP_UNDO_ITEM_RENAME:
      {
        gchar *name;

        name = g_strdup (gimp_object_get_name (item));

        gimp_item_tree_rename_item (gimp_item_get_tree (item), item,
                                    item_prop_undo->name,
                                    FALSE, NULL);

        g_free (item_prop_undo->name);
        item_prop_undo->name = name;
      }
      break;

    case GIMP_UNDO_ITEM_DISPLACE:
      {
        gint offset_x;
        gint offset_y;

        gimp_item_get_offset (item, &offset_x, &offset_y);

        gimp_item_translate (item,
                             item_prop_undo->offset_x - offset_x,
                             item_prop_undo->offset_y - offset_y,
                             FALSE);

        item_prop_undo->offset_x = offset_x;
        item_prop_undo->offset_y = offset_y;
      }
      break;

    case GIMP_UNDO_ITEM_VISIBILITY:
      {
        gboolean visible;

        visible = gimp_item_get_visible (item);
        gimp_item_set_visible (item, item_prop_undo->visible, FALSE);
        item_prop_undo->visible = visible;
      }
      break;

    case GIMP_UNDO_ITEM_LINKED:
      {
        gboolean linked;

        linked = gimp_item_get_linked (item);
        gimp_item_set_linked (item, item_prop_undo->linked, FALSE);
        item_prop_undo->linked = linked;
      }
      break;

    case GIMP_UNDO_ITEM_COLOR_TAG:
      {
        GimpColorTag color_tag;

        color_tag = gimp_item_get_color_tag (item);
        gimp_item_set_color_tag (item, item_prop_undo->color_tag, FALSE);
        item_prop_undo->color_tag = color_tag;
      }
      break;

    case GIMP_UNDO_ITEM_LOCK_CONTENT:
      {
        gboolean lock_content;

        lock_content = gimp_item_get_lock_content (item);
        gimp_item_set_lock_content (item, item_prop_undo->lock_content, FALSE);
        item_prop_undo->lock_content = lock_content;
      }
      break;

    case GIMP_UNDO_ITEM_LOCK_POSITION:
      {
        gboolean lock_position;

        lock_position = gimp_item_get_lock_position (item);
        gimp_item_set_lock_position (item, item_prop_undo->lock_position, FALSE);
        item_prop_undo->lock_position = lock_position;
      }
      break;

    case GIMP_UNDO_PARASITE_ATTACH:
    case GIMP_UNDO_PARASITE_REMOVE:
      {
        GimpParasite *parasite;

        parasite = item_prop_undo->parasite;

        item_prop_undo->parasite = gimp_parasite_copy
          (gimp_item_parasite_find (item, item_prop_undo->parasite_name));

        if (parasite)
          gimp_item_parasite_attach (item, parasite, FALSE);
        else
          gimp_item_parasite_detach (item, item_prop_undo->parasite_name, FALSE);

        if (parasite)
          gimp_parasite_free (parasite);
      }
      break;

    default:
      g_assert_not_reached ();
    }
}
コード例 #9
0
ファイル: pygimp-pdb.c プロジェクト: Minoos/gimp
PyObject *
pygimp_param_to_tuple(int nparams, const GimpParam *params)
{
    PyObject *args, *tmp;
    int i, j, n;

    args = PyTuple_New(nparams);
    for (i = 0; i < nparams && params[i].type != GIMP_PDB_END; i++) {
	PyObject *value = NULL;

	switch(params[i].type) {
	case GIMP_PDB_INT32:
	    value = PyInt_FromLong(params[i].data.d_int32);
	    break;
	case GIMP_PDB_INT16:
	    value = PyInt_FromLong(params[i].data.d_int16);
	    break;
	case GIMP_PDB_INT8:
	    value = PyInt_FromLong(params[i].data.d_int8);
	    break;
	case GIMP_PDB_FLOAT:
	    value = PyFloat_FromDouble(params[i].data.d_float);
	    break;
	case GIMP_PDB_STRING:
	    if (params[i].data.d_string == NULL) {
		Py_INCREF(Py_None);
		value = Py_None;
	    } else
		value = PyString_FromString(params[i].data.d_string);
	    break;

	    /* For these to work, the previous argument must have
	     * been an integer
	     */
	case GIMP_PDB_INT32ARRAY:
	    if (params[i].data.d_int32array == NULL) {
		value = PyTuple_New(0);
		break;
	    }
	    if ((tmp=PyTuple_GetItem(args, i-1)) == NULL) {
		Py_DECREF(args);
		return NULL;
	    }
	    if (!PyInt_Check(tmp)) {
		PyErr_SetString(PyExc_TypeError,
				"count type must be integer");
		Py_DECREF(args);
		return NULL;
	    }
	    n = PyInt_AsLong(tmp);
	    value = PyTuple_New(n);
	    for (j = 0; j < n; j++)
		PyTuple_SetItem(value, j,
			PyInt_FromLong(params[i].data.d_int32array[j]));
	    break;
	case GIMP_PDB_INT16ARRAY:
	    if (params[i].data.d_int16array == NULL) {
		value = PyTuple_New(0);
		break;
	    }
	    if ((tmp=PyTuple_GetItem(args, i-1)) == NULL) {
		Py_DECREF(args);
		return NULL;
	    }
	    if (!PyInt_Check(tmp)) {
		PyErr_SetString(PyExc_TypeError,
				"count type must be integer");
		Py_DECREF(args);
		return NULL;
	    }
	    n = PyInt_AsLong(tmp);
	    value = PyTuple_New(n);
	    for (j = 0; j < n; j++)
		PyTuple_SetItem(value, j,
			PyInt_FromLong(params[i].data.d_int16array[j]));
	    break;
	case GIMP_PDB_INT8ARRAY:
	    if (params[i].data.d_int8array == NULL) {
		value = PyTuple_New(0);
		break;
	    }
	    if ((tmp=PyTuple_GetItem(args, i-1)) == NULL) {
		Py_DECREF(args);
		return NULL;
	    }
	    if (!PyInt_Check(tmp)) {
		PyErr_SetString(PyExc_TypeError,
				"count type must be integer");
		Py_DECREF(args);
		return NULL;
	    }
	    n = PyInt_AsLong(tmp);
	    value = PyTuple_New(n);
	    for (j = 0; j < n; j++)
		PyTuple_SetItem(value, j,
			PyInt_FromLong(params[i].data.d_int8array[j]));
	    break;
	case GIMP_PDB_FLOATARRAY:
	    if (params[i].data.d_floatarray == NULL) {
		value = PyTuple_New(0);
		break;
	    }
	    if ((tmp=PyTuple_GetItem(args, i-1)) == NULL) {
		Py_DECREF(args);
		return NULL;
	    }
	    if (!PyInt_Check(tmp)) {
		PyErr_SetString(PyExc_TypeError,
				"count type must be integer");
		Py_DECREF(args);
		return NULL;
	    }
	    n = PyInt_AsLong(tmp);
	    value = PyTuple_New(n);
	    for (j = 0; j < n; j++)
		PyTuple_SetItem(value, j,
			PyFloat_FromDouble(params[i].data.d_floatarray[j]));
	    break;
	case GIMP_PDB_STRINGARRAY:
	    if (params[i].data.d_stringarray == NULL) {
		value = PyTuple_New(0);
		break;
	    }
	    if ((tmp=PyTuple_GetItem(args, i-1)) == NULL) {
		Py_DECREF(args);
		return NULL;
	    }
	    if (!PyInt_Check(tmp)) {
		PyErr_SetString(PyExc_TypeError,
				"count type must be integer");
		Py_DECREF(args);
		return NULL;
	    }
	    n = PyInt_AsLong(tmp);
	    value = PyTuple_New(n);
	    for (j = 0; j < n; j++)
		PyTuple_SetItem(value, j,
			params[i].data.d_stringarray[j] ?
			PyString_FromString(params[i].data.d_stringarray[j]) :
			PyString_FromString(""));
	    break;
	case GIMP_PDB_COLOR:
	    value = pygimp_rgb_new(&params[i].data.d_color);
	    break;
	case GIMP_PDB_REGION:
	    value = Py_BuildValue("(iiii)",
				  (int) params[i].data.d_region.x,
				  (int) params[i].data.d_region.y,
				  (int) params[i].data.d_region.width,
				  (int) params[i].data.d_region.height);
	    break;
	case GIMP_PDB_DISPLAY:
	    value = pygimp_display_new(params[i].data.d_display);
	    break;
	case GIMP_PDB_IMAGE:
	    value = pygimp_image_new(params[i].data.d_image);
	    break;
	case GIMP_PDB_LAYER:
	    value = pygimp_layer_new(params[i].data.d_layer);
	    break;
	case GIMP_PDB_CHANNEL:
	    value = pygimp_channel_new(params[i].data.d_channel);
	    break;
	case GIMP_PDB_DRAWABLE:
	    value = pygimp_drawable_new(NULL, params[i].data.d_drawable);
	    break;
	case GIMP_PDB_SELECTION:
	    value = pygimp_layer_new(params[i].data.d_selection);
	    break;
	case GIMP_PDB_BOUNDARY:
	    value = PyInt_FromLong(params[i].data.d_boundary);
	    break;
	case GIMP_PDB_VECTORS:
	    value = pygimp_vectors_new(params[i].data.d_vectors);
	    break;
	case GIMP_PDB_PARASITE:
	    value = pygimp_parasite_new(gimp_parasite_copy(
					&(params[i].data.d_parasite)));
	    break;
	case GIMP_PDB_STATUS:
	    value = PyInt_FromLong(params[i].data.d_status);
	    break;
	case GIMP_PDB_END:
	    break;
	}
	PyTuple_SetItem(args, i, value);
    }
    return args;
}
コード例 #10
0
ファイル: gimpitempropundo.c プロジェクト: jdburton/gimp-osx
static void
gimp_item_prop_undo_pop (GimpUndo            *undo,
                         GimpUndoMode         undo_mode,
                         GimpUndoAccumulator *accum)
{
  GimpItemPropUndo *item_prop_undo = GIMP_ITEM_PROP_UNDO (undo);
  GimpItem         *item           = GIMP_ITEM_UNDO (undo)->item;

  GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);

  switch (undo->undo_type)
    {
    case GIMP_UNDO_ITEM_RENAME:
      {
        gchar *name;

        name = g_strdup (gimp_object_get_name (GIMP_OBJECT (item)));
        gimp_object_take_name (GIMP_OBJECT (item), item_prop_undo->name);
        item_prop_undo->name = name;
      }
      break;

    case GIMP_UNDO_ITEM_DISPLACE:
      {
        gint offset_x;
        gint offset_y;

        gimp_item_offsets (item, &offset_x, &offset_y);

        gimp_item_translate (item,
                             item_prop_undo->offset_x - offset_x,
                             item_prop_undo->offset_y - offset_y,
                             FALSE);

        item_prop_undo->offset_x = offset_x;
        item_prop_undo->offset_y = offset_y;
      }
      break;

    case GIMP_UNDO_ITEM_VISIBILITY:
      {
        gboolean visible;

        visible = gimp_item_get_visible (item);
        gimp_item_set_visible (item, item_prop_undo->visible, FALSE);
        item_prop_undo->visible = visible;
      }
      break;

    case GIMP_UNDO_ITEM_LINKED:
      {
        gboolean linked;

        linked = gimp_item_get_linked (item);
        gimp_item_set_linked (item, item_prop_undo->linked, FALSE);
        item_prop_undo->linked = linked;
      }
      break;

    case GIMP_UNDO_PARASITE_ATTACH:
    case GIMP_UNDO_PARASITE_REMOVE:
      {
        GimpParasite *parasite;

        parasite = item_prop_undo->parasite;

        item_prop_undo->parasite = gimp_parasite_copy
          (gimp_item_parasite_find (item, item_prop_undo->parasite_name));

        if (parasite)
          gimp_parasite_list_add (item->parasites, parasite);
        else
          gimp_parasite_list_remove (item->parasites,
                                     item_prop_undo->parasite_name);

        if (parasite)
          gimp_parasite_free (parasite);
      }
      break;

    default:
      g_assert_not_reached ();
    }
}