/* PIKA - Photo and Image Kooker Application
 * a rebranding of The GNU Image Manipulation Program (created with heckimp)
 * A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
 *
 * Original copyright, applying to most contents (license remains unchanged): 
 * 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 3 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, see <https://www.gnu.org/licenses/>.
 */

#include "config.h"

#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>

#include "pdb-types.h"

#include "pikapdb.h"
#include "pika-pdb-compat.h"


/*  public functions  */

void
pika_pdb_compat_procs_register (PikaPDB           *pdb,
                                PikaPDBCompatMode  compat_mode)
{
  static const struct
  {
    const gchar *old_name;
    const gchar *new_name;
  }
  compat_procs[] =
  {
    { "pika-blend",                         "pika-edit-blend"                 },
    { "pika-brushes-list",                  "pika-brushes-get-list"           },
    { "pika-bucket-fill",                   "pika-edit-bucket-fill"           },
    { "pika-channel-delete",                "pika-item-delete"                },
    { "pika-channel-get-name",              "pika-item-get-name"              },
    { "pika-channel-get-tattoo",            "pika-item-get-tattoo"            },
    { "pika-channel-get-visible",           "pika-item-get-visible"           },
    { "pika-channel-set-name",              "pika-item-set-name"              },
    { "pika-channel-set-tattoo",            "pika-item-set-tattoo"            },
    { "pika-channel-set-visible",           "pika-item-set-visible"           },
    { "pika-color-picker",                  "pika-image-pick-color"           },
    { "pika-convert-grayscale",             "pika-image-convert-grayscale"    },
    { "pika-convert-indexed",               "pika-image-convert-indexed"      },
    { "pika-convert-rgb",                   "pika-image-convert-rgb"          },
    { "pika-crop",                          "pika-image-crop"                 },
    { "pika-drawable-bytes",                "pika-drawable-bpp"               },
    { "pika-drawable-image",                "pika-drawable-get-image"         },
    { "pika-image-floating-selection",      "pika-image-get-floating-sel"     },
    { "pika-layer-delete",                  "pika-item-delete"                },
    { "pika-layer-get-name",                "pika-item-get-name"              },
    { "pika-layer-get-tattoo",              "pika-item-get-tattoo"            },
    { "pika-layer-get-visible",             "pika-item-get-visible"           },
    { "pika-layer-mask",                    "pika-layer-get-mask"             },
    { "pika-layer-set-name",                "pika-item-set-name"              },
    { "pika-layer-set-tattoo",              "pika-item-set-tattoo"            },
    { "pika-layer-set-visible",             "pika-item-set-visible"           },
    { "pika-palette-refresh",               "pika-palettes-refresh"           },
    { "pika-patterns-list",                 "pika-patterns-get-list"          },
    { "pika-temp-PDB-name",                 "pika-procedural-db-temp-name"    },
    { "pika-undo-push-group-end",           "pika-image-undo-group-end"       },
    { "pika-undo-push-group-start",         "pika-image-undo-group-start"     },

    /*  deprecations since 2.0  */
    { "pika-brushes-get-opacity",           "pika-context-get-opacity"        },
    { "pika-brushes-get-paint-mode",        "pika-context-get-paint-mode"     },
    { "pika-brushes-set-brush",             "pika-context-set-brush"          },
    { "pika-brushes-set-opacity",           "pika-context-set-opacity"        },
    { "pika-brushes-set-paint-mode",        "pika-context-set-paint-mode"     },
    { "pika-channel-ops-duplicate",         "pika-image-duplicate"            },
    { "pika-channel-ops-offset",            "pika-drawable-offset"            },
    { "pika-gradients-get-active",          "pika-context-get-gradient"       },
    { "pika-gradients-get-gradient",        "pika-context-get-gradient"       },
    { "pika-gradients-set-active",          "pika-context-set-gradient"       },
    { "pika-gradients-set-gradient",        "pika-context-set-gradient"       },
    { "pika-image-get-cmap",                "pika-image-get-colormap"         },
    { "pika-image-set-cmap",                "pika-image-set-colormap"         },
    { "pika-palette-get-background",        "pika-context-get-background"     },
    { "pika-palette-get-foreground",        "pika-context-get-foreground"     },
    { "pika-palette-set-background",        "pika-context-set-background"     },
    { "pika-palette-set-default-colors",    "pika-context-set-default-colors" },
    { "pika-palette-set-foreground",        "pika-context-set-foreground"     },
    { "pika-palette-swap-colors",           "pika-context-swap-colors"        },
    { "pika-palettes-set-palette",          "pika-context-set-palette"        },
    { "pika-patterns-set-pattern",          "pika-context-set-pattern"        },
    { "pika-selection-clear",               "pika-selection-none"             },

    /*  deprecations since 2.2  */
    { "pika-layer-get-preserve-trans",      "pika-layer-get-lock-alpha"       },
    { "pika-layer-set-preserve-trans",      "pika-layer-set-lock-alpha"       },

    /*  deprecations since 2.6  */
    { "pika-drawable-is-valid",             "pika-item-is-valid"              },
    { "pika-drawable-is-layer",             "pika-item-is-layer"              },
    { "pika-drawable-is-text-layer",        "pika-item-is-text-layer"         },
    { "pika-drawable-is-layer-mask",        "pika-item-is-layer-mask"         },
    { "pika-drawable-is-channel",           "pika-item-is-channel"            },
    { "pika-drawable-delete",               "pika-item-delete"                },
    { "pika-drawable-get-image",            "pika-item-get-image"             },
    { "pika-drawable-get-name",             "pika-item-get-name"              },
    { "pika-drawable-set-name",             "pika-item-set-name"              },
    { "pika-drawable-get-visible",          "pika-item-get-visible"           },
    { "pika-drawable-set-visible",          "pika-item-set-visible"           },
    { "pika-drawable-get-tattoo",           "pika-item-get-tattoo"            },
    { "pika-drawable-set-tattoo",           "pika-item-set-tattoo"            },
    { "pika-drawable-parasite-find",        "pika-item-get-parasite"          },
    { "pika-drawable-parasite-attach",      "pika-item-attach-parasite"       },
    { "pika-drawable-parasite-detach",      "pika-item-detach-parasite"       },
    { "pika-drawable-parasite-list",        "pika-item-get-parasite-list"     },
    { "pika-image-get-layer-position",      "pika-image-get-item-position"    },
    { "pika-image-raise-layer",             "pika-image-raise-item"           },
    { "pika-image-lower-layer",             "pika-image-lower-item"           },
    { "pika-image-raise-layer-to-top",      "pika-image-raise-item-to-top"    },
    { "pika-image-lower-layer-to-bottom",   "pika-image-lower-item-to-bottom" },
    { "pika-image-get-channel-position",    "pika-image-get-item-position"    },
    { "pika-image-raise-channel",           "pika-image-raise-item"           },
    { "pika-image-lower-channel",           "pika-image-lower-item"           },
    { "pika-image-get-vectors-position",    "pika-image-get-item-position"    },
    { "pika-image-raise-vectors",           "pika-image-raise-item"           },
    { "pika-image-lower-vectors",           "pika-image-lower-item"           },
    { "pika-image-raise-vectors-to-top",    "pika-image-raise-item-to-top"    },
    { "pika-image-lower-vectors-to-bottom", "pika-image-lower-item-to-bottom" },
    { "pika-vectors-is-valid",              "pika-item-is-valid"              },
    { "pika-vectors-get-image",             "pika-item-get-image"             },
    { "pika-vectors-get-name",              "pika-item-get-name"              },
    { "pika-vectors-set-name",              "pika-item-set-name"              },
    { "pika-vectors-get-visible",           "pika-item-get-visible"           },
    { "pika-vectors-set-visible",           "pika-item-set-visible"           },
    { "pika-vectors-get-tattoo",            "pika-item-get-tattoo"            },
    { "pika-vectors-set-tattoo",            "pika-item-set-tattoo"            },
    { "pika-vectors-parasite-find",         "pika-item-get-parasite"          },
    { "pika-vectors-parasite-attach",       "pika-item-attach-parasite"       },
    { "pika-vectors-parasite-detach",       "pika-item-detach-parasite"       },
    { "pika-vectors-parasite-list",         "pika-item-get-parasite-list"     },
    { "pika-image-parasite-find",           "pika-image-get-parasite"         },
    { "pika-image-parasite-attach",         "pika-image-attach-parasite"      },
    { "pika-image-parasite-detach",         "pika-image-detach-parasite"      },
    { "pika-image-parasite-list",           "pika-image-get-parasite-list"    },
    { "pika-parasite-find",                 "pika-get-parasite"               },
    { "pika-parasite-attach",               "pika-attach-parasite"            },
    { "pika-parasite-detach",               "pika-detach-parasite"            },
    { "pika-parasite-list",                 "pika-get-parasite-list"          },

    /*  deprecations since 2.8  */
    { "pika-edit-paste-as-new",             "pika-edit-paste-as-new-image"    },
    { "pika-edit-named-paste-as-new", "pika-edit-named-paste-as-new-image"    }
 };

  g_return_if_fail (PIKA_IS_PDB (pdb));

  if (compat_mode != PIKA_PDB_COMPAT_OFF)
    {
      gint i;

      for (i = 0; i < G_N_ELEMENTS (compat_procs); i++)
        pika_pdb_register_compat_proc_name (pdb,
                                            compat_procs[i].old_name,
                                            compat_procs[i].new_name);
    }
}
