[gimp] Base infra for tool presets.



commit 29f7fe87b02a49049ad7740aa9285a46391bcaee
Author: Alexia Death <alexiadeath gmail com>
Date:   Sat Apr 3 18:25:31 2010 +0300

    Base infra for tool presets.

 app/actions/Makefile.am                 |    4 +
 app/actions/actions.c                   |    4 +
 app/actions/dialogs-actions.c           |    6 +
 app/actions/tool-preset-actions.c       |  132 +++++++++++++++++
 app/actions/tool-preset-actions.h       |   27 ++++
 app/config/gimpcoreconfig.c             |   49 ++++++
 app/config/gimpcoreconfig.h             |    3 +
 app/config/gimprc-blurbs.h              |   11 ++-
 app/core/Makefile.am                    |    6 +
 app/core/core-enums.h                   |    9 +-
 app/core/core-types.h                   |    1 +
 app/core/gimp.c                         |   39 +++++
 app/core/gimp.h                         |    1 +
 app/core/gimpcontext.c                  |  242 ++++++++++++++++++++++++++++---
 app/core/gimpcontext.h                  |   12 ++
 app/core/gimptoolpreset-load.c          |   52 +++++++
 app/core/gimptoolpreset-load.h          |   29 ++++
 app/core/gimptoolpreset-save.c          |   42 ++++++
 app/core/gimptoolpreset-save.h          |   27 ++++
 app/core/gimptoolpreset.c               |  223 ++++++++++++++++++++++++++++
 app/core/gimptoolpreset.h               |   53 +++++++
 app/dialogs/dialogs-constructors.c      |   25 +++
 app/dialogs/dialogs-constructors.h      |   10 +-
 app/dialogs/dialogs.c                   |   12 +-
 app/menus/menus.c                       |    9 +
 app/menus/plug-in-menus.c               |    5 +
 app/widgets/Makefile.am                 |    4 +
 app/widgets/gimphelp-ids.h              |   10 ++
 app/widgets/gimptoolpreseteditor.c      |  195 +++++++++++++++++++++++++
 app/widgets/gimptoolpreseteditor.h      |   55 +++++++
 app/widgets/gimptoolpresetfactoryview.c |   91 ++++++++++++
 app/widgets/gimptoolpresetfactoryview.h |   58 ++++++++
 app/widgets/widgets-types.h             |    3 +-
 libgimpwidgets/gimpstock.h              |    1 +
 menus/Makefile.am                       |    1 +
 menus/tool-preset-menu.xml              |   16 ++
 36 files changed, 1437 insertions(+), 30 deletions(-)
---
diff --git a/app/actions/Makefile.am b/app/actions/Makefile.am
index c1ea88d..83b0a9c 100644
--- a/app/actions/Makefile.am
+++ b/app/actions/Makefile.am
@@ -161,6 +161,10 @@ libappactions_a_SOURCES = \
 	tool-options-actions.h		\
 	tool-options-commands.c		\
 	tool-options-commands.h		\
+	tool-preset-actions.c		\
+	tool-preset-actions.h		\
+	tool-preset-editor-actions.c		\
+	tool-preset-editor-actions.h		\
 	tools-actions.c			\
 	tools-actions.h			\
 	tools-commands.c		\
diff --git a/app/actions/actions.c b/app/actions/actions.c
index 0040bcf..7ae269c 100644
--- a/app/actions/actions.c
+++ b/app/actions/actions.c
@@ -87,6 +87,7 @@
 #include "text-editor-actions.h"
 #include "text-tool-actions.h"
 #include "tool-options-actions.h"
+#include "tool-preset-actions.h"
 #include "tools-actions.h"
 #include "vectors-actions.h"
 #include "view-actions.h"
@@ -170,6 +171,9 @@ static const GimpActionFactoryEntry action_groups[] =
   { "gradients", N_("Gradients"), GIMP_STOCK_GRADIENT,
     gradients_actions_setup,
     gradients_actions_update },
+  { "tool-preset", N_("Tool Presets"), GIMP_STOCK_DYNAMICS,
+    tool_preset_actions_setup,
+    tool_preset_actions_update },
   { "help", N_("Help"), GTK_STOCK_HELP,
     help_actions_setup,
     help_actions_update },
diff --git a/app/actions/dialogs-actions.c b/app/actions/dialogs-actions.c
index 2d16df6..459cef4 100644
--- a/app/actions/dialogs-actions.c
+++ b/app/actions/dialogs-actions.c
@@ -142,6 +142,12 @@ const GimpStringActionEntry dialogs_dockable_actions[] =
     "gimp-dynamics-list",
     GIMP_HELP_DYNAMICS_DIALOG },
 
+  { "dialogs-tool-presets", GIMP_STOCK_TOOL_PRESET,
+    NC_("dialogs-action", "Tool presets"), NULL,
+    NC_("dialogs-action", "Open tool presets dialog"),
+    "gimp-tool-preset-list",
+    GIMP_HELP_TOOL_PRESET_DIALOG },
+
   { "dialogs-dynamics-editor", GIMP_STOCK_DYNAMICS,
     NC_("dialogs-action", "Paint Dynamics Editor"), NULL,
     NC_("dialogs-action", "Open the paint dynamics editor"),
diff --git a/app/actions/tool-preset-actions.c b/app/actions/tool-preset-actions.c
new file mode 100644
index 0000000..0e57ad7
--- /dev/null
+++ b/app/actions/tool-preset-actions.c
@@ -0,0 +1,132 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+#include "libgimpwidgets/gimpwidgets.h"
+
+#include "actions-types.h"
+
+#include "core/gimpcontext.h"
+#include "core/gimpdata.h"
+#include "core/gimptoolpreset.h"
+#include "core/gimptooloptions.h"
+
+#include "widgets/gimpactiongroup.h"
+#include "widgets/gimphelp-ids.h"
+
+#include "actions.h"
+#include "data-commands.h"
+#include "tool-preset-actions.h"
+
+#include "gimp-intl.h"
+
+
+static const GimpActionEntry tool_preset_actions[] =
+{
+  { "tool-preset-popup", GIMP_STOCK_TOOL_PRESET,
+    NC_("tool-preset-action", "Tool Preset Menu"), NULL, NULL, NULL,
+    GIMP_HELP_TOOL_PRESET_DIALOG },
+
+  { "tool-preset-new", GTK_STOCK_NEW,
+    NC_("tool-preset-action", "_New Tool Preset"), "",
+    NC_("tool-preset-action", "Create a new tool preset"),
+    G_CALLBACK (data_new_cmd_callback),
+    GIMP_HELP_TOOL_PRESET_NEW },
+
+  { "tool-preset-duplicate", GIMP_STOCK_DUPLICATE,
+    NC_("tool-preset-action", "D_uplicate Tool Preset"), NULL,
+    NC_("tool-preset-action", "Duplicate this tool preset"),
+    G_CALLBACK (data_duplicate_cmd_callback),
+    GIMP_HELP_TOOL_PRESET_DUPLICATE },
+
+  { "tool-preset-copy-location", GTK_STOCK_COPY,
+    NC_("tool-preset-action", "Copy Tool Preset _Location"), "",
+    NC_("tool-preset-action", "Copy tool preset file location to clipboard"),
+    G_CALLBACK (data_copy_location_cmd_callback),
+    GIMP_HELP_TOOL_PRESET_COPY_LOCATION },
+
+  { "tool-preset-delete", GTK_STOCK_DELETE,
+    NC_("tool-preset-action", "_Delete ToolPreset"), "",
+    NC_("tool-preset-action", "Delete this tool_preset"),
+    G_CALLBACK (data_delete_cmd_callback),
+    GIMP_HELP_TOOL_PRESET_DELETE },
+
+  { "tool-preset-refresh", GTK_STOCK_REFRESH,
+    NC_("tool-preset-action", "_Refresh Tool Presets"), "",
+    NC_("tool-preset-action", "Refresh tool presets"),
+    G_CALLBACK (data_refresh_cmd_callback),
+    GIMP_HELP_TOOL_PRESET_REFRESH }
+};
+
+static const GimpStringActionEntry tool_preset_edit_actions[] =
+{
+  { "tool-preset-edit", GTK_STOCK_EDIT,
+    NC_("tool-preset-action", "_Edit ToolPreset..."), NULL,
+    NC_("tool-preset-action", "Edit tool preset"),
+    "gimp-tool-preset-editor",
+    GIMP_HELP_TOOL_PRESET_EDIT }
+};
+
+
+void
+tool_preset_actions_setup (GimpActionGroup *group)
+{
+  gimp_action_group_add_actions (group, "tool-preset-action",
+                                 tool_preset_actions,
+                                 G_N_ELEMENTS (tool_preset_actions));
+
+  gimp_action_group_add_string_actions (group, "tool-preset-action",
+                                        tool_preset_edit_actions,
+                                        G_N_ELEMENTS (tool_preset_edit_actions),
+                                        G_CALLBACK (data_edit_cmd_callback));
+}
+
+void
+tool_preset_actions_update (GimpActionGroup *group,
+                            gpointer         user_data)
+{
+  GimpContext  *context  = action_data_get_context (user_data);
+  GimpToolPreset *tool_preset = NULL;
+  GimpData     *data     = NULL;
+  const gchar  *filename = NULL;
+
+  if (context)
+    {
+      tool_preset = GIMP_TOOL_PRESET (gimp_tool_preset_new("Current Options")); //FIXMEE!!!!!!!!!!!!
+
+
+      if (tool_preset)
+        {
+          data = GIMP_DATA (tool_preset);
+
+          filename = gimp_data_get_filename (data);
+        }
+    }
+
+#define SET_SENSITIVE(action,condition) \
+        gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
+
+  SET_SENSITIVE ("tool-preset-edit",          tool_preset);
+  SET_SENSITIVE ("tool-preset-duplicate",     tool_preset && GIMP_DATA_GET_CLASS (data)->duplicate);
+  SET_SENSITIVE ("tool-preset-copy-location", tool_preset && filename);
+  SET_SENSITIVE ("tool-preset-delete",        tool_preset && gimp_data_is_deletable (data));
+
+#undef SET_SENSITIVE
+}
diff --git a/app/actions/tool-preset-actions.h b/app/actions/tool-preset-actions.h
new file mode 100644
index 0000000..8625e02
--- /dev/null
+++ b/app/actions/tool-preset-actions.h
@@ -0,0 +1,27 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __TOOL_PRESET_ACTIONS_H__
+#define __TOOL_PRESET_ACTIONS_H__
+
+
+void   tool_preset_actions_setup  (GimpActionGroup *group);
+void   tool_preset_actions_update (GimpActionGroup *group,
+                                   gpointer         user_data);
+
+
+#endif /* __TOOL_PRESET_ACTIONS_H__ */
diff --git a/app/config/gimpcoreconfig.c b/app/config/gimpcoreconfig.c
index 392326f..04937d3 100644
--- a/app/config/gimpcoreconfig.c
+++ b/app/config/gimpcoreconfig.c
@@ -42,6 +42,7 @@
 #define DEFAULT_PATTERN   "Pine"
 #define DEFAULT_PALETTE   "Default"
 #define DEFAULT_GRADIENT  "FG to BG (RGB)"
+#define DEFAULT_TOOL_PRESET  "Current Options"
 #define DEFAULT_FONT      "Sans"
 #define DEFAULT_COMMENT   "Created with GIMP"
 
@@ -65,6 +66,8 @@ enum
   PROP_PALETTE_PATH_WRITABLE,
   PROP_GRADIENT_PATH,
   PROP_GRADIENT_PATH_WRITABLE,
+  PROP_TOOL_PRESET_PATH,
+  PROP_TOOL_PRESET_PATH_WRITABLE,
   PROP_FONT_PATH,
   PROP_FONT_PATH_WRITABLE,
   PROP_DEFAULT_BRUSH,
@@ -72,6 +75,7 @@ enum
   PROP_DEFAULT_PATTERN,
   PROP_DEFAULT_PALETTE,
   PROP_DEFAULT_GRADIENT,
+  PROP_DEFAULT_TOOL_PRESET,
   PROP_DEFAULT_FONT,
   PROP_GLOBAL_BRUSH,
   PROP_GLOBAL_DYNAMICS,
@@ -255,6 +259,23 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
                                  GIMP_PARAM_STATIC_STRINGS |
                                  GIMP_CONFIG_PARAM_CONFIRM);
   g_free (path);
+
+  path = gimp_config_build_data_path ("tool-presets");
+  GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_TOOL_PRESET_PATH,
+                                 "tool-preset-path", TOOL_PRESET_PATH_BLURB,
+                                 GIMP_CONFIG_PATH_DIR_LIST, path,
+                                 GIMP_PARAM_STATIC_STRINGS |
+                                 GIMP_CONFIG_PARAM_RESTART);
+  g_free (path);
+  path = gimp_config_build_writable_path ("tool-presets");
+  GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_TOOL_PRESET_PATH_WRITABLE,
+                                 "tool-preset-path-writable",
+                                 TOOL_PRESET_PATH_WRITABLE_BLURB,
+                                 GIMP_CONFIG_PATH_DIR_LIST, path,
+                                 GIMP_PARAM_STATIC_STRINGS |
+                                 GIMP_CONFIG_PARAM_RESTART);
+  g_free (path);
+
   GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_FONT_PATH_WRITABLE,
                                  "font-path-writable", NULL,
                                  GIMP_CONFIG_PATH_DIR_LIST, NULL,
@@ -280,6 +301,10 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
                                    "default-gradient", DEFAULT_GRADIENT_BLURB,
                                    DEFAULT_GRADIENT,
                                    GIMP_PARAM_STATIC_STRINGS);
+  GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_DEFAULT_TOOL_PRESET,
+                                   "default-tool-preset", DEFAULT_TOOL_PRESET_BLURB,
+                                   DEFAULT_TOOL_PRESET,
+                                   GIMP_PARAM_STATIC_STRINGS);
   GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_DEFAULT_FONT,
                                    "default-font", DEFAULT_FONT_BLURB,
                                    DEFAULT_FONT,
@@ -441,6 +466,8 @@ gimp_core_config_finalize (GObject *object)
   g_free (core_config->pattern_path_writable);
   g_free (core_config->palette_path);
   g_free (core_config->palette_path_writable);
+  g_free (core_config->tool_preset_path);
+  g_free (core_config->tool_preset_path_writable);
   g_free (core_config->gradient_path);
   g_free (core_config->gradient_path_writable);
   g_free (core_config->font_path);
@@ -449,6 +476,7 @@ gimp_core_config_finalize (GObject *object)
   g_free (core_config->default_dynamics);
   g_free (core_config->default_pattern);
   g_free (core_config->default_palette);
+  g_free (core_config->default_tool_preset);
   g_free (core_config->default_gradient);
   g_free (core_config->default_font);
   g_free (core_config->plug_in_rc_path);
@@ -514,6 +542,14 @@ gimp_core_config_set_property (GObject      *object,
       g_free (core_config->dynamics_path_writable);
       core_config->dynamics_path_writable = g_value_dup_string (value);
       break;
+    case PROP_TOOL_PRESET_PATH:
+      g_free (core_config->tool_preset_path);
+      core_config->tool_preset_path = g_value_dup_string (value);
+      break;
+    case PROP_TOOL_PRESET_PATH_WRITABLE:
+      g_free (core_config->tool_preset_path_writable);
+      core_config->tool_preset_path_writable = g_value_dup_string (value);
+      break;
     case PROP_PATTERN_PATH:
       g_free (core_config->pattern_path);
       core_config->pattern_path = g_value_dup_string (value);
@@ -566,6 +602,10 @@ gimp_core_config_set_property (GObject      *object,
       g_free (core_config->default_gradient);
       core_config->default_gradient = g_value_dup_string (value);
       break;
+    case PROP_DEFAULT_TOOL_PRESET:
+      g_free (core_config->default_tool_preset);
+      core_config->default_tool_preset = g_value_dup_string (value);
+      break;
     case PROP_DEFAULT_FONT:
       g_free (core_config->default_font);
       core_config->default_font = g_value_dup_string (value);
@@ -693,6 +733,12 @@ gimp_core_config_get_property (GObject    *object,
     case PROP_DYNAMICS_PATH_WRITABLE:
       g_value_set_string (value, core_config->dynamics_path_writable);
       break;
+    case PROP_TOOL_PRESET_PATH:
+      g_value_set_string (value, core_config->tool_preset_path);
+      break;
+    case PROP_TOOL_PRESET_PATH_WRITABLE:
+      g_value_set_string (value, core_config->tool_preset_path_writable);
+      break;
     case PROP_PATTERN_PATH:
       g_value_set_string (value, core_config->pattern_path);
       break;
@@ -732,6 +778,9 @@ gimp_core_config_get_property (GObject    *object,
     case PROP_DEFAULT_GRADIENT:
       g_value_set_string (value, core_config->default_gradient);
       break;
+    case PROP_DEFAULT_TOOL_PRESET:
+      g_value_set_string (value, core_config->default_tool_preset);
+      break;
     case PROP_DEFAULT_FONT:
       g_value_set_string (value, core_config->default_font);
       break;
diff --git a/app/config/gimpcoreconfig.h b/app/config/gimpcoreconfig.h
index 0ff23f2..87f1ec7 100644
--- a/app/config/gimpcoreconfig.h
+++ b/app/config/gimpcoreconfig.h
@@ -57,10 +57,13 @@ struct _GimpCoreConfig
   gchar                  *gradient_path_writable;
   gchar                  *font_path;
   gchar                  *font_path_writable;  /*  unused  */
+  gchar                  *tool_preset_path;
+  gchar                  *tool_preset_path_writable;
   gchar                  *default_brush;
   gchar                  *default_dynamics;
   gchar                  *default_pattern;
   gchar                  *default_palette;
+  gchar                  *default_tool_preset;
   gchar                  *default_gradient;
   gchar                  *default_font;
   gboolean                global_brush;
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 746ee82..0298bc3 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -20,10 +20,15 @@ N_("When enabled, an image will become the active image when its image " \
 #define BRUSH_PATH_WRITABLE_BLURB ""
 
 #define DYNAMICS_PATH_BLURB \
-"Sets the dynamics search path."
+N_("Sets the dynamics search path.")
 
 #define DYNAMICS_PATH_WRITABLE_BLURB ""
 
+#define TOOL_PRESET_PATH_BLURB \
+N_("Sets the dynamics search path.")
+
+#define TOOL_PRESET_PATH_WRITABLE_BLURB ""
+
 #define CANVAS_PADDING_COLOR_BLURB \
 N_("Sets the canvas padding color used if the padding mode is set to " \
    "custom color.")
@@ -58,6 +63,10 @@ N_("Context-dependent mouse pointers are helpful.  They are enabled by " \
 "Specify a default dynamics.  The dynamics is searched for in the " \
 "specified dynamics path."
 
+#define DEFAULT_TOOL_PRESET_BLURB \
+"Specify a default tool preset.  The tool preset is searched for in the " \
+"specified tool prests path."
+
 #define DEFAULT_DOT_FOR_DOT_BLURB \
 N_("When enabled, this will ensure that each pixel of an image gets " \
    "mapped to a pixel on the screen.")
diff --git a/app/core/Makefile.am b/app/core/Makefile.am
index f3def87..5cbeaad 100644
--- a/app/core/Makefile.am
+++ b/app/core/Makefile.am
@@ -359,6 +359,12 @@ libappcore_a_sources = \
 	gimptoolinfo.h				\
 	gimptooloptions.c			\
 	gimptooloptions.h			\
+	gimptoolpreset.c			\
+	gimptoolpreset.h			\
+	gimptoolpreset-load.c			\
+	gimptoolpreset-load.h			\
+	gimptoolpreset-save.c			\
+	gimptoolpreset-save.h			\
 	gimptoolpresets.c			\
 	gimptoolpresets.h			\
 	gimptreehandler.c			\
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index e692897..10b4afb 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -625,10 +625,11 @@ typedef enum  /*< pdb-skip, skip >*/
   GIMP_CONTEXT_PROP_PATTERN    = 12,
   GIMP_CONTEXT_PROP_GRADIENT   = 13,
   GIMP_CONTEXT_PROP_PALETTE    = 14,
-  GIMP_CONTEXT_PROP_FONT       = 15,
-  GIMP_CONTEXT_PROP_BUFFER     = 16,
-  GIMP_CONTEXT_PROP_IMAGEFILE  = 17,
-  GIMP_CONTEXT_PROP_TEMPLATE   = 18,
+  GIMP_CONTEXT_PROP_TOOL_PRESET= 15,
+  GIMP_CONTEXT_PROP_FONT       = 16,
+  GIMP_CONTEXT_PROP_BUFFER     = 17,
+  GIMP_CONTEXT_PROP_IMAGEFILE  = 18,
+  GIMP_CONTEXT_PROP_TEMPLATE   = 19,
 
   GIMP_CONTEXT_LAST_PROP       = GIMP_CONTEXT_PROP_TEMPLATE
 } GimpContextPropType;
diff --git a/app/core/core-types.h b/app/core/core-types.h
index 70f497f..ace5370 100644
--- a/app/core/core-types.h
+++ b/app/core/core-types.h
@@ -109,6 +109,7 @@ typedef struct _GimpGradient         GimpGradient;
 typedef struct _GimpPalette          GimpPalette;
 typedef struct _GimpPattern          GimpPattern;
 typedef struct _GimpPatternClipboard GimpPatternClipboard;
+typedef struct _GimpToolPreset       GimpToolPreset;
 typedef struct _GimpTagCache         GimpTagCache;
 
 
diff --git a/app/core/gimp.c b/app/core/gimp.c
index 802e151..c6d0573 100644
--- a/app/core/gimp.c
+++ b/app/core/gimp.c
@@ -76,6 +76,8 @@
 #include "gimptagcache.h"
 #include "gimptemplate.h"
 #include "gimptoolinfo.h"
+#include "gimptoolpreset.h"
+#include "gimptoolpreset-load.h"
 
 #include "gimp-intl.h"
 
@@ -248,6 +250,8 @@ gimp_init (Gimp *gimp)
   gimp->gradient_factory    = NULL;
   gimp->palette_factory     = NULL;
 
+  gimp->tool_preset_factory = NULL;
+
   gimp->tag_cache           = NULL;
 
   gimp->pdb                 = gimp_pdb_new (gimp);
@@ -295,6 +299,9 @@ gimp_dispose (GObject *object)
   if (gimp->palette_factory)
     gimp_data_factory_data_free (gimp->palette_factory);
 
+  if (gimp->tool_preset_factory)
+    gimp_data_factory_data_free (gimp->tool_preset_factory);
+
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
@@ -372,6 +379,12 @@ gimp_finalize (GObject *object)
       gimp->palette_factory = NULL;
     }
 
+  if (gimp->tool_preset_factory)
+    {
+      g_object_unref (gimp->tool_preset_factory);
+      gimp->tool_preset_factory = NULL;
+    }
+
   if (gimp->tag_cache)
     {
       g_object_unref (gimp->tag_cache);
@@ -501,6 +514,8 @@ gimp_get_memsize (GimpObject *object,
                                       gui_size);
   memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->palette_factory),
                                       gui_size);
+  memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->tool_preset_factory),
+                                      gui_size);
 
   memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->tag_cache),
                                       gui_size);
@@ -567,6 +582,11 @@ gimp_real_initialize (Gimp               *gimp,
     { gimp_palette_load,         NULL /* legacy loader */,            TRUE  }
   };
 
+  static const GimpDataFactoryLoaderEntry tool_preset_loader_entries[] =
+  {
+    { gimp_tool_preset_load,        GIMP_TOOL_PRESET_FILE_EXTENSION,        TRUE  }
+  };
+
   GimpData *clipboard_brush;
   GimpData *clipboard_pattern;
 
@@ -632,6 +652,17 @@ gimp_real_initialize (Gimp               *gimp,
   gimp_object_set_static_name (GIMP_OBJECT (gimp->palette_factory),
                                "palette factory");
 
+  gimp->tool_preset_factory =
+    gimp_data_factory_new (gimp,
+                           GIMP_TYPE_TOOL_PRESET,
+                           "tool-preset-path", "tool-preset-path-writable",
+                           tool_preset_loader_entries,
+                           G_N_ELEMENTS (tool_preset_loader_entries),
+                           gimp_tool_preset_new,
+                           gimp_tool_preset_get_standard);
+  gimp_object_set_static_name (GIMP_OBJECT (gimp->tool_preset_factory),
+                               "tool preset factory");
+
   gimp->tag_cache = gimp_tag_cache_new ();
 
   gimp_paint_init (gimp);
@@ -703,6 +734,8 @@ gimp_real_exit (Gimp     *gimp,
   gimp_data_factory_data_save (gimp->gradient_factory);
   gimp_data_factory_data_save (gimp->palette_factory);
 
+  gimp_data_factory_data_save (gimp->tool_preset_factory);
+
   gimp_fonts_reset (gimp);
 
   gimp_templates_save (gimp);
@@ -941,6 +974,10 @@ gimp_restore (Gimp               *gimp,
   if (! gimp->no_fonts)
     gimp_fonts_load (gimp);
 
+  /*  initialize the list of gimp tool presets   */
+  status_callback (NULL, _("Tool Presets"), 0.65);
+  gimp_data_factory_data_init (gimp->tool_preset_factory, gimp->no_data);
+
   /*  initialize the template list  */
   status_callback (NULL, _("Templates"), 0.7);
   gimp_templates_load (gimp);
@@ -962,6 +999,8 @@ gimp_restore (Gimp               *gimp,
                                 gimp_data_factory_get_container (gimp->gradient_factory));
   gimp_tag_cache_add_container (gimp->tag_cache,
                                 gimp_data_factory_get_container (gimp->palette_factory));
+  gimp_tag_cache_add_container (gimp->tag_cache,
+                                gimp_data_factory_get_container (gimp->tool_preset_factory));
 
   g_signal_emit (gimp, gimp_signals[RESTORE], 0, status_callback);
 }
diff --git a/app/core/gimp.h b/app/core/gimp.h
index 31cd82f..6658c19 100644
--- a/app/core/gimp.h
+++ b/app/core/gimp.h
@@ -97,6 +97,7 @@ struct _Gimp
   GimpDataFactory        *pattern_factory;
   GimpDataFactory        *gradient_factory;
   GimpDataFactory        *palette_factory;
+  GimpDataFactory        *tool_preset_factory;
 
   GimpTagCache           *tag_cache;
 
diff --git a/app/core/gimpcontext.c b/app/core/gimpcontext.c
index e4855af..11b2294 100644
--- a/app/core/gimpcontext.c
+++ b/app/core/gimpcontext.c
@@ -45,6 +45,7 @@
 #include "gimppaintinfo.h"
 #include "gimppalette.h"
 #include "gimppattern.h"
+#include "gimptoolpreset.h"
 #include "gimptemplate.h"
 #include "gimptoolinfo.h"
 
@@ -205,6 +206,17 @@ static void gimp_context_palette_list_thaw   (GimpContainer    *container,
 static void gimp_context_real_set_palette    (GimpContext      *context,
                                               GimpPalette      *palatte);
 
+/*  tool preset  */
+static void gimp_context_tool_preset_dirty       (GimpToolPreset   *tool_preset,
+                                                  GimpContext      *context);
+static void gimp_context_tool_preset_removed     (GimpContainer    *container,
+                                                  GimpToolPreset   *tool_preset,
+                                                  GimpContext      *context);
+static void gimp_context_tool_preset_list_thaw   (GimpContainer    *container,
+                                                  GimpContext      *context);
+static void gimp_context_real_set_tool_preset    (GimpContext      *context,
+                                                  GimpToolPreset   *tool_preset);
+
 /*  font  */
 static void gimp_context_font_dirty          (GimpFont         *font,
                                               GimpContext      *context);
@@ -284,6 +296,7 @@ enum
   PATTERN_CHANGED,
   GRADIENT_CHANGED,
   PALETTE_CHANGED,
+  TOOL_PRESET_CHANGED,
   FONT_CHANGED,
   BUFFER_CHANGED,
   IMAGEFILE_CHANGED,
@@ -308,6 +321,7 @@ static const gchar * const gimp_context_prop_names[] =
   "pattern",
   "gradient",
   "palette",
+  "tool-preset",
   "font",
   "buffer",
   "imagefile",
@@ -334,6 +348,7 @@ static GType gimp_context_prop_types[] =
   0,
   0,
   0,
+  0,
   0
 };
 
@@ -346,14 +361,15 @@ G_DEFINE_TYPE_WITH_CODE (GimpContext, gimp_context, GIMP_TYPE_VIEWABLE,
 
 static guint gimp_context_signals[LAST_SIGNAL] = { 0 };
 
-static GimpToolInfo  *standard_tool_info  = NULL;
-static GimpPaintInfo *standard_paint_info = NULL;
-static GimpBrush     *standard_brush      = NULL;
-static GimpDynamics  *standard_dynamics   = NULL;
-static GimpPattern   *standard_pattern    = NULL;
-static GimpGradient  *standard_gradient   = NULL;
-static GimpPalette   *standard_palette    = NULL;
-static GimpFont      *standard_font       = NULL;
+static GimpToolInfo   *standard_tool_info   = NULL;
+static GimpPaintInfo  *standard_paint_info  = NULL;
+static GimpBrush      *standard_brush       = NULL;
+static GimpDynamics   *standard_dynamics    = NULL;
+static GimpPattern    *standard_pattern     = NULL;
+static GimpGradient   *standard_gradient    = NULL;
+static GimpPalette    *standard_palette     = NULL;
+static GimpToolPreset *standard_tool_preset = NULL;
+static GimpFont       *standard_font        = NULL;
 
 
 static void
@@ -497,6 +513,16 @@ gimp_context_class_init (GimpContextClass *klass)
                   G_TYPE_NONE, 1,
                   GIMP_TYPE_PALETTE);
 
+  gimp_context_signals[TOOL_PRESET_CHANGED] =
+    g_signal_new ("tool-preset-changed",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (GimpContextClass, tool_preset_changed),
+                  NULL, NULL,
+                  gimp_marshal_VOID__OBJECT,
+                  G_TYPE_NONE, 1,
+                  GIMP_TYPE_TOOL_PRESET);
+
   gimp_context_signals[FONT_CHANGED] =
     g_signal_new ("font-changed",
                   G_TYPE_FROM_CLASS (klass),
@@ -558,23 +584,25 @@ gimp_context_class_init (GimpContextClass *klass)
   klass->pattern_changed         = NULL;
   klass->gradient_changed        = NULL;
   klass->palette_changed         = NULL;
+  klass->tool_preset_changed     = NULL;
   klass->font_changed            = NULL;
   klass->buffer_changed          = NULL;
   klass->imagefile_changed       = NULL;
   klass->template_changed        = NULL;
 
-  gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGE]      = GIMP_TYPE_IMAGE;
-  gimp_context_prop_types[GIMP_CONTEXT_PROP_TOOL]       = GIMP_TYPE_TOOL_INFO;
-  gimp_context_prop_types[GIMP_CONTEXT_PROP_PAINT_INFO] = GIMP_TYPE_PAINT_INFO;
-  gimp_context_prop_types[GIMP_CONTEXT_PROP_BRUSH]      = GIMP_TYPE_BRUSH;
-  gimp_context_prop_types[GIMP_CONTEXT_PROP_DYNAMICS]   = GIMP_TYPE_DYNAMICS;
-  gimp_context_prop_types[GIMP_CONTEXT_PROP_PATTERN]    = GIMP_TYPE_PATTERN;
-  gimp_context_prop_types[GIMP_CONTEXT_PROP_GRADIENT]   = GIMP_TYPE_GRADIENT;
-  gimp_context_prop_types[GIMP_CONTEXT_PROP_PALETTE]    = GIMP_TYPE_PALETTE;
-  gimp_context_prop_types[GIMP_CONTEXT_PROP_FONT]       = GIMP_TYPE_FONT;
-  gimp_context_prop_types[GIMP_CONTEXT_PROP_BUFFER]     = GIMP_TYPE_BUFFER;
-  gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGEFILE]  = GIMP_TYPE_IMAGEFILE;
-  gimp_context_prop_types[GIMP_CONTEXT_PROP_TEMPLATE]   = GIMP_TYPE_TEMPLATE;
+  gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGE]       = GIMP_TYPE_IMAGE;
+  gimp_context_prop_types[GIMP_CONTEXT_PROP_TOOL]        = GIMP_TYPE_TOOL_INFO;
+  gimp_context_prop_types[GIMP_CONTEXT_PROP_PAINT_INFO]  = GIMP_TYPE_PAINT_INFO;
+  gimp_context_prop_types[GIMP_CONTEXT_PROP_BRUSH]       = GIMP_TYPE_BRUSH;
+  gimp_context_prop_types[GIMP_CONTEXT_PROP_DYNAMICS]    = GIMP_TYPE_DYNAMICS;
+  gimp_context_prop_types[GIMP_CONTEXT_PROP_PATTERN]     = GIMP_TYPE_PATTERN;
+  gimp_context_prop_types[GIMP_CONTEXT_PROP_GRADIENT]    = GIMP_TYPE_GRADIENT;
+  gimp_context_prop_types[GIMP_CONTEXT_PROP_PALETTE]     = GIMP_TYPE_PALETTE;
+  gimp_context_prop_types[GIMP_CONTEXT_PROP_TOOL_PRESET] = GIMP_TYPE_TOOL_PRESET;
+  gimp_context_prop_types[GIMP_CONTEXT_PROP_FONT]        = GIMP_TYPE_FONT;
+  gimp_context_prop_types[GIMP_CONTEXT_PROP_BUFFER]      = GIMP_TYPE_BUFFER;
+  gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGEFILE]   = GIMP_TYPE_IMAGEFILE;
+  gimp_context_prop_types[GIMP_CONTEXT_PROP_TEMPLATE]    = GIMP_TYPE_TEMPLATE;
 
   g_object_class_install_property (object_class, GIMP_CONTEXT_PROP_GIMP,
                                    g_param_spec_object ("gimp",
@@ -662,6 +690,12 @@ gimp_context_class_init (GimpContextClass *klass)
                                    GIMP_TYPE_PALETTE,
                                    GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, GIMP_CONTEXT_PROP_TOOL_PRESET,
+                                   gimp_context_prop_names[GIMP_CONTEXT_PROP_TOOL_PRESET],
+                                   NULL,
+                                   GIMP_TYPE_TOOL_PRESET,
+                                   GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, GIMP_CONTEXT_PROP_FONT,
                                    gimp_context_prop_names[GIMP_CONTEXT_PROP_FONT],
                                    NULL,
@@ -721,6 +755,9 @@ gimp_context_init (GimpContext *context)
   context->palette         = NULL;
   context->palette_name    = NULL;
 
+  context->tool_preset      = NULL;
+  context->tool_preset_name = NULL;
+
   context->font            = NULL;
   context->font_name       = NULL;
 
@@ -814,6 +851,13 @@ gimp_context_constructor (GType                  type,
                            G_CALLBACK (gimp_context_palette_list_thaw),
                            object, 0);
 
+  g_signal_connect_object (gimp_data_factory_get_container (gimp->tool_preset_factory), "remove",
+                           G_CALLBACK (gimp_context_tool_preset_removed),
+                           object, 0);
+  g_signal_connect_object (gimp_data_factory_get_container (gimp->tool_preset_factory), "thaw",
+                           G_CALLBACK (gimp_context_tool_preset_list_thaw),
+                           object, 0);
+
   g_signal_connect_object (gimp->fonts, "remove",
                            G_CALLBACK (gimp_context_font_removed),
                            object, 0);
@@ -946,6 +990,17 @@ gimp_context_finalize (GObject *object)
       context->palette_name = NULL;
     }
 
+  if (context->tool_preset)
+    {
+      g_object_unref (context->tool_preset);
+      context->tool_preset = NULL;
+    }
+  if (context->tool_preset_name)
+    {
+      g_free (context->tool_preset_name);
+      context->tool_preset_name = NULL;
+    }
+
   if (context->font)
     {
       g_object_unref (context->font);
@@ -1045,6 +1100,9 @@ gimp_context_set_property (GObject      *object,
     case GIMP_CONTEXT_PROP_PALETTE:
       gimp_context_set_palette (context, g_value_get_object (value));
       break;
+    case GIMP_CONTEXT_PROP_TOOL_PRESET:
+      gimp_context_set_tool_preset (context, g_value_get_object (value));
+      break;
     case GIMP_CONTEXT_PROP_FONT:
       gimp_context_set_font (context, g_value_get_object (value));
       break;
@@ -1125,6 +1183,9 @@ gimp_context_get_property (GObject    *object,
     case GIMP_CONTEXT_PROP_PALETTE:
       g_value_set_object (value, gimp_context_get_palette (context));
       break;
+    case GIMP_CONTEXT_PROP_TOOL_PRESET:
+      g_value_set_object (value, gimp_context_get_tool_preset (context));
+      break;
     case GIMP_CONTEXT_PROP_FONT:
       g_value_set_object (value, gimp_context_get_font (context));
       break;
@@ -1156,6 +1217,7 @@ gimp_context_get_memsize (GimpObject *object,
   memsize += gimp_string_get_memsize (context->dynamics_name);
   memsize += gimp_string_get_memsize (context->pattern_name);
   memsize += gimp_string_get_memsize (context->palette_name);
+  memsize += gimp_string_get_memsize (context->tool_preset_name);
   memsize += gimp_string_get_memsize (context->font_name);
   memsize += gimp_string_get_memsize (context->buffer_name);
   memsize += gimp_string_get_memsize (context->imagefile_name);
@@ -1196,6 +1258,7 @@ gimp_context_serialize_property (GimpConfig       *config,
     case GIMP_CONTEXT_PROP_PATTERN:
     case GIMP_CONTEXT_PROP_GRADIENT:
     case GIMP_CONTEXT_PROP_PALETTE:
+    case GIMP_CONTEXT_PROP_TOOL_PRESET:
     case GIMP_CONTEXT_PROP_FONT:
       serialize_obj = g_value_get_object (value);
       break;
@@ -1277,6 +1340,13 @@ gimp_context_deserialize_property (GimpConfig *object,
       name_loc  = &context->palette_name;
       break;
 
+    case GIMP_CONTEXT_PROP_TOOL_PRESET:
+      container = gimp_data_factory_get_container (context->gimp->tool_preset_factory);
+      current   = (GimpObject *) context->tool_preset;
+      name_loc  = &context->tool_preset_name;
+      break;
+
+
     case GIMP_CONTEXT_PROP_FONT:
       container = context->gimp->fonts;
       current   = (GimpObject *) context->font;
@@ -1594,6 +1664,15 @@ gimp_context_copy_property (GimpContext         *src,
       dest_name_loc   = &dest->palette_name;
       break;
 
+
+    case GIMP_CONTEXT_PROP_TOOL_PRESET:
+      gimp_context_real_set_tool_preset (dest, src->tool_preset);
+      object          = src->tool_preset;
+      standard_object = standard_tool_preset;
+      src_name        = src->tool_preset_name;
+      dest_name_loc   = &dest->tool_preset_name;
+      break;
+
     case GIMP_CONTEXT_PROP_FONT:
       gimp_context_real_set_font (dest, src->font);
       object          = src->font;
@@ -2971,6 +3050,129 @@ gimp_context_real_set_palette (GimpContext *context,
   gimp_context_palette_changed (context);
 }
 
+/********************************************************************************/
+/*  tool preset *****************************************************************/
+
+GimpToolPreset *
+gimp_context_get_tool_preset (GimpContext *context)
+{
+  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+
+  return context->tool_preset;
+}
+
+void
+gimp_context_set_tool_preset (GimpContext  *context,
+                           GimpToolPreset *tool_preset)
+{
+  g_return_if_fail (GIMP_IS_CONTEXT (context));
+  g_return_if_fail (! tool_preset || GIMP_IS_TOOL_PRESET (tool_preset));
+  context_find_defined (context, GIMP_CONTEXT_PROP_TOOL_PRESET);
+
+  gimp_context_real_set_tool_preset (context, tool_preset);
+}
+
+void
+gimp_context_tool_preset_changed (GimpContext *context)
+{
+  g_return_if_fail (GIMP_IS_CONTEXT (context));
+
+  g_signal_emit (context,
+                 gimp_context_signals[TOOL_PRESET_CHANGED], 0,
+                 context->tool_preset);
+}
+
+static void
+gimp_context_tool_preset_dirty (GimpToolPreset *tool_preset,
+                             GimpContext  *context)
+{
+  g_free (context->tool_preset_name);
+  context->tool_preset_name = g_strdup (gimp_object_get_name (tool_preset));
+}
+
+static void
+gimp_context_tool_preset_removed (GimpContainer *container,
+                               GimpToolPreset  *tool_preset,
+                               GimpContext   *context)
+{
+  if (tool_preset == context->tool_preset)
+    {
+      context->tool_preset = NULL;
+
+      g_signal_handlers_disconnect_by_func (tool_preset,
+                                            gimp_context_tool_preset_dirty,
+                                            context);
+      g_object_unref (tool_preset);
+
+      if (! gimp_container_frozen (container))
+        gimp_context_tool_preset_list_thaw (container, context);
+    }
+}
+
+static void
+gimp_context_tool_preset_list_thaw (GimpContainer *container,
+                                 GimpContext   *context)
+{
+  GimpToolPreset *tool_preset;
+
+  if (! context->tool_preset_name)
+    context->tool_preset_name = g_strdup (context->gimp->config->default_tool_preset);
+
+  tool_preset = gimp_context_find_object (context, container,
+                                          context->tool_preset_name,
+                                          gimp_tool_preset_get_standard ());
+
+  gimp_context_real_set_tool_preset (context, tool_preset);
+}
+
+static void
+gimp_context_real_set_tool_preset (GimpContext  *context,
+                                GimpToolPreset *tool_preset)
+{
+  if (! standard_tool_preset)
+    {
+      standard_tool_preset = GIMP_TOOL_PRESET (gimp_tool_preset_get_standard ());
+    }
+
+  if (context->tool_preset == tool_preset)
+    {
+      return;
+    }
+
+  if (context->tool_preset_name && tool_preset != standard_tool_preset)
+    {
+      g_free (context->tool_preset_name);
+      context->tool_preset_name = NULL;
+    }
+
+  /*  disconnect from the old 's signals  */
+  if (context->tool_preset)
+    {
+      g_signal_handlers_disconnect_by_func (context->tool_preset,
+                                            gimp_context_tool_preset_dirty,
+                                            context);
+      g_object_unref (context->tool_preset);
+    }
+
+  context->tool_preset = tool_preset;
+
+  if (tool_preset)
+    {
+      g_object_ref (tool_preset);
+
+      g_signal_connect_object (tool_preset, "name-changed",
+                               G_CALLBACK (gimp_context_tool_preset_dirty),
+                               context,
+                               0);
+
+      if (tool_preset != standard_tool_preset)
+        context->tool_preset_name = g_strdup (gimp_object_get_name (tool_preset));
+    }
+
+  g_object_notify (G_OBJECT (context), "tool-preset");
+  gimp_context_tool_preset_changed (context);
+}
+
 
 /*****************************************************************************/
 /*  font     *****************************************************************/
diff --git a/app/core/gimpcontext.h b/app/core/gimpcontext.h
index 7969b4a..80e48ca 100644
--- a/app/core/gimpcontext.h
+++ b/app/core/gimpcontext.h
@@ -85,6 +85,9 @@ struct _GimpContext
   GimpPalette          *palette;
   gchar                *palette_name;
 
+  GimpToolPreset       *tool_preset;
+  gchar                *tool_preset_name;
+
   GimpFont             *font;
   gchar                *font_name;
 
@@ -130,6 +133,8 @@ struct _GimpContextClass
                                GimpGradient         *gradient);
   void (* palette_changed)    (GimpContext          *context,
                                GimpPalette          *palette);
+  void (* tool_preset_changed)(GimpContext          *context,
+                               GimpToolPreset       *tool_preset);
   void (* font_changed)       (GimpContext          *context,
                                GimpFont             *font);
   void (* buffer_changed)     (GimpContext          *context,
@@ -300,6 +305,13 @@ void            gimp_context_set_palette        (GimpContext     *context,
 void            gimp_context_palette_changed    (GimpContext     *context);
 
 
+/*  tool_preset  */
+GimpToolPreset * gimp_context_get_tool_preset     (GimpContext     *context);
+void             gimp_context_set_tool_preset     (GimpContext     *context,
+                                                   GimpToolPreset  *tool_preset);
+void             gimp_context_tool_preset_changed (GimpContext     *context);
+
+
 /*  font  */
 GimpFont      * gimp_context_get_font           (GimpContext     *context);
 void            gimp_context_set_font           (GimpContext     *context,
diff --git a/app/core/gimptoolpreset-load.c b/app/core/gimptoolpreset-load.c
new file mode 100644
index 0000000..d3749ab
--- /dev/null
+++ b/app/core/gimptoolpreset-load.c
@@ -0,0 +1,52 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+
+#include "libgimpconfig/gimpconfig.h"
+
+#include "core-types.h"
+
+#include "gimptoolpreset.h"
+#include "gimptoolpreset-load.h"
+
+
+GList *
+gimp_tool_preset_load (const gchar  *filename,
+                       GError      **error)
+{
+  GimpToolPreset *tool_preset;
+
+  g_return_val_if_fail (filename != NULL, NULL);
+  g_return_val_if_fail (g_path_is_absolute (filename), NULL);
+  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+  tool_preset = g_object_new (GIMP_TYPE_TOOL_PRESET, NULL);
+
+  if (gimp_config_deserialize_file (GIMP_CONFIG (tool_preset),
+                                    filename,
+                                    NULL, error))
+    {
+      return g_list_prepend (NULL, tool_preset);
+    }
+
+  g_object_unref (tool_preset);
+
+  return NULL;
+}
diff --git a/app/core/gimptoolpreset-load.h b/app/core/gimptoolpreset-load.h
new file mode 100644
index 0000000..379ec2c
--- /dev/null
+++ b/app/core/gimptoolpreset-load.h
@@ -0,0 +1,29 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_TOOL_PRESET_LOAD_H__
+#define __GIMP_TOOL_PRESET_LOAD_H__
+
+
+#define GIMP_TOOL_PRESET_FILE_EXTENSION ".gtp"
+
+
+GList * gimp_tool_preset_load (const gchar  *filename,
+                               GError      **error);
+
+
+#endif /* __GIMP_TOOL_PRESET_LOAD_H__ */
diff --git a/app/core/gimptoolpreset-save.c b/app/core/gimptoolpreset-save.c
new file mode 100644
index 0000000..b2d88ba
--- /dev/null
+++ b/app/core/gimptoolpreset-save.c
@@ -0,0 +1,42 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+
+#include "libgimpconfig/gimpconfig.h"
+
+#include "core-types.h"
+
+#include "gimptoolpreset.h"
+#include "gimptoolpreset-save.h"
+
+
+gboolean
+gimp_tool_preset_save (GimpData  *data,
+                       GError   **error)
+{
+  g_return_val_if_fail (GIMP_IS_TOOL_PRESET (data), FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+  return gimp_config_serialize_to_file (GIMP_CONFIG (data),
+                                        gimp_data_get_filename (data),
+                                        "GIMP tool preset file",
+                                        "end of GIMP tool preset file",
+                                        NULL, error);
+}
diff --git a/app/core/gimptoolpreset-save.h b/app/core/gimptoolpreset-save.h
new file mode 100644
index 0000000..91e0549
--- /dev/null
+++ b/app/core/gimptoolpreset-save.h
@@ -0,0 +1,27 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_TOOL_PRESET_SAVE_H__
+#define __GIMP_TOOL_PRESET_SAVE_H__
+
+
+/*  don't call this function directly, use gimp_data_save() instead  */
+gboolean   gimp_tool_preset_save (GimpData  *data,
+                                  GError   **error);
+
+
+#endif /* __GIMP_TOOL_PRESET_SAVE_H__ */
diff --git a/app/core/gimptoolpreset.c b/app/core/gimptoolpreset.c
new file mode 100644
index 0000000..382909a
--- /dev/null
+++ b/app/core/gimptoolpreset.c
@@ -0,0 +1,223 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gegl.h>
+
+#include "libgimpmath/gimpmath.h"
+#include "libgimpconfig/gimpconfig.h"
+
+#include "core-types.h"
+
+#include "gimptooloptions.h"
+#include "gimptoolpreset.h"
+#include "gimptoolpreset-load.h"
+#include "gimptoolpreset-save.h"
+
+#include "gimp-intl.h"
+
+enum
+{
+  PROP_0,
+
+  PROP_NAME,
+
+  PROP_TOOL_OPTIONS
+};
+
+
+static void          gimp_tool_preset_finalize      (GObject      *object);
+static void          gimp_tool_preset_set_property  (GObject      *object,
+                                                     guint         property_id,
+                                                     const GValue *value,
+                                                     GParamSpec   *pspec);
+static void          gimp_tool_preset_get_property  (GObject      *object,
+                                                     guint         property_id,
+                                                     GValue       *value,
+                                                     GParamSpec   *pspec);
+static void
+       gimp_tool_preset_dispatch_properties_changed (GObject      *object,
+                                                     guint         n_pspecs,
+                                                     GParamSpec  **pspecs);
+
+static const gchar * gimp_tool_preset_get_extension (GimpData     *data);
+
+
+G_DEFINE_TYPE (GimpToolPreset, gimp_tool_preset,
+               GIMP_TYPE_DATA)
+
+#define parent_class gimp_tool_preset_parent_class
+
+
+static void
+gimp_tool_preset_class_init (GimpToolPresetClass *klass)
+{
+  GObjectClass  *object_class = G_OBJECT_CLASS (klass);
+  GimpDataClass *data_class   = GIMP_DATA_CLASS (klass);
+
+  object_class->finalize                    = gimp_tool_preset_finalize;
+  object_class->set_property                = gimp_tool_preset_set_property;
+  object_class->get_property                = gimp_tool_preset_get_property;
+  object_class->dispatch_properties_changed = gimp_tool_preset_dispatch_properties_changed;
+
+  data_class->save                          = gimp_tool_preset_save;
+  data_class->get_extension                 = gimp_tool_preset_get_extension;
+
+  GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_NAME,
+                                   "name", NULL,
+                                   "Unnamed",
+                                   GIMP_PARAM_STATIC_STRINGS);
+
+  GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_TOOL_OPTIONS,
+                                   "tool-options", NULL,
+                                   GIMP_TYPE_TOOL_PRESET,
+                                   GIMP_CONFIG_PARAM_AGGREGATE);
+
+}
+
+static void
+gimp_tool_preset_init (GimpToolPreset *tool_preset)
+{
+  tool_preset->tool_options = NULL;
+}
+
+static void
+gimp_tool_preset_finalize (GObject *object)
+{
+  GimpToolPreset *tool_preset = GIMP_TOOL_PRESET (object);
+
+  g_object_unref (tool_preset->tool_options);
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gimp_tool_preset_set_property (GObject      *object,
+                               guint         property_id,
+                               const GValue *value,
+                               GParamSpec   *pspec)
+{
+  GimpToolPreset       *tool_preset    = GIMP_TOOL_PRESET (object);
+  GimpToolOptions      *src_output  = NULL;
+  GimpToolOptions      *dest_output = NULL;
+
+  switch (property_id)
+    {
+    case PROP_NAME:
+      gimp_object_set_name (GIMP_OBJECT (tool_preset), g_value_get_string (value));
+      break;
+
+    case PROP_TOOL_OPTIONS:
+      src_output  = g_value_get_object (value);
+      dest_output = tool_preset->tool_options;
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+
+  if (src_output && dest_output)
+    {
+      gimp_config_copy (GIMP_CONFIG (src_output),
+                        GIMP_CONFIG (dest_output),
+                        GIMP_CONFIG_PARAM_SERIALIZE);
+    }
+}
+
+static void
+gimp_tool_preset_get_property (GObject    *object,
+                            guint       property_id,
+                            GValue     *value,
+                            GParamSpec *pspec)
+{
+  GimpToolPreset *tool_preset = GIMP_TOOL_PRESET (object);
+
+  switch (property_id)
+    {
+    case PROP_NAME:
+      g_value_set_string (value, gimp_object_get_name (tool_preset));
+      break;
+
+    case PROP_TOOL_OPTIONS:
+      g_value_set_object (value, tool_preset->tool_options);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
+static void
+gimp_tool_preset_dispatch_properties_changed (GObject     *object,
+                                              guint        n_pspecs,
+                                              GParamSpec **pspecs)
+{
+  gint i;
+
+  G_OBJECT_CLASS (parent_class)->dispatch_properties_changed (object,
+                                                              n_pspecs, pspecs);
+
+  for (i = 0; i < n_pspecs; i++)
+    {
+      if (pspecs[i]->flags & GIMP_CONFIG_PARAM_SERIALIZE)
+        {
+          gimp_data_dirty (GIMP_DATA (object));
+          break;
+        }
+    }
+}
+
+static const gchar *
+gimp_tool_preset_get_extension (GimpData *data)
+{
+  return GIMP_TOOL_PRESET_FILE_EXTENSION;
+}
+
+
+/*  public functions  */
+
+GimpData *
+gimp_tool_preset_new (const gchar *name)
+{
+  return g_object_new (GIMP_TYPE_TOOL_PRESET,
+                       "name", name,
+ //                      "tool-options", options,
+                       NULL);
+}
+
+
+
+GimpData *
+gimp_tool_preset_get_standard (void)
+{
+  static GimpData *standard_tool_preset = NULL;
+
+  if (! standard_tool_preset)
+    {
+      standard_tool_preset = gimp_tool_preset_new ("Standard tool preset");
+
+      gimp_data_clean (standard_tool_preset);
+      gimp_data_make_internal (standard_tool_preset, "gimp-tool-preset-standard");
+
+      g_object_ref (standard_tool_preset);
+    }
+
+  return standard_tool_preset;
+}
diff --git a/app/core/gimptoolpreset.h b/app/core/gimptoolpreset.h
new file mode 100644
index 0000000..31102a4
--- /dev/null
+++ b/app/core/gimptoolpreset.h
@@ -0,0 +1,53 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_TOOL_PRESET_H__
+#define __GIMP_TOOL_PRESET_H__
+
+
+#include "gimpdata.h"
+
+
+#define GIMP_TYPE_TOOL_PRESET            (gimp_tool_preset_get_type ())
+#define GIMP_TOOL_PRESET(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOOL_PRESET, GimpToolPreset))
+#define GIMP_TOOL_PRESET_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_PRESET, GimpToolPresetClass))
+#define GIMP_IS_TOOL_PRESET(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TOOL_PRESET))
+#define GIMP_IS_TOOL_PRESET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_PRESET))
+#define GIMP_TOOL_PRESET_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TOOL_PRESET, GimpToolPresetClass))
+
+
+typedef struct _GimpToolPresetClass GimpToolPresetClass;
+
+struct _GimpToolPreset
+{
+  GimpData            parent_instance;
+  GimpToolOptions     *tool_options;
+};
+
+struct _GimpToolPresetClass
+{
+  GimpDataClass  parent_class;
+};
+
+
+GType                gimp_tool_preset_get_type     (void) G_GNUC_CONST;
+
+GimpData           * gimp_tool_preset_new          (const gchar     *name);
+
+GimpData           * gimp_tool_preset_get_standard (void);
+
+#endif  /*  __GIMP_TOOL_PRESET_H__  */
diff --git a/app/dialogs/dialogs-constructors.c b/app/dialogs/dialogs-constructors.c
index a30f3d0..d8ab4aa 100644
--- a/app/dialogs/dialogs-constructors.c
+++ b/app/dialogs/dialogs-constructors.c
@@ -64,6 +64,8 @@
 #include "widgets/gimptemplateview.h"
 #include "widgets/gimptoolbox.h"
 #include "widgets/gimptooloptionseditor.h"
+#include "widgets/gimptoolpresetfactoryview.h"
+#include "widgets/gimptoolpreseteditor.h"
 #include "widgets/gimpundoeditor.h"
 #include "widgets/gimpvectorstreeview.h"
 
@@ -443,6 +445,19 @@ dialogs_buffer_list_view_new (GimpDialogFactory *factory,
 }
 
 GtkWidget *
+dialogs_tool_preset_list_view_new (GimpDialogFactory *factory,
+                                GimpContext       *context,
+                                GimpUIManager     *ui_manager,
+                                gint               view_size)
+{
+  return gimp_tool_preset_factory_view_new (GIMP_VIEW_TYPE_LIST,
+                                            context->gimp->tool_preset_factory,
+                                            context,
+                                            view_size, 1,
+                                            gimp_dialog_factory_get_menu_factory (factory));
+}
+
+GtkWidget *
 dialogs_document_list_view_new (GimpDialogFactory *factory,
                                 GimpContext       *context,
                                 GimpUIManager     *ui_manager,
@@ -767,6 +782,16 @@ dialogs_palette_editor_get (GimpDialogFactory *factory,
                                   gimp_dialog_factory_get_menu_factory (factory));
 }
 
+GtkWidget *
+dialogs_tool_preset_editor_get (GimpDialogFactory *factory,
+                                GimpContext       *context,
+                                GimpUIManager     *ui_manager,
+                                gint               view_size)
+{
+  return gimp_tool_preset_editor_new (context,
+                                      gimp_dialog_factory_get_menu_factory (factory));
+}
+
 
 /*  private functions  */
 
diff --git a/app/dialogs/dialogs-constructors.h b/app/dialogs/dialogs-constructors.h
index 923d62d..f868728 100644
--- a/app/dialogs/dialogs-constructors.h
+++ b/app/dialogs/dialogs-constructors.h
@@ -155,6 +155,11 @@ GtkWidget * dialogs_buffer_list_view_new   (GimpDialogFactory *factory,
                                             GimpContext       *context,
                                             GimpUIManager     *ui_manager,
                                             gint               view_size);
+GtkWidget * dialogs_tool_preset_list_view_new
+                                           (GimpDialogFactory *factory,
+                                            GimpContext       *context,
+                                            GimpUIManager     *ui_manager,
+                                            gint               view_size);
 GtkWidget * dialogs_document_list_view_new (GimpDialogFactory *factory,
                                             GimpContext       *context,
                                             GimpUIManager     *ui_manager,
@@ -264,6 +269,9 @@ GtkWidget * dialogs_palette_editor_get     (GimpDialogFactory *factory,
                                             GimpContext       *context,
                                             GimpUIManager     *ui_manager,
                                             gint               view_size);
-
+GtkWidget * dialogs_tool_preset_editor_get (GimpDialogFactory *factory,
+                                            GimpContext       *context,
+                                            GimpUIManager     *ui_manager,
+                                            gint               view_size);
 
 #endif /* __DIALOGS_CONSTRUCTORS_H__ */
diff --git a/app/dialogs/dialogs.c b/app/dialogs/dialogs.c
index b9504df..a96a9e5 100644
--- a/app/dialogs/dialogs.c
+++ b/app/dialogs/dialogs.c
@@ -166,13 +166,13 @@ GimpContainer *global_recent_docks = NULL;
     TRUE                          /* hideable         */,  \
     TRUE                          /* dockable         */}
 
-#define LIST(id, name, blurb, stock_id, help_id, view_size) \
+#define LIST(id, new_func, name, blurb, stock_id, help_id, view_size) \
   { "gimp-"#id"-list"             /* identifier       */, \
     name                          /* name             */, \
     blurb                         /* blurb            */, \
     stock_id                      /* stock_id         */, \
     help_id                       /* help_id          */, \
-    dialogs_##id##_list_view_new  /* new_func         */, \
+    dialogs_##new_func##_list_view_new  /* new_func         */, \
     view_size                     /* view_size        */, \
     FALSE                         /* singleton        */, \
     FALSE                         /* session_managed  */, \
@@ -297,8 +297,10 @@ static const GimpDialogFactoryEntry entries[] =
             GIMP_HELP_TEMPLATE_DIALOG, GIMP_VIEW_SIZE_SMALL),
 
   /* Some things do not have grids, so just list */
-  LIST (dynamics, N_("Paint Dynamics"), NULL, GIMP_STOCK_DYNAMICS,
+  LIST (dynamics, dynamics, N_("Paint Dynamics"), NULL, GIMP_STOCK_DYNAMICS,
         GIMP_HELP_DYNAMICS_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
+  LIST (tool-preset, tool_preset, N_("Tool Presets"), NULL, GIMP_STOCK_TOOL_PRESET,
+        GIMP_HELP_TOOL_PRESET_DIALOG, GIMP_VIEW_SIZE_MEDIUM),
 
   /*  image related  */
   DOCKABLE ("gimp-layer-list",
@@ -363,6 +365,10 @@ static const GimpDialogFactoryEntry entries[] =
             N_("Palette Editor"), NULL, GIMP_STOCK_PALETTE,
             GIMP_HELP_PALETTE_EDITOR_DIALOG,
             dialogs_palette_editor_get, 0, TRUE),
+  DOCKABLE ("gimp-tool-preset-editor",
+            N_("Tool Preset Editor"), NULL, GIMP_STOCK_TOOL_PRESET,
+            GIMP_HELP_TOOL_PRESET_EDITOR_DIALOG,
+            dialogs_tool_preset_editor_get, 0, TRUE),
 
   /*  image windows  */
   FOREIGN_NOT_HIDEABLE ("gimp-empty-image-window",
diff --git a/app/menus/menus.c b/app/menus/menus.c
index 12b2767..04f54f2 100644
--- a/app/menus/menus.c
+++ b/app/menus/menus.c
@@ -239,6 +239,15 @@ menus_init (Gimp              *gimp,
                                       "palettes-menu.xml", plug_in_menus_setup,
                                       NULL);
 
+
+  gimp_menu_factory_manager_register (global_menu_factory, "<ToolPreset>",
+                                      "tool-preset",
+                                      "plug-in",
+                                      NULL,
+                                      "/tool-preset-popup",
+                                      "tool-preset-menu.xml", plug_in_menus_setup,
+                                      NULL);
+
   gimp_menu_factory_manager_register (global_menu_factory, "<Fonts>",
                                       "fonts",
                                       "plug-in",
diff --git a/app/menus/plug-in-menus.c b/app/menus/plug-in-menus.c
index 6cdedc0..0c9081c 100644
--- a/app/menus/plug-in-menus.c
+++ b/app/menus/plug-in-menus.c
@@ -342,6 +342,11 @@ plug_in_menus_menu_path_added (GimpPlugInProcedure *plug_in_proc,
           plug_in_menus_add_proc (manager, "/patterns-popup",
                                   plug_in_proc, menu_path);
         }
+      else if (! strcmp (manager->name, "<ToolPreset>"))
+        {
+          plug_in_menus_add_proc (manager, "/tool-preset-popup",
+                                  plug_in_proc, menu_path);
+        }
       else if (! strcmp (manager->name, "<Fonts>"))
         {
           plug_in_menus_add_proc (manager, "/fonts-popup",
diff --git a/app/widgets/Makefile.am b/app/widgets/Makefile.am
index c42a2e4..80b4c90 100644
--- a/app/widgets/Makefile.am
+++ b/app/widgets/Makefile.am
@@ -330,6 +330,10 @@ libappwidgets_a_sources = \
 	gimptooloptionseditor.h		\
 	gimptooloverlay.c		\
 	gimptooloverlay.h		\
+	gimptoolpreseteditor.c		\
+	gimptoolpreseteditor.h		\
+	gimptoolpresetfactoryview.c	\
+	gimptoolpresetfactoryview.h	\
 	gimptranslationstore.c		\
 	gimptranslationstore.h		\
 	gimpuimanager.c			\
diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h
index 3eb2e85..b9a369e 100644
--- a/app/widgets/gimphelp-ids.h
+++ b/app/widgets/gimphelp-ids.h
@@ -311,6 +311,8 @@
 
 #define GIMP_HELP_DYNAMICS_EDITOR_DIALOG          "gimp-dynamics-editor-dialog"
 
+#define GIMP_HELP_TOOL_PRESET_EDITOR_DIALOG       "gimp-tool-preset-editor-dialog"
+
 #define GIMP_HELP_DYNAMICS_DIALOG                 "gimp-dynamics-dialog"
 #define GIMP_HELP_DYNAMICS_EDIT                   "gimp-dynamics-edit"
 #define GIMP_HELP_DYNAMICS_NEW                    "gimp-dynamics-new"
@@ -390,6 +392,14 @@
 #define GIMP_HELP_BUFFER_PASTE_AS_NEW             "gimp-buffer-paste-as-new"
 #define GIMP_HELP_BUFFER_DELETE                   "gimp-buffer-delete"
 
+#define GIMP_HELP_TOOL_PRESET_DIALOG                 "gimp-tool-preset-dialog"
+#define GIMP_HELP_TOOL_PRESET_EDIT                   "gimp-tool-preset-edit"
+#define GIMP_HELP_TOOL_PRESET_NEW                    "gimp-tool-preset-new"
+#define GIMP_HELP_TOOL_PRESET_DUPLICATE              "gimp-tool-preset-duplicate"
+#define GIMP_HELP_TOOL_PRESET_COPY_LOCATION          "gimp-tool-preset-copy-location"
+#define GIMP_HELP_TOOL_PRESET_DELETE                 "gimp-tool-preset-delete"
+#define GIMP_HELP_TOOL_PRESET_REFRESH                "gimp-tool-preset-refresh"
+
 #define GIMP_HELP_DOCUMENT_CLEAR                  "gimp-document-clear"
 #define GIMP_HELP_DOCUMENT_COPY_LOCATION          "gimp-document-copy-location"
 #define GIMP_HELP_DOCUMENT_DIALOG                 "gimp-document-dialog"
diff --git a/app/widgets/gimptoolpreseteditor.c b/app/widgets/gimptoolpreseteditor.c
new file mode 100644
index 0000000..595f23a
--- /dev/null
+++ b/app/widgets/gimptoolpreseteditor.c
@@ -0,0 +1,195 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+#include "libgimpconfig/gimpconfig.h"
+#include "libgimpwidgets/gimpwidgets.h"
+
+#include "widgets-types.h"
+
+#include "core/gimp.h"
+#include "core/gimpcontext.h"
+#include "core/gimptoolpreset.h"
+
+#include "gimpdocked.h"
+#include "gimptoolpreseteditor.h"
+#include "gimpmenufactory.h"
+#include "gimppropwidgets.h"
+
+#include "gimp-intl.h"
+
+
+/*  local function prototypes  */
+
+static GObject * gimp_tool_preset_editor_constructor  (GType              type,
+                                                       guint              n_params,
+                                                       GObjectConstructParam *params);
+
+static void   gimp_tool_preset_editor_set_data        (GimpDataEditor     *editor,
+                                                       GimpData           *data);
+
+static void   gimp_tool_preset_editor_notify_model    (GimpToolPreset       *options,
+                                                       const GParamSpec     *pspec,
+                                                       GimpToolPresetEditor *editor);
+static void   gimp_tool_preset_editor_notify_data     (GimpToolPreset       *options,
+                                                       const GParamSpec   *pspec,
+                                                       GimpToolPresetEditor *editor);
+
+
+
+G_DEFINE_TYPE_WITH_CODE (GimpToolPresetEditor, gimp_tool_preset_editor,
+                         GIMP_TYPE_DATA_EDITOR,
+                         G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED, NULL))
+
+#define parent_class gimp_tool_preset_editor_parent_class
+
+
+static void
+gimp_tool_preset_editor_class_init (GimpToolPresetEditorClass *klass)
+{
+  GObjectClass        *object_class = G_OBJECT_CLASS (klass);
+  GimpDataEditorClass *editor_class = GIMP_DATA_EDITOR_CLASS (klass);
+
+  object_class->constructor = gimp_tool_preset_editor_constructor;
+
+  editor_class->set_data    = gimp_tool_preset_editor_set_data;
+  editor_class->title       = _("Tool Preset Editor");
+}
+
+static void
+gimp_tool_preset_editor_init (GimpToolPresetEditor *editor)
+{
+  GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
+  /*Nuffink*/
+}
+
+static GObject *
+gimp_tool_preset_editor_constructor (GType                  type,
+                                  guint                  n_params,
+                                  GObjectConstructParam *params)
+{
+  GObject *object;
+
+  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
+
+  gimp_docked_set_show_button_bar (GIMP_DOCKED (object), FALSE);
+
+  return object;
+}
+
+static void
+gimp_tool_preset_editor_set_data (GimpDataEditor *editor,
+                               GimpData       *data)
+{
+  GimpToolPresetEditor *tool_preset_editor = GIMP_TOOL_PRESET_EDITOR (editor);
+
+  if (editor->data)
+    g_signal_handlers_disconnect_by_func (editor->data,
+                                          gimp_tool_preset_editor_notify_data,
+                                          editor);
+
+  GIMP_DATA_EDITOR_CLASS (parent_class)->set_data (editor, data);
+
+  if (editor->data)
+    {
+      g_signal_handlers_block_by_func (tool_preset_editor->tool_preset_model,
+                                       gimp_tool_preset_editor_notify_model,
+                                       editor);
+
+      gimp_config_copy (GIMP_CONFIG (editor->data),
+                        GIMP_CONFIG (tool_preset_editor->tool_preset_model),
+                        GIMP_CONFIG_PARAM_SERIALIZE);
+
+      g_signal_handlers_unblock_by_func (tool_preset_editor->tool_preset_model,
+                                         gimp_tool_preset_editor_notify_model,
+                                         editor);
+
+      g_signal_connect (editor->data, "notify",
+                        G_CALLBACK (gimp_tool_preset_editor_notify_data),
+                        editor);
+    }
+}
+
+
+/*  public functions  */
+
+GtkWidget *
+gimp_tool_preset_editor_new (GimpContext     *context,
+                          GimpMenuFactory *menu_factory)
+{
+  g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
+  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+
+  return g_object_new (GIMP_TYPE_TOOL_PRESET_EDITOR,
+                       "menu-factory",    menu_factory,
+                       "menu-identifier", "<ToolPresetEditor>",
+                       "ui-path",         "/tool_preset-editor-popup",
+                       "data-factory",    context->gimp->tool_preset_factory,
+                       "context",         context,
+                       "data",            gimp_context_get_tool_preset (context),
+                       NULL);
+}
+
+
+/*  private functions  */
+
+static void
+gimp_tool_preset_editor_notify_model (GimpToolPreset       *options,
+                                   const GParamSpec   *pspec,
+                                   GimpToolPresetEditor *editor)
+{
+  GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
+
+  if (data_editor->data)
+    {
+      g_signal_handlers_block_by_func (data_editor->data,
+                                       gimp_tool_preset_editor_notify_data,
+                                       editor);
+
+      gimp_config_copy (GIMP_CONFIG (editor->tool_preset_model),
+                        GIMP_CONFIG (data_editor->data),
+                        GIMP_CONFIG_PARAM_SERIALIZE);
+
+      g_signal_handlers_unblock_by_func (data_editor->data,
+                                         gimp_tool_preset_editor_notify_data,
+                                         editor);
+    }
+}
+
+static void
+gimp_tool_preset_editor_notify_data (GimpToolPreset       *options,
+                                  const GParamSpec   *pspec,
+                                  GimpToolPresetEditor *editor)
+{
+  GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
+
+  g_signal_handlers_block_by_func (editor->tool_preset_model,
+                                   gimp_tool_preset_editor_notify_model,
+                                   editor);
+
+  gimp_config_copy (GIMP_CONFIG (data_editor->data),
+                    GIMP_CONFIG (editor->tool_preset_model),
+                    GIMP_CONFIG_PARAM_SERIALIZE);
+
+  g_signal_handlers_unblock_by_func (editor->tool_preset_model,
+                                     gimp_tool_preset_editor_notify_model,
+                                     editor);
+}
diff --git a/app/widgets/gimptoolpreseteditor.h b/app/widgets/gimptoolpreseteditor.h
new file mode 100644
index 0000000..70ae041
--- /dev/null
+++ b/app/widgets/gimptoolpreseteditor.h
@@ -0,0 +1,55 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_TOOL_PRESET_EDITOR_H__
+#define __GIMP_TOOL_PRESET_EDITOR_H__
+
+
+#include "gimpdataeditor.h"
+
+
+#define GIMP_TYPE_TOOL_PRESET_EDITOR            (gimp_tool_preset_editor_get_type ())
+#define GIMP_TOOL_PRESET_EDITOR(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOOL_PRESET_EDITOR, GimpToolPresetEditor))
+#define GIMP_TOOL_PRESET_EDITOR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_PRESET_EDITOR, GimpToolPresetEditorClass))
+#define GIMP_IS_TOOL_PRESET_EDITOR(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TOOL_PRESET_EDITOR))
+#define GIMP_IS_TOOL_PRESET_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_PRESET_EDITOR))
+#define GIMP_TOOL_PRESET_EDITOR_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TOOL_PRESET_EDITOR, GimpToolPresetEditorClass))
+
+
+typedef struct _GimpToolPresetEditorClass GimpToolPresetEditorClass;
+
+struct _GimpToolPresetEditor
+{
+  GimpDataEditor  parent_instance;
+
+  GimpToolPreset   *tool_preset_model;
+
+};
+
+struct _GimpToolPresetEditorClass
+{
+  GimpDataEditorClass  parent_class;
+};
+
+
+GType       gimp_tool_preset_editor_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gimp_tool_preset_editor_new   (GimpContext      *context,
+                                           GimpMenuFactory  *menu_factory);
+
+
+#endif /* __GIMP_TOOL_PRESET_EDITOR_H__ */
diff --git a/app/widgets/gimptoolpresetfactoryview.c b/app/widgets/gimptoolpresetfactoryview.c
new file mode 100644
index 0000000..9f0a452
--- /dev/null
+++ b/app/widgets/gimptoolpresetfactoryview.c
@@ -0,0 +1,91 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimptoolpresetfactoryview.c
+ * Copyright (C) 2010 Alexia Death
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+#include "libgimpwidgets/gimpwidgets.h"
+
+#include "widgets-types.h"
+
+#include "core/gimpcontainer.h"
+#include "core/gimpdatafactory.h"
+#include "core/gimpviewable.h"
+
+#include "gimpcontainerview.h"
+#include "gimpeditor.h"
+#include "gimptoolpresetfactoryview.h"
+#include "gimpviewrenderer.h"
+
+
+G_DEFINE_TYPE (GimpToolPresetFactoryView, gimp_tool_preset_factory_view,
+               GIMP_TYPE_DATA_FACTORY_VIEW)
+
+
+static void
+gimp_tool_preset_factory_view_class_init (GimpToolPresetFactoryViewClass *klass)
+{
+}
+
+static void
+gimp_tool_preset_factory_view_init (GimpToolPresetFactoryView *view)
+{
+}
+
+GtkWidget *
+gimp_tool_preset_factory_view_new (GimpViewType      view_type,
+                                   GimpDataFactory  *factory,
+                                   GimpContext      *context,
+                                   gint              view_size,
+                                   gint              view_border_width,
+                                   GimpMenuFactory  *menu_factory)
+{
+  GimpToolPresetFactoryView *factory_view;
+  GimpContainerEditor     *editor;
+
+  g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
+  g_return_val_if_fail (view_size > 0 &&
+                        view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
+  g_return_val_if_fail (view_border_width >= 0 &&
+                        view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
+                        NULL);
+
+  factory_view = g_object_new (GIMP_TYPE_TOOL_PRESET_FACTORY_VIEW, NULL);
+
+  if (! gimp_data_factory_view_construct (GIMP_DATA_FACTORY_VIEW (factory_view),
+                                          view_type,
+                                          factory,
+                                          context,
+                                          view_size, view_border_width,
+                                          menu_factory, "<ToolPreset>",
+                                          "/tool-preset-popup",
+                                          "tool-preset"))
+    {
+      g_object_unref (factory_view);
+      return NULL;
+    }
+
+  editor = GIMP_CONTAINER_EDITOR (factory_view);
+
+  gtk_widget_hide (gimp_data_factory_view_get_duplicate_button (GIMP_DATA_FACTORY_VIEW (factory_view)));
+
+  return GTK_WIDGET (factory_view);
+}
diff --git a/app/widgets/gimptoolpresetfactoryview.h b/app/widgets/gimptoolpresetfactoryview.h
new file mode 100644
index 0000000..91b0daa
--- /dev/null
+++ b/app/widgets/gimptoolpresetfactoryview.h
@@ -0,0 +1,58 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimptool_presetfactoryview.h
+ * Copyright (C) 2001 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_TOOL_PRESET_FACTORY_VIEW_H__
+#define __GIMP_TOOL_PRESET_FACTORY_VIEW_H__
+
+#include "gimpdatafactoryview.h"
+
+
+#define GIMP_TYPE_TOOL_PRESET_FACTORY_VIEW            (gimp_tool_preset_factory_view_get_type ())
+#define GIMP_TOOL_PRESET_FACTORY_VIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOOL_PRESET_FACTORY_VIEW, GimpToolPresetFactoryView))
+#define GIMP_TOOL_PRESET_FACTORY_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_PRESET_FACTORY_VIEW, GimpToolPresetFactoryViewClass))
+#define GIMP_IS_TOOL_PRESET_FACTORY_VIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TOOL_PRESET_FACTORY_VIEW))
+#define GIMP_IS_TOOL_PRESET_FACTORY_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_PRESET_FACTORY_VIEW))
+#define GIMP_TOOL_PRESET_FACTORY_VIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TOOL_PRESET_FACTORY_VIEW, GimpToolPresetFactoryViewClass))
+
+
+typedef struct _GimpToolPresetFactoryViewClass  GimpToolPresetFactoryViewClass;
+
+struct _GimpToolPresetFactoryView
+{
+  GimpDataFactoryView  parent_instance;
+};
+
+struct _GimpToolPresetFactoryViewClass
+{
+  GimpDataFactoryViewClass  parent_class;
+};
+
+
+GType       gimp_tool_preset_factory_view_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gimp_tool_preset_factory_view_new     (GimpViewType     view_type,
+                                                   GimpDataFactory *factory,
+                                                   GimpContext     *context,
+                                                   gint             view_size,
+                                                   gint             view_border_width,
+                                                   GimpMenuFactory *menu_factory);
+
+
+#endif  /*  __GIMP_TOOL_PRESET_FACTORY_VIEW_H__  */
diff --git a/app/widgets/widgets-types.h b/app/widgets/widgets-types.h
index 1acedf0..47930db 100644
--- a/app/widgets/widgets-types.h
+++ b/app/widgets/widgets-types.h
@@ -63,6 +63,7 @@ typedef struct _GimpBrushEditor              GimpBrushEditor;
 typedef struct _GimpDynamicsEditor           GimpDynamicsEditor;
 typedef struct _GimpGradientEditor           GimpGradientEditor;
 typedef struct _GimpPaletteEditor            GimpPaletteEditor;
+typedef struct _GimpToolPresetEditor         GimpToolPresetEditor;
 
 /*  GimpImageEditor widgets  */
 
@@ -110,7 +111,7 @@ typedef struct _GimpDataFactoryView          GimpDataFactoryView;
 typedef struct _GimpBrushFactoryView         GimpBrushFactoryView;
 typedef struct _GimpDynamicsFactoryView      GimpDynamicsFactoryView;
 typedef struct _GimpPatternFactoryView       GimpPatternFactoryView;
-
+typedef struct _GimpToolPresetFactoryView    GimpToolPresetFactoryView;
 
 /*  menus  */
 
diff --git a/libgimpwidgets/gimpstock.h b/libgimpwidgets/gimpstock.h
index 5805c94..491a16e 100644
--- a/libgimpwidgets/gimpstock.h
+++ b/libgimpwidgets/gimpstock.h
@@ -276,6 +276,7 @@ G_BEGIN_DECLS
 #define GIMP_STOCK_GRADIENT                 GIMP_STOCK_TOOL_BLEND
 #define GIMP_STOCK_PALETTE                  GTK_STOCK_SELECT_COLOR
 #define GIMP_STOCK_PATTERN                  GIMP_STOCK_TOOL_BUCKET_FILL
+#define GIMP_STOCK_TOOL_PRESET              GIMP_STOCK_TOOL_PAINTBRUSH
 #define GIMP_STOCK_TOOL_DESATURATE          GIMP_STOCK_CONVERT_GRAYSCALE
 
 
diff --git a/menus/Makefile.am b/menus/Makefile.am
index a2e1a43..7a0a53a 100644
--- a/menus/Makefile.am
+++ b/menus/Makefile.am
@@ -28,6 +28,7 @@ menudata_DATA = \
 	palette-editor-menu.xml		\
 	palettes-menu.xml		\
 	patterns-menu.xml		\
+	tool-preset-menu.xml		\
 	quick-mask-menu.xml		\
 	sample-points-menu.xml		\
 	selection-menu.xml		\
diff --git a/menus/tool-preset-menu.xml b/menus/tool-preset-menu.xml
new file mode 100644
index 0000000..b38652c
--- /dev/null
+++ b/menus/tool-preset-menu.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE ui SYSTEM "gtkuimanager.dtd">
+
+<ui>
+  <popup action="tool-preset-popup">
+    <menuitem action="tool-preset-edit" />
+    <separator />
+    <menuitem action="tool-preset-new" />
+    <menuitem action="tool-preset-duplicate" />
+    <menuitem action="tool-preset-copy-location" />
+    <menuitem action="tool-preset-delete" />
+    <separator />
+    <menuitem action="tool-preset-refresh" />
+    <separator />
+  </popup>
+</ui>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]