PIKApp/app/paint/pika-paint.c

145 lines
4.2 KiB
C

/* 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-2001 Spencer Kimball, Peter Mattis and others
*
* 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 <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "paint-types.h"
#include "core/pika.h"
#include "core/pikalist.h"
#include "core/pikapaintinfo.h"
#include "pika-paint.h"
#include "pikaairbrush.h"
#include "pikaclone.h"
#include "pikaconvolve.h"
#include "pikadodgeburn.h"
#include "pikaeraser.h"
#include "pikaheal.h"
#include "pikaink.h"
#include "pikamybrushcore.h"
#include "pikapaintoptions.h"
#include "pikapaintbrush.h"
#include "pikapencil.h"
#include "pikaperspectiveclone.h"
#include "pikasmudge.h"
/* local function prototypes */
static void pika_paint_register (Pika *pika,
GType paint_type,
GType paint_options_type,
const gchar *identifier,
const gchar *blurb,
const gchar *icon_name);
/* public functions */
void
pika_paint_init (Pika *pika)
{
PikaPaintRegisterFunc register_funcs[] =
{
pika_dodge_burn_register,
pika_smudge_register,
pika_convolve_register,
pika_perspective_clone_register,
pika_heal_register,
pika_clone_register,
pika_mybrush_core_register,
pika_ink_register,
pika_airbrush_register,
pika_eraser_register,
pika_paintbrush_register,
pika_pencil_register
};
gint i;
g_return_if_fail (PIKA_IS_PIKA (pika));
pika->paint_info_list = pika_list_new (PIKA_TYPE_PAINT_INFO, FALSE);
pika_object_set_static_name (PIKA_OBJECT (pika->paint_info_list),
"paint infos");
pika_container_freeze (pika->paint_info_list);
for (i = 0; i < G_N_ELEMENTS (register_funcs); i++)
{
register_funcs[i] (pika, pika_paint_register);
}
pika_container_thaw (pika->paint_info_list);
}
void
pika_paint_exit (Pika *pika)
{
g_return_if_fail (PIKA_IS_PIKA (pika));
pika_paint_info_set_standard (pika, NULL);
if (pika->paint_info_list)
{
pika_container_foreach (pika->paint_info_list,
(GFunc) g_object_run_dispose, NULL);
g_clear_object (&pika->paint_info_list);
}
}
/* private functions */
static void
pika_paint_register (Pika *pika,
GType paint_type,
GType paint_options_type,
const gchar *identifier,
const gchar *blurb,
const gchar *icon_name)
{
PikaPaintInfo *paint_info;
g_return_if_fail (PIKA_IS_PIKA (pika));
g_return_if_fail (g_type_is_a (paint_type, PIKA_TYPE_PAINT_CORE));
g_return_if_fail (g_type_is_a (paint_options_type, PIKA_TYPE_PAINT_OPTIONS));
g_return_if_fail (identifier != NULL);
g_return_if_fail (blurb != NULL);
paint_info = pika_paint_info_new (pika,
paint_type,
paint_options_type,
identifier,
blurb,
icon_name);
pika_container_add (pika->paint_info_list, PIKA_OBJECT (paint_info));
g_object_unref (paint_info);
if (paint_type == PIKA_TYPE_PAINTBRUSH)
pika_paint_info_set_standard (pika, paint_info);
}