2001-01-22 03:53:56 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* 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 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 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 <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-24 02:49:44 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core-types.h"
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
#include "gimppalette.h"
|
2001-05-10 06:34:59 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
static void gimp_palette_class_init (GimpPaletteClass *klass);
|
|
|
|
static void gimp_palette_init (GimpPalette *palette);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
|
|
|
static void gimp_palette_finalize (GObject *object);
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable,
|
|
|
|
gint width,
|
|
|
|
gint height);
|
|
|
|
static void gimp_palette_dirty (GimpData *data);
|
|
|
|
static gboolean gimp_palette_save (GimpData *data);
|
2001-02-14 03:53:07 +08:00
|
|
|
static gchar * gimp_palette_get_extension (GimpData *data);
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
static void gimp_palette_entry_free (GimpPaletteEntry *entry);
|
2001-01-22 03:53:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* private variables */
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
static GimpDataClass *parent_class = NULL;
|
2001-01-22 03:53:56 +08:00
|
|
|
|
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
GType
|
2001-01-22 03:53:56 +08:00
|
|
|
gimp_palette_get_type (void)
|
|
|
|
{
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
static GType palette_type = 0;
|
2001-01-22 03:53:56 +08:00
|
|
|
|
|
|
|
if (! palette_type)
|
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
static const GTypeInfo palette_info =
|
2001-01-22 03:53:56 +08:00
|
|
|
{
|
|
|
|
sizeof (GimpPaletteClass),
|
2001-08-11 22:39:19 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_palette_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpPalette),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_palette_init,
|
2001-01-22 03:53:56 +08:00
|
|
|
};
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
palette_type = g_type_register_static (GIMP_TYPE_DATA,
|
|
|
|
"GimpPalette",
|
|
|
|
&palette_info, 0);
|
2001-01-22 03:53:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return palette_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_palette_class_init (GimpPaletteClass *klass)
|
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
GObjectClass *object_class;
|
2001-02-12 00:14:25 +08:00
|
|
|
GimpViewableClass *viewable_class;
|
|
|
|
GimpDataClass *data_class;
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
|
|
|
data_class = GIMP_DATA_CLASS (klass);
|
2001-01-22 03:53:56 +08:00
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
object_class->finalize = gimp_palette_finalize;
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
viewable_class->get_new_preview = gimp_palette_get_new_preview;
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
data_class->dirty = gimp_palette_dirty;
|
|
|
|
data_class->save = gimp_palette_save;
|
|
|
|
data_class->get_extension = gimp_palette_get_extension;
|
2001-01-22 03:53:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_palette_init (GimpPalette *palette)
|
|
|
|
{
|
|
|
|
palette->colors = NULL;
|
|
|
|
palette->n_colors = 0;
|
2001-02-13 02:05:12 +08:00
|
|
|
palette->n_columns = 0;
|
2001-01-22 03:53:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-08-11 22:39:19 +08:00
|
|
|
gimp_palette_finalize (GObject *object)
|
2001-01-22 03:53:56 +08:00
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
GimpPalette *palette;
|
2001-01-22 03:53:56 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_PALETTE (object));
|
|
|
|
|
|
|
|
palette = GIMP_PALETTE (object);
|
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
if (palette->colors)
|
2001-01-22 03:53:56 +08:00
|
|
|
{
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
g_list_foreach (palette->colors, (GFunc) gimp_palette_entry_free, NULL);
|
|
|
|
g_list_free (palette->colors);
|
|
|
|
palette->colors = NULL;
|
2001-01-22 03:53:56 +08:00
|
|
|
}
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-01-22 03:53:56 +08:00
|
|
|
}
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
static TempBuf *
|
|
|
|
gimp_palette_get_new_preview (GimpViewable *viewable,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
|
|
|
GimpPalette *palette;
|
|
|
|
GimpPaletteEntry *entry;
|
|
|
|
TempBuf *temp_buf;
|
|
|
|
guchar *buf;
|
|
|
|
guchar *b;
|
|
|
|
GList *list;
|
|
|
|
guchar white[3] = { 255, 255, 255 };
|
|
|
|
gint columns;
|
|
|
|
gint rows;
|
|
|
|
gint x, y, i;
|
|
|
|
|
|
|
|
palette = GIMP_PALETTE (viewable);
|
|
|
|
|
|
|
|
temp_buf = temp_buf_new (width, height,
|
|
|
|
3,
|
|
|
|
0, 0,
|
|
|
|
white);
|
|
|
|
|
2001-02-13 02:05:12 +08:00
|
|
|
#define CELL_SIZE 4
|
|
|
|
|
|
|
|
columns = width / CELL_SIZE;
|
|
|
|
rows = height / CELL_SIZE;
|
2001-02-12 00:14:25 +08:00
|
|
|
|
|
|
|
buf = temp_buf_data (temp_buf);
|
|
|
|
b = g_new (guchar, width * 3);
|
|
|
|
|
|
|
|
memset (b, 255, width * 3);
|
|
|
|
|
|
|
|
list = palette->colors;
|
|
|
|
|
|
|
|
for (y = 0; y < rows && list; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < columns && list; x++)
|
|
|
|
{
|
|
|
|
entry = (GimpPaletteEntry *) list->data;
|
|
|
|
|
|
|
|
list = g_list_next (list);
|
|
|
|
|
|
|
|
gimp_rgb_get_uchar (&entry->color,
|
2001-02-13 02:05:12 +08:00
|
|
|
&b[x * CELL_SIZE * 3 + 0],
|
|
|
|
&b[x * CELL_SIZE * 3 + 1],
|
|
|
|
&b[x * CELL_SIZE * 3 + 2]);
|
2001-02-12 00:14:25 +08:00
|
|
|
|
2001-02-13 02:05:12 +08:00
|
|
|
for (i = 1; i < CELL_SIZE; i++)
|
2001-02-12 00:14:25 +08:00
|
|
|
{
|
2001-02-13 02:05:12 +08:00
|
|
|
b[(x * CELL_SIZE + i) * 3 + 0] = b[(x * CELL_SIZE) * 3 + 0];
|
|
|
|
b[(x * CELL_SIZE + i) * 3 + 1] = b[(x * CELL_SIZE) * 3 + 1];
|
|
|
|
b[(x * CELL_SIZE + i) * 3 + 2] = b[(x * CELL_SIZE) * 3 + 2];
|
2001-02-12 00:14:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-13 02:05:12 +08:00
|
|
|
for (i = 0; i < CELL_SIZE; i++)
|
2001-02-12 00:14:25 +08:00
|
|
|
{
|
2001-02-13 02:05:12 +08:00
|
|
|
memcpy (buf + ((y * CELL_SIZE + i) * width) * 3, b, width * 3);
|
2001-02-12 00:14:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-13 02:05:12 +08:00
|
|
|
#undef CELL_SIZE
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
g_free (b);
|
|
|
|
|
|
|
|
return temp_buf;
|
|
|
|
}
|
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
GimpData *
|
2001-01-22 03:53:56 +08:00
|
|
|
gimp_palette_new (const gchar *name)
|
|
|
|
{
|
|
|
|
GimpPalette *palette = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
g_return_val_if_fail (*name != '\0', NULL);
|
|
|
|
|
|
|
|
palette = GIMP_PALETTE (gtk_object_new (GIMP_TYPE_PALETTE,
|
|
|
|
"name", name,
|
|
|
|
NULL));
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (palette));
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
return GIMP_DATA (palette);
|
2001-01-22 03:53:56 +08:00
|
|
|
}
|
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
GimpData *
|
2001-02-14 03:53:07 +08:00
|
|
|
gimp_palette_get_standard (void)
|
|
|
|
{
|
|
|
|
static GimpPalette *standard_palette = NULL;
|
|
|
|
|
|
|
|
if (! standard_palette)
|
|
|
|
{
|
2001-08-10 22:41:39 +08:00
|
|
|
standard_palette = GIMP_PALETTE (g_object_new (GIMP_TYPE_PALETTE, NULL));
|
2001-02-14 03:53:07 +08:00
|
|
|
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (standard_palette), "Standard");
|
|
|
|
}
|
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
return GIMP_DATA (standard_palette);
|
2001-02-14 03:53:07 +08:00
|
|
|
}
|
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
GimpData *
|
2001-02-12 00:14:25 +08:00
|
|
|
gimp_palette_load (const gchar *filename)
|
2001-01-22 03:53:56 +08:00
|
|
|
{
|
|
|
|
GimpPalette *palette;
|
2001-02-12 00:14:25 +08:00
|
|
|
gchar str[1024];
|
2001-01-22 03:53:56 +08:00
|
|
|
gchar *tok;
|
|
|
|
FILE *fp;
|
|
|
|
gint r, g, b;
|
|
|
|
GimpRGB color;
|
|
|
|
gint linenum;
|
|
|
|
|
|
|
|
g_return_val_if_fail (filename != NULL, NULL);
|
|
|
|
g_return_val_if_fail (*filename != '\0', NULL);
|
|
|
|
|
|
|
|
r = g = b = 0;
|
|
|
|
|
|
|
|
/* Open the requested file */
|
|
|
|
if (! (fp = fopen (filename, "r")))
|
|
|
|
{
|
|
|
|
g_warning ("Failed to open palette file %s", filename);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
linenum = 0;
|
|
|
|
|
|
|
|
fread (str, 13, 1, fp);
|
|
|
|
str[13] = '\0';
|
|
|
|
linenum++;
|
|
|
|
if (strcmp (str, "GIMP Palette\n"))
|
|
|
|
{
|
|
|
|
/* bad magic, but maybe it has \r\n at the end of lines? */
|
|
|
|
if (!strcmp (str, "GIMP Palette\r"))
|
|
|
|
g_message (_("Loading palette %s:\n"
|
|
|
|
"Corrupt palette:\n"
|
|
|
|
"missing magic header\n"
|
|
|
|
"Does this file need converting from DOS?"), filename);
|
|
|
|
else
|
|
|
|
g_message (_("Loading palette %s:\n"
|
|
|
|
"Corrupt palette: missing magic header"), filename);
|
|
|
|
|
|
|
|
fclose (fp);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
palette = g_object_new (GIMP_TYPE_PALETTE, NULL);
|
2001-02-12 00:14:25 +08:00
|
|
|
|
|
|
|
gimp_data_set_filename (GIMP_DATA (palette), filename);
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
if (! fgets (str, 1024, fp))
|
2001-01-22 03:53:56 +08:00
|
|
|
{
|
2001-02-12 00:14:25 +08:00
|
|
|
g_message (_("Loading palette %s (line %d):\nRead error"),
|
|
|
|
filename, linenum);
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
fclose (fp);
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
g_object_unref (G_OBJECT (palette));
|
2001-02-12 00:14:25 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
linenum++;
|
|
|
|
|
|
|
|
if (! strncmp (str, "Name: ", strlen ("Name: ")))
|
|
|
|
{
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (palette),
|
|
|
|
g_strstrip (&str[strlen ("Name: ")]));
|
|
|
|
|
|
|
|
if (! fgets (str, 1024, fp))
|
|
|
|
{
|
2001-01-22 03:53:56 +08:00
|
|
|
g_message (_("Loading palette %s (line %d):\nRead error"),
|
|
|
|
filename, linenum);
|
|
|
|
|
|
|
|
fclose (fp);
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
g_object_unref (G_OBJECT (palette));
|
2001-01-22 03:53:56 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
linenum++;
|
2001-02-13 02:05:12 +08:00
|
|
|
|
|
|
|
if (! strncmp (str, "Columns: ", strlen ("Columns: ")))
|
|
|
|
{
|
|
|
|
gint columns;
|
|
|
|
|
|
|
|
columns = atoi (g_strstrip (&str[strlen ("Columns: ")]));
|
|
|
|
|
|
|
|
if (columns < 0 || columns > 256)
|
|
|
|
{
|
|
|
|
g_message (_("Loading palette %s (line %d):\n"
|
|
|
|
"Invalid number or columns"),
|
|
|
|
filename, linenum);
|
|
|
|
|
|
|
|
columns = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
palette->n_columns = columns;
|
|
|
|
|
|
|
|
if (! fgets (str, 1024, fp))
|
|
|
|
{
|
|
|
|
g_message (_("Loading palette %s (line %d):\nRead error"),
|
|
|
|
filename, linenum);
|
|
|
|
|
|
|
|
fclose (fp);
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
g_object_unref (G_OBJECT (palette));
|
2001-02-13 02:05:12 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
linenum++;
|
|
|
|
}
|
2001-02-12 00:14:25 +08:00
|
|
|
}
|
|
|
|
else /* old palette format */
|
|
|
|
{
|
|
|
|
g_warning ("old palette format %s", filename);
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
gimp_object_set_name (GIMP_OBJECT (palette), g_basename (filename));
|
|
|
|
}
|
|
|
|
|
|
|
|
while (! feof (fp))
|
|
|
|
{
|
2001-01-22 03:53:56 +08:00
|
|
|
if (str[0] != '#')
|
|
|
|
{
|
|
|
|
tok = strtok (str, " \t");
|
|
|
|
if (tok)
|
|
|
|
r = atoi (tok);
|
|
|
|
else
|
|
|
|
/* maybe we should just abort? */
|
|
|
|
g_message (_("Loading palette %s (line %d):\n"
|
|
|
|
"Missing RED component"), filename, linenum);
|
|
|
|
|
|
|
|
tok = strtok (NULL, " \t");
|
|
|
|
if (tok)
|
|
|
|
g = atoi (tok);
|
|
|
|
else
|
|
|
|
g_message (_("Loading palette %s (line %d):\n"
|
|
|
|
"Missing GREEN component"), filename, linenum);
|
|
|
|
|
|
|
|
tok = strtok (NULL, " \t");
|
|
|
|
if (tok)
|
|
|
|
b = atoi (tok);
|
|
|
|
else
|
|
|
|
g_message (_("Loading palette %s (line %d):\n"
|
|
|
|
"Missing BLUE component"), filename, linenum);
|
|
|
|
|
|
|
|
/* optional name */
|
|
|
|
tok = strtok (NULL, "\n");
|
|
|
|
|
|
|
|
if (r < 0 || r > 255 ||
|
|
|
|
g < 0 || g > 255 ||
|
|
|
|
b < 0 || b > 255)
|
|
|
|
g_message (_("Loading palette %s (line %d):\n"
|
|
|
|
"RGB value out of range"), filename, linenum);
|
|
|
|
|
|
|
|
gimp_rgba_set_uchar (&color,
|
|
|
|
(guchar) r,
|
|
|
|
(guchar) g,
|
|
|
|
(guchar) b,
|
|
|
|
255);
|
|
|
|
|
|
|
|
gimp_palette_add_entry (palette, tok, &color);
|
|
|
|
}
|
2001-02-12 00:14:25 +08:00
|
|
|
|
|
|
|
if (! fgets (str, 1024, fp))
|
|
|
|
{
|
|
|
|
if (feof (fp))
|
|
|
|
break;
|
|
|
|
|
|
|
|
g_message (_("Loading palette %s (line %d):\nRead error"),
|
|
|
|
filename, linenum);
|
|
|
|
|
|
|
|
fclose (fp);
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
g_object_unref (G_OBJECT (palette));
|
2001-02-12 00:14:25 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
linenum++;
|
2001-01-22 03:53:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
fclose (fp);
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
GIMP_DATA (palette)->dirty = FALSE;
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-02-14 22:57:14 +08:00
|
|
|
return GIMP_DATA (palette);
|
2001-01-22 03:53:56 +08:00
|
|
|
}
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
static void
|
|
|
|
gimp_palette_dirty (GimpData *data)
|
2001-01-22 03:53:56 +08:00
|
|
|
{
|
2001-02-12 00:14:25 +08:00
|
|
|
if (GIMP_DATA_CLASS (parent_class)->dirty)
|
|
|
|
GIMP_DATA_CLASS (parent_class)->dirty (data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_palette_save (GimpData *data)
|
|
|
|
{
|
|
|
|
GimpPalette *palette;
|
2001-01-22 03:53:56 +08:00
|
|
|
GimpPaletteEntry *entry;
|
|
|
|
GList *list;
|
|
|
|
FILE *fp;
|
|
|
|
guchar r, g, b;
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
palette = GIMP_PALETTE (data);
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
if (! (fp = fopen (GIMP_DATA (palette)->filename, "w")))
|
2001-01-22 03:53:56 +08:00
|
|
|
{
|
2001-02-12 00:14:25 +08:00
|
|
|
g_message (_("Can't save palette \"%s\"\n"),
|
|
|
|
GIMP_DATA (palette)->filename);
|
2001-01-22 03:53:56 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf (fp, "GIMP Palette\n");
|
2001-02-13 02:05:12 +08:00
|
|
|
fprintf (fp, "Name: %s\n", GIMP_OBJECT (palette)->name);
|
|
|
|
fprintf (fp, "Columns: %d\n#\n", CLAMP (palette->n_columns, 0, 256));
|
2001-01-22 03:53:56 +08:00
|
|
|
|
|
|
|
for (list = palette->colors; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
entry = (GimpPaletteEntry *) list->data;
|
|
|
|
|
|
|
|
gimp_rgb_get_uchar (&entry->color, &r, &g, &b);
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
fprintf (fp, "%3d %3d %3d\t%s\n",
|
2001-01-22 03:53:56 +08:00
|
|
|
r, g, b,
|
|
|
|
entry->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose (fp);
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
if (GIMP_DATA_CLASS (parent_class)->save)
|
|
|
|
return GIMP_DATA_CLASS (parent_class)->save (data);
|
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-02-14 03:53:07 +08:00
|
|
|
static gchar *
|
|
|
|
gimp_palette_get_extension (GimpData *data)
|
|
|
|
{
|
|
|
|
return GIMP_PALETTE_FILE_EXTENSION;
|
|
|
|
}
|
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
GimpPaletteEntry *
|
|
|
|
gimp_palette_add_entry (GimpPalette *palette,
|
|
|
|
const gchar *name,
|
|
|
|
GimpRGB *color)
|
|
|
|
{
|
|
|
|
GimpPaletteEntry *entry;
|
|
|
|
|
|
|
|
g_return_val_if_fail (palette != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_PALETTE (palette), NULL);
|
|
|
|
|
|
|
|
g_return_val_if_fail (color != NULL, NULL);
|
|
|
|
|
|
|
|
entry = g_new0 (GimpPaletteEntry, 1);
|
|
|
|
|
|
|
|
entry->color = *color;
|
|
|
|
|
|
|
|
entry->name = g_strdup (name ? name : _("Untitled"));
|
|
|
|
entry->position = palette->n_colors;
|
|
|
|
|
|
|
|
palette->colors = g_list_append (palette->colors, entry);
|
|
|
|
palette->n_colors += 1;
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (palette));
|
2001-01-22 03:53:56 +08:00
|
|
|
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_palette_delete_entry (GimpPalette *palette,
|
|
|
|
GimpPaletteEntry *entry)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
gint pos = 0;
|
|
|
|
|
|
|
|
g_return_if_fail (palette != NULL);
|
|
|
|
g_return_if_fail (GIMP_IS_PALETTE (palette));
|
|
|
|
|
|
|
|
g_return_if_fail (entry != NULL);
|
|
|
|
|
|
|
|
if (g_list_find (palette->colors, entry))
|
|
|
|
{
|
|
|
|
pos = entry->position;
|
|
|
|
gimp_palette_entry_free (entry);
|
|
|
|
|
|
|
|
palette->colors = g_list_remove (palette->colors, entry);
|
|
|
|
|
|
|
|
palette->n_colors--;
|
|
|
|
|
|
|
|
for (list = g_list_nth (palette->colors, pos);
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
entry = (GimpPaletteEntry *) list->data;
|
|
|
|
|
|
|
|
entry->position = pos++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (palette->n_colors == 0)
|
|
|
|
{
|
|
|
|
GimpRGB color;
|
|
|
|
|
|
|
|
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
|
|
|
|
|
|
|
|
gimp_palette_add_entry (palette,
|
|
|
|
_("Black"),
|
|
|
|
&color);
|
|
|
|
}
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (palette));
|
2001-01-22 03:53:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_palette_entry_free (GimpPaletteEntry *entry)
|
|
|
|
{
|
|
|
|
g_return_if_fail (entry != NULL);
|
|
|
|
|
|
|
|
g_free (entry->name);
|
|
|
|
g_free (entry);
|
|
|
|
}
|