2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-09-18 21:51:10 +08:00
|
|
|
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis and others
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-09-18 21:51:10 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-09-18 21:51:10 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2003-09-18 21:51:10 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-01-23 17:51:43 +08:00
|
|
|
#include <gegl.h>
|
2003-09-18 21:51:10 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2006-08-31 18:33:31 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
|
|
|
|
#include "tools-types.h"
|
|
|
|
|
2010-10-31 20:05:15 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "core/gimp.h"
|
2005-09-04 18:44:04 +08:00
|
|
|
#include "core/gimp-contexts.h"
|
2017-10-29 21:50:28 +08:00
|
|
|
#include "core/gimp-internal-data.h"
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2011-03-23 16:27:29 +08:00
|
|
|
#include "core/gimplist.h"
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
#include "core/gimptoolgroup.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
|
|
|
#include "core/gimptooloptions.h"
|
|
|
|
|
2018-06-29 18:31:32 +08:00
|
|
|
#include "gimp-tool-options-manager.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "gimp-tools.h"
|
|
|
|
#include "gimptooloptions-gui.h"
|
|
|
|
#include "tool_manager.h"
|
|
|
|
|
|
|
|
#include "gimpairbrushtool.h"
|
2005-06-04 01:05:01 +08:00
|
|
|
#include "gimpaligntool.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "gimpbrightnesscontrasttool.h"
|
|
|
|
#include "gimpbucketfilltool.h"
|
|
|
|
#include "gimpbycolorselecttool.h"
|
2010-06-15 05:25:08 +08:00
|
|
|
#include "gimpcagetool.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "gimpclonetool.h"
|
|
|
|
#include "gimpcolorpickertool.h"
|
|
|
|
#include "gimpconvolvetool.h"
|
|
|
|
#include "gimpcroptool.h"
|
|
|
|
#include "gimpcurvestool.h"
|
|
|
|
#include "gimpdodgeburntool.h"
|
|
|
|
#include "gimpellipseselecttool.h"
|
|
|
|
#include "gimperasertool.h"
|
|
|
|
#include "gimpfliptool.h"
|
|
|
|
#include "gimpfreeselecttool.h"
|
2005-07-29 09:48:56 +08:00
|
|
|
#include "gimpforegroundselecttool.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "gimpfuzzyselecttool.h"
|
2008-02-05 07:32:45 +08:00
|
|
|
#include "gimpgegltool.h"
|
2018-04-14 06:52:20 +08:00
|
|
|
#include "gimpgradienttool.h"
|
2015-03-05 19:29:19 +08:00
|
|
|
#include "gimphandletransformtool.h"
|
2006-09-03 02:54:35 +08:00
|
|
|
#include "gimphealtool.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "gimpinktool.h"
|
|
|
|
#include "gimpiscissorstool.h"
|
|
|
|
#include "gimplevelstool.h"
|
2012-03-27 04:56:53 +08:00
|
|
|
#include "gimpoperationtool.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "gimpmagnifytool.h"
|
|
|
|
#include "gimpmeasuretool.h"
|
|
|
|
#include "gimpmovetool.h"
|
2014-04-06 21:48:53 +08:00
|
|
|
#include "gimpmybrushtool.h"
|
2013-07-31 06:45:19 +08:00
|
|
|
#include "gimpnpointdeformationtool.h"
|
2019-06-06 06:09:28 +08:00
|
|
|
#include "gimpoffsettool.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "gimppaintbrushtool.h"
|
2020-11-07 19:59:45 +08:00
|
|
|
#include "gimppaintselecttool.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "gimppenciltool.h"
|
2006-09-08 01:10:22 +08:00
|
|
|
#include "gimpperspectiveclonetool.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "gimpperspectivetool.h"
|
|
|
|
#include "gimpthresholdtool.h"
|
2006-06-11 05:34:12 +08:00
|
|
|
#include "gimprectangleselecttool.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "gimprotatetool.h"
|
2011-08-06 19:15:02 +08:00
|
|
|
#include "gimpseamlessclonetool.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "gimpscaletool.h"
|
|
|
|
#include "gimpsheartool.h"
|
|
|
|
#include "gimpsmudgetool.h"
|
|
|
|
#include "gimptexttool.h"
|
app, icons: add 3D Transform tool
Add a new 3D Transform tool, based on GimpToolTransform3DGrid,
added in the previous commit. The tool UI provides a notbook with
three tabs, corresponding to the three GimpToolTransform3DGrid
modes:
Camera - allows setting the primary vanishing point, as well as
the camera's focal length, expressed either directly, or as the
camera's angle of view, relative to the whole image or the
transformed item. By default, the vanishing point is aligned
with the item's center, and the angle of view is fixed relative
to the item; this essentially means that each item is transformed
using a local perspective, independent of its position and size
relative to the image. A global perspective can be achieved by
using a common vanishing point and focal length (or an image-
relative angle of view).
Move - allows moving the item using X, Y, and Z offsets.
Rotate - allows rotating the item using X, Y, and Z Euler angles.
The order of rotation of the different axes can be controlled by
a set of numbered buttons next to the sliders, and the rotation's
pivot can be controlled using a pivot selector.
2020-01-06 23:31:30 +08:00
|
|
|
#include "gimptransform3dtool.h"
|
2011-08-06 06:00:35 +08:00
|
|
|
#include "gimpunifiedtransformtool.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "gimpvectortool.h"
|
2011-05-24 03:11:08 +08:00
|
|
|
#include "gimpwarptool.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
#include "gimp-intl.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
|
|
|
|
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
#define TOOL_RC_FILE_VERSION 1
|
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
|
|
|
static void gimp_tools_register (GType tool_type,
|
|
|
|
GType tool_options_type,
|
|
|
|
GimpToolOptionsGUIFunc options_gui_func,
|
|
|
|
GimpContextPropMask context_props,
|
|
|
|
const gchar *identifier,
|
|
|
|
const gchar *label,
|
|
|
|
const gchar *tooltip,
|
|
|
|
const gchar *menu_label,
|
|
|
|
const gchar *menu_accel,
|
|
|
|
const gchar *help_domain,
|
|
|
|
const gchar *help_data,
|
|
|
|
const gchar *icon_name,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
static void gimp_tools_copy_structure (Gimp *gimp,
|
|
|
|
GimpContainer *src_container,
|
|
|
|
GimpContainer *dest_container,
|
|
|
|
GHashTable *tools);
|
2003-09-18 21:51:10 +08:00
|
|
|
|
2005-04-12 05:17:59 +08:00
|
|
|
/* private variables */
|
|
|
|
|
2020-02-01 19:05:49 +08:00
|
|
|
static GBinding *toolbox_groups_binding = NULL;
|
|
|
|
static gboolean tool_options_deleted = FALSE;
|
2005-04-12 05:17:59 +08:00
|
|
|
|
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_tools_init (Gimp *gimp)
|
|
|
|
{
|
|
|
|
GimpToolRegisterFunc register_funcs[] =
|
|
|
|
{
|
2016-05-01 22:05:44 +08:00
|
|
|
/* selection tools */
|
2003-09-18 21:51:10 +08:00
|
|
|
|
2016-05-01 22:05:44 +08:00
|
|
|
gimp_rectangle_select_tool_register,
|
|
|
|
gimp_ellipse_select_tool_register,
|
|
|
|
gimp_free_select_tool_register,
|
|
|
|
gimp_fuzzy_select_tool_register,
|
|
|
|
gimp_by_color_select_tool_register,
|
|
|
|
gimp_iscissors_tool_register,
|
|
|
|
gimp_foreground_select_tool_register,
|
2020-11-07 19:59:45 +08:00
|
|
|
gimp_paint_select_tool_register,
|
2003-09-18 21:51:10 +08:00
|
|
|
|
2016-05-01 22:05:44 +08:00
|
|
|
/* path tool */
|
2003-09-18 21:51:10 +08:00
|
|
|
|
2016-05-01 22:05:44 +08:00
|
|
|
gimp_vector_tool_register,
|
2003-09-18 21:51:10 +08:00
|
|
|
|
|
|
|
/* non-modifying tools */
|
|
|
|
|
|
|
|
gimp_color_picker_tool_register,
|
2016-05-01 22:05:44 +08:00
|
|
|
gimp_magnify_tool_register,
|
|
|
|
gimp_measure_tool_register,
|
2003-09-18 21:51:10 +08:00
|
|
|
|
2016-05-01 22:05:44 +08:00
|
|
|
/* transform tools */
|
2003-09-18 21:51:10 +08:00
|
|
|
|
2016-05-01 22:05:44 +08:00
|
|
|
gimp_move_tool_register,
|
|
|
|
gimp_align_tool_register,
|
|
|
|
gimp_crop_tool_register,
|
|
|
|
gimp_unified_transform_tool_register,
|
|
|
|
gimp_rotate_tool_register,
|
|
|
|
gimp_scale_tool_register,
|
|
|
|
gimp_shear_tool_register,
|
|
|
|
gimp_handle_transform_tool_register,
|
|
|
|
gimp_perspective_tool_register,
|
app, icons: add 3D Transform tool
Add a new 3D Transform tool, based on GimpToolTransform3DGrid,
added in the previous commit. The tool UI provides a notbook with
three tabs, corresponding to the three GimpToolTransform3DGrid
modes:
Camera - allows setting the primary vanishing point, as well as
the camera's focal length, expressed either directly, or as the
camera's angle of view, relative to the whole image or the
transformed item. By default, the vanishing point is aligned
with the item's center, and the angle of view is fixed relative
to the item; this essentially means that each item is transformed
using a local perspective, independent of its position and size
relative to the image. A global perspective can be achieved by
using a common vanishing point and focal length (or an image-
relative angle of view).
Move - allows moving the item using X, Y, and Z offsets.
Rotate - allows rotating the item using X, Y, and Z Euler angles.
The order of rotation of the different axes can be controlled by
a set of numbered buttons next to the sliders, and the rotation's
pivot can be controlled using a pivot selector.
2020-01-06 23:31:30 +08:00
|
|
|
gimp_transform_3d_tool_register,
|
2016-05-01 22:05:44 +08:00
|
|
|
gimp_flip_tool_register,
|
|
|
|
gimp_cage_tool_register,
|
|
|
|
gimp_warp_tool_register,
|
|
|
|
gimp_n_point_deformation_tool_register,
|
2003-09-18 21:51:10 +08:00
|
|
|
|
2016-05-01 22:05:44 +08:00
|
|
|
/* paint tools */
|
2003-09-18 21:51:10 +08:00
|
|
|
|
2016-05-01 22:05:44 +08:00
|
|
|
gimp_seamless_clone_tool_register,
|
|
|
|
gimp_text_tool_register,
|
|
|
|
gimp_bucket_fill_tool_register,
|
2018-04-14 06:52:20 +08:00
|
|
|
gimp_gradient_tool_register,
|
2016-05-01 22:05:44 +08:00
|
|
|
gimp_pencil_tool_register,
|
|
|
|
gimp_paintbrush_tool_register,
|
|
|
|
gimp_eraser_tool_register,
|
|
|
|
gimp_airbrush_tool_register,
|
|
|
|
gimp_ink_tool_register,
|
|
|
|
gimp_mybrush_tool_register,
|
|
|
|
gimp_clone_tool_register,
|
|
|
|
gimp_heal_tool_register,
|
|
|
|
gimp_perspective_clone_tool_register,
|
|
|
|
gimp_convolve_tool_register,
|
|
|
|
gimp_smudge_tool_register,
|
|
|
|
gimp_dodge_burn_tool_register,
|
|
|
|
|
2019-06-06 06:09:28 +08:00
|
|
|
/* filter tools */
|
2016-05-01 22:05:44 +08:00
|
|
|
|
|
|
|
gimp_brightness_contrast_tool_register,
|
|
|
|
gimp_threshold_tool_register,
|
|
|
|
gimp_levels_tool_register,
|
|
|
|
gimp_curves_tool_register,
|
2019-06-06 06:09:28 +08:00
|
|
|
gimp_offset_tool_register,
|
2016-05-01 22:05:44 +08:00
|
|
|
gimp_gegl_tool_register,
|
|
|
|
gimp_operation_tool_register
|
2003-09-18 21:51:10 +08:00
|
|
|
};
|
|
|
|
|
2020-01-30 03:22:05 +08:00
|
|
|
gint i;
|
2003-09-18 21:51:10 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2008-05-22 17:01:08 +08:00
|
|
|
gimp_tool_options_create_folder ();
|
|
|
|
|
2003-10-19 00:23:15 +08:00
|
|
|
gimp_container_freeze (gimp->tool_info_list);
|
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (register_funcs); i++)
|
|
|
|
{
|
|
|
|
register_funcs[i] (gimp_tools_register, gimp);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_container_thaw (gimp->tool_info_list);
|
2004-05-10 08:41:57 +08:00
|
|
|
|
2018-06-29 18:31:32 +08:00
|
|
|
gimp_tool_options_manager_init (gimp);
|
|
|
|
|
|
|
|
tool_manager_init (gimp);
|
2020-02-01 19:05:49 +08:00
|
|
|
|
|
|
|
toolbox_groups_binding = g_object_bind_property (
|
|
|
|
gimp->config, "toolbox-groups",
|
|
|
|
gimp->tool_item_ui_list, "flat",
|
|
|
|
G_BINDING_INVERT_BOOLEAN |
|
|
|
|
G_BINDING_SYNC_CREATE);
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_tools_exit (Gimp *gimp)
|
|
|
|
{
|
2010-06-24 04:48:53 +08:00
|
|
|
GList *list;
|
2004-05-10 08:41:57 +08:00
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2020-02-01 19:05:49 +08:00
|
|
|
g_clear_object (&toolbox_groups_binding);
|
|
|
|
|
2017-06-29 18:58:03 +08:00
|
|
|
tool_manager_exit (gimp);
|
|
|
|
|
2018-06-29 18:31:32 +08:00
|
|
|
gimp_tool_options_manager_exit (gimp);
|
|
|
|
|
2010-06-24 04:48:53 +08:00
|
|
|
for (list = gimp_get_tool_info_iter (gimp);
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info = list->data;
|
|
|
|
|
2010-10-31 20:05:15 +08:00
|
|
|
gimp_tools_set_tool_options_gui (tool_info->tool_options, NULL);
|
2010-06-24 04:48:53 +08:00
|
|
|
}
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_tools_restore (Gimp *gimp)
|
|
|
|
{
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
GimpObject *object;
|
|
|
|
GList *list;
|
|
|
|
GError *error = NULL;
|
2003-09-18 21:51:10 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
/* restore tool order */
|
|
|
|
gimp_tools_reset (gimp, gimp->tool_item_list, TRUE);
|
2004-05-18 20:23:56 +08:00
|
|
|
|
2014-02-04 07:18:40 +08:00
|
|
|
/* make the generic operation tool invisible by default */
|
|
|
|
object = gimp_container_get_child_by_name (gimp->tool_info_list,
|
|
|
|
"gimp-operation-tool");
|
|
|
|
if (object)
|
|
|
|
g_object_set (object, "visible", FALSE, NULL);
|
|
|
|
|
2008-11-03 05:34:14 +08:00
|
|
|
for (list = gimp_get_tool_info_iter (gimp);
|
2003-09-18 21:51:10 +08:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
2005-09-04 18:44:04 +08:00
|
|
|
GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data);
|
2003-09-18 21:51:10 +08:00
|
|
|
|
2004-10-07 01:21:22 +08:00
|
|
|
/* get default values from prefs (see bug #120832) */
|
2015-12-29 19:47:04 +08:00
|
|
|
gimp_config_reset (GIMP_CONFIG (tool_info->tool_options));
|
2005-09-04 18:44:04 +08:00
|
|
|
}
|
|
|
|
|
2007-12-20 01:45:47 +08:00
|
|
|
if (! gimp_contexts_load (gimp, &error))
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING, error->message);
|
2007-12-20 01:45:47 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2005-09-04 18:44:04 +08:00
|
|
|
|
2017-10-29 21:50:28 +08:00
|
|
|
if (! gimp_internal_data_load (gimp, &error))
|
|
|
|
{
|
|
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING, error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
|
2015-03-04 03:24:40 +08:00
|
|
|
/* make sure there is always a tool active, so broken config files
|
|
|
|
* can't leave us with no initial tool
|
|
|
|
*/
|
|
|
|
if (! gimp_context_get_tool (gimp_get_user_context (gimp)))
|
|
|
|
{
|
|
|
|
gimp_context_set_tool (gimp_get_user_context (gimp),
|
|
|
|
gimp_get_tool_info_iter (gimp)->data);
|
|
|
|
}
|
|
|
|
|
2008-11-03 05:34:14 +08:00
|
|
|
for (list = gimp_get_tool_info_iter (gimp);
|
2005-09-04 18:44:04 +08:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data);
|
|
|
|
GimpToolOptionsGUIFunc options_gui_func;
|
|
|
|
|
2010-04-18 18:47:18 +08:00
|
|
|
/* copy all context properties except those the tool actually
|
|
|
|
* uses, because the subsequent deserialize() on the tool
|
|
|
|
* options will only set the properties that were set to
|
|
|
|
* non-default values at the time of saving, and we want to
|
|
|
|
* keep these default values as if they have been saved.
|
|
|
|
* (see bug #541586).
|
|
|
|
*/
|
2005-09-04 18:44:04 +08:00
|
|
|
gimp_context_copy_properties (gimp_get_user_context (gimp),
|
|
|
|
GIMP_CONTEXT (tool_info->tool_options),
|
2015-09-09 03:18:49 +08:00
|
|
|
GIMP_CONTEXT_PROP_MASK_ALL &~
|
|
|
|
(tool_info->context_props |
|
|
|
|
GIMP_CONTEXT_PROP_MASK_TOOL |
|
|
|
|
GIMP_CONTEXT_PROP_MASK_PAINT_INFO));
|
2004-10-07 01:21:22 +08:00
|
|
|
|
2006-12-11 23:16:13 +08:00
|
|
|
gimp_tool_options_deserialize (tool_info->tool_options, NULL);
|
2003-09-18 21:51:10 +08:00
|
|
|
|
|
|
|
options_gui_func = g_object_get_data (G_OBJECT (tool_info),
|
|
|
|
"gimp-tool-options-gui-func");
|
|
|
|
|
2018-09-27 14:31:39 +08:00
|
|
|
if (! options_gui_func)
|
|
|
|
options_gui_func = gimp_tool_options_empty_gui;
|
2003-09-18 21:51:10 +08:00
|
|
|
|
2018-09-27 14:31:39 +08:00
|
|
|
gimp_tools_set_tool_options_gui_func (tool_info->tool_options,
|
|
|
|
options_gui_func);
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-04-12 05:17:59 +08:00
|
|
|
gimp_tools_save (Gimp *gimp,
|
|
|
|
gboolean save_tool_options,
|
|
|
|
gboolean always_save)
|
2003-09-18 21:51:10 +08:00
|
|
|
{
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
GimpConfigWriter *writer;
|
|
|
|
GFile *file;
|
2003-09-18 21:51:10 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2005-09-04 18:44:04 +08:00
|
|
|
if (save_tool_options && (! tool_options_deleted || always_save))
|
2003-09-18 21:51:10 +08:00
|
|
|
{
|
2007-12-20 01:45:47 +08:00
|
|
|
GList *list;
|
|
|
|
GError *error = NULL;
|
2003-09-18 21:51:10 +08:00
|
|
|
|
2007-12-20 01:45:47 +08:00
|
|
|
if (! gimp_contexts_save (gimp, &error))
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING,
|
2013-09-15 00:59:20 +08:00
|
|
|
error->message);
|
2007-12-20 01:45:47 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2003-09-30 04:26:09 +08:00
|
|
|
|
2018-06-29 18:38:47 +08:00
|
|
|
if (! gimp_internal_data_save (gimp, &error))
|
|
|
|
{
|
|
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING,
|
|
|
|
error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2017-10-29 21:50:28 +08:00
|
|
|
|
2006-12-11 23:16:13 +08:00
|
|
|
gimp_tool_options_create_folder ();
|
|
|
|
|
2008-11-03 05:34:14 +08:00
|
|
|
for (list = gimp_get_tool_info_iter (gimp);
|
2006-12-11 23:16:13 +08:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data);
|
|
|
|
|
|
|
|
gimp_tool_options_serialize (tool_info->tool_options, NULL);
|
|
|
|
}
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
2004-05-18 20:23:56 +08:00
|
|
|
|
2014-07-28 08:04:01 +08:00
|
|
|
file = gimp_directory_file ("toolrc", NULL);
|
2005-11-07 06:01:25 +08:00
|
|
|
|
|
|
|
if (gimp->be_verbose)
|
2014-07-02 01:54:50 +08:00
|
|
|
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
|
|
|
|
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
writer = gimp_config_writer_new_from_file (file, TRUE, "GIMP toolrc", NULL);
|
|
|
|
|
|
|
|
if (writer)
|
|
|
|
{
|
|
|
|
gimp_tools_serialize (gimp, gimp->tool_item_list, writer);
|
|
|
|
|
|
|
|
gimp_config_writer_finish (writer, "end of toolrc", NULL);
|
|
|
|
}
|
|
|
|
|
2014-07-02 01:54:50 +08:00
|
|
|
g_object_unref (file);
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
|
|
|
|
2005-04-12 05:17:59 +08:00
|
|
|
gboolean
|
|
|
|
gimp_tools_clear (Gimp *gimp,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
|
2008-11-03 05:34:14 +08:00
|
|
|
for (list = gimp_get_tool_info_iter (gimp);
|
2006-12-11 23:16:13 +08:00
|
|
|
list && success;
|
2005-04-12 05:17:59 +08:00
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data);
|
|
|
|
|
2006-12-11 23:16:13 +08:00
|
|
|
success = gimp_tool_options_delete (tool_info->tool_options, NULL);
|
2005-04-12 05:17:59 +08:00
|
|
|
}
|
|
|
|
|
2005-09-04 18:44:04 +08:00
|
|
|
if (success)
|
|
|
|
success = gimp_contexts_clear (gimp, error);
|
|
|
|
|
2017-10-29 21:50:28 +08:00
|
|
|
if (success)
|
|
|
|
success = gimp_internal_data_clear (gimp, error);
|
|
|
|
|
2005-04-12 05:17:59 +08:00
|
|
|
if (success)
|
|
|
|
tool_options_deleted = TRUE;
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
gboolean
|
|
|
|
gimp_tools_serialize (Gimp *gimp,
|
|
|
|
GimpContainer *container,
|
|
|
|
GimpConfigWriter *writer)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
|
|
|
|
|
|
|
|
gimp_config_writer_open (writer, "file-version");
|
|
|
|
gimp_config_writer_printf (writer, "%d", TOOL_RC_FILE_VERSION);
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
|
|
|
|
gimp_config_writer_linefeed (writer);
|
|
|
|
|
|
|
|
return gimp_config_serialize (GIMP_CONFIG (container), writer, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_tools_deserialize (Gimp *gimp,
|
|
|
|
GimpContainer *container,
|
|
|
|
GScanner *scanner)
|
|
|
|
{
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
FILE_VERSION = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
GimpContainer *src_container;
|
|
|
|
GTokenType token;
|
|
|
|
guint scope_id;
|
|
|
|
guint old_scope_id;
|
|
|
|
gint file_version = 0;
|
|
|
|
gboolean result = FALSE;
|
|
|
|
|
|
|
|
scope_id = g_type_qname (GIMP_TYPE_TOOL_GROUP);
|
|
|
|
old_scope_id = g_scanner_set_scope (scanner, scope_id);
|
|
|
|
|
|
|
|
g_scanner_scope_add_symbol (scanner, scope_id,
|
|
|
|
"file-version",
|
|
|
|
GINT_TO_POINTER (FILE_VERSION));
|
|
|
|
|
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
|
|
|
|
|
|
|
while (g_scanner_peek_next_token (scanner) == token &&
|
|
|
|
(token != G_TOKEN_LEFT_PAREN ||
|
|
|
|
! file_version))
|
|
|
|
{
|
|
|
|
token = g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case G_TOKEN_LEFT_PAREN:
|
|
|
|
token = G_TOKEN_SYMBOL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_TOKEN_SYMBOL:
|
|
|
|
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
|
|
|
|
{
|
|
|
|
case FILE_VERSION:
|
|
|
|
token = G_TOKEN_INT;
|
|
|
|
if (gimp_scanner_parse_int (scanner, &file_version))
|
|
|
|
token = G_TOKEN_RIGHT_PAREN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_TOKEN_RIGHT_PAREN:
|
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_scanner_set_scope (scanner, old_scope_id);
|
|
|
|
|
|
|
|
if (token != G_TOKEN_LEFT_PAREN)
|
|
|
|
{
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
|
|
|
|
_("fatal parse error"), TRUE);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (file_version != TOOL_RC_FILE_VERSION)
|
|
|
|
{
|
|
|
|
g_scanner_error (scanner, "wrong toolrc file format version");
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_container_freeze (container);
|
|
|
|
|
2020-01-30 16:45:41 +08:00
|
|
|
/* make sure the various GimpToolItem types are registered */
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
g_type_class_unref (g_type_class_ref (GIMP_TYPE_TOOL_GROUP));
|
2020-01-30 16:45:41 +08:00
|
|
|
g_type_class_unref (g_type_class_ref (GIMP_TYPE_TOOL_INFO));
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
|
|
|
|
gimp_container_clear (container);
|
|
|
|
|
|
|
|
src_container = g_object_new (GIMP_TYPE_LIST,
|
|
|
|
"children-type", GIMP_TYPE_TOOL_ITEM,
|
|
|
|
"append", TRUE,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (gimp_config_deserialize (GIMP_CONFIG (src_container),
|
|
|
|
scanner, 0, NULL))
|
|
|
|
{
|
|
|
|
GHashTable *tools;
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
result = TRUE;
|
|
|
|
|
|
|
|
tools = g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
|
|
|
|
|
|
gimp_tools_copy_structure (gimp, src_container, container, tools);
|
|
|
|
|
|
|
|
for (list = gimp_get_tool_info_iter (gimp);
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info = list->data;
|
|
|
|
|
|
|
|
if (! tool_info->hidden && ! g_hash_table_contains (tools, tool_info))
|
|
|
|
{
|
2020-02-05 06:03:13 +08:00
|
|
|
if (tool_info->experimental)
|
|
|
|
{
|
|
|
|
/* if an experimental tool is not in the file, just add it to
|
|
|
|
* the tool-item list.
|
|
|
|
*/
|
|
|
|
gimp_container_add (container, GIMP_OBJECT (tool_info));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* otherwise, it means we added a new stable tool. this must
|
|
|
|
* be the user toolrc file; rejct it, so that we fall back to
|
|
|
|
* the default toolrc file, which should contain the missing
|
|
|
|
* tool.
|
|
|
|
*/
|
|
|
|
g_scanner_error (scanner, "missing tools in toolrc file");
|
|
|
|
|
|
|
|
result = FALSE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_hash_table_unref (tools);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (src_container);
|
|
|
|
|
|
|
|
gimp_container_thaw (container);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_tools_reset (Gimp *gimp,
|
|
|
|
GimpContainer *container,
|
|
|
|
gboolean user_toolrc)
|
|
|
|
{
|
|
|
|
GList *files = NULL;
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
g_return_if_fail (GIMP_IS_CONTAINER (container));
|
|
|
|
|
|
|
|
if (user_toolrc)
|
|
|
|
files = g_list_prepend (files, gimp_directory_file ("toolrc", NULL));
|
|
|
|
files = g_list_prepend (files, gimp_sysconf_directory_file ("toolrc", NULL));
|
|
|
|
|
|
|
|
files = g_list_reverse (files);
|
|
|
|
|
|
|
|
gimp_container_freeze (container);
|
|
|
|
|
|
|
|
gimp_container_clear (container);
|
|
|
|
|
|
|
|
for (list = files; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GScanner *scanner;
|
|
|
|
GFile *file = list->data;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
|
|
|
|
|
|
|
|
scanner = gimp_scanner_new_file (file, &error);
|
|
|
|
|
|
|
|
if (scanner && gimp_tools_deserialize (gimp, container, scanner))
|
|
|
|
{
|
|
|
|
gimp_scanner_unref (scanner);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (error->code != G_IO_ERROR_NOT_FOUND)
|
|
|
|
{
|
|
|
|
gimp_message_literal (gimp, NULL,
|
|
|
|
GIMP_MESSAGE_WARNING, error->message);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
|
|
|
gimp_container_clear (container);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_clear_pointer (&scanner, gimp_scanner_unref);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free_full (files, g_object_unref);
|
|
|
|
|
|
|
|
if (gimp_container_is_empty (container))
|
|
|
|
{
|
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print ("Using default tool order\n");
|
|
|
|
|
|
|
|
gimp_tools_copy_structure (gimp, gimp->tool_info_list, container, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_container_thaw (container);
|
|
|
|
}
|
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_tools_register (GType tool_type,
|
|
|
|
GType tool_options_type,
|
|
|
|
GimpToolOptionsGUIFunc options_gui_func,
|
|
|
|
GimpContextPropMask context_props,
|
|
|
|
const gchar *identifier,
|
2017-07-05 04:36:24 +08:00
|
|
|
const gchar *label,
|
|
|
|
const gchar *tooltip,
|
2012-02-14 17:00:26 +08:00
|
|
|
const gchar *menu_label,
|
2003-09-18 21:51:10 +08:00
|
|
|
const gchar *menu_accel,
|
|
|
|
const gchar *help_domain,
|
|
|
|
const gchar *help_data,
|
2014-05-07 07:01:56 +08:00
|
|
|
const gchar *icon_name,
|
2003-09-18 21:51:10 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
Gimp *gimp = (Gimp *) data;
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
const gchar *paint_core_name;
|
2006-05-24 23:04:45 +08:00
|
|
|
gboolean visible;
|
2003-09-18 21:51:10 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
g_return_if_fail (g_type_is_a (tool_type, GIMP_TYPE_TOOL));
|
|
|
|
g_return_if_fail (tool_options_type == G_TYPE_NONE ||
|
|
|
|
g_type_is_a (tool_options_type, GIMP_TYPE_TOOL_OPTIONS));
|
|
|
|
|
|
|
|
if (tool_options_type == G_TYPE_NONE)
|
|
|
|
tool_options_type = GIMP_TYPE_TOOL_OPTIONS;
|
|
|
|
|
|
|
|
if (tool_type == GIMP_TYPE_PENCIL_TOOL)
|
|
|
|
{
|
2005-12-28 02:57:01 +08:00
|
|
|
paint_core_name = "gimp-pencil";
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
|
|
|
else if (tool_type == GIMP_TYPE_PAINTBRUSH_TOOL)
|
|
|
|
{
|
2005-12-28 02:57:01 +08:00
|
|
|
paint_core_name = "gimp-paintbrush";
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
|
|
|
else if (tool_type == GIMP_TYPE_ERASER_TOOL)
|
|
|
|
{
|
2005-12-28 02:57:01 +08:00
|
|
|
paint_core_name = "gimp-eraser";
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
|
|
|
else if (tool_type == GIMP_TYPE_AIRBRUSH_TOOL)
|
|
|
|
{
|
2005-12-28 02:57:01 +08:00
|
|
|
paint_core_name = "gimp-airbrush";
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
|
|
|
else if (tool_type == GIMP_TYPE_CLONE_TOOL)
|
|
|
|
{
|
2005-12-28 02:57:01 +08:00
|
|
|
paint_core_name = "gimp-clone";
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
2006-09-03 02:54:35 +08:00
|
|
|
else if (tool_type == GIMP_TYPE_HEAL_TOOL)
|
|
|
|
{
|
|
|
|
paint_core_name = "gimp-heal";
|
|
|
|
}
|
2006-09-08 01:10:22 +08:00
|
|
|
else if (tool_type == GIMP_TYPE_PERSPECTIVE_CLONE_TOOL)
|
|
|
|
{
|
|
|
|
paint_core_name = "gimp-perspective-clone";
|
|
|
|
}
|
2003-09-18 21:51:10 +08:00
|
|
|
else if (tool_type == GIMP_TYPE_CONVOLVE_TOOL)
|
|
|
|
{
|
2005-12-28 02:57:01 +08:00
|
|
|
paint_core_name = "gimp-convolve";
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
|
|
|
else if (tool_type == GIMP_TYPE_SMUDGE_TOOL)
|
|
|
|
{
|
2005-12-28 02:57:01 +08:00
|
|
|
paint_core_name = "gimp-smudge";
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
2004-04-21 18:55:45 +08:00
|
|
|
else if (tool_type == GIMP_TYPE_DODGE_BURN_TOOL)
|
2003-09-18 21:51:10 +08:00
|
|
|
{
|
2005-12-28 02:57:01 +08:00
|
|
|
paint_core_name = "gimp-dodge-burn";
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
2004-05-26 23:34:45 +08:00
|
|
|
else if (tool_type == GIMP_TYPE_INK_TOOL)
|
|
|
|
{
|
2005-12-28 02:57:01 +08:00
|
|
|
paint_core_name = "gimp-ink";
|
2004-05-26 23:34:45 +08:00
|
|
|
}
|
2014-04-06 21:48:53 +08:00
|
|
|
else if (tool_type == GIMP_TYPE_MYBRUSH_TOOL)
|
|
|
|
{
|
|
|
|
paint_core_name = "gimp-mybrush";
|
|
|
|
}
|
2003-09-18 21:51:10 +08:00
|
|
|
else
|
|
|
|
{
|
2005-12-28 02:57:01 +08:00
|
|
|
paint_core_name = "gimp-paintbrush";
|
2003-09-18 21:51:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
tool_info = gimp_tool_info_new (gimp,
|
2006-04-12 20:49:29 +08:00
|
|
|
tool_type,
|
2003-09-18 21:51:10 +08:00
|
|
|
tool_options_type,
|
2006-04-12 20:49:29 +08:00
|
|
|
context_props,
|
|
|
|
identifier,
|
2017-07-05 04:36:24 +08:00
|
|
|
label,
|
|
|
|
tooltip,
|
2012-02-14 17:00:26 +08:00
|
|
|
menu_label,
|
2006-04-12 20:49:29 +08:00
|
|
|
menu_accel,
|
|
|
|
help_domain,
|
|
|
|
help_data,
|
2003-09-18 21:51:10 +08:00
|
|
|
paint_core_name,
|
2014-05-07 07:01:56 +08:00
|
|
|
icon_name);
|
2003-09-18 21:51:10 +08:00
|
|
|
|
2016-05-10 06:08:36 +08:00
|
|
|
visible = (! g_type_is_a (tool_type, GIMP_TYPE_FILTER_TOOL));
|
2006-05-24 23:04:45 +08:00
|
|
|
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
gimp_tool_item_set_visible (GIMP_TOOL_ITEM (tool_info), visible);
|
2018-01-05 02:23:39 +08:00
|
|
|
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
/* hack to hide the operation tool entirely */
|
2023-05-25 07:56:27 +08:00
|
|
|
if (tool_type == GIMP_TYPE_OPERATION_TOOL)
|
2018-01-05 02:23:39 +08:00
|
|
|
tool_info->hidden = TRUE;
|
|
|
|
|
2020-02-05 06:03:13 +08:00
|
|
|
/* hack to not require experimental tools to be present in toolrc */
|
|
|
|
if (tool_type == GIMP_TYPE_N_POINT_DEFORMATION_TOOL ||
|
2020-11-25 04:43:11 +08:00
|
|
|
tool_type == GIMP_TYPE_SEAMLESS_CLONE_TOOL ||
|
|
|
|
tool_type == GIMP_TYPE_PAINT_SELECT_TOOL)
|
2020-02-05 06:03:13 +08:00
|
|
|
{
|
|
|
|
tool_info->experimental = TRUE;
|
|
|
|
}
|
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
g_object_set_data (G_OBJECT (tool_info), "gimp-tool-options-gui-func",
|
|
|
|
options_gui_func);
|
|
|
|
|
|
|
|
gimp_container_add (gimp->tool_info_list, GIMP_OBJECT (tool_info));
|
|
|
|
g_object_unref (tool_info);
|
|
|
|
|
2004-08-26 17:41:18 +08:00
|
|
|
if (tool_type == GIMP_TYPE_PAINTBRUSH_TOOL)
|
2003-09-18 21:51:10 +08:00
|
|
|
gimp_tool_info_set_standard (gimp, tool_info);
|
|
|
|
}
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_tools_copy_structure (Gimp *gimp,
|
|
|
|
GimpContainer *src_container,
|
|
|
|
GimpContainer *dest_container,
|
|
|
|
GHashTable *tools)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = GIMP_LIST (src_container)->queue->head;
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpToolItem *src_tool_item = list->data;
|
|
|
|
GimpToolItem *dest_tool_item = NULL;
|
|
|
|
|
|
|
|
if (GIMP_IS_TOOL_GROUP (src_tool_item))
|
|
|
|
{
|
|
|
|
dest_tool_item = GIMP_TOOL_ITEM (gimp_tool_group_new ());
|
|
|
|
|
|
|
|
gimp_tools_copy_structure (
|
|
|
|
gimp,
|
|
|
|
gimp_viewable_get_children (GIMP_VIEWABLE (src_tool_item)),
|
|
|
|
gimp_viewable_get_children (GIMP_VIEWABLE (dest_tool_item)),
|
|
|
|
tools);
|
|
|
|
|
|
|
|
gimp_tool_group_set_active_tool (
|
|
|
|
GIMP_TOOL_GROUP (dest_tool_item),
|
|
|
|
gimp_tool_group_get_active_tool (GIMP_TOOL_GROUP (src_tool_item)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dest_tool_item = GIMP_TOOL_ITEM (
|
|
|
|
gimp_get_tool_info (gimp, gimp_object_get_name (src_tool_item)));
|
|
|
|
|
2020-01-30 16:45:41 +08:00
|
|
|
if (dest_tool_item)
|
|
|
|
{
|
|
|
|
if (! GIMP_TOOL_INFO (dest_tool_item)->hidden)
|
|
|
|
{
|
|
|
|
g_object_ref (dest_tool_item);
|
|
|
|
|
|
|
|
if (tools)
|
|
|
|
g_hash_table_add (tools, dest_tool_item);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dest_tool_item = NULL;
|
|
|
|
}
|
|
|
|
}
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dest_tool_item)
|
|
|
|
{
|
|
|
|
gimp_tool_item_set_visible (
|
|
|
|
dest_tool_item,
|
|
|
|
gimp_tool_item_get_visible (src_tool_item));
|
|
|
|
|
|
|
|
gimp_container_add (dest_container,
|
|
|
|
GIMP_OBJECT (dest_tool_item));
|
2020-01-30 16:45:41 +08:00
|
|
|
|
|
|
|
g_object_unref (dest_tool_item);
|
app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list. The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).
In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.
Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced. This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.
Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use). If neither file is found,
the hard-coded flat tool order is used. This commit doesn't
provide a default toolrc file, but the next commits will.
Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 03:02:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|