2000-12-17 05:37:03 +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 <gtk/gtk.h>
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core/core-types.h"
|
|
|
|
#include "tools/tools-types.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "tools/gimptool.h"
|
2001-02-21 20:18:09 +08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "dialog_handler.h"
|
2001-01-30 01:54:02 +08:00
|
|
|
#include "gdisplay.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "gui/palette-import-dialog.h"
|
|
|
|
|
|
|
|
#include "context_manager.h"
|
1998-06-28 18:39:58 +08:00
|
|
|
#include "gimage.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "undo.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
|
1998-06-28 18:39:58 +08:00
|
|
|
/* gimage.c: Junk (ugly dependencies) from gimpimage.c on its way
|
2000-12-29 23:22:01 +08:00
|
|
|
* to proper places. That is, the handlers should be moved to
|
|
|
|
* layers_dialog, gdisplay, tools, etc..
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-05-07 02:58:04 +08:00
|
|
|
static void gimage_dirty_handler (GimpImage *gimage);
|
|
|
|
static void gimage_destroy_handler (GimpImage *gimage);
|
|
|
|
static void gimage_cmap_change_handler (GimpImage *gimage,
|
|
|
|
gint ncol,
|
|
|
|
gpointer user_data);
|
|
|
|
static void gimage_rename_handler (GimpImage *gimage);
|
|
|
|
static void gimage_size_changed_handler (GimpImage *gimage);
|
|
|
|
static void gimage_alpha_changed_handler (GimpImage *gimage);
|
|
|
|
static void gimage_repaint_handler (GimpImage *gimage,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
1999-07-20 03:46:05 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-29 00:44:22 +08:00
|
|
|
GimpImage *
|
2000-12-29 23:22:01 +08:00
|
|
|
gimage_new (gint width,
|
|
|
|
gint height,
|
1999-10-14 07:07:45 +08:00
|
|
|
GimpImageBaseType base_type)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
2000-12-29 23:22:01 +08:00
|
|
|
GimpImage *gimage = gimp_image_new (width, height, base_type);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-06-28 18:39:58 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gimage), "dirty",
|
2000-12-29 23:22:01 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimage_dirty_handler),
|
|
|
|
NULL);
|
1998-06-28 18:39:58 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gimage), "destroy",
|
2000-12-29 23:22:01 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimage_destroy_handler),
|
|
|
|
NULL);
|
2001-01-14 11:55:56 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gimage), "name_changed",
|
2000-12-29 23:22:01 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimage_rename_handler),
|
|
|
|
NULL);
|
2001-05-07 01:56:10 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gimage), "size_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gimage_size_changed_handler),
|
2000-12-29 23:22:01 +08:00
|
|
|
NULL);
|
2001-05-07 02:58:04 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gimage), "alpha_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gimage_alpha_changed_handler),
|
2000-12-29 23:22:01 +08:00
|
|
|
NULL);
|
1998-06-28 18:39:58 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gimage), "repaint",
|
2000-12-29 23:22:01 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimage_repaint_handler),
|
|
|
|
NULL);
|
1999-01-08 03:53:05 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (gimage), "colormap_changed",
|
2000-12-29 23:22:01 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimage_cmap_change_handler),
|
|
|
|
NULL);
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2001-02-04 06:05:41 +08:00
|
|
|
gimp_container_add (image_context, GIMP_OBJECT (gimage));
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return gimage;
|
|
|
|
}
|
|
|
|
|
2001-02-14 12:55:21 +08:00
|
|
|
|
1998-06-28 18:39:58 +08:00
|
|
|
static void
|
1999-10-14 07:07:45 +08:00
|
|
|
gimage_dirty_handler (GimpImage *gimage)
|
1999-06-26 19:16:47 +08:00
|
|
|
{
|
2000-12-31 12:07:42 +08:00
|
|
|
if (active_tool && ! active_tool->preserve)
|
1999-06-26 19:16:47 +08:00
|
|
|
{
|
2000-12-31 12:07:42 +08:00
|
|
|
GDisplay* gdisp = active_tool->gdisp;
|
1999-06-26 19:16:47 +08:00
|
|
|
|
|
|
|
if (gdisp)
|
|
|
|
{
|
|
|
|
if (gdisp->gimage == gimage)
|
2001-02-21 20:18:09 +08:00
|
|
|
tool_manager_initialize_tool (active_tool, gdisp);
|
1999-06-26 19:16:47 +08:00
|
|
|
else
|
2001-02-21 20:18:09 +08:00
|
|
|
tool_manager_initialize_tool (active_tool, NULL);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-06-28 18:39:58 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-06-28 18:39:58 +08:00
|
|
|
static void
|
1999-10-14 07:07:45 +08:00
|
|
|
gimage_destroy_handler (GimpImage *gimage)
|
1998-06-28 18:39:58 +08:00
|
|
|
{
|
|
|
|
/* free the undo list */
|
|
|
|
undo_free (gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
/* check if this is the last image */
|
|
|
|
if (gimp_container_num_children (image_context) == 1)
|
1999-01-31 09:08:26 +08:00
|
|
|
{
|
1999-07-20 03:46:05 +08:00
|
|
|
dialog_show_toolbox ();
|
1999-01-31 09:08:26 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-07-20 03:46:05 +08:00
|
|
|
static void
|
|
|
|
gimage_cmap_change_handler (GimpImage *gimage,
|
|
|
|
gint ncol,
|
|
|
|
gpointer user_data)
|
1999-01-08 03:53:05 +08:00
|
|
|
{
|
2000-02-11 05:38:43 +08:00
|
|
|
if (gimp_image_base_type (gimage) == INDEXED)
|
2001-05-15 19:25:25 +08:00
|
|
|
gdisplays_update_full (gimage);
|
1999-01-08 03:53:05 +08:00
|
|
|
}
|
|
|
|
|
1998-06-28 18:39:58 +08:00
|
|
|
static void
|
1999-10-14 07:07:45 +08:00
|
|
|
gimage_rename_handler (GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-06-29 08:24:44 +08:00
|
|
|
gdisplays_update_title (gimage);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-20 03:46:05 +08:00
|
|
|
palette_import_image_renamed (gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-06-28 18:39:58 +08:00
|
|
|
static void
|
2001-05-07 01:56:10 +08:00
|
|
|
gimage_size_changed_handler (GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* shrink wrap and update all views */
|
2001-01-29 00:44:22 +08:00
|
|
|
gimp_image_invalidate_layer_previews (gimage);
|
|
|
|
gimp_image_invalidate_channel_previews (gimage);
|
2001-02-05 06:10:54 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gimage));
|
1998-12-14 02:52:34 +08:00
|
|
|
gdisplays_resize_cursor_label (gimage);
|
1998-06-29 08:24:44 +08:00
|
|
|
gdisplays_update_full (gimage);
|
|
|
|
gdisplays_shrink_wrap (gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-06-28 18:39:58 +08:00
|
|
|
static void
|
2001-05-07 02:58:04 +08:00
|
|
|
gimage_alpha_changed_handler (GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-06-29 08:24:44 +08:00
|
|
|
gdisplays_update_title (gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-06-28 18:39:58 +08:00
|
|
|
static void
|
1999-10-14 07:07:45 +08:00
|
|
|
gimage_repaint_handler (GimpImage *gimage,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-06-29 08:24:44 +08:00
|
|
|
gdisplays_update_area (gimage, x, y, w, h);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|