gimp/libgimpwidgets/gimpcolordisplay.c

171 lines
5 KiB
C
Raw Normal View History

Ported module loading to GTypeModule, getting rid of all own module 2002-10-20 Michael Natterer <mitch@gimp.org> Ported module loading to GTypeModule, getting rid of all own module registering/bookkeeping stuff for color selectors and display filters. The modules now simply register GimpColorSelector and GimpColorDisplay subclasses, the list of registered subclasses can then be obtained calling g_type_children() on the abstract base classes. This is work in progress and just the first working state after I started breaking everything... * app/gui/color-select.[ch] * libgimp/gimpcolordisplay.h * libgimp/gimpcolorselector.h: removed. * app/gui/Makefile.am * libgimp/Makefile.am: changed accordingly. * libgimp/gimpmodule.h: massively simplified. All voodoo is gone. * libgimpwidgets/gimpcolordisplay.[ch] * libgimpwidgets/gimpcolorselector.[ch]: new abstract base classes which need to be subclassed by modules. * libgimpwidgets/gimpcolorselect.[ch]: the built-in color selector from app/gui/color-select.* ported to be a GimpColorSelector subclass. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpwidgets.h * libgimpwidgets/gimpwidgetsmarshal.list * libgimpwidgets/gimpwidgetstypes.h: changed accordingly. * app/core/gimpmoduleinfo.[ch]: made it a GTypeModule subclass * app/core/gimpmodules.c: changed accordingly. * app/core/gimpcontainer.c * app/core/gimplist.c: HACKED around to allow GimpLists of GObjects (not GimpObjects). This is EEKy, so I will either make gimp->modules a simple GList and revert this bit of change, or allow GObjects all over the place in GimpContainer land... * app/display/gimpdisplayshell-filter.[ch] * app/gui/color-notebook.c: removed all module stuff and use g_type_children() to get the list of available color_selectors and display_filters. * app/display/gimpdisplayshell-filter-dialog.c * app/display/gimpdisplayshell-render.c * app/gui/module-browser.c: changed accordingly. * app/gui/gui.c: ref the built-in color selector's class before the modules are queried so it appears first in the list of GimpColorSelector's children. * modules/Makefile.am: build the water color selector again. * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * modules/colorsel_triangle.c * modules/colorsel_water.c: ported them all to the new API. * modules/gimpmodregister.[ch]: removed the old EMX module hack.
2002-10-20 10:14:17 +00:00
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpcolordisplay.c
* Copyright (C) 2002 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 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 Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "gimpwidgetstypes.h"
#include "gimpcolordisplay.h"
static void gimp_color_display_class_init (GimpColorDisplayClass *klass);
static void gimp_color_display_init (GimpColorDisplay *display);
static GObjectClass *parent_class = NULL;
GType
gimp_color_display_get_type (void)
{
static GType display_type = 0;
if (! display_type)
{
static const GTypeInfo display_info =
{
sizeof (GimpColorDisplayClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_color_display_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpColorDisplay),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_color_display_init,
};
display_type = g_type_register_static (G_TYPE_OBJECT,
"GimpColorDisplay",
&display_info, 0);
}
return display_type;
}
static void
gimp_color_display_class_init (GimpColorDisplayClass *klass)
{
parent_class = g_type_class_peek_parent (klass);
klass->clone = NULL;
klass->convert = NULL;
klass->load_state = NULL;
klass->save_state = NULL;
klass->configure = NULL;
klass->configure_cancel = NULL;
}
static void
gimp_color_display_init (GimpColorDisplay *display)
{
}
GimpColorDisplay *
gimp_color_display_new (GType display_type)
{
GimpColorDisplay *display;
g_return_val_if_fail (g_type_is_a (display_type, GIMP_TYPE_COLOR_DISPLAY),
NULL);
display = g_object_new (display_type, NULL);
return display;
}
GimpColorDisplay *
gimp_color_display_clone (GimpColorDisplay *display)
{
g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY (display), NULL);
if (GIMP_COLOR_DISPLAY_GET_CLASS (display)->clone)
return GIMP_COLOR_DISPLAY_GET_CLASS (display)->clone (display);
return NULL;
}
void
gimp_color_display_convert (GimpColorDisplay *display,
guchar *buf,
gint width,
gint height,
gint bpp,
gint bpl)
{
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
if (GIMP_COLOR_DISPLAY_GET_CLASS (display)->convert)
GIMP_COLOR_DISPLAY_GET_CLASS (display)->convert (display, buf,
width, height,
bpp, bpl);
}
void
gimp_color_display_load_state (GimpColorDisplay *display,
GimpParasite *state)
{
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
g_return_if_fail (state != NULL);
if (GIMP_COLOR_DISPLAY_GET_CLASS (display)->load_state)
GIMP_COLOR_DISPLAY_GET_CLASS (display)->load_state (display, state);
}
GimpParasite *
gimp_color_display_save_state (GimpColorDisplay *display)
{
g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY (display), NULL);
if (GIMP_COLOR_DISPLAY_GET_CLASS (display)->save_state)
return GIMP_COLOR_DISPLAY_GET_CLASS (display)->save_state (display);
return NULL;
}
void
gimp_color_display_configure (GimpColorDisplay *display,
GFunc ok_func,
gpointer ok_data,
GFunc cancel_func,
gpointer cancel_data)
{
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
if (GIMP_COLOR_DISPLAY_GET_CLASS (display)->configure)
GIMP_COLOR_DISPLAY_GET_CLASS (display)->configure (display,
ok_func, ok_data,
cancel_func, cancel_data);
}
void
gimp_color_display_configure_cancel (GimpColorDisplay *display)
{
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
if (GIMP_COLOR_DISPLAY_GET_CLASS (display)->configure_cancel)
GIMP_COLOR_DISPLAY_GET_CLASS (display)->configure_cancel (display);
}