2001-04-21 00:27:44 +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"
|
|
|
|
|
2003-09-01 02:10:15 +08:00
|
|
|
#include <string.h>
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-04-21 00:27:44 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gui-types.h"
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2003-10-06 20:17:11 +08:00
|
|
|
#include "core/gimpchannel-select.h"
|
2001-12-04 01:59:48 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.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-merge.h"
|
2003-02-13 19:23:50 +08:00
|
|
|
#include "core/gimpimage-undo.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimplayer.h"
|
2002-02-22 06:19:45 +08:00
|
|
|
#include "core/gimplayer-floating-sel.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimplayermask.h"
|
|
|
|
#include "core/gimplist.h"
|
|
|
|
|
2001-12-04 01:59:48 +08:00
|
|
|
#include "pdb/procedural_db.h"
|
|
|
|
|
2002-05-13 23:35:27 +08:00
|
|
|
#include "widgets/gimpenummenu.h"
|
2003-08-21 23:54:47 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2003-03-16 19:14:29 +08:00
|
|
|
#include "widgets/gimpitemtreeview.h"
|
2002-08-31 05:00:42 +08:00
|
|
|
#include "widgets/gimpviewabledialog.h"
|
2001-05-26 00:04:54 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
#include "layers-commands.h"
|
2003-09-01 02:10:15 +08:00
|
|
|
#include "image-commands.h"
|
2001-06-05 07:27:38 +08:00
|
|
|
#include "resize-dialog.h"
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2001-04-29 23:23:01 +08:00
|
|
|
static void layers_add_mask_query (GimpLayer *layer);
|
|
|
|
static void layers_scale_layer_query (GimpImage *gimage,
|
|
|
|
GimpLayer *layer);
|
|
|
|
static void layers_resize_layer_query (GimpImage *gimage,
|
|
|
|
GimpLayer *layer);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
#define return_if_no_image(gimage,data) \
|
2003-01-12 20:35:00 +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))); \
|
2003-03-16 19:14:29 +08:00
|
|
|
else if (GIMP_IS_ITEM_TREE_VIEW (data)) \
|
|
|
|
gimage = ((GimpItemTreeView *) data)->gimage; \
|
2003-01-12 20:35:00 +08:00
|
|
|
else \
|
|
|
|
gimage = NULL; \
|
2001-12-04 01:59:48 +08:00
|
|
|
if (! gimage) \
|
|
|
|
return
|
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
#define return_if_no_layer(gimage,layer,data) \
|
|
|
|
return_if_no_image (gimage,data); \
|
2002-02-27 00:30:14 +08:00
|
|
|
layer = gimp_image_get_active_layer (gimage); \
|
|
|
|
if (! layer) \
|
|
|
|
return
|
|
|
|
|
2001-12-04 01:59:48 +08:00
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
/* public functions */
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
void
|
2003-06-06 18:30:14 +08:00
|
|
|
layers_select_previous_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *new_layer;
|
|
|
|
gint current_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_image (gimage, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
current_layer =
|
|
|
|
gimp_image_get_layer_index (gimage, gimp_image_get_active_layer (gimage));
|
|
|
|
|
|
|
|
if (current_layer > 0)
|
|
|
|
{
|
|
|
|
new_layer = (GimpLayer *)
|
|
|
|
gimp_container_get_child_by_index (gimage->layers, current_layer - 1);
|
|
|
|
|
|
|
|
if (new_layer)
|
|
|
|
{
|
|
|
|
gimp_image_set_active_layer (gimage, new_layer);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-06-06 18:30:14 +08:00
|
|
|
layers_select_next_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *new_layer;
|
|
|
|
gint current_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_image (gimage, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
current_layer =
|
|
|
|
gimp_image_get_layer_index (gimage, gimp_image_get_active_layer (gimage));
|
|
|
|
|
2003-09-01 02:10:15 +08:00
|
|
|
new_layer =
|
|
|
|
GIMP_LAYER (gimp_container_get_child_by_index (gimage->layers,
|
2001-04-21 00:27:44 +08:00
|
|
|
current_layer + 1));
|
|
|
|
|
|
|
|
if (new_layer)
|
|
|
|
{
|
|
|
|
gimp_image_set_active_layer (gimage, new_layer);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-06 18:30:14 +08:00
|
|
|
void
|
|
|
|
layers_select_top_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *new_layer;
|
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
|
|
|
|
new_layer = (GimpLayer *)
|
|
|
|
gimp_container_get_child_by_index (gimage->layers, 0);
|
|
|
|
|
|
|
|
if (new_layer)
|
|
|
|
{
|
|
|
|
gimp_image_set_active_layer (gimage, new_layer);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
layers_select_bottom_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *new_layer;
|
|
|
|
gint num_layers;
|
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
|
|
|
|
num_layers = gimp_container_num_children (gimage->layers);
|
|
|
|
|
|
|
|
if (num_layers > 0)
|
|
|
|
{
|
|
|
|
new_layer = (GimpLayer *)
|
|
|
|
gimp_container_get_child_by_index (gimage->layers, num_layers - 1);
|
|
|
|
|
|
|
|
if (new_layer)
|
|
|
|
{
|
|
|
|
gimp_image_set_active_layer (gimage, new_layer);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
void
|
|
|
|
layers_raise_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
gimp_image_raise_layer (gimage, active_layer);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
layers_lower_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
gimp_image_lower_layer (gimage, active_layer);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
layers_raise_to_top_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
gimp_image_raise_layer_to_top (gimage, active_layer);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
layers_lower_to_bottom_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
gimp_image_lower_layer_to_bottom (gimage, active_layer);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
layers_new_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_image (gimage, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-09-02 22:39:08 +08:00
|
|
|
layers_new_layer_query (gimage, NULL, TRUE);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
layers_duplicate_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *active_layer;
|
|
|
|
GimpLayer *new_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
new_layer =
|
|
|
|
GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (active_layer),
|
|
|
|
G_TYPE_FROM_INSTANCE (active_layer),
|
|
|
|
TRUE));
|
2001-04-21 00:27:44 +08:00
|
|
|
gimp_image_add_layer (gimage, new_layer, -1);
|
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-12-04 01:59:48 +08:00
|
|
|
layers_anchor_cmd_callback (GtkWidget *widget,
|
2001-04-21 00:27:44 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
if (gimp_layer_is_floating_sel (active_layer))
|
|
|
|
{
|
|
|
|
floating_sel_anchor (active_layer);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
2001-12-04 01:59:48 +08:00
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-13 22:41:35 +08:00
|
|
|
void
|
|
|
|
layers_merge_down_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2002-02-13 22:41:35 +08:00
|
|
|
|
2002-03-19 01:24:52 +08:00
|
|
|
gimp_image_merge_down (gimage, active_layer, GIMP_EXPAND_AS_NECESSARY);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-13 22:41:35 +08:00
|
|
|
}
|
|
|
|
|
2001-12-04 01:59:48 +08:00
|
|
|
void
|
|
|
|
layers_delete_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
if (gimp_layer_is_floating_sel (active_layer))
|
|
|
|
floating_sel_remove (active_layer);
|
2001-04-21 00:27:44 +08:00
|
|
|
else
|
2002-02-27 00:30:14 +08:00
|
|
|
gimp_image_remove_layer (gimage, active_layer);
|
2001-12-04 01:59:48 +08:00
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-12-04 01:59:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-04-12 20:29:51 +08:00
|
|
|
layers_resize_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-12-04 01:59:48 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-04-12 20:29:51 +08:00
|
|
|
layers_resize_layer_query (gimage, active_layer);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-04-12 20:29:51 +08:00
|
|
|
layers_resize_to_image_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2003-09-01 02:10:15 +08:00
|
|
|
|
2002-04-12 20:29:51 +08:00
|
|
|
gimp_layer_resize_to_image (active_layer);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-04-12 20:29:51 +08:00
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-04-12 20:29:51 +08:00
|
|
|
void
|
|
|
|
layers_scale_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2002-04-12 20:29:51 +08:00
|
|
|
|
|
|
|
layers_scale_layer_query (gimage, active_layer);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-04-12 20:29:51 +08:00
|
|
|
layers_crop_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-04-12 20:29:51 +08:00
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
gint off_x, off_y;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2002-04-12 20:29:51 +08:00
|
|
|
|
2003-09-04 01:17:18 +08:00
|
|
|
if (! gimp_channel_bounds (gimp_image_get_mask (gimage),
|
|
|
|
&x1, &y1, &x2, &y2))
|
2002-04-12 20:29:51 +08:00
|
|
|
{
|
|
|
|
g_message (_("Cannot crop because the current selection is empty."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (active_layer), &off_x, &off_y);
|
2002-04-12 20:29:51 +08:00
|
|
|
|
|
|
|
off_x -= x1;
|
|
|
|
off_y -= y1;
|
|
|
|
|
2003-02-13 19:23:50 +08:00
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_LAYER_RESIZE,
|
|
|
|
_("Crop Layer"));
|
2002-04-12 20:29:51 +08:00
|
|
|
|
|
|
|
if (gimp_layer_is_floating_sel (active_layer))
|
|
|
|
floating_sel_relax (active_layer, TRUE);
|
|
|
|
|
2003-05-07 21:01:17 +08:00
|
|
|
gimp_item_resize (GIMP_ITEM (active_layer), x2 - x1, y2 - y1, off_x, off_y);
|
2002-04-12 20:29:51 +08:00
|
|
|
|
|
|
|
if (gimp_layer_is_floating_sel (active_layer))
|
|
|
|
floating_sel_rigor (active_layer, TRUE);
|
|
|
|
|
2003-02-13 19:23:50 +08:00
|
|
|
gimp_image_undo_group_end (gimage);
|
2002-04-12 20:29:51 +08:00
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
layers_mask_add_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
layers_add_mask_query (active_layer);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
layers_mask_apply_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
if (gimp_layer_get_mask (active_layer))
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2002-03-18 19:07:34 +08:00
|
|
|
gimp_layer_apply_mask (active_layer, GIMP_MASK_APPLY, TRUE);
|
2003-03-23 04:30:30 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
layers_mask_delete_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
if (gimp_layer_get_mask (active_layer))
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2002-03-18 19:07:34 +08:00
|
|
|
gimp_layer_apply_mask (active_layer, GIMP_MASK_DISCARD, TRUE);
|
2003-03-23 04:30:30 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-27 08:52:00 +08:00
|
|
|
void
|
|
|
|
layers_mask_to_selection_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
guint action)
|
|
|
|
{
|
|
|
|
GimpChannelOps op;
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *active_layer;
|
|
|
|
GimpLayerMask *mask;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2003-08-27 08:52:00 +08:00
|
|
|
op = (GimpChannelOps) action;
|
|
|
|
|
2003-08-21 23:54:47 +08:00
|
|
|
mask = gimp_layer_get_mask (active_layer);
|
|
|
|
|
|
|
|
if (mask)
|
2002-02-27 00:30:14 +08:00
|
|
|
{
|
2003-08-21 23:54:47 +08:00
|
|
|
gint off_x, off_y;
|
|
|
|
|
|
|
|
gimp_item_offsets (GIMP_ITEM (mask), &off_x, &off_y);
|
|
|
|
|
2003-10-06 20:17:11 +08:00
|
|
|
gimp_channel_select_channel (gimp_image_get_mask (gimage),
|
|
|
|
_("Layer Mask to Selection"),
|
|
|
|
GIMP_CHANNEL (mask),
|
|
|
|
off_x, off_y,
|
|
|
|
op, FALSE, 0.0, 0.0);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-27 00:30:14 +08:00
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
2003-08-21 23:54:47 +08:00
|
|
|
void
|
|
|
|
layers_alpha_add_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (active_layer)))
|
|
|
|
{
|
|
|
|
gimp_layer_add_alpha (active_layer);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-27 00:30:14 +08:00
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
2003-08-27 08:52:00 +08:00
|
|
|
void
|
|
|
|
layers_alpha_to_selection_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
guint action)
|
2003-08-21 23:54:47 +08:00
|
|
|
{
|
2003-08-27 08:52:00 +08:00
|
|
|
GimpChannelOps op;
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *active_layer;
|
2003-08-21 23:54:47 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
|
|
|
|
2003-08-27 08:52:00 +08:00
|
|
|
op = (GimpChannelOps) action;
|
|
|
|
|
2003-08-21 23:54:47 +08:00
|
|
|
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (active_layer)))
|
|
|
|
{
|
2003-10-06 20:17:11 +08:00
|
|
|
gimp_channel_select_alpha (gimp_image_get_mask (gimage), active_layer,
|
|
|
|
op, FALSE, 0.0, 0.0);
|
2003-08-21 23:54:47 +08:00
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-01 02:10:15 +08:00
|
|
|
void
|
|
|
|
layers_merge_layers_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
|
|
|
|
image_layers_merge_query (gimage, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
layers_flatten_image_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
|
|
|
|
gimp_image_flatten (gimage);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
void
|
|
|
|
layers_edit_attributes_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpLayer *active_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_layer (gimage, active_layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
layers_edit_layer_query (active_layer);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/* The new layer query dialog */
|
|
|
|
/********************************/
|
|
|
|
|
|
|
|
typedef struct _NewLayerOptions NewLayerOptions;
|
|
|
|
|
|
|
|
struct _NewLayerOptions
|
|
|
|
{
|
|
|
|
GtkWidget *query_box;
|
|
|
|
GtkWidget *name_entry;
|
|
|
|
GtkWidget *size_se;
|
|
|
|
|
|
|
|
GimpFillType fill_type;
|
|
|
|
gint xsize;
|
|
|
|
gint ysize;
|
|
|
|
|
|
|
|
GimpImage *gimage;
|
|
|
|
};
|
|
|
|
|
2002-03-18 19:07:34 +08:00
|
|
|
static GimpFillType fill_type = GIMP_TRANSPARENT_FILL;
|
2001-04-21 00:27:44 +08:00
|
|
|
static gchar *layer_name = NULL;
|
|
|
|
|
|
|
|
static void
|
|
|
|
new_layer_query_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
NewLayerOptions *options;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GimpImage *gimage;
|
|
|
|
|
|
|
|
options = (NewLayerOptions *) data;
|
|
|
|
|
|
|
|
if (layer_name)
|
|
|
|
g_free (layer_name);
|
|
|
|
layer_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
|
|
|
|
|
2003-09-01 02:10:15 +08:00
|
|
|
options->xsize =
|
2001-04-21 00:27:44 +08:00
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 0));
|
|
|
|
options->ysize =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (options->size_se), 1));
|
|
|
|
|
|
|
|
fill_type = options->fill_type;
|
|
|
|
|
|
|
|
if ((gimage = options->gimage))
|
|
|
|
{
|
2002-03-04 22:52:54 +08:00
|
|
|
layer = gimp_layer_new (gimage,
|
|
|
|
options->xsize,
|
|
|
|
options->ysize,
|
2001-04-21 00:27:44 +08:00
|
|
|
gimp_image_base_type_with_alpha (gimage),
|
2002-03-04 22:52:54 +08:00
|
|
|
layer_name,
|
|
|
|
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
|
2003-09-01 02:10:15 +08:00
|
|
|
if (layer)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer),
|
|
|
|
gimp_get_user_context (gimage->gimp),
|
|
|
|
fill_type);
|
2001-04-21 00:27:44 +08:00
|
|
|
gimp_image_add_layer (gimage, layer, -1);
|
2003-09-01 02:10:15 +08:00
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2003-09-01 02:10:15 +08:00
|
|
|
}
|
|
|
|
else
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
g_message ("new_layer_query_ok_callback():\n"
|
|
|
|
"could not allocate new layer");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (options->query_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-12-17 21:41:23 +08:00
|
|
|
layers_new_layer_query (GimpImage *gimage,
|
2002-09-02 22:39:08 +08:00
|
|
|
GimpLayer *template,
|
|
|
|
gboolean interactive)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
NewLayerOptions *options;
|
2001-11-16 05:31:07 +08:00
|
|
|
GimpLayer *floating_sel;
|
2001-04-21 00:27:44 +08:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkObject *adjustment;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkWidget *frame;
|
2002-05-13 23:35:27 +08:00
|
|
|
GtkWidget *button;
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2001-11-16 05:31:07 +08:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
2003-05-08 22:06:03 +08:00
|
|
|
g_return_if_fail (template == NULL || GIMP_IS_LAYER (template));
|
2001-11-16 05:31:07 +08:00
|
|
|
|
|
|
|
/* If there is a floating selection, the new command transforms
|
|
|
|
* the current fs into a new layer
|
|
|
|
*/
|
|
|
|
if ((floating_sel = gimp_image_floating_sel (gimage)))
|
|
|
|
{
|
|
|
|
floating_sel_to_layer (floating_sel);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-11-16 05:31:07 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-09-02 22:39:08 +08:00
|
|
|
if (template || ! interactive)
|
2001-12-17 21:41:23 +08:00
|
|
|
{
|
2002-09-02 22:39:08 +08:00
|
|
|
GimpLayer *new_layer;
|
|
|
|
gint width, height;
|
|
|
|
gint off_x, off_y;
|
|
|
|
gdouble opacity;
|
|
|
|
GimpLayerModeEffects mode;
|
|
|
|
|
|
|
|
if (template)
|
|
|
|
{
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (template), &off_x, &off_y);
|
|
|
|
width = gimp_item_width (GIMP_ITEM (template));
|
|
|
|
height = gimp_item_height (GIMP_ITEM (template));
|
2002-09-02 22:39:08 +08:00
|
|
|
opacity = template->opacity;
|
|
|
|
mode = template->mode;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
width = gimp_image_get_width (gimage);
|
|
|
|
height = gimp_image_get_height (gimage);
|
|
|
|
off_x = 0;
|
|
|
|
off_y = 0;
|
|
|
|
opacity = 1.0;
|
|
|
|
mode = GIMP_NORMAL_MODE;
|
|
|
|
}
|
2001-12-17 21:41:23 +08:00
|
|
|
|
2003-02-13 19:23:50 +08:00
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_EDIT_PASTE,
|
|
|
|
_("New Layer"));
|
2001-12-17 21:41:23 +08:00
|
|
|
|
2002-03-04 22:52:54 +08:00
|
|
|
new_layer = gimp_layer_new (gimage,
|
|
|
|
width,
|
|
|
|
height,
|
2001-12-17 21:41:23 +08:00
|
|
|
gimp_image_base_type_with_alpha (gimage),
|
|
|
|
_("Empty Layer Copy"),
|
2002-09-02 22:39:08 +08:00
|
|
|
opacity,
|
|
|
|
mode);
|
|
|
|
|
|
|
|
if (template)
|
|
|
|
{
|
|
|
|
gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_layer),
|
|
|
|
gimp_get_user_context (gimage->gimp),
|
|
|
|
GIMP_TRANSPARENT_FILL);
|
2003-05-09 03:11:17 +08:00
|
|
|
gimp_item_translate (GIMP_ITEM (new_layer), off_x, off_y, FALSE);
|
2002-09-02 22:39:08 +08:00
|
|
|
}
|
2001-12-17 21:41:23 +08:00
|
|
|
|
|
|
|
gimp_image_add_layer (gimage, new_layer, -1);
|
|
|
|
|
2003-02-13 19:23:50 +08:00
|
|
|
gimp_image_undo_group_end (gimage);
|
2001-12-17 21:41:23 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-29 23:23:01 +08:00
|
|
|
options = g_new0 (NewLayerOptions, 1);
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
options->fill_type = fill_type;
|
|
|
|
options->gimage = gimage;
|
|
|
|
|
|
|
|
/* The dialog */
|
|
|
|
options->query_box =
|
2002-08-31 05:00:42 +08:00
|
|
|
gimp_viewable_dialog_new (GIMP_VIEWABLE (gimage),
|
|
|
|
_("New Layer"), "new_layer_options",
|
2003-03-27 22:25:18 +08:00
|
|
|
GIMP_STOCK_LAYER,
|
2002-09-01 15:25:41 +08:00
|
|
|
_("Create a New Layer"),
|
2002-08-31 05:00:42 +08:00
|
|
|
gimp_standard_help_func,
|
2003-08-21 23:54:47 +08:00
|
|
|
GIMP_HELP_LAYER_NEW,
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-08-31 05:00:42 +08:00
|
|
|
GTK_STOCK_CANCEL, gtk_widget_destroy,
|
|
|
|
NULL, 1, NULL, FALSE, TRUE,
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-08-31 05:00:42 +08:00
|
|
|
GTK_STOCK_OK, new_layer_query_ok_callback,
|
|
|
|
options, NULL, NULL, TRUE, FALSE,
|
2001-11-24 07:04:49 +08:00
|
|
|
|
2002-08-31 05:00:42 +08:00
|
|
|
NULL);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2001-08-12 05:10:44 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (options->query_box),
|
|
|
|
(GWeakNotify) g_free,
|
|
|
|
options);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
/* The main vbox */
|
2002-09-08 00:47:39 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 4);
|
2001-04-21 00:27:44 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
|
|
|
|
vbox);
|
|
|
|
|
|
|
|
table = gtk_table_new (3, 2, FALSE);
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* The name label and entry */
|
|
|
|
options->name_entry = gtk_entry_new ();
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
|
|
|
|
(layer_name ? layer_name : _("New Layer")));
|
2002-09-08 00:47:39 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
|
|
|
_("Layer _Name:"), 1.0, 0.5,
|
|
|
|
options->name_entry, 1, FALSE);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
/* The size labels */
|
|
|
|
label = gtk_label_new (_("Layer Width:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Height:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* The size sizeentry */
|
2002-09-08 00:47:39 +08:00
|
|
|
spinbutton = gimp_spin_button_new (&adjustment,
|
|
|
|
1, 1, 1, 1, 10, 1,
|
|
|
|
1, 2);
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10);
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
options->size_se = gimp_size_entry_new (1, gimage->unit, "%a",
|
2002-09-08 00:47:39 +08:00
|
|
|
TRUE, TRUE, FALSE, 10,
|
2001-04-21 00:27:44 +08:00
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
2002-09-08 00:47:39 +08:00
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (options->size_se), 1, 4);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (options->size_se), 0, 2);
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (options->size_se),
|
|
|
|
GTK_SPIN_BUTTON (spinbutton), NULL);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (options->size_se), spinbutton,
|
|
|
|
1, 2, 0, 1);
|
|
|
|
gtk_widget_show (spinbutton);
|
2002-09-08 00:47:39 +08:00
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), options->size_se, 1, 2, 1, 3,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (options->size_se);
|
|
|
|
|
2003-09-01 02:10:15 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (options->size_se),
|
2001-04-21 00:27:44 +08:00
|
|
|
GIMP_UNIT_PIXEL);
|
|
|
|
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 0,
|
|
|
|
gimage->xresolution, FALSE);
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_se), 1,
|
|
|
|
gimage->yresolution, FALSE);
|
|
|
|
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (options->size_se), 0,
|
|
|
|
GIMP_MIN_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE);
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (options->size_se), 1,
|
|
|
|
GIMP_MIN_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE);
|
|
|
|
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options->size_se), 0,
|
|
|
|
0, gimage->width);
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (options->size_se), 1,
|
|
|
|
0, gimage->height);
|
|
|
|
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (options->size_se), 0,
|
|
|
|
gimage->width);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (options->size_se), 1,
|
|
|
|
gimage->height);
|
|
|
|
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
/* The radio frame */
|
2002-05-14 01:15:17 +08:00
|
|
|
frame = gimp_enum_radio_frame_new_with_range (GIMP_TYPE_FILL_TYPE,
|
|
|
|
GIMP_FOREGROUND_FILL,
|
|
|
|
GIMP_TRANSPARENT_FILL,
|
|
|
|
gtk_label_new (_("Layer Fill Type")),
|
|
|
|
2,
|
|
|
|
G_CALLBACK (gimp_radio_button_update),
|
|
|
|
&options->fill_type,
|
|
|
|
&button);
|
2002-05-13 23:35:27 +08:00
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (button),
|
2003-09-01 02:10:15 +08:00
|
|
|
GINT_TO_POINTER (options->fill_type));
|
2001-04-21 00:27:44 +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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************/
|
|
|
|
/* The edit layer attributes dialog */
|
|
|
|
/**************************************/
|
|
|
|
|
|
|
|
typedef struct _EditLayerOptions EditLayerOptions;
|
|
|
|
|
|
|
|
struct _EditLayerOptions
|
|
|
|
{
|
|
|
|
GtkWidget *query_box;
|
|
|
|
GtkWidget *name_entry;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GimpImage *gimage;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
edit_layer_query_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
EditLayerOptions *options;
|
|
|
|
GimpLayer *layer;
|
|
|
|
|
|
|
|
options = (EditLayerOptions *) data;
|
2003-03-17 10:25:39 +08:00
|
|
|
layer = options->layer;
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2003-03-17 10:25:39 +08:00
|
|
|
if (options->gimage)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2002-02-26 08:04:55 +08:00
|
|
|
const gchar *new_name;
|
|
|
|
|
|
|
|
new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry));
|
|
|
|
|
|
|
|
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (layer))))
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2003-03-17 10:25:39 +08:00
|
|
|
gimp_item_rename (GIMP_ITEM (layer), new_name);
|
|
|
|
gimp_image_flush (options->gimage);
|
2002-02-26 08:04:55 +08:00
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
2003-09-01 02:10:15 +08:00
|
|
|
gtk_widget_destroy (options->query_box);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
layers_edit_layer_query (GimpLayer *layer)
|
|
|
|
{
|
|
|
|
EditLayerOptions *options;
|
|
|
|
GtkWidget *vbox;
|
2002-09-08 00:47:39 +08:00
|
|
|
GtkWidget *table;
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
options = g_new0 (EditLayerOptions, 1);
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
options->layer = layer;
|
2002-02-26 01:58:50 +08:00
|
|
|
options->gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
/* The dialog */
|
|
|
|
options->query_box =
|
2002-08-31 05:00:42 +08:00
|
|
|
gimp_viewable_dialog_new (GIMP_VIEWABLE (layer),
|
|
|
|
_("Layer Attributes"),
|
|
|
|
"edit_layer_attributes",
|
|
|
|
GIMP_STOCK_EDIT,
|
|
|
|
_("Edit Layer Attributes"),
|
|
|
|
gimp_standard_help_func,
|
2003-08-21 23:54:47 +08:00
|
|
|
GIMP_HELP_LAYER_EDIT,
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-08-31 05:00:42 +08:00
|
|
|
GTK_STOCK_CANCEL, gtk_widget_destroy,
|
|
|
|
NULL, 1, NULL, FALSE, TRUE,
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-08-31 05:00:42 +08:00
|
|
|
GTK_STOCK_OK, edit_layer_query_ok_callback,
|
|
|
|
options, NULL, NULL, TRUE, FALSE,
|
2001-11-24 07:04:49 +08:00
|
|
|
|
2002-08-31 05:00:42 +08:00
|
|
|
NULL);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2001-08-12 05:10:44 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (options->query_box),
|
|
|
|
(GWeakNotify) g_free,
|
|
|
|
options);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
/* The main vbox */
|
2002-09-08 00:47:39 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 4);
|
2001-04-21 00:27:44 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
|
|
|
|
vbox);
|
|
|
|
|
2002-09-08 00:47:39 +08:00
|
|
|
/* The name label and entry */
|
|
|
|
table = gtk_table_new (1, 2, FALSE);
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
options->name_entry = gtk_entry_new ();
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
|
|
|
|
((gimp_layer_is_floating_sel (layer) ?
|
|
|
|
_("Floating Selection") :
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (layer)))));
|
2002-09-08 00:47:39 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
|
|
|
_("Layer _Name"), 1.0, 0.5,
|
|
|
|
options->name_entry, 1, FALSE);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (options->name_entry, "activate",
|
2001-07-25 08:42:47 +08:00
|
|
|
G_CALLBACK (edit_layer_query_ok_callback),
|
|
|
|
options);
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (options->query_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************/
|
|
|
|
/* The add mask query dialog */
|
|
|
|
/*******************************/
|
|
|
|
|
|
|
|
typedef struct _AddMaskOptions AddMaskOptions;
|
|
|
|
|
|
|
|
struct _AddMaskOptions
|
|
|
|
{
|
2002-03-18 19:07:34 +08:00
|
|
|
GtkWidget *query_box;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GimpAddMaskType add_mask_type;
|
2003-03-06 21:22:11 +08:00
|
|
|
gboolean invert;
|
2001-04-21 00:27:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_mask_query_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
AddMaskOptions *options;
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayerMask *mask;
|
|
|
|
GimpLayer *layer;
|
|
|
|
|
|
|
|
options = (AddMaskOptions *) data;
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
if ((layer = (options->layer)) && (gimage = GIMP_ITEM (layer)->gimage))
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
mask = gimp_layer_create_mask (layer, options->add_mask_type);
|
2003-03-06 21:22:11 +08:00
|
|
|
|
|
|
|
if (options->invert)
|
|
|
|
gimp_channel_invert (GIMP_CHANNEL (mask), FALSE);
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
gimp_layer_add_mask (layer, mask, TRUE);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (mask);
|
2002-09-01 15:25:41 +08:00
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (options->query_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
layers_add_mask_query (GimpLayer *layer)
|
|
|
|
{
|
|
|
|
AddMaskOptions *options;
|
|
|
|
GtkWidget *frame;
|
2003-03-06 21:22:11 +08:00
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *sep;
|
2001-04-21 00:27:44 +08:00
|
|
|
GimpImage *gimage;
|
2003-09-01 02:10:15 +08:00
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
/* The new options structure */
|
|
|
|
options = g_new (AddMaskOptions, 1);
|
|
|
|
options->layer = layer;
|
2002-03-18 19:07:34 +08:00
|
|
|
options->add_mask_type = GIMP_ADD_WHITE_MASK;
|
2003-03-06 21:22:11 +08:00
|
|
|
options->invert = FALSE;
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
2003-09-01 02:10:15 +08:00
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
/* The dialog */
|
|
|
|
options->query_box =
|
2002-08-31 05:00:42 +08:00
|
|
|
gimp_viewable_dialog_new (GIMP_VIEWABLE (layer),
|
2002-09-01 15:25:41 +08:00
|
|
|
_("Add Layer Mask"), "add_mask_options",
|
2002-08-31 05:00:42 +08:00
|
|
|
GTK_STOCK_ADD,
|
2002-09-01 15:25:41 +08:00
|
|
|
_("Add a Mask to the Layer"),
|
2002-08-31 05:00:42 +08:00
|
|
|
gimp_standard_help_func,
|
2003-08-21 23:54:47 +08:00
|
|
|
GIMP_HELP_LAYER_MASK_ADD,
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-08-31 05:00:42 +08:00
|
|
|
GTK_STOCK_CANCEL, gtk_widget_destroy,
|
|
|
|
NULL, 1, NULL, FALSE, TRUE,
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-08-31 05:00:42 +08:00
|
|
|
GTK_STOCK_OK, add_mask_query_ok_callback,
|
|
|
|
options, NULL, NULL, TRUE, FALSE,
|
2001-11-24 07:04:49 +08:00
|
|
|
|
2002-08-31 05:00:42 +08:00
|
|
|
NULL);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2001-08-12 05:10:44 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (options->query_box),
|
2003-03-06 21:22:11 +08:00
|
|
|
(GWeakNotify) g_free, options);
|
|
|
|
|
|
|
|
frame = gimp_enum_radio_frame_new (GIMP_TYPE_ADD_MASK_TYPE,
|
|
|
|
gtk_label_new (_("Initialize Layer Mask to:")),
|
|
|
|
6,
|
|
|
|
G_CALLBACK (gimp_radio_button_update),
|
|
|
|
&options->add_mask_type,
|
|
|
|
&button);
|
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (button),
|
2003-09-01 02:10:15 +08:00
|
|
|
GINT_TO_POINTER (options->add_mask_type));
|
2002-02-21 00:15:53 +08:00
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
|
|
|
|
frame);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2003-03-06 21:22:11 +08:00
|
|
|
sep = gtk_hseparator_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_BIN (frame)->child), sep, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (sep);
|
|
|
|
|
|
|
|
button = gtk_check_button_new_with_mnemonic (_("In_vert Mask"));
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), options->invert);
|
|
|
|
g_signal_connect (button, "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&options->invert);
|
|
|
|
|
|
|
|
gtk_box_pack_end (GTK_BOX (GTK_BIN (frame)->child), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
gtk_widget_show (options->query_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************/
|
|
|
|
/* The scale layer dialog */
|
|
|
|
/****************************/
|
|
|
|
|
|
|
|
typedef struct _ScaleLayerOptions ScaleLayerOptions;
|
|
|
|
|
|
|
|
struct _ScaleLayerOptions
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
Resize *resize;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
scale_layer_query_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ScaleLayerOptions *options;
|
|
|
|
GimpLayer *layer;
|
|
|
|
|
|
|
|
options = (ScaleLayerOptions *) data;
|
|
|
|
|
|
|
|
if (options->resize->width > 0 && options->resize->height > 0 &&
|
|
|
|
(layer = (options->layer)))
|
|
|
|
{
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
gtk_widget_set_sensitive (options->resize->resize_shell, FALSE);
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
|
|
|
|
|
|
|
if (gimage)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
2003-05-07 19:09:00 +08:00
|
|
|
{
|
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_LAYER_SCALE,
|
|
|
|
_("Scale Layer"));
|
|
|
|
|
|
|
|
floating_sel_relax (layer, TRUE);
|
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2003-05-08 22:54:04 +08:00
|
|
|
gimp_item_scale_by_origin (GIMP_ITEM (layer),
|
|
|
|
options->resize->width,
|
|
|
|
options->resize->height,
|
|
|
|
options->resize->interpolation,
|
|
|
|
TRUE);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
2003-05-07 19:09:00 +08:00
|
|
|
{
|
|
|
|
floating_sel_rigor (layer, TRUE);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2003-05-07 19:09:00 +08:00
|
|
|
gimp_image_undo_group_end (gimage);
|
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (options->resize->resize_shell);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_message (_("Invalid width or height.\n"
|
|
|
|
"Both must be positive."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
layers_scale_layer_query (GimpImage *gimage,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpLayer *layer)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
ScaleLayerOptions *options;
|
|
|
|
|
2002-09-08 00:47:39 +08:00
|
|
|
options = g_new0 (ScaleLayerOptions, 1);
|
|
|
|
|
|
|
|
options->layer = layer;
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
options->resize =
|
2002-09-08 20:18:23 +08:00
|
|
|
resize_widget_new (GIMP_VIEWABLE (layer),
|
2001-10-29 19:47:11 +08:00
|
|
|
ScaleWidget,
|
2003-05-08 21:12:46 +08:00
|
|
|
gimp_item_width (GIMP_ITEM (layer)),
|
|
|
|
gimp_item_height (GIMP_ITEM (layer)),
|
2001-04-21 00:27:44 +08:00
|
|
|
gimage->xresolution,
|
|
|
|
gimage->yresolution,
|
|
|
|
gimage->unit,
|
|
|
|
TRUE,
|
2001-07-25 08:42:47 +08:00
|
|
|
G_CALLBACK (scale_layer_query_ok_callback),
|
2002-09-08 00:47:39 +08:00
|
|
|
options);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2001-08-12 05:10:44 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (options->resize->resize_shell),
|
|
|
|
(GWeakNotify) g_free,
|
|
|
|
options);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
gtk_widget_show (options->resize->resize_shell);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
/* The resize layer dialog */
|
|
|
|
/*****************************/
|
|
|
|
|
|
|
|
typedef struct _ResizeLayerOptions ResizeLayerOptions;
|
|
|
|
|
|
|
|
struct _ResizeLayerOptions
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
Resize *resize;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
resize_layer_query_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
ResizeLayerOptions *options;
|
|
|
|
GimpLayer *layer;
|
|
|
|
|
|
|
|
options = (ResizeLayerOptions *) data;
|
|
|
|
|
|
|
|
if (options->resize->width > 0 && options->resize->height > 0 &&
|
|
|
|
(layer = (options->layer)))
|
|
|
|
{
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
gtk_widget_set_sensitive (options->resize->resize_shell, FALSE);
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
|
|
|
|
|
|
|
if (gimage)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
2003-05-07 21:01:17 +08:00
|
|
|
{
|
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_LAYER_RESIZE,
|
|
|
|
_("Resize Layer"));
|
|
|
|
|
|
|
|
floating_sel_relax (layer, TRUE);
|
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2003-05-07 21:01:17 +08:00
|
|
|
gimp_item_resize (GIMP_ITEM (layer),
|
|
|
|
options->resize->width,
|
|
|
|
options->resize->height,
|
|
|
|
options->resize->offset_x,
|
|
|
|
options->resize->offset_y);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
2003-05-07 21:01:17 +08:00
|
|
|
{
|
|
|
|
floating_sel_rigor (layer, TRUE);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2003-05-07 21:01:17 +08:00
|
|
|
gimp_image_undo_group_end (gimage);
|
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (options->resize->resize_shell);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_message (_("Invalid width or height.\n"
|
|
|
|
"Both must be positive."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
layers_resize_layer_query (GimpImage *gimage,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpLayer *layer)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
ResizeLayerOptions *options;
|
|
|
|
|
2002-09-08 00:47:39 +08:00
|
|
|
options = g_new0 (ResizeLayerOptions, 1);
|
|
|
|
|
|
|
|
options->layer = layer;
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
options->resize =
|
2002-09-08 20:18:23 +08:00
|
|
|
resize_widget_new (GIMP_VIEWABLE (layer),
|
2001-10-29 19:47:11 +08:00
|
|
|
ResizeWidget,
|
2003-05-08 21:12:46 +08:00
|
|
|
gimp_item_width (GIMP_ITEM (layer)),
|
|
|
|
gimp_item_height (GIMP_ITEM (layer)),
|
2001-04-21 00:27:44 +08:00
|
|
|
gimage->xresolution,
|
|
|
|
gimage->yresolution,
|
|
|
|
gimage->unit,
|
|
|
|
TRUE,
|
2001-07-25 08:42:47 +08:00
|
|
|
G_CALLBACK (resize_layer_query_ok_callback),
|
2002-09-08 00:47:39 +08:00
|
|
|
options);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2001-08-12 05:10:44 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (options->resize->resize_shell),
|
|
|
|
(GWeakNotify) g_free,
|
|
|
|
options);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
gtk_widget_show (options->resize->resize_shell);
|
|
|
|
}
|