gimp/app/gui/layers-commands.c

1322 lines
33 KiB
C
Raw Normal View History

/* 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 <string.h>
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "paint-funcs/paint-funcs.h"
app/Makefile.am removed. 2001-07-07 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/context_manager.[ch]: removed. * app/app_procs.c: call tool_mananger instead of context_manager functions, pass "the_gimp" to some more functions. * app/drawable.[ch]: pass a GimpContext to drawable_fill(). * app/errors.c: behave according to "stack_trace_mode" when using the debugging signal handler. * app/gimprc.[ch]: removed the core/ config variables. * app/selection.c: set the selection's state to INVISIBLE in selection_pause(). * app/core/Makefile.am * app/core/gimpcoreconfig.[ch]: new files (the configuration variables used by core/). * app/core/gimpcontext.[ch]: removed the global contexts (user, default, ...) and their functions. It's no longer possible to pass NULL to the context functions to manipulate the current context (gimpcontext.c doesn't know the current context any more). * app/core/gimp.[ch]: added them here. The functions are now called gimp_[set|get]_*_context(). Added gimp_create_context() which is the only function to create contexts now. * app/gui/dialogs.[ch] * app/gui/gui.[ch]: pass "gimp" to all functions. * app/tools/tool_manager.[ch] * app/tools/tools.[ch]: pass "gimp" to lots of functions. Added the "global_tool_context" logic and the global/non-global paint options switching from the context_manager. Pass "gimp" to all tools' "register" functions. * app/tools/*: changed accordingly. * app/devices.c * app/disp_callbacks.c * app/file-open.[ch] * app/file-save.c * app/gdisplay.c * app/gimage.c * app/libgimp_glue.c * app/module_db.c * app/nav_window.c * app/plug_in.c * app/qmask.c * app/undo.c * app/base/base-config.c * app/core/gimpbrushpipe.c * app/core/gimpdrawable-offset.c * app/core/gimpgradient.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimpimage-new.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimptoolinfo.[ch] * app/core/gimpundo.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/menus.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/paths-dialog.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/resize-dialog.c * app/gui/test-commands.c * app/gui/tool-options-dialog.c * app/gui/toolbox.c * app/gui/tools-commands.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/widgets/gimpchannellistview.c * app/widgets/gimpdnd.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimpimagedock.c * app/widgets/gimplayerlistview.c * app/pdb/brushes_cmds.c * app/pdb/drawable_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/palette_cmds.c * app/pdb/patterns_cmds.c * app/pdb/procedural_db.c * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly: remove usage of gimp_context_[get|set]_*(NULL), create contexts with gimp_create_context(). Get the user/current context with gimp_get_[user|current]_context(). Added/removed access to the global "the_gimp" variable in some places. Get the core's config variables from "core_config".
2001-07-07 12:17:23 +00:00
#include "core/gimp.h"
#include "core/gimpimage.h"
#include "core/gimpimage-mask.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-28 17:51:06 +00:00
#include "core/gimpimage-merge.h"
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
#include "core/gimplist.h"
gdk_pixbuf_new_from_stream -> _from_inline 2001-10-13 Michael Natterer <mitch@gimp.org> * RELEASE-TO-CVS.patch: gdk_pixbuf_new_from_stream -> _from_inline * app/display/Makefile.am * app/display/gimpdisplay-foreach.[ch]: new files for functions operating on all displays (will go away as soon as the display behaves like a proper view which doesn't need to be updated explicitly). * app/display/gimpdisplay-callbacks.c * app/display/gimpdisplay-scale.[ch] * app/display/gimpdisplay-scroll.[ch] * app/display/gimpdisplay.[ch]: "scale" and "scroll" namespace cleanup, moved bounds_checking() to gimpdisplay-scroll.[ch], lots of unfinished, intermediate stuff. * app/display/gimpdisplayshell.[ch]: added some GObject framework for the GimpDisplayShell object (not used yet). * app/app_procs.c * app/docindex.c * app/image_map.c * app/nav_window.c * app/path.c * app/qmask.c * app/undo.c * app/gui/channels-commands.c * app/gui/convert-dialog.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/gui.c * app/gui/image-commands.c * app/gui/layer-select.c * app/gui/layers-commands.c * app/gui/offset-dialog.c * app/gui/paths-dialog.c * app/gui/preferences-dialog.c * app/gui/select-commands.c * app/gui/view-commands.c * app/tools/gimpairbrushtool.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimpposterizetool.c * app/tools/gimprectselecttool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/gimptransformtool.c * app/widgets/gimpbufferview.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c * app/widgets/gimplistitem.c * tools/pdbgen/pdb/display.pdb * app/pdb/display_cmds.c: changed accordingly (mostly including "gimpdisplay-foreach.h" instead of "gimpdisplay.h")
2001-10-13 12:52:30 +00:00
#include "display/gimpdisplay-foreach.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "layers-commands.h"
#include "resize-dialog.h"
#include "floating_sel.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
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);
static void layers_menu_set_sensitivity (GimpImage *gimage);
void
layers_previous_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *new_layer;
gint current_layer;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
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);
gdisplays_flush ();
}
}
}
void
layers_next_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *new_layer;
gint current_layer;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
current_layer =
gimp_image_get_layer_index (gimage, gimp_image_get_active_layer (gimage));
new_layer =
GIMP_LAYER (gimp_container_get_child_by_index (gimage->layers,
current_layer + 1));
if (new_layer)
{
gimp_image_set_active_layer (gimage, new_layer);
gdisplays_flush ();
}
}
void
layers_raise_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
gimp_image_raise_layer (gimage, gimp_image_get_active_layer (gimage));
gdisplays_flush ();
}
void
layers_lower_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
gimp_image_lower_layer (gimage, gimp_image_get_active_layer (gimage));
gdisplays_flush ();
}
void
layers_raise_to_top_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
gimp_image_raise_layer_to_top (gimage, gimp_image_get_active_layer (gimage));
gdisplays_flush ();
}
void
layers_lower_to_bottom_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
gimp_image_lower_layer_to_bottom (gimage,
gimp_image_get_active_layer (gimage));
gdisplays_flush ();
}
void
layers_new_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
layers_new_layer_query (gimage);
}
void
layers_duplicate_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *active_layer;
GimpLayer *new_layer;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
active_layer = gimp_image_get_active_layer (gimage);
new_layer = gimp_layer_copy (active_layer, TRUE);
gimp_image_add_layer (gimage, new_layer, -1);
gdisplays_flush ();
}
void
layers_delete_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
layer = gimp_image_get_active_layer (gimage);
if (! layer)
return;
if (gimp_layer_is_floating_sel (layer))
floating_sel_remove (layer);
else
gimp_image_remove_layer (gimage, layer);
app/Makefile.am removed. 2001-07-08 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/drawable.[ch]: removed. * app/core/gimpdrawable.[ch]: added the functions here. Made an end to the myth that FG/BG and the undo system (!!!) are not really part of the core. * app/disp_callbacks.c * app/floating_sel.c * app/image_map.c * app/qmask.c * app/undo.c * app/core/gimpchannel.c * app/core/gimpdrawable-desaturate.c * app/core/gimpdrawable-equalize.c * app/core/gimpdrawable-invert.c * app/core/gimpdrawable-offset.c * app/core/gimpedit.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimpimage-new.c * app/core/gimpimage.[ch] * app/core/gimplayer.c * app/core/gimplayermask.c * app/gui/channels-commands.c * app/gui/gui.c * app/gui/layers-commands.c * app/tools/gimpairbrushtool.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimplevelstool.c * app/tools/gimppainttool.c * app/tools/gimpposterizetool.c * app/tools/gimpscaletool.c * app/tools/gimpthresholdtool.c * app/tools/gimptransformtool.c * app/tools/tool_manager.c * app/widgets/gimpchannellistitem.c * app/widgets/gimpchannellistview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c * app/pdb/channel_cmds.c * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/image_cmds.c * app/pdb/layer_cmds.c * app/pdb/parasite_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb: changed accordingly. Misc small fixes and cleanups.
2001-07-07 22:49:01 +00:00
gdisplays_flush ();
}
void
layers_scale_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
layers_scale_layer_query (gimage, gimp_image_get_active_layer (gimage));
}
void
layers_resize_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
layers_resize_layer_query (gimage, gimp_image_get_active_layer (gimage));
}
void
layers_resize_to_image_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
gimp_layer_resize_to_image (gimp_image_get_active_layer (gimage));
gdisplays_flush ();
}
void
layers_add_layer_mask_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
layers_add_mask_query (gimp_image_get_active_layer (gimage));
}
void
layers_apply_layer_mask_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
layer = gimp_image_get_active_layer (gimage);
/* Make sure there is a layer mask to apply */
if (layer && gimp_layer_get_mask (layer))
{
gboolean flush = ! layer->mask->apply_mask || layer->mask->show_mask;
gimp_layer_apply_mask (layer, APPLY, TRUE);
if (flush)
gdisplays_flush ();
}
}
void
layers_delete_layer_mask_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
layer = gimp_image_get_active_layer (gimage);
/* Make sure there is a layer mask to apply */
if (layer && gimp_layer_get_mask (layer))
{
gboolean flush = layer->mask->apply_mask || layer->mask->show_mask;
gimp_layer_apply_mask (layer, DISCARD, TRUE);
if (flush)
gdisplays_flush ();
}
}
void
layers_anchor_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
floating_sel_anchor (gimp_image_get_active_layer (gimage));
gdisplays_flush ();
}
void
layers_merge_layers_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
layers_layer_merge_query (gimage, TRUE);
}
void
layers_merge_down_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
gimp_image_merge_down (gimage, gimp_image_get_active_layer (gimage),
EXPAND_AS_NECESSARY);
gdisplays_flush ();
}
void
layers_flatten_image_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
gimp_image_flatten (gimage);
gdisplays_flush ();
}
void
layers_alpha_select_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
gimp_image_mask_layer_alpha (gimage, gimp_image_get_active_layer (gimage));
gdisplays_flush ();
}
void
layers_mask_select_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
gimp_image_mask_layer_mask (gimage, gimp_image_get_active_layer (gimage));
gdisplays_flush ();
}
void
layers_add_alpha_channel_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
layer = gimp_image_get_active_layer (gimage);
if (! layer)
return;
gimp_layer_add_alpha (layer);
gdisplays_flush ();
}
void
layers_edit_attributes_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *layer;
gimage = (GimpImage *) gimp_widget_get_callback_context (widget);
if (! gimage)
return;
layer = gimp_image_get_active_layer (gimage);
if (! layer)
return;
layers_edit_layer_query (layer);
}
/********************************/
/* 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;
};
static GimpFillType fill_type = TRANSPARENT_FILL;
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)));
options->xsize =
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))
{
/* Start a group undo */
undo_push_group_start (gimage, LAYER_ADD_UNDO);
layer = gimp_layer_new (gimage, options->xsize, options->ysize,
gimp_image_base_type_with_alpha (gimage),
layer_name, OPAQUE_OPACITY, NORMAL_MODE);
if (layer)
{
app/Makefile.am removed. 2001-07-08 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/drawable.[ch]: removed. * app/core/gimpdrawable.[ch]: added the functions here. Made an end to the myth that FG/BG and the undo system (!!!) are not really part of the core. * app/disp_callbacks.c * app/floating_sel.c * app/image_map.c * app/qmask.c * app/undo.c * app/core/gimpchannel.c * app/core/gimpdrawable-desaturate.c * app/core/gimpdrawable-equalize.c * app/core/gimpdrawable-invert.c * app/core/gimpdrawable-offset.c * app/core/gimpedit.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimpimage-new.c * app/core/gimpimage.[ch] * app/core/gimplayer.c * app/core/gimplayermask.c * app/gui/channels-commands.c * app/gui/gui.c * app/gui/layers-commands.c * app/tools/gimpairbrushtool.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimplevelstool.c * app/tools/gimppainttool.c * app/tools/gimpposterizetool.c * app/tools/gimpscaletool.c * app/tools/gimpthresholdtool.c * app/tools/gimptransformtool.c * app/tools/tool_manager.c * app/widgets/gimpchannellistitem.c * app/widgets/gimpchannellistview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c * app/pdb/channel_cmds.c * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/image_cmds.c * app/pdb/layer_cmds.c * app/pdb/parasite_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb: changed accordingly. Misc small fixes and cleanups.
2001-07-07 22:49:01 +00:00
gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer),
gimp_get_user_context (gimage->gimp),
fill_type);
gimp_image_add_layer (gimage, layer, -1);
/* End the group undo */
undo_push_group_end (gimage);
gdisplays_flush ();
}
else
{
g_message ("new_layer_query_ok_callback():\n"
"could not allocate new layer");
}
}
gtk_widget_destroy (options->query_box);
}
void
layers_new_layer_query (GimpImage *gimage)
{
NewLayerOptions *options;
GimpLayer *floating_sel;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *label;
GtkObject *adjustment;
GtkWidget *spinbutton;
GtkWidget *frame;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
/* 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);
gdisplays_flush ();
return;
}
options = g_new0 (NewLayerOptions, 1);
options->fill_type = fill_type;
options->gimage = gimage;
/* The dialog */
options->query_box =
gimp_dialog_new (_("New Layer Options"), "new_layer_options",
gimp_standard_help_func,
"dialogs/layers/new_layer.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
GTK_STOCK_OK, new_layer_query_ok_callback,
options, NULL, NULL, TRUE, FALSE,
NULL);
g_object_weak_ref (G_OBJECT (options->query_box),
(GWeakNotify) g_free,
options);
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 2);
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 */
label = gtk_label_new (_("Layer Name:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 1);
gtk_widget_show (label);
options->name_entry = gtk_entry_new ();
gtk_widget_set_usize (options->name_entry, 75, 0);
gtk_table_attach_defaults (GTK_TABLE (table),
options->name_entry, 1, 2, 0, 1);
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
(layer_name ? layer_name : _("New Layer")));
gtk_widget_show (options->name_entry);
/* 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 */
adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 2);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
gtk_widget_set_usize (spinbutton, 75, 0);
options->size_se = gimp_size_entry_new (1, gimage->unit, "%a",
TRUE, TRUE, FALSE, 75,
GIMP_SIZE_ENTRY_UPDATE_SIZE);
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);
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);
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (options->size_se),
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 */
frame = gimp_radio_group_new2
(TRUE, _("Layer Fill Type"),
G_CALLBACK (gimp_radio_button_update),
&options->fill_type,
GINT_TO_POINTER (options->fill_type),
_("Foreground"), GINT_TO_POINTER (FOREGROUND_FILL), NULL,
_("Background"), GINT_TO_POINTER (BACKGROUND_FILL), NULL,
_("White"), GINT_TO_POINTER (WHITE_FILL), NULL,
_("Transparent"), GINT_TO_POINTER (TRANSPARENT_FILL), NULL,
NULL);
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;
if ((layer = options->layer))
{
/* Set the new layer name */
if (GIMP_OBJECT (layer)->name && gimp_layer_is_floating_sel (layer))
{
/* If the layer is a floating selection, make it a layer */
floating_sel_to_layer (layer);
}
else
{
/* We're doing a plain rename */
undo_push_layer_rename (options->gimage, layer);
}
gimp_object_set_name (GIMP_OBJECT (layer),
gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
}
gdisplays_flush ();
gtk_widget_destroy (options->query_box);
}
void
layers_edit_layer_query (GimpLayer *layer)
{
EditLayerOptions *options;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
/* The new options structure */
options = g_new (EditLayerOptions, 1);
options->layer = layer;
options->gimage = gimp_drawable_gimage (GIMP_DRAWABLE (layer));
/* The dialog */
options->query_box =
gimp_dialog_new (_("Edit Layer Attributes"), "edit_layer_attributes",
gimp_standard_help_func,
"dialogs/layers/edit_layer_attributes.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
GTK_STOCK_OK, edit_layer_query_ok_callback,
options, NULL, NULL, TRUE, FALSE,
NULL);
g_object_weak_ref (G_OBJECT (options->query_box),
(GWeakNotify) g_free,
options);
g_signal_connect_object (G_OBJECT (layer), "removed",
G_CALLBACK (gtk_widget_destroy),
G_OBJECT (options->query_box),
G_CONNECT_SWAPPED);
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
vbox);
/* The name hbox, label and entry */
hbox = gtk_hbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
label = gtk_label_new (_("Layer name:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
options->name_entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (hbox), options->name_entry, TRUE, TRUE, 0);
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
((gimp_layer_is_floating_sel (layer) ?
_("Floating Selection") :
gimp_object_get_name (GIMP_OBJECT (layer)))));
gtk_widget_show (options->name_entry);
g_signal_connect (G_OBJECT (options->name_entry), "activate",
G_CALLBACK (edit_layer_query_ok_callback),
options);
gtk_widget_show (hbox);
gtk_widget_show (vbox);
gtk_widget_show (options->query_box);
}
/*******************************/
/* The add mask query dialog */
/*******************************/
typedef struct _AddMaskOptions AddMaskOptions;
struct _AddMaskOptions
{
GtkWidget *query_box;
GimpLayer *layer;
AddMaskType add_mask_type;
};
static void
add_mask_query_ok_callback (GtkWidget *widget,
gpointer data)
{
AddMaskOptions *options;
GimpImage *gimage;
GimpLayerMask *mask;
GimpLayer *layer;
options = (AddMaskOptions *) data;
if ((layer = (options->layer)) &&
(gimage = GIMP_DRAWABLE (layer)->gimage))
{
mask = gimp_layer_create_mask (layer, options->add_mask_type);
gimp_layer_add_mask (layer, mask, TRUE);
gdisplays_flush ();
}
gtk_widget_destroy (options->query_box);
}
static void
layers_add_mask_query (GimpLayer *layer)
{
AddMaskOptions *options;
GtkWidget *frame;
GimpImage *gimage;
/* The new options structure */
options = g_new (AddMaskOptions, 1);
options->layer = layer;
options->add_mask_type = ADD_WHITE_MASK;
gimage = GIMP_DRAWABLE (layer)->gimage;
/* The dialog */
options->query_box =
gimp_dialog_new (_("Add Mask Options"), "add_mask_options",
gimp_standard_help_func,
"dialogs/layers/add_layer_mask.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
GTK_STOCK_OK, add_mask_query_ok_callback,
options, NULL, NULL, TRUE, FALSE,
NULL);
g_object_weak_ref (G_OBJECT (options->query_box),
(GWeakNotify) g_free,
options);
g_signal_connect_object (G_OBJECT (layer), "removed",
G_CALLBACK (gtk_widget_destroy),
G_OBJECT (options->query_box),
G_CONNECT_SWAPPED);
/* The radio frame and box */
if (gimage->selection_mask)
{
options->add_mask_type = ADD_SELECTION_MASK;
frame = gimp_radio_group_new2 (TRUE, _("Initialize Layer Mask to:"),
G_CALLBACK (gimp_radio_button_update),
&options->add_mask_type,
GINT_TO_POINTER (options->add_mask_type),
_("Selection"),
GINT_TO_POINTER (ADD_SELECTION_MASK), NULL,
_("Inverse Selection"),
GINT_TO_POINTER (ADD_INV_SELECTION_MASK), NULL,
_("White (Full Opacity)"),
GINT_TO_POINTER (ADD_WHITE_MASK), NULL,
_("Black (Full Transparency)"),
GINT_TO_POINTER (ADD_BLACK_MASK), NULL,
_("Layer's Alpha Channel"),
GINT_TO_POINTER (ADD_ALPHA_MASK), NULL,
NULL);
}
else
{
frame = gimp_radio_group_new2 (TRUE, _("Initialize Layer Mask to:"),
G_CALLBACK (gimp_radio_button_update),
&options->add_mask_type,
GINT_TO_POINTER (options->add_mask_type),
_("White (Full Opacity)"),
GINT_TO_POINTER (ADD_WHITE_MASK), NULL,
_("Black (Full Transparency)"),
GINT_TO_POINTER (ADD_BLACK_MASK), NULL,
_("Layer's Alpha Channel"),
GINT_TO_POINTER (ADD_ALPHA_MASK), NULL,
NULL);
}
gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
frame);
gtk_widget_show (frame);
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;
GimpImage *gimage;
GimpLayer *layer;
options = (ScaleLayerOptions *) data;
if (options->resize->width > 0 && options->resize->height > 0 &&
(layer = (options->layer)))
{
gtk_widget_set_sensitive (options->resize->resize_shell, FALSE);
if ((gimage = GIMP_DRAWABLE (layer)->gimage) != NULL)
{
undo_push_group_start (gimage, LAYER_SCALE_UNDO);
if (gimp_layer_is_floating_sel (layer))
floating_sel_relax (layer, TRUE);
gimp_layer_scale (layer,
options->resize->width, options->resize->height,
TRUE);
if (gimp_layer_is_floating_sel (layer))
floating_sel_rigor (layer, TRUE);
undo_push_group_end (gimage);
gdisplays_flush ();
}
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,
Cleanup weekend... 2001-10-29 Michael Natterer <mitch@gimp.org> Cleanup weekend... * app/app_procs.c: pass "no_interface" to gimp_new(). * app/core/gimp.[ch]: added "gboolean no_interface" and the load_procs and save_procs GSLists. * app/core/gimptoolinfo.[ch]: added a "Gimp" pointer to the GimpToolInfo object so more functions find their context without accessing the global "the_gimp" variable. * app/display/display-types.h: removed the GDisplay -> GimpDisplay typedef. * app/display/gimpdisplay.c: look at gimp->no_interface, don't include "appenv.h". * app/file/file-open.[ch] * app/file/file-save.[ch]: don't use "the_gimp" any more. Instead, pass around lots of "Gimp" pointers. Removed the global load_procs and save_procs variables here. Use access() to find out whether a file is readable/writable, removed the manual voodoo and it's Win32 wrappers. Added an optional (can be NULL) "PlunInProcDef" parameter to file_save(), removed file_save_with_proc(). * app/gui/menus.c: Use the unused "gpointer data" parameter of the GtkItemFactory callbacks to pass a "Gimp" pointer to all of them. This reduces the usage of the global "the_gimp" hack to zero in app/gui/... yeah. * app/gui/channels-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/select-commands.c * app/gui/test-commands.c * app/gui/tools-commands.c * app/gui/view-commands.c: use the passed "Gimp" pointer. * app/gui/color-area.[ch] * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.[ch] * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch] * app/gui/gui.c * app/gui/info-window.[ch] * app/gui/module-browser.[ch] * app/gui/palette-editor.c * app/gui/palette-import-dialog.[ch] * app/gui/paths-dialog.c * app/gui/preferences-dialog.[ch] * app/gui/resize-dialog.[ch] * app/gui/tool-options-dialog.[ch] * app/gui/toolbox.c: pass around lots more "Gimp" and "GimpContext" pointers and don't use "the_gimp" any more. * app/tools/gimptool.h: added a pointer to the corresponding GimpToolInfo object (which in turn has a pointer to a Gimp). * app/tools/tool_manager.[ch]: set the pointer after creating the tool object. Removed tool_manager_get_info_by_tool() as there is a tool->tool_info pointer now. * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool.c * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimpperspectivetool.c * app/tools/gimpposterizetool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpsheartool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/path_tool.c * app/tools/xinput_airbrush.c: s/GDisplay/GimpDisplay/g. Use tool->tool_info and tool_info->gimp in some places to get rid of using "the_gimp". Removing the remaining ones involves changing the tool options system and is scheduled next... * app/widgets/gimpdnd.c * app/widgets/gimpdocumentview.c: pass a "Gimp" pointer to all file_open_*() functions. * app/gdisplay_color.[ch] * app/gdisplay_color_ui.[ch] * app/image_map.[ch] * app/nav_window.[ch] * app/path.c * app/path_bezier.c * app/path_transform.h * app/qmask.[ch]: s/GDisplay/GimpDisplay/g * tools/pdbgen/pdb/fileops.pdb: load_procs and save_procs are members of the "Gimp" object now. * tools/pdbgen/pdb/plug_in.pdb: use gimp->no_interface, don't include "appenv.h". * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2001-10-29 11:47:11 +00:00
GimpLayer *layer)
{
ScaleLayerOptions *options;
/* the new options structure */
options = g_new (ScaleLayerOptions, 1);
options->layer = layer;
options->resize =
Cleanup weekend... 2001-10-29 Michael Natterer <mitch@gimp.org> Cleanup weekend... * app/app_procs.c: pass "no_interface" to gimp_new(). * app/core/gimp.[ch]: added "gboolean no_interface" and the load_procs and save_procs GSLists. * app/core/gimptoolinfo.[ch]: added a "Gimp" pointer to the GimpToolInfo object so more functions find their context without accessing the global "the_gimp" variable. * app/display/display-types.h: removed the GDisplay -> GimpDisplay typedef. * app/display/gimpdisplay.c: look at gimp->no_interface, don't include "appenv.h". * app/file/file-open.[ch] * app/file/file-save.[ch]: don't use "the_gimp" any more. Instead, pass around lots of "Gimp" pointers. Removed the global load_procs and save_procs variables here. Use access() to find out whether a file is readable/writable, removed the manual voodoo and it's Win32 wrappers. Added an optional (can be NULL) "PlunInProcDef" parameter to file_save(), removed file_save_with_proc(). * app/gui/menus.c: Use the unused "gpointer data" parameter of the GtkItemFactory callbacks to pass a "Gimp" pointer to all of them. This reduces the usage of the global "the_gimp" hack to zero in app/gui/... yeah. * app/gui/channels-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/select-commands.c * app/gui/test-commands.c * app/gui/tools-commands.c * app/gui/view-commands.c: use the passed "Gimp" pointer. * app/gui/color-area.[ch] * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.[ch] * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch] * app/gui/gui.c * app/gui/info-window.[ch] * app/gui/module-browser.[ch] * app/gui/palette-editor.c * app/gui/palette-import-dialog.[ch] * app/gui/paths-dialog.c * app/gui/preferences-dialog.[ch] * app/gui/resize-dialog.[ch] * app/gui/tool-options-dialog.[ch] * app/gui/toolbox.c: pass around lots more "Gimp" and "GimpContext" pointers and don't use "the_gimp" any more. * app/tools/gimptool.h: added a pointer to the corresponding GimpToolInfo object (which in turn has a pointer to a Gimp). * app/tools/tool_manager.[ch]: set the pointer after creating the tool object. Removed tool_manager_get_info_by_tool() as there is a tool->tool_info pointer now. * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool.c * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimpperspectivetool.c * app/tools/gimpposterizetool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpsheartool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/path_tool.c * app/tools/xinput_airbrush.c: s/GDisplay/GimpDisplay/g. Use tool->tool_info and tool_info->gimp in some places to get rid of using "the_gimp". Removing the remaining ones involves changing the tool options system and is scheduled next... * app/widgets/gimpdnd.c * app/widgets/gimpdocumentview.c: pass a "Gimp" pointer to all file_open_*() functions. * app/gdisplay_color.[ch] * app/gdisplay_color_ui.[ch] * app/image_map.[ch] * app/nav_window.[ch] * app/path.c * app/path_bezier.c * app/path_transform.h * app/qmask.[ch]: s/GDisplay/GimpDisplay/g * tools/pdbgen/pdb/fileops.pdb: load_procs and save_procs are members of the "Gimp" object now. * tools/pdbgen/pdb/plug_in.pdb: use gimp->no_interface, don't include "appenv.h". * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2001-10-29 11:47:11 +00:00
resize_widget_new (gimage,
ScaleWidget,
ResizeLayer,
G_OBJECT (layer),
"removed",
gimp_drawable_width (GIMP_DRAWABLE (layer)),
gimp_drawable_height (GIMP_DRAWABLE (layer)),
gimage->xresolution,
gimage->yresolution,
gimage->unit,
TRUE,
G_CALLBACK (scale_layer_query_ok_callback),
NULL,
options);
g_object_weak_ref (G_OBJECT (options->resize->resize_shell),
(GWeakNotify) g_free,
options);
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;
GimpImage *gimage;
GimpLayer *layer;
options = (ResizeLayerOptions *) data;
if (options->resize->width > 0 && options->resize->height > 0 &&
(layer = (options->layer)))
{
gtk_widget_set_sensitive (options->resize->resize_shell, FALSE);
if ((gimage = GIMP_DRAWABLE (layer)->gimage) != NULL)
{
undo_push_group_start (gimage, LAYER_RESIZE_UNDO);
if (gimp_layer_is_floating_sel (layer))
floating_sel_relax (layer, TRUE);
gimp_layer_resize (layer,
options->resize->width,
options->resize->height,
options->resize->offset_x,
options->resize->offset_y);
if (gimp_layer_is_floating_sel (layer))
floating_sel_rigor (layer, TRUE);
undo_push_group_end (gimage);
gdisplays_flush ();
}
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,
Cleanup weekend... 2001-10-29 Michael Natterer <mitch@gimp.org> Cleanup weekend... * app/app_procs.c: pass "no_interface" to gimp_new(). * app/core/gimp.[ch]: added "gboolean no_interface" and the load_procs and save_procs GSLists. * app/core/gimptoolinfo.[ch]: added a "Gimp" pointer to the GimpToolInfo object so more functions find their context without accessing the global "the_gimp" variable. * app/display/display-types.h: removed the GDisplay -> GimpDisplay typedef. * app/display/gimpdisplay.c: look at gimp->no_interface, don't include "appenv.h". * app/file/file-open.[ch] * app/file/file-save.[ch]: don't use "the_gimp" any more. Instead, pass around lots of "Gimp" pointers. Removed the global load_procs and save_procs variables here. Use access() to find out whether a file is readable/writable, removed the manual voodoo and it's Win32 wrappers. Added an optional (can be NULL) "PlunInProcDef" parameter to file_save(), removed file_save_with_proc(). * app/gui/menus.c: Use the unused "gpointer data" parameter of the GtkItemFactory callbacks to pass a "Gimp" pointer to all of them. This reduces the usage of the global "the_gimp" hack to zero in app/gui/... yeah. * app/gui/channels-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/select-commands.c * app/gui/test-commands.c * app/gui/tools-commands.c * app/gui/view-commands.c: use the passed "Gimp" pointer. * app/gui/color-area.[ch] * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.[ch] * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch] * app/gui/gui.c * app/gui/info-window.[ch] * app/gui/module-browser.[ch] * app/gui/palette-editor.c * app/gui/palette-import-dialog.[ch] * app/gui/paths-dialog.c * app/gui/preferences-dialog.[ch] * app/gui/resize-dialog.[ch] * app/gui/tool-options-dialog.[ch] * app/gui/toolbox.c: pass around lots more "Gimp" and "GimpContext" pointers and don't use "the_gimp" any more. * app/tools/gimptool.h: added a pointer to the corresponding GimpToolInfo object (which in turn has a pointer to a Gimp). * app/tools/tool_manager.[ch]: set the pointer after creating the tool object. Removed tool_manager_get_info_by_tool() as there is a tool->tool_info pointer now. * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool.c * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimpperspectivetool.c * app/tools/gimpposterizetool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpsheartool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/path_tool.c * app/tools/xinput_airbrush.c: s/GDisplay/GimpDisplay/g. Use tool->tool_info and tool_info->gimp in some places to get rid of using "the_gimp". Removing the remaining ones involves changing the tool options system and is scheduled next... * app/widgets/gimpdnd.c * app/widgets/gimpdocumentview.c: pass a "Gimp" pointer to all file_open_*() functions. * app/gdisplay_color.[ch] * app/gdisplay_color_ui.[ch] * app/image_map.[ch] * app/nav_window.[ch] * app/path.c * app/path_bezier.c * app/path_transform.h * app/qmask.[ch]: s/GDisplay/GimpDisplay/g * tools/pdbgen/pdb/fileops.pdb: load_procs and save_procs are members of the "Gimp" object now. * tools/pdbgen/pdb/plug_in.pdb: use gimp->no_interface, don't include "appenv.h". * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2001-10-29 11:47:11 +00:00
GimpLayer *layer)
{
ResizeLayerOptions *options;
/* the new options structure */
options = g_new (ResizeLayerOptions, 1);
options->layer = layer;
options->resize =
Cleanup weekend... 2001-10-29 Michael Natterer <mitch@gimp.org> Cleanup weekend... * app/app_procs.c: pass "no_interface" to gimp_new(). * app/core/gimp.[ch]: added "gboolean no_interface" and the load_procs and save_procs GSLists. * app/core/gimptoolinfo.[ch]: added a "Gimp" pointer to the GimpToolInfo object so more functions find their context without accessing the global "the_gimp" variable. * app/display/display-types.h: removed the GDisplay -> GimpDisplay typedef. * app/display/gimpdisplay.c: look at gimp->no_interface, don't include "appenv.h". * app/file/file-open.[ch] * app/file/file-save.[ch]: don't use "the_gimp" any more. Instead, pass around lots of "Gimp" pointers. Removed the global load_procs and save_procs variables here. Use access() to find out whether a file is readable/writable, removed the manual voodoo and it's Win32 wrappers. Added an optional (can be NULL) "PlunInProcDef" parameter to file_save(), removed file_save_with_proc(). * app/gui/menus.c: Use the unused "gpointer data" parameter of the GtkItemFactory callbacks to pass a "Gimp" pointer to all of them. This reduces the usage of the global "the_gimp" hack to zero in app/gui/... yeah. * app/gui/channels-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/select-commands.c * app/gui/test-commands.c * app/gui/tools-commands.c * app/gui/view-commands.c: use the passed "Gimp" pointer. * app/gui/color-area.[ch] * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.[ch] * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch] * app/gui/gui.c * app/gui/info-window.[ch] * app/gui/module-browser.[ch] * app/gui/palette-editor.c * app/gui/palette-import-dialog.[ch] * app/gui/paths-dialog.c * app/gui/preferences-dialog.[ch] * app/gui/resize-dialog.[ch] * app/gui/tool-options-dialog.[ch] * app/gui/toolbox.c: pass around lots more "Gimp" and "GimpContext" pointers and don't use "the_gimp" any more. * app/tools/gimptool.h: added a pointer to the corresponding GimpToolInfo object (which in turn has a pointer to a Gimp). * app/tools/tool_manager.[ch]: set the pointer after creating the tool object. Removed tool_manager_get_info_by_tool() as there is a tool->tool_info pointer now. * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool.c * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimpperspectivetool.c * app/tools/gimpposterizetool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpsheartool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/path_tool.c * app/tools/xinput_airbrush.c: s/GDisplay/GimpDisplay/g. Use tool->tool_info and tool_info->gimp in some places to get rid of using "the_gimp". Removing the remaining ones involves changing the tool options system and is scheduled next... * app/widgets/gimpdnd.c * app/widgets/gimpdocumentview.c: pass a "Gimp" pointer to all file_open_*() functions. * app/gdisplay_color.[ch] * app/gdisplay_color_ui.[ch] * app/image_map.[ch] * app/nav_window.[ch] * app/path.c * app/path_bezier.c * app/path_transform.h * app/qmask.[ch]: s/GDisplay/GimpDisplay/g * tools/pdbgen/pdb/fileops.pdb: load_procs and save_procs are members of the "Gimp" object now. * tools/pdbgen/pdb/plug_in.pdb: use gimp->no_interface, don't include "appenv.h". * app/pdb/fileops_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
2001-10-29 11:47:11 +00:00
resize_widget_new (gimage,
ResizeWidget,
ResizeLayer,
G_OBJECT (layer),
"removed",
gimp_drawable_width (GIMP_DRAWABLE (layer)),
gimp_drawable_height (GIMP_DRAWABLE (layer)),
gimage->xresolution,
gimage->yresolution,
gimage->unit,
TRUE,
G_CALLBACK (resize_layer_query_ok_callback),
NULL,
options);
g_object_weak_ref (G_OBJECT (options->resize->resize_shell),
(GWeakNotify) g_free,
options);
gtk_widget_show (options->resize->resize_shell);
}
/****************************/
/* The layer merge dialog */
/****************************/
typedef struct _LayerMergeOptions LayerMergeOptions;
struct _LayerMergeOptions
{
GtkWidget *query_box;
GimpImage *gimage;
gboolean merge_visible;
MergeType merge_type;
};
static void
layer_merge_query_ok_callback (GtkWidget *widget,
gpointer data)
{
LayerMergeOptions *options;
GimpImage *gimage;
options = (LayerMergeOptions *) data;
if (! (gimage = options->gimage))
return;
if (options->merge_visible)
gimp_image_merge_visible_layers (gimage, options->merge_type);
gdisplays_flush ();
gtk_widget_destroy (options->query_box);
}
void
layers_layer_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;
options->merge_type = EXPAND_AS_NECESSARY;
/* The dialog */
options->query_box =
gimp_dialog_new (_("Layer Merge Options"), "layer_merge_options",
gimp_standard_help_func,
"dialogs/layers/merge_visible_layers.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
GTK_STOCK_OK, layer_merge_query_ok_callback,
options, NULL, NULL, TRUE, FALSE,
NULL);
g_object_weak_ref (G_OBJECT (options->query_box),
(GWeakNotify) g_free,
options);
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
vbox);
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 (EXPAND_AS_NECESSARY), NULL,
_("Clipped to image"),
GINT_TO_POINTER (CLIP_TO_IMAGE), NULL,
_("Clipped to bottom layer"),
GINT_TO_POINTER (CLIP_TO_BOTTOM_LAYER), NULL,
NULL);
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);
}
void
layers_show_context_menu (GimpImage *gimage)
{
GtkItemFactory *item_factory;
layers_menu_set_sensitivity (gimage);
item_factory = gtk_item_factory_from_path ("<Layers>");
register the button icons with GTK_ICON_SIZE_BUTTON, but set them as 2001-08-05 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpstock.[ch]: register the button icons with GTK_ICON_SIZE_BUTTON, but set them as scalable fallbacks for themselves so they get scaled for menus. * app/gui/menus.c: set stock icons for much more menu entries. * app/widgets/gimpwidgets-utils.[ch]: new utility function gimp_item_factory_popup_with_data(). * app/disp_callbacks.[ch] * app/gui/brushes-commands.c * app/gui/channels-commands.c * app/gui/gradients-commands.c * app/gui/layers-commands.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/patterns-commands.c: use the new function. * app/tools/gimpcolorbalancetool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c: s/_("Reset")/GIMP_STOCK_RESET/ * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch]: moved the button_box utility functions from the container editor to GimpContainerView itself. * app/widgets/gimpbufferview.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpcontainergridview.[ch] * app/widgets/gimpdatafactoryview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c: changed accordingly. Removed lots of duplicated code and use stock images instead of pixmaps. * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimppatheditor.c: use stock images instead of pixmaps. * pixmaps/Makefile.am: removed "yes" and "no", added "stroke". * pixmaps/anchor.xpm * pixmaps/delete.xpm * pixmaps/lower.xpm * pixmaps/new.xpm * pixmaps/paste-as-new.xpm * pixmaps/paste-into.xpm * pixmaps/paste.xpm * pixmaps/raise.xpm * pixmaps/refresh.xpm * pixmaps/toselection.xpm: made them all 16x16 so they are scaled nicely in menus. Should probably be 18x18.
2001-08-04 20:38:54 +00:00
gimp_item_factory_popup_with_data (item_factory, gimage);
}
static void
layers_menu_set_sensitivity (GimpImage *gimage)
{
GimpLayer *layer;
gboolean fs = FALSE; /* floating sel */
gboolean ac = FALSE; /* active channel */
gboolean lm = FALSE; /* layer mask */
gboolean lp = FALSE; /* layers present */
gboolean alpha = FALSE; /* alpha channel present */
gboolean indexed = FALSE; /* is indexed */
gboolean next_alpha = FALSE;
GList *list;
GList *next = NULL;
GList *prev = NULL;
g_return_if_fail (gimage != NULL);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
layer = gimp_image_get_active_layer (gimage);
if (layer)
lm = (gimp_layer_get_mask (layer)) ? TRUE : FALSE;
fs = (gimp_image_floating_sel (gimage) != NULL);
ac = (gimp_image_get_active_channel (gimage) != NULL);
alpha = layer && gimp_layer_has_alpha (layer);
lp = ! gimp_image_is_empty (gimage);
indexed = (gimp_image_base_type (gimage) == INDEXED);
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
if (layer == (GimpLayer *) list->data)
{
prev = g_list_previous (list);
next = g_list_next (list);
break;
}
}
if (next)
next_alpha = gimp_layer_has_alpha (GIMP_LAYER (next->data));
else
next_alpha = FALSE;
#define SET_SENSITIVE(menu,condition) \
gimp_menu_item_set_sensitive ("<Layers>/" menu, (condition) != 0)
SET_SENSITIVE ("New Layer...", gimage);
SET_SENSITIVE ("Stack/Raise Layer",
!fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("Stack/Lower Layer",
!fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("Stack/Layer to Top",
!fs && !ac && gimage && lp && alpha && prev);
SET_SENSITIVE ("Stack/Layer to Bottom",
!fs && !ac && gimage && lp && next && next_alpha);
SET_SENSITIVE ("Duplicate Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("Anchor Layer", !fs && !ac && gimage && lp);
SET_SENSITIVE ("Delete Layer", !ac && gimage && lp);
SET_SENSITIVE ("Layer Boundary Size...", !ac && gimage && lp);
SET_SENSITIVE ("Layer to Imagesize", !ac && gimage && lp);
SET_SENSITIVE ("Scale Layer...", !ac && gimage && lp);
SET_SENSITIVE ("Merge Visible Layers...", !fs && !ac && gimage && lp);
SET_SENSITIVE ("Merge Down", !fs && !ac && gimage && lp && next);
SET_SENSITIVE ("Flatten Image", !fs && !ac && gimage && lp);
SET_SENSITIVE ("Add Layer Mask...",
!fs && !ac && gimage && !lm && lp && alpha && !indexed);
SET_SENSITIVE ("Apply Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("Delete Layer Mask", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("Mask to Selection", !fs && !ac && gimage && lm && lp);
SET_SENSITIVE ("Add Alpha Channel", !fs && !alpha);
SET_SENSITIVE ("Alpha to Selection", !fs && !ac && gimage && lp && alpha);
SET_SENSITIVE ("Edit Layer Attributes...", !fs && !ac && gimage && lp);
#undef SET_SENSITIVE
}