gimp/app/tools/gimptexttool.c

1053 lines
32 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
1997-11-25 06:05:25 +08:00
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* GimpTextTool
* Copyright (C) 2002-2004 Sven Neumann <sven@gimp.org>
*
1997-11-25 06:05:25 +08:00
* 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.
1997-11-25 06:05:25 +08:00
*/
#include "config.h"
#include <stdio.h>
1997-11-25 06:05:25 +08:00
#include <stdlib.h>
#include <string.h>
#include <errno.h>
1999-05-05 06:18:13 +08:00
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include <gtk/gtk.h>
2005-01-26 03:11:26 +08:00
#include "libgimpconfig/gimpconfig.h"
Makefile.am configure.in added the new library below. 2001-01-24 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added the new library below. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.[ch] * libgimpwidgets/gimpcolorbutton.[ch] * libgimpwidgets/gimpdialog.[ch] * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimphelpui.[ch] * libgimpwidgets/gimppatheditor.[ch] * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpquerybox.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch] * libgimpwidgets/gimpwidgets.[ch] * libgimpwidgets/gimpwidgets.def * libgimpwidgets/gimpwidgetstypes.h: new shared library. Currently there are some ugly dependencies into libgimp. These will be removed and go to a "libgimpglue" library which will be a library for functions which share a common interface between plug-ins and the app but have different implementations. Include "libgimp/gimpunit.h" from "libgimpwidgets/gimpwidgetstypes.h" to simulate this upcoming separation. * libgimp/Makefile.am * libgimp/gimpchainbutton.[ch] * libgimp/gimpcolorarea.[ch] * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimpfileselection.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimppixmap.[ch] * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: removed from here. * libgimp/gimpui.h * libgimp/gimpuitypes.h * libgimp/makefile.mingw.in * libgimp/makefile.msc: changed accordingly. * app/[all ui files] * app/pdb/palette_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: #include "libgimpwidgets/gimpwidgets.h" and removed useless includes. * app/apptypes.h: #include "libgimpwidgets/gimpwidgetstypes.h" * app/Makefile.am * plug-ins/[all makefiles which link against libgimpui]: link against libgimpwidgets.la * po-libgimp/POTFILES.in: changed file locations.
2001-01-25 06:36:18 +08:00
#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 20:45:22 +08:00
#include "tools-types.h"
Finally landed the new GimpConfig based gimprc parser. It's not finished 2002-11-18 Sven Neumann <sven@gimp.org> Finally landed the new GimpConfig based gimprc parser. It's not finished yet but we need to start somewhere. This release removes the old gimprc.[ch] files. The gimprc format changes slightly, but the changes are minimal. The Preferences dialog is temporarily disabled since it still needs to be ported. If you are are afraid, stay away from CVS for a few days ;-) * app/Makefile.am * app/gimprc.[ch]: removed the old gimprc system. * app/base/Makefile.am * app/base/base-config.[ch]: removed these files in favor of config/gimpbaseconfig.[ch]. * app/core/Makefile.am * app/core/gimpcoreconfig.[ch]: removed these files in favor of config/gimpcoreconfig.[ch]. * app/config/Makefile.am * app/config/config-types.h: moved typedefs into this new file. * app/config/gimpbaseconfig.[ch] * app/config/gimpcoreconfig.[ch] * app/config/gimpdisplayconfig.[ch] * app/config/gimpguiconfig.[ch] * app/config/gimprc.[ch] * app/config/test-config.c: brought into shape for real use. * app/base/base-types.h: include config/config-types.h here. Added a global GimpBaseConfig *base_config variable to ease migration. * app/gui/Makefile.am: temporarily disabled the preferences dialog. * app/app_procs.c * app/undo.c * app/undo_history.c * app/base/base.[ch] * app/base/gimphistogram.c * app/base/pixel-processor.c * app/base/temp-buf.c * app/base/tile-cache.c * app/core/core-types.h * app/core/gimp-documents.c * app/core/gimp.c * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpcontext.c * app/core/gimpdrawable-transform.c * app/core/gimpimage-new.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpmodules.c * app/core/gimppattern.c * app/display/Makefile.am * app/display/gimpdisplay-handlers.c * app/display/gimpdisplay.[ch] * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-layer-select.c * app/display/gimpdisplayshell-render.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-selection.c * app/display/gimpdisplayshell.[ch] * app/display/gimpnavigationview.c * app/file/file-save.c * app/gui/device-status-dialog.c * app/gui/dialogs-constructors.c * app/gui/file-commands.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gui.c * app/gui/menus.c * app/gui/paths-dialog.c * app/gui/resize-dialog.c * app/gui/session.c * app/gui/test-commands.c * app/gui/tips-dialog.c * app/gui/tips-dialog.h * app/gui/user-install-dialog.c * app/gui/view-commands.c * app/paint/gimppaintcore.c * app/plug-in/plug-in.c * app/plug-in/plug-ins.c * app/tools/gimpbezierselecttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpinktool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimptexttool.[ch] * app/tools/selection_options.c * app/tools/tools.c * app/tools/transform_options.c * app/widgets/gimphelp.c * app/widgets/gimpitemfactory.c * app/widgets/gimpselectioneditor.c * app/xcf/xcf-load.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/transform_tools.pdb: use the new config system instead of the old gimprc stuff. * etc/gimprc.in * etc/gimprc_user.in: adapted to the new gimprc format. Will update the man-page later... * app/pdb/fileops_cmds.c * app/pdb/gimprc_cmds.c * app/pdb/image_cmds.c * app/pdb/layer_cmds.c * app/pdb/transform_tools_cmds.c * libgimp/gimpgimprc_pdb.c: regenerated.
2002-11-19 04:50:31 +08:00
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage-undo-push.h"
#include "core/gimplayer-floating-sel.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
#include "core/gimpundostack.h"
#include "text/gimptext.h"
#include "text/gimptext-vectors.h"
#include "text/gimptextlayer.h"
#include "text/gimptextundo.h"
#include "vectors/gimpvectors-warp.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimptexteditor.h"
#include "widgets/gimpviewabledialog.h"
#include "display/gimpdisplay.h"
#include "gimpeditselectiontool.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 22:39:40 +08:00
#include "gimptextoptions.h"
#include "gimptexttool.h"
#include "gimptoolcontrol.h"
#include "gimp-intl.h"
#define TEXT_UNDO_TIMEOUT 3
/* local function prototypes */
static GObject * gimp_text_tool_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_text_tool_dispose (GObject *object);
static void gimp_text_tool_finalize (GObject *object);
static void gimp_text_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
static void gimp_text_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_text_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_text_tool_connect (GimpTextTool *text_tool,
GimpTextLayer *layer,
GimpText *text);
static void gimp_text_tool_layer_notify (GimpTextLayer *layer,
GParamSpec *pspec,
GimpTextTool *text_tool);
static void gimp_text_tool_proxy_notify (GimpText *text,
GParamSpec *pspec,
GimpTextTool *text_tool);
static void gimp_text_tool_text_notify (GimpText *text,
GParamSpec *pspec,
GimpTextTool *text_tool);
static gboolean gimp_text_tool_idle_apply (GimpTextTool *text_tool);
static void gimp_text_tool_apply (GimpTextTool *text_tool);
static void gimp_text_tool_create_vectors (GimpTextTool *text_tool);
static void gimp_text_tool_create_vectors_warped
(GimpTextTool *text_tool);
static void gimp_text_tool_create_layer (GimpTextTool *text_tool,
GimpText *text);
static void gimp_text_tool_editor (GimpTextTool *text_tool);
static void gimp_text_tool_editor_update (GimpTextTool *text_tool);
static void gimp_text_tool_text_changed (GimpTextEditor *editor,
GimpTextTool *text_tool);
static void gimp_text_tool_layer_changed (GimpImage *image,
GimpTextTool *text_tool);
static void gimp_text_tool_set_image (GimpTextTool *text_tool,
GimpImage *image);
static gboolean gimp_text_tool_set_drawable (GimpTextTool *text_tool,
GimpDrawable *drawable,
gboolean confirm);
G_DEFINE_TYPE (GimpTextTool, gimp_text_tool, GIMP_TYPE_TOOL)
#define parent_class gimp_text_tool_parent_class
1997-11-25 06:05:25 +08:00
void
2002-03-29 11:50:29 +08:00
gimp_text_tool_register (GimpToolRegisterCallback callback,
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 19:31:08 +08:00
gpointer data)
{
2002-03-29 11:50:29 +08:00
(* callback) (GIMP_TYPE_TEXT_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 22:39:40 +08:00
GIMP_TYPE_TEXT_OPTIONS,
gimp_text_options_gui,
GIMP_CONTEXT_FOREGROUND_MASK | GIMP_CONTEXT_FONT_MASK,
./mitch --sanitize-identifier-namespace 2002-03-20 Michael Natterer <mitch@gimp.org> ./mitch --sanitize-identifier-namespace * app/core/gimpcontext.c * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-dnd.c * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/dialogs.c * app/gui/edit-commands.c * app/gui/gui.c * app/gui/menus.c * app/gui/vectors-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/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/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/gimpiscissorstool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppaintbrushtool.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/gimpsheartool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/gimpvectortool.c * app/widgets/gimpdnd.c * app/widgets/gimptoolbox-indicator-area.c * app/widgets/gimptoolbox.c: s/gimp:/gimp-/g and s/_/-/g for all identifier strings (e.g. gimp:eraser_tool -> gimp-eraser-tool, gimp:layer-list -> gimp-layer-list, ...) * plug-ins/tools/common/gimpbrushselecttool.c: s/gimp:brush_select_tool/gimp-brush-select-tool-module/ Don't quite remember why I introduced the "gimp:" prefix in the first place, but we can always add it back if we need it (for whatever reason) You may want to edit your ~/.gimp-1.3/sessionrc and devicerc or all session settings will be lost due to parse errors.
2002-03-21 20:17:17 +08:00
"gimp-text-tool",
_("Text"),
2006-09-19 02:00:22 +08:00
_("Text Tool: Create or edit text layers"),
N_("Te_xt"), "T",
NULL, GIMP_HELP_TOOL_TEXT,
2002-03-29 11:50:29 +08:00
GIMP_STOCK_TOOL_TEXT,
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 19:31:08 +08:00
data);
}
static void
gimp_text_tool_class_init (GimpTextToolClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
object_class->constructor = gimp_text_tool_constructor;
object_class->dispose = gimp_text_tool_dispose;
object_class->finalize = gimp_text_tool_finalize;
tool_class->control = gimp_text_tool_control;
tool_class->button_press = gimp_text_tool_button_press;
tool_class->key_press = gimp_edit_selection_tool_key_press;
tool_class->cursor_update = gimp_text_tool_cursor_update;
}
static void
gimp_text_tool_init (GimpTextTool *text_tool)
{
GimpTool *tool = GIMP_TOOL (text_tool);
text_tool->proxy = NULL;
text_tool->pending = NULL;
text_tool->idle_id = 0;
text_tool->text = NULL;
text_tool->layer = NULL;
text_tool->image = NULL;
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_TEXT);
gimp_tool_control_set_action_object_1 (tool->control,
"context/context-font-select-set");
}
static GObject *
gimp_text_tool_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpTextTool *text_tool;
GimpTextOptions *options;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
text_tool = GIMP_TEXT_TOOL (object);
options = GIMP_TEXT_TOOL_GET_OPTIONS (text_tool);
text_tool->proxy = g_object_new (GIMP_TYPE_TEXT, NULL);
gimp_text_options_connect_text (options, text_tool->proxy);
g_signal_connect_object (text_tool->proxy, "notify",
G_CALLBACK (gimp_text_tool_proxy_notify),
text_tool, 0);
return object;
}
static void
gimp_text_tool_dispose (GObject *object)
{
GimpTextTool *text_tool = GIMP_TEXT_TOOL (object);
gimp_text_tool_set_drawable (text_tool, NULL, FALSE);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gimp_text_tool_finalize (GObject *object)
{
GimpTextTool *text_tool = GIMP_TEXT_TOOL (object);
if (text_tool->proxy)
{
g_object_unref (text_tool->proxy);
text_tool->proxy = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
1997-11-25 06:05:25 +08:00
static void
gimp_text_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display)
1997-11-25 06:05:25 +08:00
{
GimpTextTool *text_tool = GIMP_TEXT_TOOL (tool);
switch (action)
{
case GIMP_TOOL_ACTION_PAUSE:
case GIMP_TOOL_ACTION_RESUME:
break;
case GIMP_TOOL_ACTION_HALT:
gimp_text_tool_set_drawable (text_tool, NULL, FALSE);
break;
}
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
}
static void
gimp_text_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
{
GimpTextTool *text_tool = GIMP_TEXT_TOOL (tool);
GimpText *text = text_tool->text;
GimpDrawable *drawable;
GIMP_TOOL_CLASS (parent_class)->button_press (tool, coords, time, state,
display);
1997-11-25 06:05:25 +08:00
text_tool->x1 = coords->x;
text_tool->y1 = coords->y;
drawable = gimp_image_get_active_drawable (display->image);
gimp_text_tool_set_drawable (text_tool, drawable, FALSE);
if (GIMP_IS_LAYER (drawable))
{
GimpItem *item = GIMP_ITEM (drawable);
coords->x -= item->offset_x;
coords->y -= item->offset_y;
if (coords->x > 0 && coords->x < item->width &&
coords->y > 0 && coords->y < item->height)
{
/* did the user click on a text layer? */
if (gimp_text_tool_set_drawable (text_tool, drawable, TRUE))
{
/* on second click, open the text editor */
if (text && text_tool->text == text)
gimp_text_tool_editor (text_tool);
return;
}
}
}
/* create a new text layer */
gimp_text_tool_connect (text_tool, NULL, NULL);
gimp_text_tool_editor (text_tool);
}
1997-11-25 06:05:25 +08:00
static void
gimp_text_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display)
1997-11-25 06:05:25 +08:00
{
/* FIXME: should do something fancy here... */
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
1997-11-25 06:05:25 +08:00
}
static void
gimp_text_tool_connect (GimpTextTool *text_tool,
GimpTextLayer *layer,
GimpText *text)
{
GimpTool *tool = GIMP_TOOL (text_tool);
g_return_if_fail (text == NULL || (layer != NULL && layer->text == text));
if (! text && text_tool->editor)
gtk_widget_destroy (text_tool->editor);
if (text_tool->text != text)
{
GimpTextOptions *options = GIMP_TEXT_TOOL_GET_OPTIONS (tool);
if (text_tool->text)
{
g_signal_handlers_disconnect_by_func (text_tool->text,
gimp_text_tool_text_notify,
text_tool);
if (text_tool->pending)
gimp_text_tool_apply (text_tool);
if (options->to_vectors_button)
{
gtk_widget_set_sensitive (options->to_vectors_button, FALSE);
g_signal_handlers_disconnect_by_func (options->to_vectors_button,
gimp_text_tool_create_vectors,
text_tool);
}
if (options->along_vectors_button)
{
gtk_widget_set_sensitive (options->along_vectors_button,
FALSE);
g_signal_handlers_disconnect_by_func (options->along_vectors_button,
gimp_text_tool_create_vectors_warped,
text_tool);
}
g_object_unref (text_tool->text);
text_tool->text = NULL;
g_object_set (text_tool->proxy, "text", NULL, NULL);
}
gimp_context_define_property (GIMP_CONTEXT (options),
GIMP_CONTEXT_PROP_FOREGROUND,
text != NULL);
if (text)
{
gimp_config_sync (G_OBJECT (text), G_OBJECT (text_tool->proxy), 0);
text_tool->text = g_object_ref (text);
g_signal_connect (text, "notify",
G_CALLBACK (gimp_text_tool_text_notify),
text_tool);
if (options->to_vectors_button)
{
g_signal_connect_swapped (options->to_vectors_button, "clicked",
G_CALLBACK (gimp_text_tool_create_vectors),
text_tool);
gtk_widget_set_sensitive (options->to_vectors_button, TRUE);
}
if (options->along_vectors_button)
{
g_signal_connect_swapped (options->along_vectors_button, "clicked",
G_CALLBACK (gimp_text_tool_create_vectors_warped),
text_tool);
gtk_widget_set_sensitive (options->along_vectors_button, TRUE);
}
if (text_tool->editor)
gimp_text_tool_editor_update (text_tool);
}
}
if (text_tool->layer != layer)
{
if (text_tool->layer)
{
g_signal_handlers_disconnect_by_func (text_tool->layer,
gimp_text_tool_layer_notify,
text_tool);
text_tool->layer = NULL;
}
text_tool->layer = layer;
if (layer)
g_signal_connect_object (text_tool->layer, "notify::modified",
G_CALLBACK (gimp_text_tool_layer_notify),
text_tool, 0);
}
}
static void
gimp_text_tool_layer_notify (GimpTextLayer *layer,
GParamSpec *pspec,
GimpTextTool *text_tool)
{
if (layer->modified)
gimp_text_tool_connect (text_tool, NULL, NULL);
}
static void
gimp_text_tool_proxy_notify (GimpText *text,
GParamSpec *pspec,
GimpTextTool *text_tool)
{
if (! text_tool->text)
return;
if ((pspec->flags & G_PARAM_READWRITE) == G_PARAM_READWRITE)
{
text_tool->pending = g_list_append (text_tool->pending, pspec);
if (text_tool->idle_id)
g_source_remove (text_tool->idle_id);
text_tool->idle_id =
g_idle_add_full (G_PRIORITY_LOW,
(GSourceFunc) gimp_text_tool_idle_apply, text_tool,
NULL);
}
}
static void
gimp_text_tool_text_notify (GimpText *text,
GParamSpec *pspec,
GimpTextTool *text_tool)
{
g_return_if_fail (text == text_tool->text);
if ((pspec->flags & G_PARAM_READWRITE) == G_PARAM_READWRITE)
{
GValue value = { 0, };
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (text), pspec->name, &value);
g_signal_handlers_block_by_func (text_tool->proxy,
gimp_text_tool_proxy_notify,
text_tool);
g_object_set_property (G_OBJECT (text_tool->proxy), pspec->name, &value);
g_signal_handlers_unblock_by_func (text_tool->proxy,
gimp_text_tool_proxy_notify,
text_tool);
g_value_unset (&value);
}
if (text_tool->editor && strcmp (pspec->name, "text") == 0)
gimp_text_tool_editor_update (text_tool);
}
static gboolean
gimp_text_tool_idle_apply (GimpTextTool *text_tool)
{
text_tool->idle_id = 0;
gimp_text_tool_apply (text_tool);
return FALSE;
}
static void
gimp_text_tool_apply (GimpTextTool *text_tool)
{
const GParamSpec *pspec = NULL;
GimpImage *image;
GimpTextLayer *layer;
GObject *src;
GObject *dest;
GList *list;
gboolean push_undo = TRUE;
gboolean undo_group = FALSE;
if (text_tool->idle_id)
{
g_source_remove (text_tool->idle_id);
text_tool->idle_id = 0;
}
g_return_if_fail (text_tool->text != NULL);
g_return_if_fail (text_tool->layer != NULL);
layer = text_tool->layer;
image = gimp_item_get_image (GIMP_ITEM (layer));
g_return_if_fail (layer->text == text_tool->text);
/* Walk over the list of changes and figure out if we are changing
* a single property or need to push a full text undo.
*/
for (list = text_tool->pending;
list && list->next && list->next->data == list->data;
list = list->next)
/* do nothing */;
if (g_list_length (list) == 1)
pspec = list->data;
/* If we are changing a single property, we don't need to push
* an undo if all of the following is true:
* - the redo stack is empty
* - the last item on the undo stack is a text undo
* - the last undo changed the same text property on the same layer
* - the last undo happened less than TEXT_UNDO_TIMEOUT seconds ago
*/
if (pspec)
{
GimpUndo *undo = gimp_image_undo_can_compress (image, GIMP_TYPE_TEXT_UNDO,
GIMP_UNDO_TEXT_LAYER);
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (layer))
{
GimpTextUndo *text_undo = GIMP_TEXT_UNDO (undo);
if (text_undo->pspec == pspec)
{
if (gimp_undo_get_age (undo) < TEXT_UNDO_TIMEOUT)
{
GimpTool *tool = GIMP_TOOL (text_tool);
push_undo = FALSE;
gimp_undo_reset_age (undo);
Changed GimpViewable preview rendering to have a context to get 2006-08-29 Michael Natterer <mitch@gimp.org> Changed GimpViewable preview rendering to have a context to get FG/BG/whatever from. Use the context to enable dynamic FG/BG colors in gradients. Fixes bug #127676 and bug #352214. Addresses bug #128367 (doesn't fix it because there's no loading/saving and no GUI yet). * app/core/core-enums.[ch]: added enum GimpGradientColor to enable specifying gradient colors in terms of foreground and background. * app/core/gimpgradient.[ch]: added color_type members to the GimpGradientSegment struct and honor them in gimp_gradient_get_color_at(). Added GimpContext parameters to all functions which finally call get_color_at(). * app/core/gimp-gradients.c: use the new method to implement the builtin gradients. * app/core/gimpviewable.[ch]: added GimpContext parameters to all get_preview() and get_pixbuf() functions. * app/core/gimpbrush.c * app/core/gimpbuffer.c * app/core/gimpdrawable-preview.[ch] * app/core/gimpgradient.c * app/core/gimpimage-preview.[ch] * app/core/gimpimagefile.c * app/core/gimppalette.c * app/core/gimppattern.c * app/core/gimpundo.[ch] * app/text/gimpfont.c * app/vectors/gimpvectors-preview.[ch]: changed ::get_preview() and ::get_pixbuf() implementations accordingly. * app/core/gimpdrawable-blend.c * app/core/gimppalette-import.[ch] * app/dialogs/dialogs-constructors.c * app/dialogs/palette-import-dialog.c * app/dialogs/resize-dialog.c * app/display/gimpdisplayshell-layer-select.c * app/display/gimpdisplayshell.c * app/display/gimpnavigationeditor.c * app/paint/gimppaintoptions.c * app/tools/gimpeditselectiontool.c * app/tools/gimptexttool.c * app/actions/gradient-editor-commands.c * app/widgets/gimpaction.c * app/widgets/gimpbrusheditor.[ch] * app/widgets/gimpbufferview.c * app/widgets/gimpcellrendererviewable.c * app/widgets/gimpchanneltreeview.c * app/widgets/gimpclipboard.c * app/widgets/gimpcoloreditor.c * app/widgets/gimpcomponenteditor.c * app/widgets/gimpcontainerbox.c * app/widgets/gimpcontainercombobox.c * app/widgets/gimpcontainereditor.c * app/widgets/gimpcontainerentry.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainertreeview.[ch] * app/widgets/gimpdataeditor.[ch] * app/widgets/gimpdevicestatus.c * app/widgets/gimpdnd.[ch] * app/widgets/gimpdrawabletreeview.c * app/widgets/gimpfiledialog.c * app/widgets/gimpgradienteditor.[ch] * app/widgets/gimpgradientselect.c * app/widgets/gimpitemtreeview.c * app/widgets/gimplayertreeview.c * app/widgets/gimppaletteeditor.[ch] * app/widgets/gimppropwidgets.[ch] * app/widgets/gimpselectioneditor.c * app/widgets/gimpthumbbox.[ch] * app/widgets/gimptoolbox-image-area.c * app/widgets/gimptoolbox-indicator-area.c * app/widgets/gimptooloptionseditor.c * app/widgets/gimpundoeditor.c * app/widgets/gimpvectorstreeview.c * app/widgets/gimpview-popup.[ch] * app/widgets/gimpview.[ch] * app/widgets/gimpviewablebutton.c * app/widgets/gimpviewabledialog.c * app/widgets/gimpviewrenderer.[ch] * app/widgets/gimpviewrenderer-frame.c * app/widgets/gimpviewrendererbrush.c * app/widgets/gimpviewrendererbuffer.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrenderergradient.c * app/widgets/gimpviewrendererimage.c * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb: added tons of GimpContext members and parameters, implement GimpDocked::set_context() in many widgets. Pass these locally remembered contexts to GimpViewable functions. Did some minor cleanups on the way. There are still some minor FIXMEs around where the code uses a NULL context (which is allowed by the APIs) * app/pdb/drawable_cmds.c * app/pdb/gradient_cmds.c * app/pdb/gradients_cmds.c * app/pdb/image_cmds.c: regenerated.
2006-08-30 05:44:51 +08:00
gimp_undo_refresh_preview (undo,
GIMP_CONTEXT (gimp_tool_get_options (tool)));
}
}
}
}
if (push_undo)
{
if (layer->modified)
added undo type GIMP_UNDO_TEXT_LAYER_MODIFIED and undo group types 2004-04-01 Michael Natterer <mitch@gimp.org> * app/core/core-enums.[ch] (enum GimpUndoType): added undo type GIMP_UNDO_TEXT_LAYER_MODIFIED and undo group types GIMP_UNDO_GROUP_DRAWABLE and GIMP_UNDO_GROUP_DRAWABLE_MOD. * app/core/gimpimage-undo-push.[ch]: added new new function gimp_image_undo_push_text_layer_modified() which makes modifications of the text_layer's "modified" boolean undoable. * app/core/gimpdrawable.[ch]: added new virtual function GimpDrawable::push_undo() and moved the actual undo pushing into the default implementation gimp_drawable_real_push_undo(). * app/text/gimptextlayer.c (gimp_text_layer_push_undo): new function. Pushes the text_layer's modified state to the undo stack after upchaining and sets modified to TRUE. (gimp_text_layer_set_tiles): ditto. (gimp_lext_layer_apply_region) (gimp_text_layer_replace_region): removed because their default implementations already call gimp_drawable_push_undo(). (gimp_text_layer_swap_pixels): removed because swap_pixels() is used by undo only and doesn't need to care about the text_layer's modified state. (gimp_text_layer_render): don't set modified to FALSE here because we can't push an undo step here. (gimp_text_layer_set): push the modified state to the undo stack and set it to FALSE here. Also push the layer's tiles if the layer was modified. * app/tools/gimptexttool.c (gimp_text_tool_apply): push "modified" to the undo stack and set it to FALSE here, too. Fixes bug #137767.
2004-04-01 22:51:58 +08:00
{
undo_group = TRUE;
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TEXT, NULL);
added undo type GIMP_UNDO_TEXT_LAYER_MODIFIED and undo group types 2004-04-01 Michael Natterer <mitch@gimp.org> * app/core/core-enums.[ch] (enum GimpUndoType): added undo type GIMP_UNDO_TEXT_LAYER_MODIFIED and undo group types GIMP_UNDO_GROUP_DRAWABLE and GIMP_UNDO_GROUP_DRAWABLE_MOD. * app/core/gimpimage-undo-push.[ch]: added new new function gimp_image_undo_push_text_layer_modified() which makes modifications of the text_layer's "modified" boolean undoable. * app/core/gimpdrawable.[ch]: added new virtual function GimpDrawable::push_undo() and moved the actual undo pushing into the default implementation gimp_drawable_real_push_undo(). * app/text/gimptextlayer.c (gimp_text_layer_push_undo): new function. Pushes the text_layer's modified state to the undo stack after upchaining and sets modified to TRUE. (gimp_text_layer_set_tiles): ditto. (gimp_lext_layer_apply_region) (gimp_text_layer_replace_region): removed because their default implementations already call gimp_drawable_push_undo(). (gimp_text_layer_swap_pixels): removed because swap_pixels() is used by undo only and doesn't need to care about the text_layer's modified state. (gimp_text_layer_render): don't set modified to FALSE here because we can't push an undo step here. (gimp_text_layer_set): push the modified state to the undo stack and set it to FALSE here. Also push the layer's tiles if the layer was modified. * app/tools/gimptexttool.c (gimp_text_tool_apply): push "modified" to the undo stack and set it to FALSE here, too. Fixes bug #137767.
2004-04-01 22:51:58 +08:00
gimp_image_undo_push_text_layer_modified (image, NULL, layer);
gimp_image_undo_push_drawable_mod (image,
NULL, GIMP_DRAWABLE (layer));
added undo type GIMP_UNDO_TEXT_LAYER_MODIFIED and undo group types 2004-04-01 Michael Natterer <mitch@gimp.org> * app/core/core-enums.[ch] (enum GimpUndoType): added undo type GIMP_UNDO_TEXT_LAYER_MODIFIED and undo group types GIMP_UNDO_GROUP_DRAWABLE and GIMP_UNDO_GROUP_DRAWABLE_MOD. * app/core/gimpimage-undo-push.[ch]: added new new function gimp_image_undo_push_text_layer_modified() which makes modifications of the text_layer's "modified" boolean undoable. * app/core/gimpdrawable.[ch]: added new virtual function GimpDrawable::push_undo() and moved the actual undo pushing into the default implementation gimp_drawable_real_push_undo(). * app/text/gimptextlayer.c (gimp_text_layer_push_undo): new function. Pushes the text_layer's modified state to the undo stack after upchaining and sets modified to TRUE. (gimp_text_layer_set_tiles): ditto. (gimp_lext_layer_apply_region) (gimp_text_layer_replace_region): removed because their default implementations already call gimp_drawable_push_undo(). (gimp_text_layer_swap_pixels): removed because swap_pixels() is used by undo only and doesn't need to care about the text_layer's modified state. (gimp_text_layer_render): don't set modified to FALSE here because we can't push an undo step here. (gimp_text_layer_set): push the modified state to the undo stack and set it to FALSE here. Also push the layer's tiles if the layer was modified. * app/tools/gimptexttool.c (gimp_text_tool_apply): push "modified" to the undo stack and set it to FALSE here, too. Fixes bug #137767.
2004-04-01 22:51:58 +08:00
}
gimp_image_undo_push_text_layer (image, NULL, layer, pspec);
}
src = G_OBJECT (text_tool->proxy);
dest = G_OBJECT (text_tool->text);
g_signal_handlers_block_by_func (dest,
gimp_text_tool_text_notify, text_tool);
g_object_freeze_notify (dest);
for (; list; list = list->next)
{
GValue value = { 0, };
/* look ahead and compress changes */
if (list->next && list->next->data == list->data)
continue;
pspec = list->data;
g_value_init (&value, pspec->value_type);
g_object_get_property (src, pspec->name, &value);
g_object_set_property (dest, pspec->name, &value);
g_value_unset (&value);
}
g_list_free (text_tool->pending);
text_tool->pending = NULL;
g_object_thaw_notify (dest);
g_signal_handlers_unblock_by_func (dest,
gimp_text_tool_text_notify, text_tool);
added undo type GIMP_UNDO_TEXT_LAYER_MODIFIED and undo group types 2004-04-01 Michael Natterer <mitch@gimp.org> * app/core/core-enums.[ch] (enum GimpUndoType): added undo type GIMP_UNDO_TEXT_LAYER_MODIFIED and undo group types GIMP_UNDO_GROUP_DRAWABLE and GIMP_UNDO_GROUP_DRAWABLE_MOD. * app/core/gimpimage-undo-push.[ch]: added new new function gimp_image_undo_push_text_layer_modified() which makes modifications of the text_layer's "modified" boolean undoable. * app/core/gimpdrawable.[ch]: added new virtual function GimpDrawable::push_undo() and moved the actual undo pushing into the default implementation gimp_drawable_real_push_undo(). * app/text/gimptextlayer.c (gimp_text_layer_push_undo): new function. Pushes the text_layer's modified state to the undo stack after upchaining and sets modified to TRUE. (gimp_text_layer_set_tiles): ditto. (gimp_lext_layer_apply_region) (gimp_text_layer_replace_region): removed because their default implementations already call gimp_drawable_push_undo(). (gimp_text_layer_swap_pixels): removed because swap_pixels() is used by undo only and doesn't need to care about the text_layer's modified state. (gimp_text_layer_render): don't set modified to FALSE here because we can't push an undo step here. (gimp_text_layer_set): push the modified state to the undo stack and set it to FALSE here. Also push the layer's tiles if the layer was modified. * app/tools/gimptexttool.c (gimp_text_tool_apply): push "modified" to the undo stack and set it to FALSE here, too. Fixes bug #137767.
2004-04-01 22:51:58 +08:00
if (push_undo)
{
g_object_set (layer, "modified", FALSE, NULL);
if (undo_group)
gimp_image_undo_group_end (image);
added undo type GIMP_UNDO_TEXT_LAYER_MODIFIED and undo group types 2004-04-01 Michael Natterer <mitch@gimp.org> * app/core/core-enums.[ch] (enum GimpUndoType): added undo type GIMP_UNDO_TEXT_LAYER_MODIFIED and undo group types GIMP_UNDO_GROUP_DRAWABLE and GIMP_UNDO_GROUP_DRAWABLE_MOD. * app/core/gimpimage-undo-push.[ch]: added new new function gimp_image_undo_push_text_layer_modified() which makes modifications of the text_layer's "modified" boolean undoable. * app/core/gimpdrawable.[ch]: added new virtual function GimpDrawable::push_undo() and moved the actual undo pushing into the default implementation gimp_drawable_real_push_undo(). * app/text/gimptextlayer.c (gimp_text_layer_push_undo): new function. Pushes the text_layer's modified state to the undo stack after upchaining and sets modified to TRUE. (gimp_text_layer_set_tiles): ditto. (gimp_lext_layer_apply_region) (gimp_text_layer_replace_region): removed because their default implementations already call gimp_drawable_push_undo(). (gimp_text_layer_swap_pixels): removed because swap_pixels() is used by undo only and doesn't need to care about the text_layer's modified state. (gimp_text_layer_render): don't set modified to FALSE here because we can't push an undo step here. (gimp_text_layer_set): push the modified state to the undo stack and set it to FALSE here. Also push the layer's tiles if the layer was modified. * app/tools/gimptexttool.c (gimp_text_tool_apply): push "modified" to the undo stack and set it to FALSE here, too. Fixes bug #137767.
2004-04-01 22:51:58 +08:00
}
gimp_image_flush (image);
}
static void
gimp_text_tool_create_vectors (GimpTextTool *text_tool)
{
GimpVectors *vectors;
if (! text_tool->text || ! text_tool->image)
return;
vectors = gimp_text_vectors_new (text_tool->image, text_tool->text);
if (text_tool->layer)
{
gint x, y;
gimp_item_offsets (GIMP_ITEM (text_tool->layer), &x, &y);
gimp_item_translate (GIMP_ITEM (vectors), x, y, FALSE);
}
gimp_image_add_vectors (text_tool->image, vectors, -1);
gimp_image_flush (text_tool->image);
}
static void
gimp_text_tool_create_vectors_warped (GimpTextTool *text_tool)
{
GimpVectors *vectors0;
GimpVectors *vectors;
GimpText *text = text_tool->text;
gdouble box_height;
if (! text || ! text_tool->image || ! text_tool->layer)
return;
box_height = gimp_item_height (GIMP_ITEM (text_tool->layer));
vectors0 = gimp_image_get_active_vectors (text_tool->image);
if (! vectors0)
return;
vectors = gimp_text_vectors_new (text_tool->image, text_tool->text);
gimp_vectors_warp_vectors (vectors0, vectors, 0.5 * box_height);
gimp_image_add_vectors (text_tool->image, vectors, -1);
gimp_image_set_active_vectors (text_tool->image, vectors);
gimp_item_set_visible (GIMP_ITEM (vectors), TRUE, FALSE);
gimp_image_flush (text_tool->image);
}
static void
gimp_text_tool_create_layer (GimpTextTool *text_tool,
GimpText *text)
1997-11-25 06:05:25 +08:00
{
GimpTool *tool = GIMP_TOOL (text_tool);
GimpImage *image;
GimpLayer *layer;
1997-11-25 06:05:25 +08:00
if (text)
{
text = gimp_config_duplicate (GIMP_CONFIG (text));
}
else
{
gchar *str;
str = gimp_text_editor_get_text (GIMP_TEXT_EDITOR (text_tool->editor));
g_object_set (text_tool->proxy,
"text", str,
NULL);
g_free (str);
text = gimp_config_duplicate (GIMP_CONFIG (text_tool->proxy));
}
image = tool->display->image;
layer = gimp_text_layer_new (image, text);
g_object_unref (text);
if (! layer)
return;
gimp_text_tool_connect (text_tool, GIMP_TEXT_LAYER (layer), text);
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TEXT,
_("Add Text Layer"));
if (gimp_image_floating_sel (image))
{
g_signal_handlers_block_by_func (image,
gimp_text_tool_layer_changed,
text_tool);
floating_sel_anchor (gimp_image_floating_sel (image));
g_signal_handlers_unblock_by_func (image,
gimp_text_tool_layer_changed,
text_tool);
}
GIMP_ITEM (layer)->offset_x = text_tool->x1;
GIMP_ITEM (layer)->offset_y = text_tool->y1;
1997-11-25 06:05:25 +08:00
gimp_image_add_layer (image, layer, -1);
1997-11-25 06:05:25 +08:00
gimp_image_undo_group_end (image);
gimp_image_flush (image);
gimp_text_tool_set_drawable (text_tool, GIMP_DRAWABLE (layer), FALSE);
1997-11-25 06:05:25 +08:00
}
static void
gimp_text_tool_editor (GimpTextTool *text_tool)
{
GimpTextOptions *options = GIMP_TEXT_TOOL_GET_OPTIONS (text_tool);
GimpDialogFactory *dialog_factory;
GtkWindow *parent = NULL;
if (text_tool->editor)
{
gtk_window_present (GTK_WINDOW (text_tool->editor));
return;
}
dialog_factory = gimp_dialog_factory_from_name ("toplevel");
if (GIMP_TOOL (text_tool)->display)
parent = GTK_WINDOW (GIMP_TOOL (text_tool)->display->shell);
text_tool->editor = gimp_text_options_editor_new (parent, options,
dialog_factory->menu_factory,
_("GIMP Text Editor"));
g_object_add_weak_pointer (G_OBJECT (text_tool->editor),
(gpointer) &text_tool->editor);
gimp_dialog_factory_add_foreign (dialog_factory,
"gimp-text-tool-dialog",
text_tool->editor);
if (text_tool->text)
gimp_text_editor_set_text (GIMP_TEXT_EDITOR (text_tool->editor),
text_tool->text->text, -1);
g_signal_connect_object (text_tool->editor, "text-changed",
G_CALLBACK (gimp_text_tool_text_changed),
text_tool, 0);
gtk_widget_show (text_tool->editor);
}
static void
gimp_text_tool_editor_update (GimpTextTool *text_tool)
{
gchar *str = NULL;
if (! text_tool->editor)
return;
if (text_tool->text)
g_object_get (text_tool->text, "text", &str, NULL);
g_signal_handlers_block_by_func (text_tool->editor,
gimp_text_tool_text_changed, text_tool);
gimp_text_editor_set_text (GIMP_TEXT_EDITOR (text_tool->editor),
str, str ? -1 : 0);
g_signal_handlers_unblock_by_func (text_tool->editor,
gimp_text_tool_text_changed, text_tool);
g_free (str);
}
static void
gimp_text_tool_text_changed (GimpTextEditor *editor,
GimpTextTool *text_tool)
{
if (text_tool->text)
{
gchar *text;
text = gimp_text_editor_get_text (GIMP_TEXT_EDITOR (text_tool->editor));
g_object_set (text_tool->proxy, "text", text, NULL);
g_free (text);
}
else
{
gimp_text_tool_create_layer (text_tool, NULL);
}
}
#define RESPONSE_NEW 1
static void
gimp_text_tool_confirm_response (GtkWidget *widget,
gint response_id,
GimpTextTool *text_tool)
{
GimpTextLayer *layer = text_tool->layer;
gtk_widget_destroy (widget);
if (layer && layer->text)
{
switch (response_id)
{
case RESPONSE_NEW:
gimp_text_tool_create_layer (text_tool, layer->text);
break;
case GTK_RESPONSE_OK:
gimp_text_tool_connect (text_tool, layer, layer->text);
gimp_text_tool_editor (text_tool);
break;
default:
break;
}
}
}
static void
gimp_text_tool_confirm_dialog (GimpTextTool *text_tool)
{
GimpTool *tool = GIMP_TOOL (text_tool);
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *label;
g_return_if_fail (text_tool->layer != NULL);
if (text_tool->confirm_dialog)
{
gtk_window_present (GTK_WINDOW (text_tool->confirm_dialog));
return;
}
dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (text_tool->layer),
GIMP_CONTEXT (gimp_tool_get_options (tool)),
_("Confirm Text Editing"),
"gimp-text-tool-confirm",
GIMP_STOCK_TEXT_LAYER,
_("Confirm Text Editing"),
tool->display->shell,
gimp_standard_help_func,
tool->tool_info->help_id,
GTK_STOCK_NEW, RESPONSE_NEW,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_EDIT, GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
RESPONSE_NEW,
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
g_signal_connect (dialog, "response",
G_CALLBACK (gimp_text_tool_confirm_response),
text_tool);
vbox = gtk_vbox_new (FALSE, 6);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
label = gtk_label_new (_("The layer you selected is a text layer but "
"it has been modified using other tools. "
"Editing the layer with the text tool will "
"discard these modifications."
"\n\n"
"You can edit the layer or create a new "
"text layer from its text attributes."));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
gtk_widget_show (dialog);
text_tool->confirm_dialog = dialog;
g_signal_connect_swapped (dialog, "destroy",
G_CALLBACK (g_nullify_pointer),
&text_tool->confirm_dialog);
}
static void
gimp_text_tool_layer_changed (GimpImage *image,
GimpTextTool *text_tool)
{
GimpLayer *layer = gimp_image_get_active_layer (image);
gimp_text_tool_set_drawable (text_tool, GIMP_DRAWABLE (layer), FALSE);
}
static void
gimp_text_tool_set_image (GimpTextTool *text_tool,
GimpImage *image)
{
if (text_tool->image == image)
return;
if (text_tool->image)
{
g_signal_handlers_disconnect_by_func (text_tool->image,
gimp_text_tool_layer_changed,
text_tool);
g_object_remove_weak_pointer (G_OBJECT (text_tool->image),
(gpointer) &text_tool->image);
text_tool->image = NULL;
}
if (image)
{
GimpTextOptions *options = GIMP_TEXT_TOOL_GET_OPTIONS (text_tool);
text_tool->image = image;
g_object_add_weak_pointer (G_OBJECT (text_tool->image),
(gpointer) &text_tool->image);
g_signal_connect_object (text_tool->image, "active-layer-changed",
G_CALLBACK (gimp_text_tool_layer_changed),
text_tool, 0);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (options->size_entry),
0, image->yresolution, FALSE);
}
}
static gboolean
gimp_text_tool_set_drawable (GimpTextTool *text_tool,
GimpDrawable *drawable,
gboolean confirm)
{
GimpImage *image = NULL;
if (text_tool->confirm_dialog)
gtk_widget_destroy (text_tool->confirm_dialog);
if (drawable)
image = gimp_item_get_image (GIMP_ITEM (drawable));
gimp_text_tool_set_image (text_tool, image);
if (GIMP_IS_TEXT_LAYER (drawable) && GIMP_TEXT_LAYER (drawable)->text)
{
GimpTextLayer *layer = GIMP_TEXT_LAYER (drawable);
if (layer == text_tool->layer && layer->text == text_tool->text)
return TRUE;
if (layer->modified)
{
if (confirm)
{
gimp_text_tool_connect (text_tool, layer, NULL);
gimp_text_tool_confirm_dialog (text_tool);
return TRUE;
}
}
else
{
gimp_text_tool_connect (text_tool, layer, layer->text);
return TRUE;
}
}
gimp_text_tool_connect (text_tool, NULL, NULL);
text_tool->layer = NULL;
return FALSE;
}
void
gimp_text_tool_set_layer (GimpTextTool *text_tool,
GimpLayer *layer)
{
g_return_if_fail (GIMP_IS_TEXT_TOOL (text_tool));
g_return_if_fail (layer == NULL || GIMP_IS_LAYER (layer));
if (gimp_text_tool_set_drawable (text_tool, GIMP_DRAWABLE (layer), TRUE))
{
GimpTool *tool = GIMP_TOOL (text_tool);
GimpItem *item = GIMP_ITEM (layer);
GimpContext *context;
GimpDisplay *display;
context = gimp_get_user_context (tool->tool_info->gimp);
display = gimp_context_get_display (context);
if (! display || display->image != item->image)
{
GList *list;
display = NULL;
for (list = GIMP_LIST (tool->tool_info->gimp->displays)->list;
list;
list = g_list_next (list))
{
display = list->data;
if (display->image == item->image)
{
gimp_context_set_display (context, display);
break;
}
display = NULL;
}
}
tool->display = display;
if (tool->display)
{
tool->drawable = GIMP_DRAWABLE (layer);
gimp_text_tool_editor (text_tool);
}
}
}