2001-06-26 20:09:43 +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>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-10-13 20:52:30 +08:00
|
|
|
#include "gui-types.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
#include "core/gimp.h"
|
2003-09-04 01:17:18 +08:00
|
|
|
#include "core/gimpchannel.h"
|
2001-10-17 19:33:43 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "core/gimpimage.h"
|
2002-03-15 23:09:58 +08:00
|
|
|
#include "core/gimpimage-crop.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "core/gimpimage-duplicate.h"
|
2003-05-19 02:48:36 +08:00
|
|
|
#include "core/gimpimage-flip.h"
|
2002-02-13 22:41:35 +08:00
|
|
|
#include "core/gimpimage-merge.h"
|
include the new "paint-funcs/paint-funcs-types.h".
2001-11-28 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: include the new
"paint-funcs/paint-funcs-types.h".
* app/paint-funcs/Makefile.am
* app/paint-funcs/paint-funcs-types.h: new file. Includes
"base/base-types.h".
* app/paint-funcs/paint-funcs.[ch]: removed the enums here,
include "paint-funcs-types.h".
* app/widgets/widgets-types.h: include "display/display-types.h"
* app/display/display-types.h: include "widgets/widgets-types.h".
* app/tools/tools-types.h: include "display/display-types.h"
* app/gui/gui-types.h: include "tools/tools-types.h".
The order of namespaces/dependencies should be (but is not):
(base, paint-funcs) -> (core, file, xcf, pdb) ->
(widgets, display) -> tools -> gui
* app/path.c: include "tools/tools-types.h".
* app/core/Makefile.am
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-merge.[ch]
* app/core/gimpimage-resize.[ch]
* app/core/gimpimage-scale.[ch]: new files.
* app/core/gimpimage.[ch]: removed the stuff which is in the new
files. Reordered all functions in both the .h and .c files,
commented the groups of functions.
* app/core/gimpcontainer.c: create the handler_id using a counter,
not the address of a pointer, because the address *may* be the
same twice, added debugging output.
* app/core/gimpviewable.[ch]: added primitive support for getting
a preview GdkPixbuf.
* app/nav_window.c
* app/undo.c
* app/undo_history.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.[ch]
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/layers-commands.c
* app/gui/palette-import-dialog.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/widgets/gimpcontainerview-utils.c
* app/xcf/xcf-load.c: changed accordingly, some cleanup.
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions.
* app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu
items to the name of the last plug-in (Fixes #50986).
* app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and
"Redo" to the resp. undo names. Much simplified the WM icon stuff
by removing most code and using gimp_viewable_get_new_preview_pixbuf().
* app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark
returned by gimp_container_add_handler().
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-29 01:51:06 +08:00
|
|
|
#include "core/gimpimage-resize.h"
|
2003-05-20 18:36:29 +08:00
|
|
|
#include "core/gimpimage-rotate.h"
|
include the new "paint-funcs/paint-funcs-types.h".
2001-11-28 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: include the new
"paint-funcs/paint-funcs-types.h".
* app/paint-funcs/Makefile.am
* app/paint-funcs/paint-funcs-types.h: new file. Includes
"base/base-types.h".
* app/paint-funcs/paint-funcs.[ch]: removed the enums here,
include "paint-funcs-types.h".
* app/widgets/widgets-types.h: include "display/display-types.h"
* app/display/display-types.h: include "widgets/widgets-types.h".
* app/tools/tools-types.h: include "display/display-types.h"
* app/gui/gui-types.h: include "tools/tools-types.h".
The order of namespaces/dependencies should be (but is not):
(base, paint-funcs) -> (core, file, xcf, pdb) ->
(widgets, display) -> tools -> gui
* app/path.c: include "tools/tools-types.h".
* app/core/Makefile.am
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-merge.[ch]
* app/core/gimpimage-resize.[ch]
* app/core/gimpimage-scale.[ch]: new files.
* app/core/gimpimage.[ch]: removed the stuff which is in the new
files. Reordered all functions in both the .h and .c files,
commented the groups of functions.
* app/core/gimpcontainer.c: create the handler_id using a counter,
not the address of a pointer, because the address *may* be the
same twice, added debugging output.
* app/core/gimpviewable.[ch]: added primitive support for getting
a preview GdkPixbuf.
* app/nav_window.c
* app/undo.c
* app/undo_history.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.[ch]
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/layers-commands.c
* app/gui/palette-import-dialog.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/widgets/gimpcontainerview-utils.c
* app/xcf/xcf-load.c: changed accordingly, some cleanup.
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions.
* app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu
items to the name of the last plug-in (Fixes #50986).
* app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and
"Redo" to the resp. undo names. Much simplified the WM icon stuff
by removing most code and using gimp_viewable_get_new_preview_pixbuf().
* app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark
returned by gimp_container_add_handler().
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-29 01:51:06 +08:00
|
|
|
#include "core/gimpimage-scale.h"
|
2003-02-13 19:23:50 +08:00
|
|
|
#include "core/gimpimage-undo.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2002-08-31 05:00:42 +08:00
|
|
|
#include "widgets/gimpviewabledialog.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2002-06-27 06:16:59 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2002-02-22 23:08:47 +08:00
|
|
|
#include "display/gimpprogress.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "convert-dialog.h"
|
2002-02-13 22:41:35 +08:00
|
|
|
#include "image-commands.h"
|
2003-07-27 18:34:15 +08:00
|
|
|
#include "grid-dialog.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "resize-dialog.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
|
2001-11-17 01:08:41 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Resize *resize;
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpImage *gimage;
|
|
|
|
} ImageResize;
|
|
|
|
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
#define return_if_no_display(gdisp,data) \
|
2002-12-11 00:38:16 +08:00
|
|
|
if (GIMP_IS_DISPLAY (data)) \
|
|
|
|
gdisp = data; \
|
|
|
|
else if (GIMP_IS_GIMP (data)) \
|
|
|
|
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data))); \
|
|
|
|
else \
|
|
|
|
gdisp = NULL; \
|
2001-10-29 19:47:11 +08:00
|
|
|
if (! gdisp) \
|
|
|
|
return
|
|
|
|
|
|
|
|
#define return_if_no_image(gimage,data) \
|
2002-12-11 00:38:16 +08:00
|
|
|
if (GIMP_IS_DISPLAY (data)) \
|
|
|
|
gimage = ((GimpDisplay *) data)->gimage; \
|
|
|
|
else if (GIMP_IS_GIMP (data)) \
|
|
|
|
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
|
|
|
|
else \
|
|
|
|
gimage = NULL; \
|
2001-10-29 19:47:11 +08:00
|
|
|
if (! gimage) \
|
|
|
|
return
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* local functions */
|
|
|
|
|
|
|
|
static void image_resize_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void image_scale_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void image_scale_warn_callback (GtkWidget *widget,
|
|
|
|
gboolean do_scale,
|
|
|
|
gpointer data);
|
|
|
|
static void image_scale_implement (ImageResize *image_scale);
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
|
|
|
image_convert_rgb_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
convert_to_rgb (gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
image_convert_grayscale_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
convert_to_grayscale (gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
image_convert_indexed_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
convert_to_indexed (gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
image_resize_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-06-26 20:09:43 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
ImageResize *image_resize;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
gimage = gdisp->gimage;
|
|
|
|
|
|
|
|
image_resize = g_new0 (ImageResize, 1);
|
|
|
|
|
2001-11-17 01:08:41 +08:00
|
|
|
image_resize->gdisp = gdisp;
|
2001-06-26 20:09:43 +08:00
|
|
|
image_resize->gimage = gimage;
|
2002-09-08 00:47:39 +08:00
|
|
|
|
|
|
|
image_resize->resize =
|
2002-09-08 20:18:23 +08:00
|
|
|
resize_widget_new (GIMP_VIEWABLE (gimage),
|
2002-09-08 00:47:39 +08:00
|
|
|
ResizeWidget,
|
|
|
|
gimage->width,
|
|
|
|
gimage->height,
|
|
|
|
gimage->xresolution,
|
|
|
|
gimage->yresolution,
|
|
|
|
gimage->unit,
|
|
|
|
GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot,
|
|
|
|
G_CALLBACK (image_resize_callback),
|
|
|
|
image_resize);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_object (gdisp, "disconnect",
|
2002-09-08 20:18:23 +08:00
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
2003-01-06 06:07:10 +08:00
|
|
|
image_resize->resize->resize_shell,
|
2002-09-08 20:18:23 +08:00
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
|
2001-08-15 00:33:28 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (image_resize->resize->resize_shell),
|
|
|
|
(GWeakNotify) g_free,
|
|
|
|
image_resize);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
gtk_widget_show (image_resize->resize->resize_shell);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
image_scale_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-06-26 20:09:43 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
ImageResize *image_scale;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
gimage = gdisp->gimage;
|
|
|
|
|
|
|
|
image_scale = g_new0 (ImageResize, 1);
|
|
|
|
|
2001-11-17 01:08:41 +08:00
|
|
|
image_scale->gdisp = gdisp;
|
2001-06-26 20:09:43 +08:00
|
|
|
image_scale->gimage = gimage;
|
2002-09-08 00:47:39 +08:00
|
|
|
|
|
|
|
image_scale->resize =
|
2002-09-08 20:18:23 +08:00
|
|
|
resize_widget_new (GIMP_VIEWABLE (gimage),
|
2002-09-08 00:47:39 +08:00
|
|
|
ScaleWidget,
|
|
|
|
gimage->width,
|
|
|
|
gimage->height,
|
|
|
|
gimage->xresolution,
|
|
|
|
gimage->yresolution,
|
|
|
|
gimage->unit,
|
|
|
|
GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot,
|
|
|
|
G_CALLBACK (image_scale_callback),
|
|
|
|
image_scale);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_object (gdisp, "disconnect",
|
2002-09-08 20:18:23 +08:00
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
2003-01-06 06:07:10 +08:00
|
|
|
image_scale->resize->resize_shell,
|
2002-09-08 20:18:23 +08:00
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
|
2001-08-15 00:33:28 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (image_scale->resize->resize_shell),
|
|
|
|
(GWeakNotify) g_free,
|
|
|
|
image_scale);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
gtk_widget_show (image_scale->resize->resize_shell);
|
|
|
|
}
|
|
|
|
|
2003-05-19 02:48:36 +08:00
|
|
|
void
|
|
|
|
image_flip_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
guint action)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpProgress *progress;
|
|
|
|
return_if_no_display (gdisp, data);
|
|
|
|
|
|
|
|
progress = gimp_progress_start (gdisp, _("Flipping..."), TRUE, NULL, NULL);
|
|
|
|
|
|
|
|
gimp_image_flip (gdisp->gimage, (GimpOrientationType) action,
|
|
|
|
gimp_progress_update_and_flush, progress);
|
|
|
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
gimp_image_flush (gdisp->gimage);
|
|
|
|
}
|
|
|
|
|
2003-05-20 18:36:29 +08:00
|
|
|
void
|
|
|
|
image_rotate_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
guint action)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpProgress *progress;
|
|
|
|
return_if_no_display (gdisp, data);
|
|
|
|
|
|
|
|
progress = gimp_progress_start (gdisp, _("Rotating..."), TRUE, NULL, NULL);
|
|
|
|
|
|
|
|
gimp_image_rotate (gdisp->gimage, (GimpRotationType) action,
|
|
|
|
gimp_progress_update_and_flush, progress);
|
|
|
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
gimp_image_flush (gdisp->gimage);
|
|
|
|
}
|
|
|
|
|
2002-03-15 23:09:58 +08:00
|
|
|
void
|
|
|
|
image_crop_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
return_if_no_display (gdisp, data);
|
|
|
|
|
2003-09-04 01:17:18 +08:00
|
|
|
if (! gimp_channel_bounds (gimp_image_get_mask (gdisp->gimage),
|
|
|
|
&x1, &y1, &x2, &y2))
|
2002-03-15 23:09:58 +08:00
|
|
|
{
|
|
|
|
g_message (_("Cannot crop because the current selection is empty."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_image_crop (gdisp->gimage, x1, y1, x2, y2, FALSE, TRUE);
|
2003-05-19 02:48:36 +08:00
|
|
|
gimp_image_flush (gdisp->gimage);
|
2002-03-15 23:09:58 +08:00
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
|
|
|
image_duplicate_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpImage *new_gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
new_gimage = gimp_image_duplicate (gimage);
|
2001-08-14 22:53:55 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_create_display (new_gimage->gimp, new_gimage, 0x0101);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (new_gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2002-02-13 22:41:35 +08:00
|
|
|
void
|
|
|
|
image_merge_layers_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
|
|
|
|
image_layers_merge_query (gimage, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
image_flatten_image_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
|
|
|
|
gimp_image_flatten (gimage);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-13 22:41:35 +08:00
|
|
|
}
|
2003-01-11 01:55:53 +08:00
|
|
|
|
2003-07-27 18:34:15 +08:00
|
|
|
void
|
|
|
|
image_configure_grid_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpDisplayShell *shell;
|
2003-10-10 22:11:47 +08:00
|
|
|
GimpImage *gimage;
|
2003-07-27 18:34:15 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
|
|
|
|
2003-10-10 22:11:47 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
gimage = GIMP_IMAGE (gdisp->gimage);
|
2003-07-27 18:34:15 +08:00
|
|
|
|
|
|
|
if (! shell->grid_dialog)
|
|
|
|
{
|
2003-10-10 22:11:47 +08:00
|
|
|
shell->grid_dialog = grid_dialog_new (GIMP_IMAGE (gimage));
|
2003-07-27 18:34:15 +08:00
|
|
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (shell->grid_dialog),
|
|
|
|
GTK_WINDOW (shell));
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (shell->grid_dialog),
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (shell->grid_dialog),
|
|
|
|
(gpointer *) &shell->grid_dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (shell->grid_dialog));
|
|
|
|
}
|
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
|
2002-02-13 22:41:35 +08:00
|
|
|
/****************************/
|
|
|
|
/* The layer merge dialog */
|
|
|
|
/****************************/
|
|
|
|
|
|
|
|
typedef struct _LayerMergeOptions LayerMergeOptions;
|
|
|
|
|
|
|
|
struct _LayerMergeOptions
|
|
|
|
{
|
2002-03-19 01:24:52 +08:00
|
|
|
GtkWidget *query_box;
|
|
|
|
GimpImage *gimage;
|
|
|
|
gboolean merge_visible;
|
|
|
|
GimpMergeType merge_type;
|
2002-02-13 22:41:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
image_layers_merge_query_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
LayerMergeOptions *options)
|
2002-02-13 22:41:35 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
GimpImage *gimage = options->gimage;
|
2002-02-13 22:41:35 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (! gimage)
|
2002-02-13 22:41:35 +08:00
|
|
|
return;
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
{
|
|
|
|
if (options->merge_visible)
|
|
|
|
gimp_image_merge_visible_layers (gimage, options->merge_type);
|
2002-02-13 22:41:35 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
2002-02-13 22:41:35 +08:00
|
|
|
|
|
|
|
gtk_widget_destroy (options->query_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
image_layers_merge_query (GimpImage *gimage,
|
|
|
|
/* if FALSE, anchor active layer */
|
|
|
|
gboolean merge_visible)
|
|
|
|
{
|
|
|
|
LayerMergeOptions *options;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *frame;
|
|
|
|
|
|
|
|
/* The new options structure */
|
|
|
|
options = g_new (LayerMergeOptions, 1);
|
|
|
|
options->gimage = gimage;
|
|
|
|
options->merge_visible = merge_visible;
|
2002-03-19 01:24:52 +08:00
|
|
|
options->merge_type = GIMP_EXPAND_AS_NECESSARY;
|
2002-02-13 22:41:35 +08:00
|
|
|
|
|
|
|
/* The dialog */
|
|
|
|
options->query_box =
|
2002-08-31 05:00:42 +08:00
|
|
|
gimp_viewable_dialog_new (GIMP_VIEWABLE (gimage),
|
|
|
|
_("Merge Layers"), "layers_merge_options",
|
|
|
|
GIMP_STOCK_MERGE_DOWN,
|
|
|
|
_("Layers Merge Options"),
|
|
|
|
gimp_standard_help_func,
|
2003-08-22 09:42:57 +08:00
|
|
|
GIMP_HELP_IMAGE_MERGE_LAYERS,
|
2002-02-13 22:41:35 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2002-02-13 22:41:35 +08:00
|
|
|
|
2002-08-31 05:00:42 +08:00
|
|
|
NULL);
|
2002-02-13 22:41:35 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
g_signal_connect (options->query_box, "response",
|
|
|
|
G_CALLBACK (image_layers_merge_query_response),
|
|
|
|
options);
|
|
|
|
|
2002-02-13 22:41:35 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (options->query_box),
|
|
|
|
(GWeakNotify) g_free,
|
|
|
|
options);
|
|
|
|
|
|
|
|
/* The main vbox */
|
2003-11-06 23:27:05 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
|
2002-02-13 22:41:35 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
|
|
|
|
vbox);
|
|
|
|
|
GimpViewableDialogs everywhere, cleanup:
2002-09-01 Michael Natterer <mitch@gimp.org>
GimpViewableDialogs everywhere, cleanup:
* libgimpwidgets/gimpstock.c: added texts for the RESIZE, SCALE
and CROP stock items.
* app/widgets/gimpviewabledialog.c: update the title when the
viewable's name changes.
* app/gui/color-notebook.[ch]: added color_notebook_viewable_new()
which creates a GimpViewableDialog.
* app/widgets/gimpgradienteditor.[ch]
* app/gui/colormap-editor-commands.c
* app/gui/file-new-dialog.c
* app/gui/gradient-editor-commands.c
* app/gui/palette-editor-commands.c
* app/undo_history.c: use GimpViewableDialogs and the new
color_notebook constructor.
* app/gui/convert-dialog.c: #include "widgets/gimpviewabledialog.h"
* app/gui/image-commands.c
* app/gui/info-dialog.c
* app/gui/resize-dialog.c: minor cleanups.
* app/gui/info-window.c: cleaned up the whole thing, esp. the
"Extended" page. Added HSV color display to the color picker
frame. Set the icons as frame titles, stuff...
* app/tools/gimpimagemaptool.[ch]: removed "shell_title",
"shell_name" and "stock_id" from the GimpImageMapTool struct
because they can be obtained from the tool's GimpToolInfo object.
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcurvestool.c
* app/tools/gimphuesaturationtool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c: changed accordingly.
* app/tools/gimphistogramtool.c: same here: take values from
tool->tool_info instead of hardcoding them.
* app/tools/gimpcroptool.[ch]: removed the static crop dialog
variables and added them to the GimpCropTool struct. Feels safer
and makes the callback code much simpler. Use stock items for the
dialog's "Resize" and "Crop" buttons.
* app/tools/gimpmeasuretool.c
* app/tools/gimprotatetool.c: for consistency don't name the tools
"Blah Tool", also the dialog titles need to match the menu
entries.
Unrelated:
* libgimpwidgets/gimpwidgets.c: the recently changed, gtk-doc
comment was correct, as gtk-doc takes the parameter names from
the header, not the .c file.
* app/tools/gimptransformtool.c: set the transform tool's state to
TRANSFORM_CREATING after changing displays, so the initial matrix
components are saved correctly for the "Reset" function.
2002-09-01 16:44:57 +08:00
|
|
|
frame =
|
|
|
|
gimp_radio_group_new2 (TRUE,
|
|
|
|
merge_visible ?
|
|
|
|
_("Final, Merged Layer should be:") :
|
|
|
|
_("Final, Anchored Layer should be:"),
|
|
|
|
G_CALLBACK (gimp_radio_button_update),
|
|
|
|
&options->merge_type,
|
|
|
|
GINT_TO_POINTER (options->merge_type),
|
|
|
|
|
|
|
|
_("Expanded as necessary"),
|
|
|
|
GINT_TO_POINTER (GIMP_EXPAND_AS_NECESSARY), NULL,
|
|
|
|
|
|
|
|
_("Clipped to image"),
|
|
|
|
GINT_TO_POINTER (GIMP_CLIP_TO_IMAGE), NULL,
|
|
|
|
|
|
|
|
_("Clipped to bottom layer"),
|
|
|
|
GINT_TO_POINTER (GIMP_CLIP_TO_BOTTOM_LAYER), NULL,
|
|
|
|
|
|
|
|
NULL);
|
2002-02-13 22:41:35 +08:00
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (options->query_box);
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
image_resize_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ImageResize *image_resize;
|
|
|
|
|
|
|
|
image_resize = (ImageResize *) data;
|
|
|
|
|
|
|
|
g_assert (image_resize != NULL);
|
|
|
|
g_assert (image_resize->gimage != NULL);
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (image_resize->resize->resize_shell, FALSE);
|
|
|
|
|
2003-06-04 00:42:46 +08:00
|
|
|
if (image_resize->resize->width > 0 &&
|
2003-08-22 09:42:57 +08:00
|
|
|
image_resize->resize->height > 0)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2003-06-04 00:42:46 +08:00
|
|
|
GimpProgress *progress;
|
|
|
|
|
|
|
|
progress = gimp_progress_start (image_resize->gdisp,
|
|
|
|
_("Resizing..."),
|
|
|
|
TRUE, NULL, NULL);
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
gimp_image_resize (image_resize->gimage,
|
|
|
|
image_resize->resize->width,
|
|
|
|
image_resize->resize->height,
|
|
|
|
image_resize->resize->offset_x,
|
2003-06-04 00:42:46 +08:00
|
|
|
image_resize->resize->offset_y,
|
|
|
|
gimp_progress_update_and_flush, progress);
|
|
|
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (image_resize->gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
2003-08-22 09:42:57 +08:00
|
|
|
else
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
|
|
|
g_message (_("Resize Error: Both width and height must be "
|
|
|
|
"greater than zero."));
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (image_resize->resize->resize_shell);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
image_scale_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ImageResize *image_scale;
|
|
|
|
|
|
|
|
image_scale = (ImageResize *) data;
|
|
|
|
|
|
|
|
g_assert (image_scale != NULL);
|
|
|
|
g_assert (image_scale->gimage != NULL);
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (image_scale->resize->resize_shell, FALSE);
|
|
|
|
|
|
|
|
if (gimp_image_check_scaling (image_scale->gimage,
|
|
|
|
image_scale->resize->width,
|
|
|
|
image_scale->resize->height))
|
|
|
|
{
|
|
|
|
image_scale_implement (image_scale);
|
|
|
|
|
|
|
|
gtk_widget_destroy (image_scale->resize->resize_shell);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
dialog =
|
|
|
|
gimp_query_boolean_box (_("Layer Too Small"),
|
|
|
|
gimp_standard_help_func,
|
2003-08-22 09:42:57 +08:00
|
|
|
GIMP_HELP_IMAGE_SCALE_WARNING,
|
2002-01-10 04:39:49 +08:00
|
|
|
GTK_STOCK_DIALOG_QUESTION,
|
2001-06-26 20:09:43 +08:00
|
|
|
_("The chosen image size will shrink\n"
|
|
|
|
"some layers completely away.\n"
|
|
|
|
"Is this what you want?"),
|
2001-07-31 01:17:36 +08:00
|
|
|
GTK_STOCK_OK, GTK_STOCK_CANCEL,
|
|
|
|
G_OBJECT (image_scale->resize->resize_shell),
|
2001-06-26 20:09:43 +08:00
|
|
|
"destroy",
|
|
|
|
image_scale_warn_callback,
|
|
|
|
image_scale);
|
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
image_scale_warn_callback (GtkWidget *widget,
|
|
|
|
gboolean do_scale,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ImageResize *image_scale;
|
|
|
|
|
|
|
|
image_scale = (ImageResize *) data;
|
|
|
|
|
|
|
|
if (do_scale) /* User doesn't mind losing layers... */
|
|
|
|
{
|
|
|
|
image_scale_implement (image_scale);
|
|
|
|
|
|
|
|
gtk_widget_destroy (image_scale->resize->resize_shell);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (image_scale->resize->resize_shell, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
image_scale_implement (ImageResize *image_scale)
|
|
|
|
{
|
2003-06-04 00:42:46 +08:00
|
|
|
GimpImage *gimage;
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
g_assert (image_scale != NULL);
|
|
|
|
g_assert (image_scale->gimage != NULL);
|
|
|
|
|
|
|
|
gimage = image_scale->gimage;
|
|
|
|
|
2003-06-04 00:42:46 +08:00
|
|
|
if (image_scale->resize->resolution_x == gimage->xresolution &&
|
|
|
|
image_scale->resize->resolution_y == gimage->yresolution &&
|
|
|
|
image_scale->resize->unit == gimage->unit &&
|
|
|
|
image_scale->resize->width == gimage->width &&
|
|
|
|
image_scale->resize->height == gimage->height)
|
|
|
|
return;
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2003-06-04 00:42:46 +08:00
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_IMAGE_SCALE,
|
|
|
|
_("Scale Image"));
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2003-06-04 00:42:46 +08:00
|
|
|
gimp_image_set_resolution (gimage,
|
|
|
|
image_scale->resize->resolution_x,
|
|
|
|
image_scale->resize->resolution_y);
|
|
|
|
gimp_image_set_unit (gimage, image_scale->resize->unit);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2003-06-04 00:42:46 +08:00
|
|
|
if (image_scale->resize->width != gimage->width ||
|
2001-06-26 20:09:43 +08:00
|
|
|
image_scale->resize->height != gimage->height)
|
|
|
|
{
|
2003-06-04 00:42:46 +08:00
|
|
|
if (image_scale->resize->width > 0 &&
|
2003-08-22 09:42:57 +08:00
|
|
|
image_scale->resize->height > 0)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-11-17 01:08:41 +08:00
|
|
|
GimpProgress *progress;
|
|
|
|
|
2002-02-22 23:08:47 +08:00
|
|
|
progress = gimp_progress_start (image_scale->gdisp,
|
|
|
|
_("Scaling..."),
|
|
|
|
TRUE, NULL, NULL);
|
2001-11-17 01:08:41 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
gimp_image_scale (gimage,
|
|
|
|
image_scale->resize->width,
|
2001-11-17 01:08:41 +08:00
|
|
|
image_scale->resize->height,
|
2002-02-12 10:31:45 +08:00
|
|
|
image_scale->resize->interpolation,
|
2002-02-22 23:08:47 +08:00
|
|
|
gimp_progress_update_and_flush, progress);
|
2001-11-17 01:08:41 +08:00
|
|
|
|
2002-02-22 23:08:47 +08:00
|
|
|
gimp_progress_end (progress);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_message (_("Scale Error: Both width and height must be "
|
|
|
|
"greater than zero."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-04 00:42:46 +08:00
|
|
|
gimp_image_undo_group_end (gimage);
|
|
|
|
|
|
|
|
gimp_image_flush (gimage);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|