Gimp/app/tools/gimpvectortool.c

853 lines
30 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Vector tool
* Copyright (C) 2003 Simon Budig <simon@gimp.org>
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
devel-docs/Makefile.am new file documenting the core's include policy. 2002-05-03 Michael Natterer <mitch@gimp.org> * devel-docs/Makefile.am * devel-docs/includes.txt: new file documenting the core's include policy. * HACKING: mention it here. * libgimptool/gimptooltypes.h: removed GimpToolOptions here. * app/core/core-types.h: and added it here. This is a temp hack needed because GimpToolInfo needs to know the GimpToolOptions type. * libgimpproxy/gimpproxytypes.h: regenerated. * libgimptool/gimptoolmodule.h: don't include gimptooltypes.h here... * libgimptool/gimptoolmodule.c: ...but here. * app/config/gimpconfig-params.c: include "libgimpbase/gimpbase.h" entirely, not single files from it. * app/core/gimp.c * app/core/gimpcontext.c * app/core/gimpcoreconfig.c * app/core/gimpdatafactory.c * app/core/gimpdocuments.c * app/core/gimpdrawable-blend.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpdrawable-offset.c * app/core/gimpdrawable-transform.c * app/core/gimpdrawable.c * app/core/gimpedit.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-guides.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-new.c * app/core/gimpimage-projection.c * app/core/gimpimage-qmask.c * app/core/gimpimage-resize.c * app/core/gimpimage-scale.c * app/core/gimpimage.c * app/core/gimpitem.c * app/core/gimpmodules.c * app/core/gimppaintinfo.c * app/core/gimpparasite.c * app/core/gimppreviewcache.c * app/core/gimptoolinfo.c * app/core/gimpunit.c: include "core-types.h" and no other types file. * app/display/gimpdisplay.c * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell.c: include "tools/tools-types.h" instead of "libgimptool/gimptooltypes.h", warn about inclusion on "gui/gui-types.h" * app/file/file-open.c * app/file/file-save.c: don't include "libgimptool/gimptooltypes.h". * app/gui/about-dialog.c * app/gui/brush-select.c * app/gui/brushes-commands.c * app/gui/color-select.c * app/gui/data-commands.c * app/gui/device-status-dialog.c * app/gui/dialogs.c * app/gui/gradients-commands.c * app/gui/help-commands.c * app/gui/info-window.c * app/gui/palettes-commands.c * app/gui/patterns-commands.c * app/gui/resize-dialog.c * app/gui/tips-dialog.c * app/gui/tool-options-dialog.c: include "gui-types.h" and no other types file. * app/paint/gimpairbrush.c * app/paint/gimpclone.c * app/paint/gimpconvolve.c * app/paint/gimpdodgeburn.c * app/paint/gimperaser.c * app/paint/gimppaintbrush.c * app/paint/gimppaintcore-stroke.c * app/paint/gimppaintcore.c * app/paint/gimppaintoptions.c * app/paint/gimppencil.c * app/paint/gimpsmudge.c * app/paint/paint.c: include "paint-types.h" and no other types file. * app/pdb/pdb-types.h: don't include "libgimptool/gimptooltypes.h". * app/plug-in/plug-in-progress.c: warn about inclusion of "display/display-types.h" * app/tools/tools-types.h: include "libgimptool/gimptooltypes.h". * 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/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/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.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/gimppaintbrushtool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimppenciltool.c * app/tools/gimpperspectivetool.c * app/tools/gimpposterizetool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpselectiontool.c * app/tools/gimpsheartool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/gimptoolcontrol.c * app/tools/gimptoolcontrol.h * app/tools/gimptransformtool.c * app/tools/gimpvectortool.c * app/tools/tools.c: include "tools-types.h" and no other types file, warn about inclusion of "gui/gui-types.h". * app/widgets/gimpcolorpanel.c * app/widgets/gimptoolbox-color-area.c: warn about inclusion of "gui/gui-types.h". * app/xcf/xcf-load.c * app/xcf/xcf.c: don't include "libgimptool/gimptooltypes.h". Split tool-safe-mode up in two files, one including libgimpproxy, one libgimp. * plug-ins/tools/Makefile.am * plug-ins/tools/tool-safe-mode-plug-in.[ch]: new files including libgimp/ stuff only. * plug-ins/tools/tool-safe-mode.[ch]: include libgimpproxy/ and libgimptool/ but don't include libgimp/ because of conflicting declarations. Unrelated: * app/tools/gimpclonetool.c: create the clone core so we don't crash. * app/gui/file-open-dialog.c: changed the way we create previews so that only out-of-date previews are created on a click in the preview area. Unconditional creation can still be forced by <Ctrl>+click. Changed the tooltip to document this.
2002-05-03 05:45:22 -07:00
#include "tools-types.h"
#include "config/gimpdialogconfig.h"
#include "core/gimp.h"
#include "core/gimpimage.h"
#include "core/gimpimage-pick-item.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage-undo-push.h"
#include "core/gimptoolinfo.h"
#include "core/gimpundostack.h"
#include "paint/gimppaintoptions.h" /* GIMP_PAINT_OPTIONS_CONTEXT_MASK */
#include "vectors/gimpvectors.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimptoolpath.h"
#include "gimptoolcontrol.h"
Made GimpToolOptions a GimpContext subclass and objectified all tool 2003-02-05 Michael Natterer <mitch@gimp.org> Made GimpToolOptions a GimpContext subclass and objectified all tool options types. * app/core/core-types.h: replaced GimpToolOptionsNewFunc by GimpToolOptionsGUIFunc. * libgimpproxy/gimpproxytypes.h: regenerated. * app/core/gimppaintinfo.[ch]: added "GType paint_options_type". * app/core/gimptoolinfo.[ch]: added "GType tool_options_type", removed tool_info->context since GimpToolOptions are a GimpContext now. Added "gboolean use_context" as a temp_hack. * libgimptool/gimptooltypes.h: added the tool_options_type to the tool registering callback. * app/tools/tool_options.[ch]: is a real GimpContext subclass now. * app/paint/paint-types.h * app/paint/paint.c: added the paint_options_type to the paint registering stuff. * app/paint/gimppaintoptions.[ch]: is a real GimpToolOptions subclass now. * app/paint/Makefile.am * app/paint/gimpairbrushoptions.[ch] * app/paint/gimpcloneoptions.[ch] * app/paint/gimpconvolveoptions.[ch] * app/paint/gimpdodgeburnoptions.[ch] * app/paint/gimperaseroptions.[ch] * app/paint/gimpsmudgeoptions.[ch]: new files holding GimpPaintOptions subclasses. * app/paint/gimpairbrush.[ch] * app/paint/gimpclone.[ch] * app/paint/gimpconvolve.[ch] * app/paint/gimpdodgeburn.[ch] * app/paint/gimperaser.[ch] * app/paint/gimppaintbrush.c * app/paint/gimppaintcore.c * app/paint/gimppencil.[ch] * app/paint/gimpsmudge.[ch]: removed paint options stuff, lots of related changed & cleanups. * tools/pdbgen/pdb/paint_tools.pdb: changed accordingly. * app/pdb/paint_tools_cmds.c: regenerated. * app/tools/Makefile.am * app/tools/gimpblendoptions.[ch] * app/tools/gimpbucketfilloptions.[ch] * app/tools/gimpcolorpickeroptions.[ch] * app/tools/gimpcropoptions.[ch] * app/tools/gimpflipoptions.[ch] * app/tools/gimpinkoptions.[ch] * app/tools/gimpmagnifyoptions.[ch] * app/tools/gimpmeasureoptions.[ch] * app/tools/gimpmoveoptions.[ch] * app/tools/gimptextoptions.[ch] * app/tools/gimpvectoroptions.[ch]: new files holding the various tool options classes. * app/tools/selection_options.[ch] * app/tools/transform_options.[ch]: made them objects. * app/tools/paint_options.[ch]: contains only the paint_options GUI and reset stuff. * app/tools/tools-types.h: removed SelectionOptions typedef for now. * app/tools/[all tools]: removed the tool options stuff except some GUI constructors. Tons of related changes. * app/tools/tool_manager.[ch]: changed tool registration / restore / switching accordingly. * app/widgets/gimpdrawablelistview.c * app/widgets/gimpselectioneditor.c: changed accordingly.
2003-02-05 06:39:40 -08:00
#include "gimpvectoroptions.h"
#include "gimpvectortool.h"
#include "dialogs/fill-dialog.h"
configure.in added new directory app/dialogs and link libappdialogs.c into 2004-09-13 Michael Natterer <mitch@gimp.org> * configure.in * app/Makefile.am: added new directory app/dialogs and link libappdialogs.c into the gimp binary. * app/gui/Makefile.am * app/gui/gui-types.h * app/gui/gui-vtable.c * app/gui/gui.c * app/gui/about-dialog.[ch] * app/gui/authors.h * app/gui/color-notebook.[ch] * app/gui/convert-dialog.[ch] * app/gui/dialogs-constructors.[ch] * app/gui/dialogs.[ch] * app/gui/file-dialog-utils.[ch] * app/gui/file-new-dialog.[ch] * app/gui/file-open-dialog.[ch] * app/gui/file-open-location-dialog.[ch] * app/gui/file-save-dialog.[ch] * app/gui/grid-dialog.[ch] * app/gui/info-dialog.[ch] * app/gui/info-window.[ch] * app/gui/module-browser.[ch] * app/gui/offset-dialog.[ch] * app/gui/palette-import-dialog.[ch] * app/gui/preferences-dialog.[ch] * app/gui/quit-dialog.[ch] * app/gui/resize-dialog.[ch] * app/gui/resolution-calibrate-dialog.[ch] * app/gui/stroke-dialog.[ch] * app/gui/tips-dialog.[ch] * app/gui/tips-parser.[ch] * app/gui/user-install-dialog.[ch]: removed these files... * app/dialogs/Makefile.am * app/dialogs/dialogs-types.h * app/dialogs/*.[ch]: ...and added them here. Changed some filenames like module-browser -> module-dialog. * app/app_procs.c * app/actions/actions-types.h * app/actions/actions.c * app/actions/dialogs-actions.c * app/actions/dialogs-commands.c * app/actions/dockable-commands.c * app/actions/drawable-commands.c * app/actions/edit-commands.c * app/actions/file-commands.c * app/actions/gradient-editor-commands.c * app/actions/image-commands.c * app/actions/layers-commands.c * app/actions/palettes-commands.c * app/actions/select-commands.c * app/actions/templates-commands.c * app/actions/templates-commands.h * app/actions/vectors-commands.c * app/actions/view-commands.c * app/display/gimpdisplayshell-cursor.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell.[ch] * app/tools/gimpcroptool.c * app/tools/gimpperspectivetool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpsheartool.c * app/tools/gimptransformtool.[ch] * app/tools/gimpvectortool.c * app/widgets/gimpcolormapeditor.[ch] * app/widgets/gimpcolorpanel.c * app/widgets/gimpgradienteditor.[ch] * app/widgets/gimppaletteeditor.[ch] * app/widgets/gimptoolbox-color-area.c * menus/toolbox-menu.xml.in * tools/authorsgen/authorsgen.pl: changed accordingly.
2004-09-13 08:15:23 -07:00
#include "dialogs/stroke-dialog.h"
#include "gimp-intl.h"
#define TOGGLE_MASK gimp_get_extend_selection_mask ()
#define MOVE_MASK GDK_MOD1_MASK
#define INSDEL_MASK gimp_get_toggle_behavior_mask ()
/* local function prototypes */
Made GimpToolOptions a GimpContext subclass and objectified all tool 2003-02-05 Michael Natterer <mitch@gimp.org> Made GimpToolOptions a GimpContext subclass and objectified all tool options types. * app/core/core-types.h: replaced GimpToolOptionsNewFunc by GimpToolOptionsGUIFunc. * libgimpproxy/gimpproxytypes.h: regenerated. * app/core/gimppaintinfo.[ch]: added "GType paint_options_type". * app/core/gimptoolinfo.[ch]: added "GType tool_options_type", removed tool_info->context since GimpToolOptions are a GimpContext now. Added "gboolean use_context" as a temp_hack. * libgimptool/gimptooltypes.h: added the tool_options_type to the tool registering callback. * app/tools/tool_options.[ch]: is a real GimpContext subclass now. * app/paint/paint-types.h * app/paint/paint.c: added the paint_options_type to the paint registering stuff. * app/paint/gimppaintoptions.[ch]: is a real GimpToolOptions subclass now. * app/paint/Makefile.am * app/paint/gimpairbrushoptions.[ch] * app/paint/gimpcloneoptions.[ch] * app/paint/gimpconvolveoptions.[ch] * app/paint/gimpdodgeburnoptions.[ch] * app/paint/gimperaseroptions.[ch] * app/paint/gimpsmudgeoptions.[ch]: new files holding GimpPaintOptions subclasses. * app/paint/gimpairbrush.[ch] * app/paint/gimpclone.[ch] * app/paint/gimpconvolve.[ch] * app/paint/gimpdodgeburn.[ch] * app/paint/gimperaser.[ch] * app/paint/gimppaintbrush.c * app/paint/gimppaintcore.c * app/paint/gimppencil.[ch] * app/paint/gimpsmudge.[ch]: removed paint options stuff, lots of related changed & cleanups. * tools/pdbgen/pdb/paint_tools.pdb: changed accordingly. * app/pdb/paint_tools_cmds.c: regenerated. * app/tools/Makefile.am * app/tools/gimpblendoptions.[ch] * app/tools/gimpbucketfilloptions.[ch] * app/tools/gimpcolorpickeroptions.[ch] * app/tools/gimpcropoptions.[ch] * app/tools/gimpflipoptions.[ch] * app/tools/gimpinkoptions.[ch] * app/tools/gimpmagnifyoptions.[ch] * app/tools/gimpmeasureoptions.[ch] * app/tools/gimpmoveoptions.[ch] * app/tools/gimptextoptions.[ch] * app/tools/gimpvectoroptions.[ch]: new files holding the various tool options classes. * app/tools/selection_options.[ch] * app/tools/transform_options.[ch]: made them objects. * app/tools/paint_options.[ch]: contains only the paint_options GUI and reset stuff. * app/tools/tools-types.h: removed SelectionOptions typedef for now. * app/tools/[all tools]: removed the tool options stuff except some GUI constructors. Tons of related changes. * app/tools/tool_manager.[ch]: changed tool registration / restore / switching accordingly. * app/widgets/gimpdrawablelistview.c * app/widgets/gimpselectioneditor.c: changed accordingly.
2003-02-05 06:39:40 -08:00
static void gimp_vector_tool_dispose (GObject *object);
static void gimp_vector_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
static void gimp_vector_tool_button_press (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonPressType press_type,
GimpDisplay *display);
static void gimp_vector_tool_button_release (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display);
static void gimp_vector_tool_motion (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_vector_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_vector_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_vector_tool_start (GimpVectorTool *vector_tool,
GimpDisplay *display);
static void gimp_vector_tool_halt (GimpVectorTool *vector_tool);
static void gimp_vector_tool_path_changed (GimpToolWidget *path,
GimpVectorTool *vector_tool);
static void gimp_vector_tool_path_begin_change
(GimpToolWidget *path,
const gchar *desc,
GimpVectorTool *vector_tool);
static void gimp_vector_tool_path_end_change (GimpToolWidget *path,
gboolean success,
GimpVectorTool *vector_tool);
static void gimp_vector_tool_path_activate (GimpToolWidget *path,
GdkModifierType state,
GimpVectorTool *vector_tool);
static void gimp_vector_tool_vectors_changed (GimpImage *image,
GimpVectorTool *vector_tool);
static void gimp_vector_tool_vectors_removed (GimpVectors *vectors,
GimpVectorTool *vector_tool);
static void gimp_vector_tool_to_selection (GimpVectorTool *vector_tool);
static void gimp_vector_tool_to_selection_extended
(GimpVectorTool *vector_tool,
GdkModifierType state);
static void gimp_vector_tool_fill_vectors (GimpVectorTool *vector_tool,
GtkWidget *button);
static void gimp_vector_tool_fill_callback (GtkWidget *dialog,
GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpFillOptions *options,
gpointer data);
static void gimp_vector_tool_stroke_vectors (GimpVectorTool *vector_tool,
GtkWidget *button);
static void gimp_vector_tool_stroke_callback (GtkWidget *dialog,
GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpStrokeOptions *options,
gpointer data);
Treat changes to the selection like changes to any other drawable: 2003-10-06 Michael Natterer <mitch@gimp.org> Treat changes to the selection like changes to any other drawable: * app/core/gimpchannel.c * app/core/gimpchannel-combine.c: call gimp_drawable_update() after changing the channel. * app/core/gimpimage.[ch]: added struct GimpImageFlushAccumulator with one member "gboolean mask_changed". Connect to "update" of the selection and set accum.mask_changed to TRUE in the callback. Added default implementation for GimpImage::flush() and emit "mask_changed" there. Unrelated: * app/core/gimpimage.h: removed GimpGuide struct... * app/core/gimpimage-guides.h: ...and added it here. * app/core/gimpimage-undo-push.c (undo_pop_mask) (undo_pop_channel_mod): don't distinguish between selection and non-selection channels and just call gimp_drawable_update(). * app/core/gimpundo.h * app/core/gimpimage-undo.c: removed "gboolean mask_changed" from the GimpUndoAccumulator struct since we don't have to care about that signal explicitly any more. * app/display/gimpdisplay-foreach.[ch]: removed gimp_displays_flush(). * tools/pdbgen/pdb/display.pdb (displays_flush_invoker): call gimp_image_flush() on all images so the flush accumulator is honored. This generalization enables the removal of more special purpose code which was needed to treat the selection different: * app/core/gimpimage-mask-select.[ch]: removed... * app/core/gimpchannel-select.[ch]: ...and added under a new name because it's not selection specific any more. * app/core/gimpimage-mask.[ch]: removed... * app/core/gimpselection.[ch]: ...added the two remaining functions here. Removed all calls to gimp_image_mask_changed(). * app/core/Makefile.am * app/core/gimp-edit.c * app/core/gimpdrawable-transform.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/display/gimpdisplayshell.c * app/gui/channels-commands.c * app/gui/layers-commands.c * app/gui/select-commands.c * app/gui/vectors-commands.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimprectselecttool.c * app/tools/gimptransformtool.c * app/widgets/gimpchanneltreeview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/paths.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/selection_tools.pdb: changed accordingly. * app/core/gimpdrawable-bucket-fill.c * app/core/gimpimage-colormap.c * app/core/gimplayer-floating-sel.c * app/core/gimplayer.c * app/gui/image-menu.c * app/paint/gimppaintcore.c * app/tools/gimpcroptool.c * app/tools/gimpinkoptions.c * app/tools/gimpvectortool.c: removed useless and/or obsolete #includes. * app/pdb/display_cmds.c * app/pdb/paths_cmds.c * app/pdb/selection_cmds.c * app/pdb/selection_tools_cmds.c: regenerated.
2003-10-06 05:17:11 -07:00
G_DEFINE_TYPE (GimpVectorTool, gimp_vector_tool, GIMP_TYPE_DRAW_TOOL)
#define parent_class gimp_vector_tool_parent_class
void
gimp_vector_tool_register (GimpToolRegisterCallback callback,
gpointer data)
{
2002-03-28 19:50:29 -08:00
(* callback) (GIMP_TYPE_VECTOR_TOOL,
Made GimpToolOptions a GimpContext subclass and objectified all tool 2003-02-05 Michael Natterer <mitch@gimp.org> Made GimpToolOptions a GimpContext subclass and objectified all tool options types. * app/core/core-types.h: replaced GimpToolOptionsNewFunc by GimpToolOptionsGUIFunc. * libgimpproxy/gimpproxytypes.h: regenerated. * app/core/gimppaintinfo.[ch]: added "GType paint_options_type". * app/core/gimptoolinfo.[ch]: added "GType tool_options_type", removed tool_info->context since GimpToolOptions are a GimpContext now. Added "gboolean use_context" as a temp_hack. * libgimptool/gimptooltypes.h: added the tool_options_type to the tool registering callback. * app/tools/tool_options.[ch]: is a real GimpContext subclass now. * app/paint/paint-types.h * app/paint/paint.c: added the paint_options_type to the paint registering stuff. * app/paint/gimppaintoptions.[ch]: is a real GimpToolOptions subclass now. * app/paint/Makefile.am * app/paint/gimpairbrushoptions.[ch] * app/paint/gimpcloneoptions.[ch] * app/paint/gimpconvolveoptions.[ch] * app/paint/gimpdodgeburnoptions.[ch] * app/paint/gimperaseroptions.[ch] * app/paint/gimpsmudgeoptions.[ch]: new files holding GimpPaintOptions subclasses. * app/paint/gimpairbrush.[ch] * app/paint/gimpclone.[ch] * app/paint/gimpconvolve.[ch] * app/paint/gimpdodgeburn.[ch] * app/paint/gimperaser.[ch] * app/paint/gimppaintbrush.c * app/paint/gimppaintcore.c * app/paint/gimppencil.[ch] * app/paint/gimpsmudge.[ch]: removed paint options stuff, lots of related changed & cleanups. * tools/pdbgen/pdb/paint_tools.pdb: changed accordingly. * app/pdb/paint_tools_cmds.c: regenerated. * app/tools/Makefile.am * app/tools/gimpblendoptions.[ch] * app/tools/gimpbucketfilloptions.[ch] * app/tools/gimpcolorpickeroptions.[ch] * app/tools/gimpcropoptions.[ch] * app/tools/gimpflipoptions.[ch] * app/tools/gimpinkoptions.[ch] * app/tools/gimpmagnifyoptions.[ch] * app/tools/gimpmeasureoptions.[ch] * app/tools/gimpmoveoptions.[ch] * app/tools/gimptextoptions.[ch] * app/tools/gimpvectoroptions.[ch]: new files holding the various tool options classes. * app/tools/selection_options.[ch] * app/tools/transform_options.[ch]: made them objects. * app/tools/paint_options.[ch]: contains only the paint_options GUI and reset stuff. * app/tools/tools-types.h: removed SelectionOptions typedef for now. * app/tools/[all tools]: removed the tool options stuff except some GUI constructors. Tons of related changes. * app/tools/tool_manager.[ch]: changed tool registration / restore / switching accordingly. * app/widgets/gimpdrawablelistview.c * app/widgets/gimpselectioneditor.c: changed accordingly.
2003-02-05 06:39:40 -08:00
GIMP_TYPE_VECTOR_OPTIONS,
gimp_vector_options_gui,
GIMP_PAINT_OPTIONS_CONTEXT_MASK |
GIMP_CONTEXT_PROP_MASK_PATTERN |
GIMP_CONTEXT_PROP_MASK_GRADIENT, /* for stroking */
"gimp-vector-tool",
_("Paths"),
2006-09-18 11:00:22 -07:00
_("Paths Tool: Create and edit paths"),
N_("Pat_hs"), "b",
NULL, GIMP_HELP_TOOL_PATH,
GIMP_ICON_TOOL_PATH,
app/tools/gimpairbrushtool.[ch] app/tools/gimpbezierselecttool.[ch] 2002-05-03 Sven Neumann <sven@gimp.org> * app/tools/gimpairbrushtool.[ch] * app/tools/gimpbezierselecttool.[ch] * app/tools/gimpblendtool.[ch] * app/tools/gimpbrightnesscontrasttool.[ch] * app/tools/gimpbucketfilltool[.ch] * app/tools/gimpbycolorselecttool[.ch] * app/tools/gimpclonetool[.ch] * app/tools/gimpcolorbalancetool[.ch] * app/tools/gimpcolorpickertool[.ch] * app/tools/gimpconvolvetool[.ch] * app/tools/gimpcroptool[.ch] * app/tools/gimpcurvestool[.ch] * app/tools/gimpdodgeburntool[.ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool[.ch] * app/tools/gimperasertool[.ch] * app/tools/gimpfliptool[.ch] * app/tools/gimpfreeselecttool[.ch] * app/tools/gimpfuzzyselecttool[.ch] * app/tools/gimphistogramtool[.ch] * app/tools/gimphuesaturationtool[.ch] * app/tools/gimpinktool[.ch] * app/tools/gimpiscissorstool[.ch] * app/tools/gimplevelstool[.ch] * app/tools/gimpmagnifytool[.ch] * app/tools/gimpmeasuretool[.ch] * app/tools/gimpmovetool[.ch] * app/tools/gimppaintbrushtool[.ch] * app/tools/gimppainttool.c * app/tools/gimppathtool[.ch] * app/tools/gimppenciltool[.ch] * app/tools/gimpperspectivetool[.ch] * app/tools/gimpposterizetool[.ch] * app/tools/gimprectselecttool[.ch] * app/tools/gimprotatetool[.ch] * app/tools/gimpscaletool[.ch] * app/tools/gimpselectiontool.c * app/tools/gimpsheartool[.ch] * app/tools/gimpsmudgetool[.ch] * app/tools/gimptexttool[.ch] * app/tools/gimpthresholdtool[.ch] * app/tools/gimptool.c * app/tools/gimptoolcontrol.h * app/tools/gimptoolmodule[.ch] * app/tools/gimptransformtool.c * app/tools/gimpvectortool[.ch] * app/tools/path_tool.c * app/tools/tool_manager[.ch] * app/tools/tools.c * libgimptool/gimptool.c * libgimptool/gimptoolcontrol.h * libgimptool/gimptoolmodule.h: removed tons of warnings. Do we need to add -Werror to the CFLAGS to avoid such a mess in the future ?! Also had to enforce the GIMP coding style in lots of places :-( * libgimp/gimppixelrgn.c: got sick and tired of debugging plug-ins, so I've added checks for most parameters passed to the GimpPixelRgn functions. This will slow down plug-in execution a little bit but should help to find bugs early.
2002-05-03 04:31:08 -07:00
data);
}
static void
gimp_vector_tool_class_init (GimpVectorToolClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
object_class->dispose = gimp_vector_tool_dispose;
tool_class->control = gimp_vector_tool_control;
tool_class->button_press = gimp_vector_tool_button_press;
tool_class->button_release = gimp_vector_tool_button_release;
tool_class->motion = gimp_vector_tool_motion;
tool_class->modifier_key = gimp_vector_tool_modifier_key;
tool_class->cursor_update = gimp_vector_tool_cursor_update;
}
static void
gimp_vector_tool_init (GimpVectorTool *vector_tool)
{
GimpTool *tool = GIMP_TOOL (vector_tool);
gimp_tool_control_set_handle_empty_image (tool->control, TRUE);
Bug 496772 – Position shown in the statusbar needs more precision (for 2008-08-20 Michael Natterer <mitch@gimp.org> Bug 496772 – Position shown in the statusbar needs more precision (for some tools) * app/display/display-enums.[ch]: add enum GimpCursorPrecision which can be one of { PIXEL_CENTER, PIXEL_BORDER, SUBPIXEL }. * app/display/gimpdisplayshell-cursor.[ch]: add "precision" parameter to gimp_display_shell_update_cursor() and pass it on to the statusbar. * app/display/gimpstatusbar.[ch]: add "precision" parameters to the cursor coordinates APIs, offset the passed coords accordingly and display them with one decimal point if SUBPIXEL is requested and the display's unit is PIXEL. Keep a second floating-point format string around at any time. * app/tools/gimptoolcontrol.[ch]: add a "precision" member and API so tools can configure the precision they need. Defalt to PIXEL_CENTER since that's right for almost all tools. * app/display/gimpdisplayshell-callbacks.c: pass the tool's precision to gimp_display_shell_update_cursor(). * app/tools/gimptool.[ch]: add "precision" parameter to gimp_tool_push_status_coords() and pass it on to the statusbar. * app/tools/gimpaligntool.c * app/tools/gimpblendtool.c * app/tools/gimpcolortool.c * app/tools/gimpcroptool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfliptool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimptransformtool.c * app/tools/gimpvectortool.c: set precision in init() where needed. Adjust the precision in the fly when needed, e.g. while moving guides or when toggling hard-edge on paint tools. Also pass an appropriate precision to gimp_tool_push_status_coords(), which is not always the tool's precision as used for cursor display. svn path=/trunk/; revision=26681
2008-08-20 09:22:09 -07:00
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_SUBPIXEL);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_PATHS);
vector_tool->saved_mode = GIMP_VECTOR_MODE_DESIGN;
}
static void
gimp_vector_tool_dispose (GObject *object)
{
GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (object);
gimp_vector_tool_set_vectors (vector_tool, NULL);
g_clear_object (&vector_tool->widget);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gimp_vector_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display)
{
GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (tool);
switch (action)
{
case GIMP_TOOL_ACTION_PAUSE:
case GIMP_TOOL_ACTION_RESUME:
break;
case GIMP_TOOL_ACTION_HALT:
gimp_vector_tool_halt (vector_tool);
break;
case GIMP_TOOL_ACTION_COMMIT:
break;
}
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
}
static void
gimp_vector_tool_button_press (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonPressType press_type,
GimpDisplay *display)
{
GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (tool);
if (tool->display && display != tool->display)
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, tool->display);
if (! tool->display)
{
gimp_vector_tool_start (vector_tool, display);
gimp_tool_widget_hover (vector_tool->widget, coords, state, TRUE);
}
if (gimp_tool_widget_button_press (vector_tool->widget, coords, time, state,
press_type))
{
vector_tool->grab_widget = vector_tool->widget;
}
gimp_tool_control_activate (tool->control);
}
static void
gimp_vector_tool_button_release (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display)
{
GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (tool);
gimp_tool_control_halt (tool->control);
if (vector_tool->grab_widget)
{
gimp_tool_widget_button_release (vector_tool->grab_widget,
coords, time, state, release_type);
vector_tool->grab_widget = NULL;
}
}
static void
gimp_vector_tool_motion (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
{
GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (tool);
if (vector_tool->grab_widget)
{
gimp_tool_widget_motion (vector_tool->grab_widget, coords, time, state);
}
}
static void
gimp_vector_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display)
{
GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (tool);
GimpVectorOptions *options = GIMP_VECTOR_TOOL_GET_OPTIONS (tool);
if (key == TOGGLE_MASK)
return;
if (key == INSDEL_MASK || key == MOVE_MASK)
{
GimpVectorMode button_mode = options->edit_mode;
if (press)
{
if (key == (state & (INSDEL_MASK | MOVE_MASK)))
{
/* first modifier pressed */
vector_tool->saved_mode = options->edit_mode;
}
}
else
{
if (! (state & (INSDEL_MASK | MOVE_MASK)))
{
/* last modifier released */
button_mode = vector_tool->saved_mode;
}
}
if (state & MOVE_MASK)
{
button_mode = GIMP_VECTOR_MODE_MOVE;
}
else if (state & INSDEL_MASK)
{
button_mode = GIMP_VECTOR_MODE_EDIT;
}
if (button_mode != options->edit_mode)
{
g_object_set (options, "vectors-edit-mode", button_mode, NULL);
}
}
}
static void
gimp_vector_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display)
{
GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (tool);
GimpDisplayShell *shell = gimp_display_get_shell (display);
if (display != tool->display || ! vector_tool->widget)
{
GimpToolCursorType tool_cursor = GIMP_TOOL_CURSOR_PATHS;
if (gimp_image_pick_vectors (gimp_display_get_image (display),
coords->x, coords->y,
FUNSCALEX (shell,
GIMP_TOOL_HANDLE_SIZE_CIRCLE / 2),
FUNSCALEY (shell,
GIMP_TOOL_HANDLE_SIZE_CIRCLE / 2)))
{
tool_cursor = GIMP_TOOL_CURSOR_HAND;
}
gimp_tool_control_set_tool_cursor (tool->control, tool_cursor);
}
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
}
static void
gimp_vector_tool_start (GimpVectorTool *vector_tool,
GimpDisplay *display)
{
GimpTool *tool = GIMP_TOOL (vector_tool);
GimpVectorOptions *options = GIMP_VECTOR_TOOL_GET_OPTIONS (tool);
GimpDisplayShell *shell = gimp_display_get_shell (display);
GimpToolWidget *widget;
tool->display = display;
vector_tool->widget = widget = gimp_tool_path_new (shell);
gimp_draw_tool_set_widget (GIMP_DRAW_TOOL (tool), widget);
g_object_bind_property (G_OBJECT (options), "vectors-edit-mode",
G_OBJECT (widget), "edit-mode",
G_BINDING_SYNC_CREATE |
G_BINDING_BIDIRECTIONAL);
g_object_bind_property (G_OBJECT (options), "vectors-polygonal",
G_OBJECT (widget), "polygonal",
G_BINDING_SYNC_CREATE |
G_BINDING_BIDIRECTIONAL);
gimp_tool_path_set_vectors (GIMP_TOOL_PATH (widget),
vector_tool->vectors);
g_signal_connect (widget, "changed",
G_CALLBACK (gimp_vector_tool_path_changed),
vector_tool);
g_signal_connect (widget, "begin-change",
G_CALLBACK (gimp_vector_tool_path_begin_change),
vector_tool);
g_signal_connect (widget, "end-change",
G_CALLBACK (gimp_vector_tool_path_end_change),
vector_tool);
g_signal_connect (widget, "activate",
G_CALLBACK (gimp_vector_tool_path_activate),
vector_tool);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
}
static void
gimp_vector_tool_halt (GimpVectorTool *vector_tool)
{
GimpTool *tool = GIMP_TOOL (vector_tool);
if (tool->display)
gimp_tool_pop_status (tool, tool->display);
gimp_vector_tool_set_vectors (vector_tool, NULL);
if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tool)))
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
gimp_draw_tool_set_widget (GIMP_DRAW_TOOL (tool), NULL);
g_clear_object (&vector_tool->widget);
tool->display = NULL;
}
static void
gimp_vector_tool_path_changed (GimpToolWidget *path,
GimpVectorTool *vector_tool)
{
GimpDisplayShell *shell = gimp_tool_widget_get_shell (path);
GimpImage *image = gimp_display_get_image (shell->display);
GimpVectors *vectors;
g_object_get (path,
"vectors", &vectors,
NULL);
if (vectors != vector_tool->vectors)
{
if (vectors && ! gimp_item_is_attached (GIMP_ITEM (vectors)))
{
gimp_image_add_vectors (image, vectors,
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
gimp_image_flush (image);
gimp_vector_tool_set_vectors (vector_tool, vectors);
}
else
{
gimp_vector_tool_set_vectors (vector_tool, vectors);
if (vectors)
gimp_image_set_active_vectors (image, vectors);
}
}
if (vectors)
g_object_unref (vectors);
}
static void
gimp_vector_tool_path_begin_change (GimpToolWidget *path,
const gchar *desc,
GimpVectorTool *vector_tool)
{
GimpDisplayShell *shell = gimp_tool_widget_get_shell (path);
GimpImage *image = gimp_display_get_image (shell->display);
gimp_image_undo_push_vectors_mod (image, desc, vector_tool->vectors);
}
static void
gimp_vector_tool_path_end_change (GimpToolWidget *path,
gboolean success,
GimpVectorTool *vector_tool)
{
GimpDisplayShell *shell = gimp_tool_widget_get_shell (path);
GimpImage *image = gimp_display_get_image (shell->display);
if (! success)
{
GimpUndo *undo;
GimpUndoAccumulator accum = { 0, };
undo = gimp_undo_stack_pop_undo (gimp_image_get_undo_stack (image),
GIMP_UNDO_MODE_UNDO, &accum);
gimp_image_undo_event (image, GIMP_UNDO_EVENT_UNDO_EXPIRED, undo);
gimp_undo_free (undo, GIMP_UNDO_MODE_UNDO);
g_object_unref (undo);
}
gimp_image_flush (image);
}
static void
gimp_vector_tool_path_activate (GimpToolWidget *path,
GdkModifierType state,
GimpVectorTool *vector_tool)
{
gimp_vector_tool_to_selection_extended (vector_tool, state);
}
static void
gimp_vector_tool_vectors_changed (GimpImage *image,
GimpVectorTool *vector_tool)
{
gimp_vector_tool_set_vectors (vector_tool,
gimp_image_get_active_vectors (image));
}
static void
gimp_vector_tool_vectors_removed (GimpVectors *vectors,
GimpVectorTool *vector_tool)
{
gimp_vector_tool_set_vectors (vector_tool, NULL);
}
void
gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
GimpVectors *vectors)
{
GimpTool *tool;
GimpItem *item = NULL;
GimpVectorOptions *options;
g_return_if_fail (GIMP_IS_VECTOR_TOOL (vector_tool));
g_return_if_fail (vectors == NULL || GIMP_IS_VECTORS (vectors));
tool = GIMP_TOOL (vector_tool);
options = GIMP_VECTOR_TOOL_GET_OPTIONS (vector_tool);
if (vectors)
item = GIMP_ITEM (vectors);
if (vectors == vector_tool->vectors)
return;
if (vector_tool->vectors)
{
GimpImage *old_image;
old_image = gimp_item_get_image (GIMP_ITEM (vector_tool->vectors));
g_signal_handlers_disconnect_by_func (old_image,
gimp_vector_tool_vectors_changed,
vector_tool);
g_signal_handlers_disconnect_by_func (vector_tool->vectors,
gimp_vector_tool_vectors_removed,
vector_tool);
g_clear_object (&vector_tool->vectors);
if (options->to_selection_button)
{
gtk_widget_set_sensitive (options->to_selection_button, FALSE);
g_signal_handlers_disconnect_by_func (options->to_selection_button,
gimp_vector_tool_to_selection,
tool);
g_signal_handlers_disconnect_by_func (options->to_selection_button,
gimp_vector_tool_to_selection_extended,
tool);
}
if (options->fill_button)
{
gtk_widget_set_sensitive (options->fill_button, FALSE);
g_signal_handlers_disconnect_by_func (options->fill_button,
gimp_vector_tool_fill_vectors,
tool);
}
if (options->stroke_button)
{
gtk_widget_set_sensitive (options->stroke_button, FALSE);
g_signal_handlers_disconnect_by_func (options->stroke_button,
gimp_vector_tool_stroke_vectors,
tool);
}
}
if (! vectors ||
(tool->display &&
gimp_display_get_image (tool->display) != gimp_item_get_image (item)))
{
gimp_vector_tool_halt (vector_tool);
}
if (! vectors)
return;
vector_tool->vectors = g_object_ref (vectors);
g_signal_connect_object (gimp_item_get_image (item), "active-vectors-changed",
G_CALLBACK (gimp_vector_tool_vectors_changed),
vector_tool, 0);
g_signal_connect_object (vectors, "removed",
G_CALLBACK (gimp_vector_tool_vectors_removed),
vector_tool, 0);
if (options->to_selection_button)
{
g_signal_connect_swapped (options->to_selection_button, "clicked",
G_CALLBACK (gimp_vector_tool_to_selection),
tool);
g_signal_connect_swapped (options->to_selection_button, "extended-clicked",
G_CALLBACK (gimp_vector_tool_to_selection_extended),
tool);
gtk_widget_set_sensitive (options->to_selection_button, TRUE);
}
if (options->fill_button)
{
g_signal_connect_swapped (options->fill_button, "clicked",
G_CALLBACK (gimp_vector_tool_fill_vectors),
tool);
gtk_widget_set_sensitive (options->fill_button, TRUE);
}
if (options->stroke_button)
{
g_signal_connect_swapped (options->stroke_button, "clicked",
G_CALLBACK (gimp_vector_tool_stroke_vectors),
tool);
gtk_widget_set_sensitive (options->stroke_button, TRUE);
}
if (tool->display)
{
gimp_tool_path_set_vectors (GIMP_TOOL_PATH (vector_tool->widget), vectors);
}
else
{
GimpContext *context = gimp_get_user_context (tool->tool_info->gimp);
GimpDisplay *display = gimp_context_get_display (context);
if (! display ||
gimp_display_get_image (display) != gimp_item_get_image (item))
{
GList *list;
display = NULL;
for (list = gimp_get_display_iter (gimp_item_get_image (item)->gimp);
list;
list = g_list_next (list))
{
display = list->data;
if (gimp_display_get_image (display) == gimp_item_get_image (item))
{
gimp_context_set_display (context, display);
break;
}
display = NULL;
}
}
if (display)
gimp_vector_tool_start (vector_tool, display);
}
if (options->edit_mode != GIMP_VECTOR_MODE_DESIGN)
g_object_set (options, "vectors-edit-mode",
GIMP_VECTOR_MODE_DESIGN, NULL);
}
static void
gimp_vector_tool_to_selection (GimpVectorTool *vector_tool)
{
gimp_vector_tool_to_selection_extended (vector_tool, 0);
}
static void
gimp_vector_tool_to_selection_extended (GimpVectorTool *vector_tool,
GdkModifierType state)
{
GimpImage *image;
if (! vector_tool->vectors)
return;
image = gimp_item_get_image (GIMP_ITEM (vector_tool->vectors));
gimp_item_to_selection (GIMP_ITEM (vector_tool->vectors),
gimp_modifiers_to_channel_op (state),
TRUE, FALSE, 0, 0);
gimp_image_flush (image);
}
static void
gimp_vector_tool_fill_vectors (GimpVectorTool *vector_tool,
GtkWidget *button)
{
GimpDialogConfig *config;
GimpImage *image;
GimpDrawable *drawable;
GtkWidget *dialog;
if (! vector_tool->vectors)
return;
image = gimp_item_get_image (GIMP_ITEM (vector_tool->vectors));
config = GIMP_DIALOG_CONFIG (image->gimp->config);
drawable = gimp_image_get_active_drawable (image);
if (! drawable)
{
gimp_tool_message (GIMP_TOOL (vector_tool),
GIMP_TOOL (vector_tool)->display,
_("There is no active layer or channel to fill"));
return;
}
dialog = fill_dialog_new (GIMP_ITEM (vector_tool->vectors),
drawable,
GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (vector_tool)),
_("Fill Path"),
GIMP_ICON_TOOL_BUCKET_FILL,
GIMP_HELP_PATH_FILL,
button,
config->fill_options,
gimp_vector_tool_fill_callback,
vector_tool);
gtk_widget_show (dialog);
}
static void
gimp_vector_tool_fill_callback (GtkWidget *dialog,
GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpFillOptions *options,
gpointer data)
{
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (context->gimp->config);
GimpImage *image = gimp_item_get_image (item);
GError *error = NULL;
gimp_config_sync (G_OBJECT (options),
G_OBJECT (config->fill_options), 0);
if (! gimp_item_fill (item, drawable, options,
TRUE, NULL, &error))
{
gimp_message_literal (context->gimp,
G_OBJECT (dialog),
GIMP_MESSAGE_WARNING,
error ? error->message : "NULL");
g_clear_error (&error);
return;
}
gimp_image_flush (image);
gtk_widget_destroy (dialog);
}
static void
gimp_vector_tool_stroke_vectors (GimpVectorTool *vector_tool,
GtkWidget *button)
{
GimpDialogConfig *config;
GimpImage *image;
GimpDrawable *drawable;
GtkWidget *dialog;
if (! vector_tool->vectors)
return;
image = gimp_item_get_image (GIMP_ITEM (vector_tool->vectors));
config = GIMP_DIALOG_CONFIG (image->gimp->config);
drawable = gimp_image_get_active_drawable (image);
if (! drawable)
{
Added message severities and make sure all messages are routed through a 2006-10-09 Michael Natterer <mitch@gimp.org> Added message severities and make sure all messages are routed through a central function, so redirecting to the error console or stderr work again: * app/core/core-enums.[ch]: added enum GimpMessageSeverity { INFO, WARNING, ERROR }. * app/core/gimp.[ch] (gimp_message) (gimp_message_valist): added severity parameter. Changed "GimpProgress *progress" parameter to "GObject *handler", where "handler" can be either a GimpProgress, a GtkWidget or NULL. * app/core/gimp-gui.[ch] (gimp_show_message): ditto. Honor --console-messages again. Always dispatch to the GUI message handler first if it exists. * app/gui/gui-message.[ch]: pass severity parameters around. (gui_message_error_dialog): if "handler" is a progress, dispatch the message to it first. If it is a widget (and *not* a progress), use a GtkMessageDialog on top of that widget's toplevel. Fall back to the usual GimpErrorDialog otherwise. * app/core/gimpprogress.[ch] (gimp_progress_message): added severity parameter. Also added boolean return value to the virtual function so it can decide to fail if it can't handle the message. * app/display/gimpdisplay.c: implement GimpProgress::message() and redirect the message to GimpDisplayShell. * app/display/gimpdisplayshell-progress.c: implement GimpProgress::message() and redirect the message to GimpStatusbar if it is not an error and if the status bar is visible. * app/display/gimpstatusbar.[ch]: implement GimpProgress::message(), but fail on messages that contain a newline. Show the right icons for the message severities (work in progress). * app/display/gimpdisplayshell.[ch]: removed gimp_display_shell_message() and its _valist() variant. * app/widgets/gimperrorconsole.[ch]: show the right icons for the message severities. * app/widgets/gimpthumbbox.c (gimp_thumb_box_progress_message): return TRUE to swallow all messages. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_show_message_dialog(). Added gimp_get_message_stock_id(). * app/errors.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/select-commands.c * app/actions/text-editor-commands.c * app/actions/vectors-commands.c * app/core/gimpimage-convert.c * app/core/gimpimagefile.c * app/dialogs/convert-dialog.c * app/dialogs/file-open-dialog.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/palette-import-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/pdb/gimppdb.c * app/plug-in/gimpplugin.c * app/tools/gimpimagemaptool.c * app/tools/gimptool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimppdbdialog.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/palette.pdb: added severity parameter to gimp_message() calls. Convert all calls to gimp_show_message_dialog() and gimp_display_shell_message() to gimp_message(). Also converted some more g_message() calls. * app/pdb/brush_cmds.c * app/pdb/gradient_cmds.c * app/pdb/image_cmds.c * app/pdb/message_cmds.c * app/pdb/palette_cmds.c: regenerated.
2006-10-09 01:17:22 -07:00
gimp_tool_message (GIMP_TOOL (vector_tool),
GIMP_TOOL (vector_tool)->display,
_("There is no active layer or channel to stroke to"));
return;
}
dialog = stroke_dialog_new (GIMP_ITEM (vector_tool->vectors),
drawable,
GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (vector_tool)),
_("Stroke Path"),
GIMP_ICON_PATH_STROKE,
GIMP_HELP_PATH_STROKE,
button,
config->stroke_options,
gimp_vector_tool_stroke_callback,
vector_tool);
gtk_widget_show (dialog);
}
static void
gimp_vector_tool_stroke_callback (GtkWidget *dialog,
GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpStrokeOptions *options,
gpointer data)
{
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (context->gimp->config);
GimpImage *image = gimp_item_get_image (item);
GError *error = NULL;
gimp_config_sync (G_OBJECT (options),
G_OBJECT (config->stroke_options), 0);
if (! gimp_item_stroke (item, drawable, context, options, NULL,
TRUE, NULL, &error))
{
gimp_message_literal (context->gimp,
G_OBJECT (dialog),
GIMP_MESSAGE_WARNING,
error ? error->message : "NULL");
g_clear_error (&error);
return;
}
gimp_image_flush (image);
gtk_widget_destroy (dialog);
}