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>
|
|
|
|
|
2004-07-28 00:46:43 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-types.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2003-12-09 05:56:22 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
|
|
|
#include "core/core-enums.h"
|
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"
|
2004-04-20 21:44:19 +08:00
|
|
|
#include "core/gimpimage-convert.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
|
|
|
|
2004-05-25 20:02:54 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2004-02-01 04:23:53 +08:00
|
|
|
#include "widgets/gimpdock.h"
|
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
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "gui/convert-dialog.h"
|
2004-05-25 20:02:54 +08:00
|
|
|
#include "gui/dialogs.h"
|
|
|
|
#include "gui/file-new-dialog.h"
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "gui/grid-dialog.h"
|
|
|
|
#include "gui/resize-dialog.h"
|
|
|
|
|
2004-05-03 22:03:51 +08:00
|
|
|
#include "actions.h"
|
2002-02-13 22:41:35 +08:00
|
|
|
#include "image-commands.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
typedef struct _ImageResizeOptions ImageResizeOptions;
|
|
|
|
|
|
|
|
struct _ImageResizeOptions
|
2001-11-17 01:08:41 +08:00
|
|
|
{
|
2004-05-06 21:17:49 +08:00
|
|
|
ResizeDialog *dialog;
|
2004-05-25 22:37:02 +08:00
|
|
|
|
|
|
|
GimpContext *context;
|
2004-05-06 21:17:49 +08:00
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpImage *gimage;
|
2004-05-25 22:37:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _LayerMergeOptions LayerMergeOptions;
|
|
|
|
|
|
|
|
struct _LayerMergeOptions
|
|
|
|
{
|
|
|
|
GtkWidget *query_box;
|
|
|
|
|
|
|
|
GimpContext *context;
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpMergeType merge_type;
|
|
|
|
};
|
2001-11-17 01:08:41 +08:00
|
|
|
|
|
|
|
|
2004-05-03 22:46:29 +08:00
|
|
|
/* local function prototypes */
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
static void image_resize_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void image_scale_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void image_scale_warn (ImageResizeOptions *options,
|
|
|
|
const gchar *warning_title,
|
|
|
|
const gchar *warning_message);
|
|
|
|
static void image_scale_warn_callback (GtkWidget *widget,
|
|
|
|
gboolean do_scale,
|
|
|
|
gpointer data);
|
|
|
|
static void image_scale_implement (ImageResizeOptions *options);
|
|
|
|
static void image_merge_layers_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
LayerMergeOptions *options);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2004-05-25 20:02:54 +08:00
|
|
|
void
|
|
|
|
image_new_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
|
|
dialog = gimp_dialog_factory_dialog_new (global_dialog_factory,
|
|
|
|
gtk_widget_get_screen (widget),
|
|
|
|
"gimp-file-new-dialog", -1);
|
2004-06-01 16:41:28 +08:00
|
|
|
if (dialog)
|
|
|
|
file_new_dialog_set (dialog, NULL, NULL);
|
2004-05-25 20:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
image_new_from_image_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
|
|
dialog = gimp_dialog_factory_dialog_new (global_dialog_factory,
|
|
|
|
gtk_widget_get_screen (widget),
|
|
|
|
"gimp-file-new-dialog", -1);
|
|
|
|
|
|
|
|
if (dialog)
|
|
|
|
{
|
|
|
|
GimpImage *gimage = action_data_get_image (data);
|
|
|
|
|
|
|
|
if (gimage)
|
|
|
|
file_new_dialog_set (dialog, gimage, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2004-06-10 22:25:04 +08:00
|
|
|
image_convert_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2004-08-10 00:08:36 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GimpDisplay *gdisp;
|
2004-05-03 22:46:29 +08:00
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
return_if_no_widget (widget, data);
|
2004-08-10 00:08:36 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-06-10 22:25:04 +08:00
|
|
|
switch ((GimpImageBaseType) value)
|
|
|
|
{
|
|
|
|
case GIMP_RGB:
|
|
|
|
case GIMP_GRAY:
|
|
|
|
gimp_image_convert (gimage, (GimpImageBaseType) value,
|
2004-08-10 00:08:36 +08:00
|
|
|
0, 0, FALSE, FALSE, 0, NULL, NULL, NULL);
|
2004-06-10 22:25:04 +08:00
|
|
|
gimp_image_flush (gimage);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_INDEXED:
|
2004-08-10 00:08:36 +08:00
|
|
|
gtk_widget_show (convert_dialog_new (gimage, widget, gdisp));
|
2004-06-10 22:25:04 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
image_resize_cmd_callback (GtkAction *action,
|
2001-06-26 20:09:43 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
ImageResizeOptions *options;
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpImage *gimage;
|
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;
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
options = g_new0 (ImageResizeOptions, 1);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
options->context = action_data_get_context (data);
|
|
|
|
options->gdisp = gdisp;
|
|
|
|
options->gimage = gimage;
|
2002-09-08 00:47:39 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
options->dialog =
|
2004-05-06 21:17:49 +08:00
|
|
|
resize_dialog_new (GIMP_VIEWABLE (gimage), gdisp->shell,
|
|
|
|
RESIZE_DIALOG,
|
2002-09-08 00:47:39 +08:00
|
|
|
gimage->width,
|
|
|
|
gimage->height,
|
|
|
|
gimage->xresolution,
|
|
|
|
gimage->yresolution,
|
2004-06-02 06:04:20 +08:00
|
|
|
GIMP_DISPLAY_SHELL (gdisp->shell)->unit,
|
2002-09-08 00:47:39 +08:00
|
|
|
G_CALLBACK (image_resize_callback),
|
2004-05-25 22:37:02 +08:00
|
|
|
options);
|
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),
|
2004-05-25 22:37:02 +08:00
|
|
|
options->dialog->shell,
|
2002-09-08 20:18:23 +08:00
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (options->dialog->shell),
|
2001-08-15 00:33:28 +08:00
|
|
|
(GWeakNotify) g_free,
|
2004-05-25 22:37:02 +08:00
|
|
|
options);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gtk_widget_show (options->dialog->shell);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
image_scale_cmd_callback (GtkAction *action,
|
2001-06-26 20:09:43 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
ImageResizeOptions *options;
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpImage *gimage;
|
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;
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
options = g_new0 (ImageResizeOptions, 1);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
options->context = action_data_get_context (data);
|
|
|
|
options->gdisp = gdisp;
|
|
|
|
options->gimage = gimage;
|
2002-09-08 00:47:39 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
options->dialog =
|
2004-05-06 21:17:49 +08:00
|
|
|
resize_dialog_new (GIMP_VIEWABLE (gimage), gdisp->shell,
|
|
|
|
SCALE_DIALOG,
|
2002-09-08 00:47:39 +08:00
|
|
|
gimage->width,
|
|
|
|
gimage->height,
|
|
|
|
gimage->xresolution,
|
|
|
|
gimage->yresolution,
|
2004-06-02 06:04:20 +08:00
|
|
|
GIMP_DISPLAY_SHELL (gdisp->shell)->unit,
|
2002-09-08 00:47:39 +08:00
|
|
|
G_CALLBACK (image_scale_callback),
|
2004-05-25 22:37:02 +08:00
|
|
|
options);
|
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),
|
2004-05-25 22:37:02 +08:00
|
|
|
options->dialog->shell,
|
2002-09-08 20:18:23 +08:00
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (options->dialog->shell),
|
2001-08-15 00:33:28 +08:00
|
|
|
(GWeakNotify) g_free,
|
2004-05-25 22:37:02 +08:00
|
|
|
options);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gtk_widget_show (options->dialog->shell);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2003-05-19 02:48:36 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
image_flip_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2003-05-19 02:48:36 +08:00
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpProgress *progress;
|
|
|
|
return_if_no_display (gdisp, data);
|
|
|
|
|
|
|
|
progress = gimp_progress_start (gdisp, _("Flipping..."), TRUE, NULL, NULL);
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gimp_image_flip (gdisp->gimage, action_data_get_context (data),
|
2004-04-29 20:52:29 +08:00
|
|
|
(GimpOrientationType) value,
|
2003-05-19 02:48:36 +08:00
|
|
|
gimp_progress_update_and_flush, progress);
|
|
|
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
gimp_image_flush (gdisp->gimage);
|
|
|
|
}
|
|
|
|
|
2003-05-20 18:36:29 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
image_rotate_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2003-05-20 18:36:29 +08:00
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpProgress *progress;
|
|
|
|
return_if_no_display (gdisp, data);
|
|
|
|
|
|
|
|
progress = gimp_progress_start (gdisp, _("Rotating..."), TRUE, NULL, NULL);
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gimp_image_rotate (gdisp->gimage, action_data_get_context (data),
|
2004-04-29 20:52:29 +08:00
|
|
|
(GimpRotationType) value,
|
2003-05-20 18:36:29 +08:00
|
|
|
gimp_progress_update_and_flush, progress);
|
|
|
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
gimp_image_flush (gdisp->gimage);
|
|
|
|
}
|
|
|
|
|
2002-03-15 23:09:58 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
image_crop_cmd_callback (GtkAction *action,
|
2002-03-15 23:09:58 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2004-05-03 22:46:29 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
return_if_no_image (gimage, data);
|
2002-03-15 23:09:58 +08:00
|
|
|
|
2004-05-03 22:46:29 +08:00
|
|
|
if (! gimp_channel_bounds (gimp_image_get_mask (gimage),
|
2003-09-04 01:17:18 +08:00
|
|
|
&x1, &y1, &x2, &y2))
|
2002-03-15 23:09:58 +08:00
|
|
|
{
|
|
|
|
g_message (_("Cannot crop because the current selection is empty."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gimp_image_crop (gimage, action_data_get_context (data),
|
2004-04-15 07:37:34 +08:00
|
|
|
x1, y1, x2, y2, FALSE, TRUE);
|
2004-05-03 22:46:29 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-03-15 23:09:58 +08:00
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
image_duplicate_cmd_callback (GtkAction *action,
|
2001-06-26 20:09:43 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2004-06-02 06:04:20 +08:00
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpImage *new_gimage;
|
|
|
|
return_if_no_display (gdisp, data);
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
gimage = gdisp->gimage;
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
new_gimage = gimp_image_duplicate (gimage);
|
2004-06-02 06:04:20 +08:00
|
|
|
|
|
|
|
gimp_create_display (new_gimage->gimp,
|
|
|
|
new_gimage,
|
|
|
|
shell->unit, shell->scale);
|
|
|
|
|
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
|
2004-04-29 20:52:29 +08:00
|
|
|
image_merge_layers_cmd_callback (GtkAction *action,
|
2002-02-13 22:41:35 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
LayerMergeOptions *options;
|
|
|
|
GimpImage *gimage;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *frame;
|
2004-05-03 22:46:29 +08:00
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
return_if_no_widget (widget, data);
|
2002-02-13 22:41:35 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
options = g_new0 (LayerMergeOptions, 1);
|
|
|
|
|
|
|
|
options->context = action_data_get_context (data);
|
|
|
|
options->gimage = gimage;
|
|
|
|
options->merge_type = GIMP_EXPAND_AS_NECESSARY;
|
|
|
|
|
|
|
|
options->query_box =
|
|
|
|
gimp_viewable_dialog_new (GIMP_VIEWABLE (gimage),
|
|
|
|
_("Merge Layers"), "gimp-image-merge-layers",
|
|
|
|
GIMP_STOCK_MERGE_DOWN,
|
|
|
|
_("Layers Merge Options"),
|
|
|
|
widget,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_IMAGE_MERGE_LAYERS,
|
|
|
|
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
|
|
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_connect (options->query_box, "response",
|
|
|
|
G_CALLBACK (image_merge_layers_response),
|
|
|
|
options);
|
|
|
|
|
|
|
|
g_object_weak_ref (G_OBJECT (options->query_box),
|
|
|
|
(GWeakNotify) g_free,
|
|
|
|
options);
|
|
|
|
|
|
|
|
frame = gimp_int_radio_group_new (TRUE, _("Final, Merged Layer should be:"),
|
|
|
|
G_CALLBACK (gimp_radio_button_update),
|
|
|
|
&options->merge_type, options->merge_type,
|
|
|
|
|
|
|
|
_("Expanded as necessary"),
|
|
|
|
GIMP_EXPAND_AS_NECESSARY, NULL,
|
|
|
|
|
|
|
|
_("Clipped to image"),
|
|
|
|
GIMP_CLIP_TO_IMAGE, NULL,
|
|
|
|
|
|
|
|
_("Clipped to bottom layer"),
|
|
|
|
GIMP_CLIP_TO_BOTTOM_LAYER, NULL,
|
|
|
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (frame), 12);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
|
|
|
|
frame);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
gtk_widget_show (options->query_box);
|
2002-02-13 22:41:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
image_flatten_image_cmd_callback (GtkAction *action,
|
2002-02-13 22:41:35 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gimp_image_flatten (gimage, action_data_get_context (data));
|
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
|
2004-04-29 20:52:29 +08:00
|
|
|
image_configure_grid_cmd_callback (GtkAction *action,
|
2003-07-27 18:34:15 +08:00
|
|
|
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);
|
2004-04-29 20:52:29 +08:00
|
|
|
gimage = gdisp->gimage;
|
2003-07-27 18:34:15 +08:00
|
|
|
|
|
|
|
if (! shell->grid_dialog)
|
|
|
|
{
|
2004-04-29 20:52:29 +08:00
|
|
|
shell->grid_dialog = grid_dialog_new (gdisp->gimage, gdisp->shell);
|
2003-07-27 18:34:15 +08:00
|
|
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (shell->grid_dialog),
|
2004-04-29 20:52:29 +08:00
|
|
|
GTK_WINDOW (gdisp->shell));
|
2003-07-27 18:34:15 +08:00
|
|
|
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
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
image_resize_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
ImageResizeOptions *options = data;
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gtk_widget_set_sensitive (options->dialog->shell, FALSE);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
if (options->dialog->width > 0 &&
|
|
|
|
options->dialog->height > 0)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2003-06-04 00:42:46 +08:00
|
|
|
GimpProgress *progress;
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
progress = gimp_progress_start (options->gdisp,
|
2003-06-04 00:42:46 +08:00
|
|
|
_("Resizing..."),
|
|
|
|
TRUE, NULL, NULL);
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gimp_image_resize (options->gimage,
|
|
|
|
options->context,
|
|
|
|
options->dialog->width,
|
|
|
|
options->dialog->height,
|
|
|
|
options->dialog->offset_x,
|
|
|
|
options->dialog->offset_y,
|
2003-06-04 00:42:46 +08:00
|
|
|
gimp_progress_update_and_flush, progress);
|
|
|
|
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gimp_image_flush (options->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."));
|
|
|
|
}
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gtk_widget_destroy (options->dialog->shell);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
image_scale_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
ImageResizeOptions *options = data;
|
2003-12-09 20:56:22 +08:00
|
|
|
GimpImageScaleCheckType scale_check;
|
2004-07-14 18:31:59 +08:00
|
|
|
gint64 max_memsize;
|
2003-12-09 20:56:22 +08:00
|
|
|
gint64 new_memsize;
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gtk_widget_set_sensitive (options->dialog->shell, FALSE);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-07-14 18:31:59 +08:00
|
|
|
max_memsize =
|
|
|
|
GIMP_GUI_CONFIG (options->gimage->gimp->config)->max_new_image_size;
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
scale_check = gimp_image_scale_check (options->gimage,
|
|
|
|
options->dialog->width,
|
|
|
|
options->dialog->height,
|
2004-07-14 18:31:59 +08:00
|
|
|
max_memsize,
|
2003-12-09 20:56:22 +08:00
|
|
|
&new_memsize);
|
2003-12-09 05:56:22 +08:00
|
|
|
switch (scale_check)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2003-12-09 19:49:47 +08:00
|
|
|
case GIMP_IMAGE_SCALE_TOO_BIG:
|
|
|
|
{
|
|
|
|
gchar *size_str;
|
|
|
|
gchar *max_size_str;
|
2004-05-25 22:37:02 +08:00
|
|
|
gchar *warning_message;
|
2003-12-09 19:49:47 +08:00
|
|
|
|
2003-12-09 20:56:22 +08:00
|
|
|
size_str = gimp_memsize_to_string (new_memsize);
|
2004-07-14 18:31:59 +08:00
|
|
|
max_size_str = gimp_memsize_to_string (max_memsize);
|
2003-12-09 19:49:47 +08:00
|
|
|
|
|
|
|
warning_message = g_strdup_printf
|
2003-12-09 20:56:22 +08:00
|
|
|
(_("You are trying to create an image with a size of %s.\n\n"
|
2003-12-09 19:49:47 +08:00
|
|
|
"Choose OK to create this image anyway.\n"
|
2003-12-09 20:56:22 +08:00
|
|
|
"Choose Cancel if you did not intend to create such a "
|
|
|
|
"large image.\n\n"
|
|
|
|
"To prevent this dialog from appearing, increase the "
|
|
|
|
"\"Maximum Image Size\" setting (currently %s) in the "
|
2003-12-09 19:49:47 +08:00
|
|
|
"Preferences dialog."),
|
|
|
|
size_str, max_size_str);
|
|
|
|
|
2003-12-09 20:56:22 +08:00
|
|
|
g_free (size_str);
|
|
|
|
g_free (max_size_str);
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
image_scale_warn (options, _("Image exceeds maximum image size"),
|
2003-12-09 05:56:22 +08:00
|
|
|
warning_message);
|
2003-12-09 20:56:22 +08:00
|
|
|
|
|
|
|
g_free (warning_message);
|
2003-12-09 19:49:47 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_IMAGE_SCALE_TOO_SMALL:
|
2004-05-25 22:37:02 +08:00
|
|
|
image_scale_warn (options, _("Layer Too Small"),
|
|
|
|
_("The chosen image size will shrink some layers "
|
|
|
|
"completely away. Is this what you want?"));
|
2003-12-09 19:49:47 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_IMAGE_SCALE_OK:
|
|
|
|
/* If all is well, return directly after scaling image. */
|
2004-05-25 22:37:02 +08:00
|
|
|
image_scale_implement (options);
|
|
|
|
gtk_widget_destroy (options->dialog->shell);
|
2003-12-09 19:49:47 +08:00
|
|
|
break;
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
2003-12-09 19:49:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-05-25 22:37:02 +08:00
|
|
|
image_scale_warn (ImageResizeOptions *options,
|
|
|
|
const gchar *warning_title,
|
|
|
|
const gchar *warning_message)
|
2003-12-09 19:49:47 +08:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
dialog = gimp_query_boolean_box (warning_title,
|
2004-05-25 22:37:02 +08:00
|
|
|
options->dialog->shell,
|
2003-12-09 19:49:47 +08:00
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_IMAGE_SCALE_WARNING,
|
|
|
|
GTK_STOCK_DIALOG_QUESTION,
|
|
|
|
warning_message,
|
|
|
|
GTK_STOCK_OK, GTK_STOCK_CANCEL,
|
2004-05-25 22:37:02 +08:00
|
|
|
G_OBJECT (options->dialog->shell),
|
2003-12-09 19:49:47 +08:00
|
|
|
"destroy",
|
|
|
|
image_scale_warn_callback,
|
2004-05-25 22:37:02 +08:00
|
|
|
options);
|
2003-12-09 19:49:47 +08:00
|
|
|
gtk_widget_show (dialog);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
image_scale_warn_callback (GtkWidget *widget,
|
|
|
|
gboolean do_scale,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
ImageResizeOptions *options = data;
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
if (do_scale)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
image_scale_implement (options);
|
|
|
|
gtk_widget_destroy (options->dialog->shell);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
gtk_widget_set_sensitive (options->dialog->shell, TRUE);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-05-25 22:37:02 +08:00
|
|
|
image_scale_implement (ImageResizeOptions *options)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpImage *gimage = options->gimage;
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
if (options->dialog->resolution_x == gimage->xresolution &&
|
|
|
|
options->dialog->resolution_y == gimage->yresolution &&
|
|
|
|
options->dialog->unit == gimage->unit &&
|
|
|
|
options->dialog->width == gimage->width &&
|
|
|
|
options->dialog->height == gimage->height)
|
2003-06-04 00:42:46 +08:00
|
|
|
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,
|
2004-05-25 22:37:02 +08:00
|
|
|
options->dialog->resolution_x,
|
|
|
|
options->dialog->resolution_y);
|
|
|
|
gimp_image_set_unit (gimage, options->dialog->unit);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
if (options->dialog->width != gimage->width ||
|
|
|
|
options->dialog->height != gimage->height)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2004-05-25 22:37:02 +08:00
|
|
|
if (options->dialog->width > 0 &&
|
|
|
|
options->dialog->height > 0)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-11-17 01:08:41 +08:00
|
|
|
GimpProgress *progress;
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
progress = gimp_progress_start (options->gdisp,
|
2002-02-22 23:08:47 +08:00
|
|
|
_("Scaling..."),
|
|
|
|
TRUE, NULL, NULL);
|
2001-11-17 01:08:41 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
gimp_image_scale (gimage,
|
2004-05-25 22:37:02 +08:00
|
|
|
options->dialog->width,
|
|
|
|
options->dialog->height,
|
|
|
|
options->dialog->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
|
|
|
}
|
2004-05-25 22:37:02 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
image_merge_layers_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
LayerMergeOptions *options)
|
|
|
|
{
|
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
{
|
|
|
|
gimp_image_merge_visible_layers (options->gimage,
|
|
|
|
options->context,
|
|
|
|
options->merge_type);
|
|
|
|
gimp_image_flush (options->gimage);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (options->query_box);
|
|
|
|
}
|