1998-06-30 23:31:32 +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.
|
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-09-24 09:19:57 +08:00
|
|
|
#include <stdlib.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <stdio.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#include <string.h>
|
2000-05-27 06:28:40 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
#include <glib-object.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core-types.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/pixel-region.h"
|
|
|
|
#include "base/tile.h"
|
|
|
|
#include "base/tile-manager.h"
|
|
|
|
|
2001-04-07 23:58:26 +08:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2001-07-11 20:39:49 +08:00
|
|
|
#include "gimp.h"
|
2001-02-02 02:44:22 +08:00
|
|
|
#include "gimpchannel.h"
|
2001-07-08 06:49:01 +08:00
|
|
|
#include "gimpcontext.h"
|
2001-02-02 02:44:22 +08:00
|
|
|
#include "gimpdrawable.h"
|
2001-02-07 08:06:58 +08:00
|
|
|
#include "gimpdrawable-preview.h"
|
2000-12-30 08:16:50 +08:00
|
|
|
#include "gimpimage.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "gimpimage-mask.h"
|
2001-02-02 02:44:22 +08:00
|
|
|
#include "gimplayer.h"
|
2001-02-19 21:06:09 +08:00
|
|
|
#include "gimplist.h"
|
2001-11-23 07:46:13 +08:00
|
|
|
#include "gimpmarshal.h"
|
2001-07-10 03:48:30 +08:00
|
|
|
#include "gimpparasite.h"
|
|
|
|
#include "gimpparasitelist.h"
|
2001-02-02 02:44:22 +08:00
|
|
|
#include "gimppreviewcache.h"
|
2001-05-25 01:09:57 +08:00
|
|
|
|
gave parasite undo a MISC_UNDO class for now so it compiles
* app/gimpdrawable.c: gave parasite undo a MISC_UNDO class for now
so it compiles
* app/tools_cmds.c: fix crop invoker to give correct args to
crop_image
* app/color_cmds.c: s/GRAY/GRAY_LUT/g;
* app/brush_select.[ch]: removed PDB procs, export brush_active_dialogs,
brush_select_dialog, s/active_dialogs/brush_active_dialogs/
* app/gimage_cmds.[ch]
* app/channel_ops.[ch]: removed channel ops PDB procs, moved duplicate
function from gimage_cmds to channel_ops, export offset and duplicate
* app/gimpbrushlist.[ch]: removed PDB procs
* app/gradient.[ch]: removed PDB procs,
* app/gradient_header.h: exported G_SAMPLE, GradSelect, num_gradients,
grad_active_dialogs, gradient_select_dialog
* app/gradient_select.c: removed PDB procs,
s/active_dialogs/grad_active_dialogs/
* app/patterns.[ch]: removed PDB procs
* app/pattern_select.[ch]: removed PDB procs,
s/active_dialogs/pattern_active_dialogs/
* app/procedural_db.c: removed PDB procs and supporting functions
* app/procedrual_db.h: fiddled with enums
* app/channel_cmds.[ch]
* app/drawable_cmds.[ch]
* app/parasite_cmds.[ch]: pdbgenned now, removed header files
* app/gimpparasite.c: minor cleanup
* app/internal_procs.c: use pdbgen stuff
* app/tools_cmds.c
* app/text_tool_cmds.c: updated from pdbgen
* app/brushes_cmds.c
* app/brush_select_cmds.c
* app/gradient_cmds.c
* app/gradient_select_cmds.c
* app/patterns_cmds.c
* app/pattern_select_cmds.c
* app/procedural_db_cmds.c: new pdbgen files
* app/Makefile.am: file shuffle (see above)
-Yosh
1999-04-24 04:54:02 +08:00
|
|
|
#include "undo.h"
|
1998-06-30 23:31:32 +08:00
|
|
|
|
1998-11-23 22:47:09 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2001-03-05 00:52:37 +08:00
|
|
|
VISIBILITY_CHANGED,
|
2001-01-15 01:11:14 +08:00
|
|
|
REMOVED,
|
1998-06-30 23:31:32 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2001-01-20 21:21:49 +08:00
|
|
|
|
2001-07-11 20:39:49 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2001-02-05 06:10:54 +08:00
|
|
|
static void gimp_drawable_class_init (GimpDrawableClass *klass);
|
|
|
|
static void gimp_drawable_init (GimpDrawable *drawable);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
|
|
|
static void gimp_drawable_finalize (GObject *object);
|
|
|
|
|
2001-02-05 06:10:54 +08:00
|
|
|
static void gimp_drawable_name_changed (GimpObject *drawable);
|
|
|
|
static void gimp_drawable_invalidate_preview (GimpViewable *viewable);
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2001-01-10 08:36:54 +08:00
|
|
|
|
2001-01-20 21:21:49 +08:00
|
|
|
/* private variables */
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
static guint gimp_drawable_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2001-02-05 06:10:54 +08:00
|
|
|
static GimpViewableClass *parent_class = NULL;
|
1998-06-30 23:31:32 +08:00
|
|
|
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
GType
|
1999-09-02 09:41:18 +08:00
|
|
|
gimp_drawable_get_type (void)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
static GType drawable_type = 0;
|
2000-12-29 00:19:55 +08:00
|
|
|
|
|
|
|
if (! drawable_type)
|
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
static const GTypeInfo drawable_info =
|
2000-12-29 00:19:55 +08:00
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
sizeof (GimpDrawableClass),
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_drawable_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
2000-12-29 00:19:55 +08:00
|
|
|
sizeof (GimpDrawable),
|
2001-08-11 22:39:19 +08:00
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_drawable_init,
|
2000-12-29 00:19:55 +08:00
|
|
|
};
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
drawable_type = g_type_register_static (GIMP_TYPE_VIEWABLE,
|
|
|
|
"GimpDrawable",
|
|
|
|
&drawable_info, 0);
|
2000-12-29 00:19:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return drawable_type;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-12-29 00:19:55 +08:00
|
|
|
gimp_drawable_class_init (GimpDrawableClass *klass)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2001-08-11 22:39:19 +08:00
|
|
|
GObjectClass *object_class;
|
2001-02-05 06:10:54 +08:00
|
|
|
GimpObjectClass *gimp_object_class;
|
|
|
|
GimpViewableClass *viewable_class;
|
1999-08-22 19:45:31 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
|
|
|
viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
2001-01-10 08:36:54 +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);
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2001-03-05 00:52:37 +08:00
|
|
|
gimp_drawable_signals[VISIBILITY_CHANGED] =
|
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_signal_new ("visibility_changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDrawableClass, visibility_changed),
|
|
|
|
NULL, NULL,
|
2001-11-23 07:46:13 +08:00
|
|
|
gimp_marshal_VOID__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
|
|
|
G_TYPE_NONE, 0);
|
2001-03-05 00:52:37 +08:00
|
|
|
|
2001-01-15 01:11:14 +08:00
|
|
|
gimp_drawable_signals[REMOVED] =
|
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_signal_new ("removed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDrawableClass, removed),
|
|
|
|
NULL, NULL,
|
2001-11-23 07:46:13 +08:00
|
|
|
gimp_marshal_VOID__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
|
|
|
G_TYPE_NONE, 0);
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
object_class->finalize = gimp_drawable_finalize;
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_object_class->name_changed = gimp_drawable_name_changed;
|
2001-01-10 11:13:03 +08:00
|
|
|
|
2001-02-05 06:10:54 +08:00
|
|
|
viewable_class->invalidate_preview = gimp_drawable_invalidate_preview;
|
2001-02-07 08:06:58 +08:00
|
|
|
viewable_class->get_preview = gimp_drawable_get_preview;
|
2001-02-05 06:10:54 +08:00
|
|
|
|
2001-07-08 06:49:01 +08:00
|
|
|
klass->visibility_changed = NULL;
|
|
|
|
klass->removed = NULL;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
2001-01-20 21:21:49 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_init (GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
drawable->tiles = NULL;
|
|
|
|
drawable->visible = FALSE;
|
|
|
|
drawable->width = 0;
|
|
|
|
drawable->height = 0;
|
|
|
|
drawable->offset_x = 0;
|
|
|
|
drawable->offset_y = 0;
|
|
|
|
drawable->bytes = 0;
|
2001-07-11 20:39:49 +08:00
|
|
|
drawable->ID = 0;
|
2001-01-20 21:21:49 +08:00
|
|
|
drawable->tattoo = 0;
|
|
|
|
drawable->gimage = NULL;
|
|
|
|
drawable->type = -1;
|
|
|
|
drawable->has_alpha = FALSE;
|
|
|
|
drawable->preview_cache = NULL;
|
|
|
|
drawable->preview_valid = FALSE;
|
2001-07-05 06:59:25 +08:00
|
|
|
drawable->parasites = gimp_parasite_list_new ();
|
2001-01-20 21:21:49 +08:00
|
|
|
drawable->preview_cache = NULL;
|
|
|
|
drawable->preview_valid = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-08-11 22:39:19 +08:00
|
|
|
gimp_drawable_finalize (GObject *object)
|
2001-01-20 21:21:49 +08:00
|
|
|
{
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (object));
|
|
|
|
|
|
|
|
drawable = GIMP_DRAWABLE (object);
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
if (drawable->gimage && drawable->gimage->gimp)
|
|
|
|
{
|
|
|
|
g_hash_table_remove (drawable->gimage->gimp->drawable_table,
|
|
|
|
GINT_TO_POINTER (drawable->ID));
|
|
|
|
drawable->gimage = NULL;
|
|
|
|
}
|
2001-01-20 21:21:49 +08:00
|
|
|
|
|
|
|
if (drawable->tiles)
|
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
|
|
|
{
|
|
|
|
tile_manager_destroy (drawable->tiles);
|
|
|
|
drawable->tiles = NULL;
|
|
|
|
}
|
2001-01-20 21:21:49 +08:00
|
|
|
|
|
|
|
if (drawable->preview_cache)
|
|
|
|
gimp_preview_cache_invalidate (&drawable->preview_cache);
|
|
|
|
|
|
|
|
if (drawable->parasites)
|
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 (drawable->parasites));
|
|
|
|
drawable->parasites = NULL;
|
|
|
|
}
|
2001-01-20 21:21:49 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-01-20 21:21:49 +08:00
|
|
|
}
|
|
|
|
|
2001-01-10 11:13:03 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_name_changed (GimpObject *object)
|
|
|
|
{
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpDrawable *drawable2;
|
2001-02-19 21:06:09 +08:00
|
|
|
GList *list, *list2, *base_list;
|
2001-01-10 11:13:03 +08:00
|
|
|
gint unique_ext = 0;
|
|
|
|
gchar *ext;
|
|
|
|
gchar *new_name = NULL;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (object));
|
|
|
|
|
|
|
|
drawable = GIMP_DRAWABLE (object);
|
|
|
|
|
|
|
|
/* if no other layers to check name against */
|
2001-02-19 21:06:09 +08:00
|
|
|
if (drawable->gimage == NULL ||
|
|
|
|
gimp_image_is_empty (drawable->gimage))
|
2001-01-10 11:13:03 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (GIMP_IS_LAYER (drawable))
|
2001-02-19 21:06:09 +08:00
|
|
|
base_list = GIMP_LIST (drawable->gimage->layers)->list;
|
2001-01-10 11:13:03 +08:00
|
|
|
else if (GIMP_IS_CHANNEL (drawable))
|
2001-02-19 21:06:09 +08:00
|
|
|
base_list = GIMP_LIST (drawable->gimage->channels)->list;
|
2001-01-10 11:13:03 +08:00
|
|
|
else
|
|
|
|
base_list = NULL;
|
|
|
|
|
2001-02-19 21:06:09 +08:00
|
|
|
for (list = base_list;
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
2001-01-10 11:13:03 +08:00
|
|
|
{
|
|
|
|
drawable2 = GIMP_DRAWABLE (list->data);
|
|
|
|
|
|
|
|
if (drawable != drawable2 &&
|
|
|
|
strcmp (gimp_object_get_name (GIMP_OBJECT (drawable)),
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (drawable2))) == 0)
|
|
|
|
{
|
|
|
|
ext = strrchr (GIMP_OBJECT (drawable)->name, '#');
|
|
|
|
|
|
|
|
if (ext)
|
|
|
|
{
|
|
|
|
gchar *ext_str;
|
|
|
|
|
|
|
|
unique_ext = atoi (ext + 1);
|
|
|
|
|
|
|
|
ext_str = g_strdup_printf ("%d", unique_ext);
|
|
|
|
|
|
|
|
/* check if the extension really is of the form "#<n>" */
|
|
|
|
if (! strcmp (ext_str, ext + 1))
|
|
|
|
{
|
|
|
|
*ext = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unique_ext = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (ext_str);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unique_ext = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
unique_ext++;
|
|
|
|
|
|
|
|
g_free (new_name);
|
|
|
|
|
|
|
|
new_name = g_strdup_printf ("%s#%d",
|
|
|
|
GIMP_OBJECT (drawable)->name,
|
|
|
|
unique_ext);
|
|
|
|
|
2001-02-19 21:06:09 +08:00
|
|
|
for (list2 = base_list; list2; list2 = g_list_next (list2))
|
2001-01-10 11:13:03 +08:00
|
|
|
{
|
|
|
|
drawable2 = GIMP_DRAWABLE (list2->data);
|
|
|
|
|
|
|
|
if (drawable == drawable2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (! strcmp (GIMP_OBJECT (drawable2)->name, new_name))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (list2);
|
|
|
|
|
|
|
|
g_free (GIMP_OBJECT (drawable)->name);
|
|
|
|
|
|
|
|
GIMP_OBJECT (drawable)->name = new_name;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-05 06:10:54 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_invalidate_preview (GimpViewable *viewable)
|
|
|
|
{
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpImage *gimage;
|
|
|
|
|
2001-05-07 00:14:34 +08:00
|
|
|
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
|
|
|
|
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
|
|
|
|
|
2001-02-05 06:10:54 +08:00
|
|
|
drawable = GIMP_DRAWABLE (viewable);
|
|
|
|
|
|
|
|
drawable->preview_valid = FALSE;
|
|
|
|
|
|
|
|
gimage = gimp_drawable_gimage (drawable);
|
|
|
|
|
|
|
|
if (gimage)
|
2001-06-18 21:10:03 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gimage));
|
2001-02-05 06:10:54 +08:00
|
|
|
}
|
|
|
|
|
2001-01-20 21:21:49 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_configure (GimpDrawable *drawable,
|
|
|
|
GimpImage *gimage,
|
2001-12-03 21:44:59 +08:00
|
|
|
gint width,
|
|
|
|
gint height,
|
2001-01-20 21:21:49 +08:00
|
|
|
GimpImageType type,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2001-07-11 20:39:49 +08:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
2001-12-13 07:48:18 +08:00
|
|
|
g_return_if_fail (name != NULL);
|
2001-07-11 20:39:49 +08:00
|
|
|
|
|
|
|
drawable->ID = gimage->gimp->next_drawable_ID++;
|
|
|
|
|
|
|
|
g_hash_table_insert (gimage->gimp->drawable_table,
|
|
|
|
GINT_TO_POINTER (drawable->ID),
|
2001-12-13 07:48:18 +08:00
|
|
|
drawable);
|
2001-01-20 21:21:49 +08:00
|
|
|
|
|
|
|
drawable->width = width;
|
|
|
|
drawable->height = height;
|
|
|
|
drawable->type = type;
|
2001-12-13 07:48:18 +08:00
|
|
|
drawable->bytes = GIMP_IMAGE_TYPE_BYTES (type);
|
|
|
|
drawable->has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (type);
|
2001-01-20 21:21:49 +08:00
|
|
|
drawable->offset_x = 0;
|
|
|
|
drawable->offset_y = 0;
|
|
|
|
|
|
|
|
if (drawable->tiles)
|
|
|
|
tile_manager_destroy (drawable->tiles);
|
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
drawable->tiles = tile_manager_new (width, height,
|
|
|
|
drawable->bytes);
|
2001-03-05 00:52:37 +08:00
|
|
|
|
2001-07-09 05:44:52 +08:00
|
|
|
drawable->visible = TRUE;
|
2001-01-20 21:21:49 +08:00
|
|
|
|
2001-07-11 20:39:49 +08:00
|
|
|
gimp_drawable_set_gimage (drawable, gimage);
|
2001-01-20 21:21:49 +08:00
|
|
|
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (drawable), name);
|
|
|
|
|
|
|
|
/* preview variables */
|
|
|
|
drawable->preview_cache = NULL;
|
|
|
|
drawable->preview_valid = FALSE;
|
|
|
|
}
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
GimpDrawable *
|
|
|
|
gimp_drawable_copy (GimpDrawable *drawable,
|
|
|
|
GType new_type,
|
|
|
|
gboolean add_alpha)
|
|
|
|
{
|
|
|
|
GimpDrawable *new_drawable;
|
|
|
|
GimpImageType new_image_type;
|
|
|
|
PixelRegion srcPR;
|
|
|
|
PixelRegion destPR;
|
|
|
|
gchar *new_name;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
|
|
|
|
|
|
|
|
/* formulate the new name */
|
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
gchar *ext;
|
|
|
|
gint number;
|
|
|
|
gint len;
|
|
|
|
|
|
|
|
name = gimp_object_get_name (GIMP_OBJECT (drawable));
|
|
|
|
|
|
|
|
ext = strrchr (name, '#');
|
|
|
|
len = strlen (_("copy"));
|
|
|
|
|
|
|
|
if ((strlen (name) >= len &&
|
|
|
|
strcmp (&name[strlen (name) - len], _("copy")) == 0) ||
|
|
|
|
(ext && (number = atoi (ext + 1)) > 0 &&
|
|
|
|
((int)(log10 (number) + 1)) == strlen (ext + 1)))
|
|
|
|
{
|
|
|
|
/* don't have redundant "copy"s */
|
|
|
|
new_name = g_strdup (name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_name = g_strdup_printf (_("%s copy"), name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (add_alpha)
|
|
|
|
{
|
|
|
|
new_image_type = gimp_drawable_type_with_alpha (drawable);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_image_type = drawable->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
new_drawable = g_object_new (new_type, NULL);
|
|
|
|
|
|
|
|
gimp_drawable_configure (new_drawable,
|
|
|
|
gimp_drawable_gimage (drawable),
|
|
|
|
gimp_drawable_width (drawable),
|
|
|
|
gimp_drawable_height (drawable),
|
|
|
|
new_image_type,
|
|
|
|
new_name);
|
|
|
|
|
|
|
|
new_drawable->offset_x = drawable->offset_x;
|
|
|
|
new_drawable->offset_y = drawable->offset_y;
|
|
|
|
new_drawable->visible = drawable->visible;
|
|
|
|
|
|
|
|
pixel_region_init (&srcPR, drawable->tiles,
|
|
|
|
0, 0,
|
|
|
|
drawable->width,
|
|
|
|
drawable->height,
|
|
|
|
FALSE);
|
|
|
|
pixel_region_init (&destPR, new_drawable->tiles,
|
|
|
|
0, 0,
|
|
|
|
drawable->width,
|
|
|
|
drawable->height,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
if (new_image_type == drawable->type)
|
|
|
|
{
|
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
add_alpha_region (&srcPR, &destPR);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (G_OBJECT (new_drawable->parasites));
|
|
|
|
new_drawable->parasites = gimp_parasite_list_copy (drawable->parasites);
|
|
|
|
|
|
|
|
return new_drawable;
|
|
|
|
}
|
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
gint
|
|
|
|
gimp_drawable_get_ID (GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
|
|
|
|
|
|
|
return drawable->ID;
|
|
|
|
}
|
|
|
|
|
2000-12-29 00:19:55 +08:00
|
|
|
GimpDrawable *
|
2001-07-11 20:39:49 +08:00
|
|
|
gimp_drawable_get_by_ID (Gimp *gimp,
|
|
|
|
gint drawable_id)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2001-07-11 20:39:49 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
|
|
|
if (gimp->drawable_table == NULL)
|
1998-06-30 23:31:32 +08:00
|
|
|
return NULL;
|
|
|
|
|
2001-07-11 20:39:49 +08:00
|
|
|
return (GimpDrawable *) g_hash_table_lookup (gimp->drawable_table,
|
2001-04-13 22:50:43 +08:00
|
|
|
GINT_TO_POINTER (drawable_id));
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
2001-01-20 21:21:49 +08:00
|
|
|
GimpImage *
|
|
|
|
gimp_drawable_gimage (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
|
|
|
return drawable->gimage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_drawable_set_gimage (GimpDrawable *drawable,
|
|
|
|
GimpImage *gimage)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2001-07-08 06:49:01 +08:00
|
|
|
g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage));;
|
2001-01-20 21:21:49 +08:00
|
|
|
|
|
|
|
if (gimage == NULL)
|
|
|
|
drawable->tattoo = 0;
|
|
|
|
else if (drawable->tattoo == 0 || drawable->gimage != gimage )
|
|
|
|
drawable->tattoo = gimp_image_get_new_tattoo (gimage);
|
|
|
|
|
|
|
|
drawable->gimage = gimage;
|
|
|
|
}
|
|
|
|
|
2001-07-08 06:49:01 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_update (GimpDrawable *drawable,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
2001-12-03 21:44:59 +08:00
|
|
|
gint w,
|
|
|
|
gint h)
|
2001-07-08 06:49:01 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
|
|
|
gimage = gimp_drawable_gimage (drawable);
|
|
|
|
|
|
|
|
g_return_if_fail (gimage != NULL);
|
|
|
|
|
|
|
|
gimp_drawable_offsets (drawable, &offset_x, &offset_y);
|
|
|
|
x += offset_x;
|
|
|
|
y += offset_y;
|
|
|
|
|
|
|
|
gimp_image_update (gimage, x, y, w, h);
|
|
|
|
|
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (drawable));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_drawable_apply_image (GimpDrawable *drawable,
|
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2,
|
|
|
|
TileManager *tiles,
|
2001-12-03 21:44:59 +08:00
|
|
|
gint sparse)
|
2001-07-08 06:49:01 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
2001-12-03 21:44:59 +08:00
|
|
|
if (! tiles)
|
2001-07-08 06:49:01 +08:00
|
|
|
undo_push_image (drawable->gimage, drawable,
|
|
|
|
x1, y1, x2, y2);
|
|
|
|
else
|
|
|
|
undo_push_image_mod (drawable->gimage, drawable,
|
|
|
|
x1, y1, x2, y2, tiles, sparse);
|
|
|
|
}
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
void
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_merge_shadow (GimpDrawable *drawable,
|
2001-07-08 06:49:01 +08:00
|
|
|
gboolean undo)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2001-01-20 21:21:49 +08:00
|
|
|
GimpImage *gimage;
|
2000-12-29 00:19:55 +08:00
|
|
|
PixelRegion shadowPR;
|
|
|
|
gint x1, y1, x2, y2;
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
gimage = gimp_drawable_gimage (drawable);
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (gimage->shadow != NULL);
|
1999-01-28 06:00:44 +08:00
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
/* A useful optimization here is to limit the update to the
|
|
|
|
* extents of the selection mask, as it cannot extend beyond
|
|
|
|
* them.
|
|
|
|
*/
|
|
|
|
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
|
|
|
|
pixel_region_init (&shadowPR, gimage->shadow, x1, y1,
|
|
|
|
(x2 - x1), (y2 - y1), FALSE);
|
2000-12-30 08:16:50 +08:00
|
|
|
gimp_image_apply_image (gimage, drawable, &shadowPR, undo, OPAQUE_OPACITY,
|
2001-12-09 07:12:59 +08:00
|
|
|
GIMP_REPLACE_MODE, NULL, x1, y1);
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-20 21:21:49 +08:00
|
|
|
gimp_drawable_fill (GimpDrawable *drawable,
|
|
|
|
const GimpRGB *color)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2001-01-20 21:21:49 +08:00
|
|
|
GimpImage *gimage;
|
2000-12-29 00:19:55 +08:00
|
|
|
PixelRegion destPR;
|
|
|
|
guchar c[MAX_CHANNELS];
|
|
|
|
guchar i;
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gimage = gimp_drawable_gimage (drawable);
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (gimage != NULL);
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2001-12-14 23:30:31 +08:00
|
|
|
switch (GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable)))
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2001-12-14 23:30:31 +08:00
|
|
|
case GIMP_RGB:
|
2001-01-20 21:21:49 +08:00
|
|
|
gimp_rgba_get_uchar (color,
|
|
|
|
&c[RED_PIX],
|
|
|
|
&c[GREEN_PIX],
|
|
|
|
&c[BLUE_PIX],
|
|
|
|
&c[ALPHA_PIX]);
|
2001-12-12 02:11:56 +08:00
|
|
|
if (gimp_drawable_type (drawable) != GIMP_RGBA_IMAGE)
|
2001-01-20 21:21:49 +08:00
|
|
|
c[ALPHA_PIX] = 255;
|
1998-06-30 23:31:32 +08:00
|
|
|
break;
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2001-12-14 23:30:31 +08:00
|
|
|
case GIMP_GRAY:
|
2001-01-20 21:21:49 +08:00
|
|
|
gimp_rgba_get_uchar (color,
|
|
|
|
&c[GRAY_PIX],
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&c[ALPHA_G_PIX]);
|
2001-12-12 02:11:56 +08:00
|
|
|
if (gimp_drawable_type (drawable) != GIMP_GRAYA_IMAGE)
|
2001-01-20 21:21:49 +08:00
|
|
|
c[ALPHA_G_PIX] = 255;
|
1998-06-30 23:31:32 +08:00
|
|
|
break;
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2001-12-14 23:30:31 +08:00
|
|
|
case GIMP_INDEXED:
|
2001-01-20 21:21:49 +08:00
|
|
|
gimp_rgb_get_uchar (color,
|
|
|
|
&c[RED_PIX],
|
|
|
|
&c[GREEN_PIX],
|
|
|
|
&c[BLUE_PIX]);
|
2001-12-11 23:58:07 +08:00
|
|
|
gimp_image_transform_color (gimage, drawable, c, &i, GIMP_RGB);
|
1998-06-30 23:31:32 +08:00
|
|
|
c[INDEXED_PIX] = i;
|
2001-12-12 02:11:56 +08:00
|
|
|
if (gimp_drawable_type (drawable) == GIMP_INDEXEDA_IMAGE)
|
2001-01-20 21:21:49 +08:00
|
|
|
gimp_rgba_get_uchar (color,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&c[ALPHA_I_PIX]);
|
1998-06-30 23:31:32 +08:00
|
|
|
break;
|
2000-12-29 00:19:55 +08:00
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
default:
|
2001-12-11 23:58:07 +08:00
|
|
|
g_warning ("%s: Cannot fill unknown image type.",
|
|
|
|
G_GNUC_PRETTY_FUNCTION);
|
1998-06-30 23:31:32 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pixel_region_init (&destPR,
|
|
|
|
gimp_drawable_data (drawable),
|
|
|
|
0, 0,
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_width (drawable),
|
1998-06-30 23:31:32 +08:00
|
|
|
gimp_drawable_height (drawable),
|
|
|
|
TRUE);
|
|
|
|
color_region (&destPR, c);
|
2001-07-08 06:49:01 +08:00
|
|
|
|
|
|
|
gimp_drawable_update (drawable,
|
|
|
|
0, 0,
|
|
|
|
gimp_drawable_width (drawable),
|
|
|
|
gimp_drawable_height (drawable));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_drawable_fill_by_type (GimpDrawable *drawable,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpFillType fill_type)
|
|
|
|
{
|
|
|
|
GimpRGB color;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
|
|
|
color.a = 1.0;
|
|
|
|
|
|
|
|
switch (fill_type)
|
|
|
|
{
|
|
|
|
case FOREGROUND_FILL:
|
|
|
|
gimp_context_get_foreground (context, &color);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BACKGROUND_FILL:
|
|
|
|
gimp_context_get_background (context, &color);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WHITE_FILL:
|
|
|
|
gimp_rgb_set (&color, 1.0, 1.0, 1.0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TRANSPARENT_FILL:
|
|
|
|
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NO_FILL:
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
2001-11-16 20:23:01 +08:00
|
|
|
g_warning ("%s: unknown fill type %d", G_GNUC_PRETTY_FUNCTION, fill_type);
|
2001-07-08 06:49:01 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_drawable_fill (drawable, &color);
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gboolean
|
1998-06-30 23:31:32 +08:00
|
|
|
gimp_drawable_mask_bounds (GimpDrawable *drawable,
|
1999-08-22 19:45:31 +08:00
|
|
|
gint *x1,
|
|
|
|
gint *y1,
|
|
|
|
gint *x2,
|
|
|
|
gint *y2)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
GimpImage *gimage;
|
2001-01-20 21:21:49 +08:00
|
|
|
gint off_x, off_y;
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
gimage = gimp_drawable_gimage (drawable);
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (gimage != NULL, FALSE);
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2001-11-29 06:42:19 +08:00
|
|
|
if (gimp_image_mask_bounds (gimage, x1, y1, x2, y2))
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
|
|
|
gimp_drawable_offsets (drawable, &off_x, &off_y);
|
1999-08-22 19:45:31 +08:00
|
|
|
*x1 = CLAMP (*x1 - off_x, 0, gimp_drawable_width (drawable));
|
1998-06-30 23:31:32 +08:00
|
|
|
*y1 = CLAMP (*y1 - off_y, 0, gimp_drawable_height (drawable));
|
1999-08-22 19:45:31 +08:00
|
|
|
*x2 = CLAMP (*x2 - off_x, 0, gimp_drawable_width (drawable));
|
1998-06-30 23:31:32 +08:00
|
|
|
*y2 = CLAMP (*y2 - off_y, 0, gimp_drawable_height (drawable));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-08-22 19:45:31 +08:00
|
|
|
*x2 = gimp_drawable_width (drawable);
|
1998-06-30 23:31:32 +08:00
|
|
|
*y2 = gimp_drawable_height (drawable);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-15 01:11:14 +08:00
|
|
|
/* The removed signal is sent out when the layer is no longer
|
|
|
|
* associcated with an image. It's needed because layers aren't
|
|
|
|
* destroyed immediately, but kept around for undo purposes. Connect
|
|
|
|
* to the removed signal to update bits of UI that are tied to a
|
2001-01-20 21:21:49 +08:00
|
|
|
* particular layer.
|
|
|
|
*/
|
2001-01-15 01:11:14 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_removed (GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
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_signal_emit (G_OBJECT (drawable), gimp_drawable_signals[REMOVED], 0);
|
2001-01-15 01:11:14 +08:00
|
|
|
}
|
1998-06-30 23:31:32 +08:00
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gboolean
|
2000-12-29 00:19:55 +08:00
|
|
|
gimp_drawable_has_alpha (const GimpDrawable *drawable)
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
|
|
|
return drawable->has_alpha;
|
1999-08-22 19:45:31 +08:00
|
|
|
}
|
1998-10-14 10:54:02 +08:00
|
|
|
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-19 07:41:39 +08:00
|
|
|
GimpImageType
|
2000-12-29 00:19:55 +08:00
|
|
|
gimp_drawable_type (const GimpDrawable *drawable)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
|
|
|
|
|
|
|
return drawable->type;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
GimpImageType
|
2000-12-29 00:19:55 +08:00
|
|
|
gimp_drawable_type_with_alpha (const GimpDrawable *drawable)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
1999-08-22 19:45:31 +08:00
|
|
|
|
2001-12-14 23:30:31 +08:00
|
|
|
return GIMP_IMAGE_TYPE_WITH_ALPHA (gimp_drawable_type (drawable));
|
2001-12-13 07:48:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_is_rgb (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
2001-12-14 23:30:31 +08:00
|
|
|
return GIMP_IMAGE_TYPE_IS_RGB (gimp_drawable_type (drawable));
|
2001-12-13 07:48:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_is_gray (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
2001-12-14 23:30:31 +08:00
|
|
|
return GIMP_IMAGE_TYPE_IS_GRAY (gimp_drawable_type (drawable));
|
2001-12-13 07:48:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_is_indexed (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
2001-12-14 23:30:31 +08:00
|
|
|
return GIMP_IMAGE_TYPE_IS_INDEXED (gimp_drawable_type (drawable));
|
2001-12-13 07:48:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TileManager *
|
|
|
|
gimp_drawable_data (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
|
|
|
return drawable->tiles;
|
|
|
|
}
|
|
|
|
|
|
|
|
TileManager *
|
|
|
|
gimp_drawable_shadow (GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
|
|
|
if (! (gimage = gimp_drawable_gimage (drawable)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return gimp_image_shadow (gimage, drawable->width, drawable->height,
|
|
|
|
drawable->bytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gimp_drawable_bytes (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
|
|
|
|
|
|
|
return drawable->bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gimp_drawable_bytes_with_alpha (const GimpDrawable *drawable)
|
|
|
|
{
|
2001-12-14 23:30:31 +08:00
|
|
|
GimpImageType type;
|
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
|
|
|
|
2001-12-14 23:30:31 +08:00
|
|
|
type = GIMP_IMAGE_TYPE_WITH_ALPHA (gimp_drawable_type (drawable));
|
2001-12-13 07:48:18 +08:00
|
|
|
|
2001-12-14 23:30:31 +08:00
|
|
|
return GIMP_IMAGE_TYPE_BYTES (type);
|
2001-12-13 07:48:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gimp_drawable_width (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
|
|
|
|
|
|
|
return drawable->width;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gimp_drawable_height (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
|
|
|
|
|
|
|
return drawable->height;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gboolean
|
2001-03-05 00:52:37 +08:00
|
|
|
gimp_drawable_get_visible (const GimpDrawable *drawable)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-01-31 21:07:39 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
return drawable->visible;
|
|
|
|
}
|
|
|
|
|
2001-03-05 00:52:37 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_set_visible (GimpDrawable *drawable,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
|
|
|
visible = visible ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if (drawable->visible != visible)
|
|
|
|
{
|
|
|
|
drawable->visible = visible;
|
|
|
|
|
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_signal_emit (G_OBJECT (drawable),
|
|
|
|
gimp_drawable_signals[VISIBILITY_CHANGED], 0);
|
2001-07-08 06:49:01 +08:00
|
|
|
|
|
|
|
gimp_drawable_update (drawable,
|
|
|
|
0, 0,
|
|
|
|
drawable->width,
|
|
|
|
drawable->height);
|
2001-03-05 00:52:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_offsets (const GimpDrawable *drawable,
|
|
|
|
gint *off_x,
|
|
|
|
gint *off_y)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
|
|
|
*off_x = drawable->offset_x;
|
|
|
|
*off_y = drawable->offset_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
guchar *
|
|
|
|
gimp_drawable_cmap (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
|
|
|
if (! (gimage = gimp_drawable_gimage (drawable)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return gimage->cmap;
|
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
guchar *
|
|
|
|
gimp_drawable_get_color_at (GimpDrawable *drawable,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
1999-02-16 16:53:54 +08:00
|
|
|
{
|
2000-10-28 23:43:56 +08:00
|
|
|
Tile *tile;
|
1999-08-22 19:45:31 +08:00
|
|
|
guchar *src;
|
|
|
|
guchar *dest;
|
1999-02-16 16:53:54 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
2000-03-02 06:05:22 +08:00
|
|
|
g_return_val_if_fail (gimp_drawable_gimage (drawable) ||
|
2001-08-11 22:39:19 +08:00
|
|
|
! gimp_drawable_is_indexed (drawable), NULL);
|
2000-03-09 19:58:03 +08:00
|
|
|
|
|
|
|
/* do not make this a g_return_if_fail() */
|
|
|
|
if ( !(x >= 0 && x < drawable->width && y >= 0 && y < drawable->height))
|
|
|
|
return NULL;
|
2000-02-17 19:44:27 +08:00
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
dest = g_new (guchar, 5);
|
2000-02-17 19:44:27 +08:00
|
|
|
|
1999-02-16 16:53:54 +08:00
|
|
|
tile = tile_manager_get_tile (gimp_drawable_data (drawable), x, y,
|
|
|
|
TRUE, FALSE);
|
|
|
|
src = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT);
|
2000-02-17 19:44:27 +08:00
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_image_get_color (gimp_drawable_gimage (drawable),
|
1999-02-16 16:53:54 +08:00
|
|
|
gimp_drawable_type (drawable), dest, src);
|
2000-02-17 19:44:27 +08:00
|
|
|
|
2000-12-14 02:53:35 +08:00
|
|
|
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_drawable_type (drawable)))
|
1999-02-16 16:53:54 +08:00
|
|
|
dest[3] = src[gimp_drawable_bytes (drawable) - 1];
|
|
|
|
else
|
|
|
|
dest[3] = 255;
|
2000-02-17 19:44:27 +08:00
|
|
|
|
1999-10-17 08:07:55 +08:00
|
|
|
if (gimp_drawable_is_indexed (drawable))
|
1999-02-16 16:53:54 +08:00
|
|
|
dest[4] = src[0];
|
|
|
|
else
|
|
|
|
dest[4] = 0;
|
2000-02-17 19:44:27 +08:00
|
|
|
|
1999-02-16 16:53:54 +08:00
|
|
|
tile_release (tile, FALSE);
|
2000-02-17 19:44:27 +08:00
|
|
|
|
1999-02-16 16:53:54 +08:00
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
1998-10-08 16:15:21 +08:00
|
|
|
void
|
1999-10-17 08:07:55 +08:00
|
|
|
gimp_drawable_parasite_attach (GimpDrawable *drawable,
|
2000-05-27 06:28:40 +08:00
|
|
|
GimpParasite *parasite)
|
1998-10-08 16:15:21 +08:00
|
|
|
{
|
2000-01-31 21:07:39 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
1999-04-23 14:07:09 +08:00
|
|
|
/* only set the dirty bit manually if we can be saved and the new
|
|
|
|
parasite differs from the current one and we arn't undoable */
|
2000-05-27 06:28:40 +08:00
|
|
|
if (gimp_parasite_is_undoable (parasite))
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
/* do a group in case we have attach_parent set */
|
|
|
|
undo_push_group_start (drawable->gimage, PARASITE_ATTACH_UNDO);
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
undo_push_drawable_parasite (drawable->gimage, drawable, parasite);
|
|
|
|
}
|
2000-05-27 06:28:40 +08:00
|
|
|
else if (gimp_parasite_is_persistent (parasite) &&
|
2000-12-29 00:19:55 +08:00
|
|
|
! gimp_parasite_compare (parasite,
|
|
|
|
gimp_drawable_parasite_find
|
|
|
|
(drawable, gimp_parasite_name (parasite))))
|
|
|
|
{
|
2001-11-16 20:23:01 +08:00
|
|
|
undo_push_cantundo (drawable->gimage, _("parasite attached to drawable"));
|
2000-12-29 00:19:55 +08:00
|
|
|
}
|
1999-08-22 19:45:31 +08:00
|
|
|
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasite_list_add (drawable->parasites, parasite);
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_PARENT))
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasite_shift_parent (parasite);
|
1999-10-17 08:07:55 +08:00
|
|
|
gimp_image_parasite_attach (drawable->gimage, parasite);
|
1999-08-22 19:45:31 +08:00
|
|
|
}
|
2000-05-27 06:28:40 +08:00
|
|
|
else if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_GRANDPARENT))
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasite_shift_parent (parasite);
|
|
|
|
gimp_parasite_shift_parent (parasite);
|
|
|
|
gimp_parasite_attach (drawable->gimage->gimp, parasite);
|
1999-08-22 19:45:31 +08:00
|
|
|
}
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
if (gimp_parasite_is_undoable (parasite))
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
|
|
|
undo_push_group_end (drawable->gimage);
|
|
|
|
}
|
1998-10-08 16:15:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-10-17 08:07:55 +08:00
|
|
|
gimp_drawable_parasite_detach (GimpDrawable *drawable,
|
1999-08-22 19:45:31 +08:00
|
|
|
const gchar *parasite)
|
1998-10-08 16:15:21 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
GimpParasite *p;
|
1999-08-22 19:45:31 +08:00
|
|
|
|
2000-01-31 21:07:39 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
2001-07-05 06:59:25 +08:00
|
|
|
if (! (p = gimp_parasite_list_find (drawable->parasites, parasite)))
|
1998-12-16 19:23:30 +08:00
|
|
|
return;
|
1999-08-22 19:45:31 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
if (gimp_parasite_is_undoable (p))
|
1999-04-23 14:07:09 +08:00
|
|
|
undo_push_drawable_parasite_remove (drawable->gimage, drawable,
|
2000-05-27 06:28:40 +08:00
|
|
|
gimp_parasite_name (p));
|
|
|
|
else if (gimp_parasite_is_persistent (p))
|
2001-11-16 20:23:01 +08:00
|
|
|
undo_push_cantundo (drawable->gimage, _("parasite detached from drawable"));
|
1999-08-22 19:45:31 +08:00
|
|
|
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasite_list_remove (drawable->parasites, parasite);
|
1998-10-08 16:15:21 +08:00
|
|
|
}
|
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
GimpParasite *
|
|
|
|
gimp_drawable_parasite_find (const GimpDrawable *drawable,
|
|
|
|
const gchar *name)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2001-12-13 07:48:18 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
2000-02-17 19:44:27 +08:00
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
return gimp_parasite_list_find (drawable->parasites, name);
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_parasite_list_foreach_func (gchar *key,
|
|
|
|
GimpParasite *p,
|
|
|
|
gchar ***cur)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2001-12-13 07:48:18 +08:00
|
|
|
*(*cur)++ = (gchar *) g_strdup (key);
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
gchar **
|
|
|
|
gimp_drawable_parasite_list (const GimpDrawable *drawable,
|
|
|
|
gint *count)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2001-12-13 07:48:18 +08:00
|
|
|
gchar **list;
|
|
|
|
gchar **cur;
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
2001-12-13 07:48:18 +08:00
|
|
|
g_return_val_if_fail (count != NULL, NULL);
|
2000-02-17 19:44:27 +08:00
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
*count = gimp_parasite_list_length (drawable->parasites);
|
|
|
|
cur = list = g_new (gchar *, *count);
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
gimp_parasite_list_foreach (drawable->parasites,
|
|
|
|
(GHFunc) gimp_drawable_parasite_list_foreach_func,
|
|
|
|
&cur);
|
2000-02-17 19:44:27 +08:00
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
return list;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
GimpTattoo
|
|
|
|
gimp_drawable_get_tattoo (const GimpDrawable *drawable)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2001-12-13 07:48:18 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), 0);
|
2000-02-17 19:44:27 +08:00
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
return drawable->tattoo;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-12-13 07:48:18 +08:00
|
|
|
gimp_drawable_set_tattoo (GimpDrawable *drawable,
|
|
|
|
GimpTattoo tattoo)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
drawable->tattoo = tattoo;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|