Commit 29f7fe87 authored by Alexia Death's avatar Alexia Death

Base infra for tool presets.

parent a6b2d102
......@@ -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 \
......
......@@ -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 },
......
......@@ -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"),
......
/* 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
}
/* 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__ */
......@@ -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;
......
......@@ -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;
......
......@@ -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.")
......
......@@ -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 \
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -97,6 +97,7 @@ struct _Gimp
GimpDataFactory *pattern_factory;
GimpDataFactory *gradient_factory;
GimpDataFactory *palette_factory;
GimpDataFactory *tool_preset_factory;
GimpTagCache *tag_cache;
......
......@@ -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;