app/core/Makefile.am app/core/core-types.h added GimpToolPresets, derived

2006-12-10  Sven Neumann  <sven@gimp.org>

	* app/core/Makefile.am
	* app/core/core-types.h
	* app/core/gimptoolpresets.[ch]: added GimpToolPresets, derived
	from GimpList.

	* app/core/gimptoolinfo.[ch]: use the new type, renamed
	member "options_presets" to "presets".

	* app/actions/tool-options-actions.c
	* app/actions/tool-options-commands.c
	* app/core/gimptooloptions.[ch]
	* app/menus/tool-options-menu.c
	* app/widgets/gimptooloptionseditor.c: changed accordingly.

	* app/tools/gimp-tools.c: let the GimpToolPresets object deal
with
	loading and saving the presets from ${gimpdir}/tool-options.

	* app/core/gimpcontainer-filter.c
	* app/core/gimpdocumentlist.c
	* app/core/gimplist.c
	* app/text/gimpfontlist.c: use canonical property names.
This commit is contained in:
Sven Neumann
2006-12-10 19:13:58 +00:00
committed by Sven Neumann
parent fb0bd47a22
commit df8bf728a6
19 changed files with 420 additions and 132 deletions

View File

@ -1,3 +1,27 @@
2006-12-10 Sven Neumann <sven@gimp.org>
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimptoolpresets.[ch]: added GimpToolPresets, derived
from GimpList.
* app/core/gimptoolinfo.[ch]: use the new type, renamed
member "options_presets" to "presets".
* app/actions/tool-options-actions.c
* app/actions/tool-options-commands.c
* app/core/gimptooloptions.[ch]
* app/menus/tool-options-menu.c
* app/widgets/gimptooloptionseditor.c: changed accordingly.
* app/tools/gimp-tools.c: let the GimpToolPresets object deal with
loading and saving the presets from ${gimpdir}/tool-options.
* app/core/gimpcontainer-filter.c
* app/core/gimpdocumentlist.c
* app/core/gimplist.c
* app/text/gimpfontlist.c: use canonical property names.
2006-12-10 Sven Neumann <sven@gimp.org>
* modules/controller_midi.c (midi_set_device): use

View File

@ -117,34 +117,34 @@ tool_options_actions_update (GimpActionGroup *group,
GimpContext *context = gimp_get_user_context (group->gimp);
GimpToolInfo *tool_info = gimp_context_get_tool (context);
SET_VISIBLE ("tool-options-save-menu", tool_info->options_presets);
SET_VISIBLE ("tool-options-restore-menu", tool_info->options_presets);
SET_VISIBLE ("tool-options-rename-menu", tool_info->options_presets);
SET_VISIBLE ("tool-options-delete-menu", tool_info->options_presets);
SET_VISIBLE ("tool-options-save-menu", tool_info->presets);
SET_VISIBLE ("tool-options-restore-menu", tool_info->presets);
SET_VISIBLE ("tool-options-rename-menu", tool_info->presets);
SET_VISIBLE ("tool-options-delete-menu", tool_info->presets);
tool_options_actions_update_presets (group, "tool-options-save-",
G_CALLBACK (tool_options_save_to_cmd_callback),
GTK_STOCK_SAVE,
GIMP_HELP_TOOL_OPTIONS_SAVE,
tool_info->options_presets);
GIMP_CONTAINER (tool_info->presets));
tool_options_actions_update_presets (group, "tool-options-restore-",
G_CALLBACK (tool_options_restore_from_cmd_callback),
GTK_STOCK_REVERT_TO_SAVED,
GIMP_HELP_TOOL_OPTIONS_RESTORE,
tool_info->options_presets);
GIMP_CONTAINER (tool_info->presets));
tool_options_actions_update_presets (group, "tool-options-rename-",
G_CALLBACK (tool_options_rename_saved_cmd_callback),
GTK_STOCK_EDIT,
GIMP_HELP_TOOL_OPTIONS_RENAME,
tool_info->options_presets);
GIMP_CONTAINER (tool_info->presets));
tool_options_actions_update_presets (group, "tool-options-delete-",
G_CALLBACK (tool_options_delete_saved_cmd_callback),
GTK_STOCK_DELETE,
GIMP_HELP_TOOL_OPTIONS_DELETE,
tool_info->options_presets);
GIMP_CONTAINER (tool_info->presets));
}

View File

@ -31,6 +31,7 @@
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
#include "core/gimptooloptions.h"
#include "core/gimptoolpresets.h"
#include "widgets/gimpeditor.h"
#include "widgets/gimphelp-ids.h"
@ -90,7 +91,7 @@ tool_options_save_to_cmd_callback (GtkAction *action,
GimpToolOptions *options;
options = (GimpToolOptions *)
gimp_container_get_child_by_index (tool_info->options_presets, value);
gimp_container_get_child_by_index (tool_info->presets, value);
if (options)
{
@ -112,8 +113,7 @@ tool_options_restore_from_cmd_callback (GtkAction *action,
GimpToolInfo *tool_info = gimp_context_get_tool (context);
GimpToolOptions *options;
options = (GimpToolOptions *)
gimp_container_get_child_by_index (tool_info->options_presets, value);
options = gimp_tool_presets_get_options (tool_info->presets, value);
if (options)
gimp_config_sync (G_OBJECT (options),
@ -130,8 +130,7 @@ tool_options_rename_saved_cmd_callback (GtkAction *action,
GimpToolInfo *tool_info = gimp_context_get_tool (context);
GimpToolOptions *options;
options = (GimpToolOptions *)
gimp_container_get_child_by_index (tool_info->options_presets, value);
options = gimp_tool_presets_get_options (tool_info->presets, value);
if (options)
{
@ -160,10 +159,10 @@ tool_options_delete_saved_cmd_callback (GtkAction *action,
GimpToolOptions *options;
options = (GimpToolOptions *)
gimp_container_get_child_by_index (tool_info->options_presets, value);
gimp_container_get_child_by_index (tool_info->presets, value);
if (options)
gimp_container_remove (tool_info->options_presets, GIMP_OBJECT (options));
gimp_container_remove (tool_info->presets, GIMP_OBJECT (options));
}
void
@ -245,7 +244,7 @@ tool_options_save_callback (GtkWidget *widget,
else
gimp_object_set_static_name (GIMP_OBJECT (copy), _("Saved Options"));
gimp_container_insert (tool_info->options_presets, GIMP_OBJECT (copy), -1);
gimp_container_insert (tool_info->presets, GIMP_OBJECT (copy), -1);
g_object_unref (copy);
}

View File

@ -253,6 +253,8 @@ libappcore_a_sources = \
gimptoolinfo.h \
gimptooloptions.c \
gimptooloptions.h \
gimptoolpresets.c \
gimptoolpresets.h \
gimpunit.c \
gimpunit.h \
gimpundo.c \

View File

@ -68,6 +68,7 @@ typedef struct _GimpImage GimpImage;
typedef struct _GimpContainer GimpContainer;
typedef struct _GimpList GimpList;
typedef struct _GimpDocumentList GimpDocumentList;
typedef struct _GimpToolPresets GimpToolPresets;
/* context objects */

View File

@ -78,7 +78,7 @@ gimp_container_filter (const GimpContainer *container,
result =
g_object_new (G_TYPE_FROM_INSTANCE (container),
"children_type", gimp_container_children_type (container),
"children-type", gimp_container_children_type (container),
"policy", GIMP_CONTAINER_POLICY_WEAK,
NULL);

View File

@ -157,8 +157,8 @@ gimp_document_list_new (Gimp *gimp)
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
document_list = g_object_new (GIMP_TYPE_DOCUMENT_LIST,
"name", "document_list",
"children_type", GIMP_TYPE_IMAGEFILE,
"name", "document-list",
"children-type", GIMP_TYPE_IMAGEFILE,
"policy", GIMP_CONTAINER_POLICY_STRONG,
NULL);

View File

@ -335,7 +335,7 @@ gimp_list_new (GType children_type,
g_return_val_if_fail (g_type_is_a (children_type, GIMP_TYPE_OBJECT), NULL);
list = g_object_new (GIMP_TYPE_LIST,
"children_type", children_type,
"children-type", children_type,
"policy", GIMP_CONTAINER_POLICY_STRONG,
"unique-names", unique_names ? TRUE : FALSE,
NULL);
@ -369,7 +369,7 @@ gimp_list_new_weak (GType children_type,
g_return_val_if_fail (g_type_is_a (children_type, GIMP_TYPE_OBJECT), NULL);
list = g_object_new (GIMP_TYPE_LIST,
"children_type", children_type,
"children-type", children_type,
"policy", GIMP_CONTAINER_POLICY_WEAK,
"unique-names", unique_names ? TRUE : FALSE,
NULL);

View File

@ -35,6 +35,7 @@
#include "gimppaintinfo.h"
#include "gimptoolinfo.h"
#include "gimptooloptions.h"
#include "gimptoolpresets.h"
enum
@ -146,10 +147,10 @@ gimp_tool_info_finalize (GObject *object)
tool_info->tool_options = NULL;
}
if (tool_info->options_presets)
if (tool_info->presets)
{
g_object_unref (tool_info->options_presets);
tool_info->options_presets = NULL;
g_object_unref (tool_info->presets);
tool_info->presets = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
@ -279,8 +280,7 @@ gimp_tool_info_new (Gimp *gimp,
if (tool_info->tool_options_type != GIMP_TYPE_TOOL_OPTIONS)
{
tool_info->options_presets = gimp_list_new (tool_info->tool_options_type,
TRUE);
tool_info->presets = gimp_tool_presets_new (tool_info);
}
return tool_info;

View File

@ -56,7 +56,7 @@ struct _GimpToolInfo
GimpToolOptions *tool_options;
GimpPaintInfo *paint_info;
GimpContainer *options_presets;
GimpToolPresets *presets;
};
struct _GimpToolInfoClass

View File

@ -138,43 +138,12 @@ gimp_tool_options_reset (GimpToolOptions *tool_options)
GIMP_TOOL_OPTIONS_GET_CLASS (tool_options)->reset (tool_options);
}
gchar *
gimp_tool_options_build_filename (GimpToolOptions *tool_options,
const gchar *extension)
{
gchar *filename;
g_return_val_if_fail (GIMP_IS_TOOL_OPTIONS (tool_options), NULL);
if (extension)
{
gchar *basename;
basename = g_strconcat (GIMP_OBJECT (tool_options->tool_info)->name,
".", extension, NULL);
filename = g_build_filename (gimp_directory (),
"tool-options",
basename,
NULL);
g_free (basename);
}
else
{
filename = g_build_filename (gimp_directory (),
"tool-options",
GIMP_OBJECT (tool_options->tool_info)->name,
NULL);
}
return filename;
}
gboolean
gimp_tool_options_serialize (GimpToolOptions *tool_options,
const gchar *extension,
GError **error)
{
const gchar *name;
gchar *filename;
gchar *header;
gchar *footer;
@ -183,7 +152,9 @@ gimp_tool_options_serialize (GimpToolOptions *tool_options,
g_return_val_if_fail (GIMP_IS_TOOL_OPTIONS (tool_options), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
filename = gimp_tool_options_build_filename (tool_options, extension);
name = gimp_object_get_name (GIMP_OBJECT (tool_options->tool_info));
filename = gimp_tool_options_build_filename (name, extension);
if (tool_options->tool_info->gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
@ -211,13 +182,16 @@ gimp_tool_options_deserialize (GimpToolOptions *tool_options,
const gchar *extension,
GError **error)
{
const gchar *name;
gchar *filename;
gboolean retval;
g_return_val_if_fail (GIMP_IS_TOOL_OPTIONS (tool_options), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
filename = gimp_tool_options_build_filename (tool_options, extension);
name = gimp_object_get_name (GIMP_OBJECT (tool_options->tool_info));
filename = gimp_tool_options_build_filename (name, extension);
if (tool_options->tool_info->gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
@ -231,3 +205,32 @@ gimp_tool_options_deserialize (GimpToolOptions *tool_options,
return retval;
}
gchar *
gimp_tool_options_build_filename (const gchar *tool_name,
const gchar *extension)
{
gchar *filename;
g_return_val_if_fail (tool_name != NULL, NULL);
if (extension)
{
gchar *basename = g_strconcat (tool_name, ".", extension, NULL);
filename = g_build_filename (gimp_directory (),
"tool-options",
basename,
NULL);
g_free (basename);
}
else
{
filename = g_build_filename (gimp_directory (),
"tool-options",
tool_name,
NULL);
}
return filename;
}

View File

@ -52,8 +52,6 @@ GType gimp_tool_options_get_type (void) G_GNUC_CONST;
void gimp_tool_options_reset (GimpToolOptions *tool_options);
gchar * gimp_tool_options_build_filename (GimpToolOptions *tool_options,
const gchar *extension);
gboolean gimp_tool_options_serialize (GimpToolOptions *tool_options,
const gchar *extension,
GError **error);
@ -61,5 +59,8 @@ gboolean gimp_tool_options_deserialize (GimpToolOptions *tool_options,
const gchar *extension,
GError **error);
gchar * gimp_tool_options_build_filename (const gchar *tool_name,
const gchar *extension);
#endif /* __GIMP_TOOL_OPTIONS_H__ */

234
app/core/gimptoolpresets.c Normal file
View File

@ -0,0 +1,234 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimptoolpresets.c
* Copyright (C) 2006 Sven Neumann <sven@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 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "gimptoolinfo.h"
#include "gimptooloptions.h"
#include "gimptoolpresets.h"
enum
{
PROP_0,
PROP_TOOL_INFO
};
static void gimp_tool_presets_finalize (GObject *object);
static void gimp_tool_presets_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_tool_presets_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (GimpToolPresets, gimp_tool_presets, GIMP_TYPE_LIST)
#define parent_class gimp_tool_presets_parent_class
static void
gimp_tool_presets_class_init (GimpToolPresetsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_tool_presets_set_property;
object_class->get_property = gimp_tool_presets_get_property;
object_class->finalize = gimp_tool_presets_finalize;
g_object_class_install_property (object_class, PROP_TOOL_INFO,
g_param_spec_object ("tool-info",
NULL, NULL,
GIMP_TYPE_TOOL_INFO,
G_PARAM_CONSTRUCT_ONLY |
GIMP_PARAM_READWRITE));
}
static void
gimp_tool_presets_init (GimpToolPresets *list)
{
}
static void
gimp_tool_presets_finalize (GObject *object)
{
GimpToolPresets *presets = GIMP_TOOL_PRESETS (object);
if (presets->tool_info)
{
g_object_unref (presets->tool_info);
presets->tool_info = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_tool_presets_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpToolPresets *presets = GIMP_TOOL_PRESETS (object);
switch (property_id)
{
case PROP_TOOL_INFO:
presets->tool_info = GIMP_TOOL_INFO (g_value_dup_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_tool_presets_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpToolPresets *presets = GIMP_TOOL_PRESETS (object);
switch (property_id)
{
case PROP_TOOL_INFO:
g_value_set_object (value, presets->tool_info);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
GimpToolPresets *
gimp_tool_presets_new (GimpToolInfo *tool_info)
{
GimpToolPresets *presets;
gchar *name;
g_return_val_if_fail (GIMP_IS_TOOL_INFO (tool_info), NULL);
presets = g_object_new (GIMP_TYPE_TOOL_PRESETS,
"tool-info", tool_info,
"children-type", tool_info->tool_options_type,
"policy", GIMP_CONTAINER_POLICY_STRONG,
NULL);
name = g_strdup_printf ("%s options",
gimp_object_get_name (GIMP_OBJECT (tool_info)));
gimp_object_take_name (GIMP_OBJECT (presets), name);
return presets;
}
GimpToolOptions *
gimp_tool_presets_get_options (GimpToolPresets *presets,
gint index)
{
g_return_val_if_fail (GIMP_IS_TOOL_PRESETS (presets), NULL);
return (GimpToolOptions *)
gimp_container_get_child_by_index (GIMP_CONTAINER (presets), index);
}
gboolean
gimp_tool_presets_save (GimpToolPresets *presets,
gboolean be_verbose,
GError **error)
{
const gchar *name;
gchar *filename;
gchar *footer;
gboolean retval;
g_return_val_if_fail (GIMP_IS_TOOL_PRESETS (presets), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
name = gimp_object_get_name (GIMP_OBJECT (presets->tool_info));
filename = gimp_tool_options_build_filename (name, "presets");
if (be_verbose)
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
footer = g_strdup_printf ("end of %s", GIMP_OBJECT (presets)->name);
retval = gimp_config_serialize_to_file (GIMP_CONFIG (presets), filename,
GIMP_OBJECT (presets)->name, footer,
NULL, error);
g_free (footer);
g_free (filename);
return retval;
}
gboolean
gimp_tool_presets_load (GimpToolPresets *presets,
gboolean be_verbose,
GError **error)
{
GList *list;
const gchar *name;
gchar *filename;
gboolean retval;
g_return_val_if_fail (GIMP_IS_TOOL_PRESETS (presets), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
name = gimp_object_get_name (GIMP_OBJECT (presets->tool_info));
filename = gimp_tool_options_build_filename (name, "presets");
if (be_verbose)
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
retval = gimp_config_deserialize_file (GIMP_CONFIG (presets), filename,
presets->tool_info->gimp,
error);
g_free (filename);
gimp_list_reverse (GIMP_LIST (presets));
for (list = GIMP_LIST (presets)->list; list; list = g_list_next (list))
{
g_object_set (list->data, "tool-info", presets->tool_info, NULL);
}
return retval;
}

View File

@ -0,0 +1,66 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimptoolpresets.h
* Copyright (C) 2006 Sven Neumann <sven@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 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_TOOL_PRESETS_H__
#define __GIMP_TOOL_PRESETS_H__
#include "core/gimplist.h"
#define GIMP_TYPE_TOOL_PRESETS (gimp_tool_presets_get_type ())
#define GIMP_TOOL_PRESETS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOOL_PRESETS, GimpToolPresets))
#define GIMP_TOOL_PRESETS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_PRESETS, GimpToolPresetsClass))
#define GIMP_IS_TOOL_PRESETS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TOOL_PRESETS))
#define GIMP_IS_TOOL_PRESETS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_PRESETS))
#define GIMP_TOOL_PRESETS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TOOL_PRESETS, GimpToolPresetsClass))
typedef struct _GimpToolPresetsClass GimpToolPresetsClass;
struct _GimpToolPresets
{
GimpList parent_instance;
GimpToolInfo *tool_info;
};
struct _GimpToolPresetsClass
{
GimpListClass parent_class;
};
GType gimp_tool_presets_get_type (void) G_GNUC_CONST;
GimpToolPresets * gimp_tool_presets_new (GimpToolInfo *tool_info);
GimpToolOptions * gimp_tool_presets_get_options (GimpToolPresets *presets,
gint index);
gboolean gimp_tool_presets_save (GimpToolPresets *presets,
gboolean be_verbose,
GError **error);
gboolean gimp_tool_presets_load (GimpToolPresets *presets,
gboolean be_verbose,
GError **error);
#endif /* __GIMP_TOOL_PRESETS_H__ */

View File

@ -101,7 +101,7 @@ tool_options_menu_update_after (GimpUIManager *manager,
context = gimp_get_user_context (manager->gimp);
tool_info = gimp_context_get_tool (context);
if (! tool_info->options_presets)
if (! tool_info->presets)
return;
merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));
@ -111,19 +111,19 @@ tool_options_menu_update_after (GimpUIManager *manager,
tool_options_menu_update_presets (manager, merge_id, ui_path,
"Save", "save",
tool_info->options_presets);
GIMP_CONTAINER (tool_info->presets));
tool_options_menu_update_presets (manager, merge_id, ui_path,
"Restore", "restore",
tool_info->options_presets);
GIMP_CONTAINER (tool_info->presets));
tool_options_menu_update_presets (manager, merge_id, ui_path,
"Rename", "rename",
tool_info->options_presets);
GIMP_CONTAINER (tool_info->presets));
tool_options_menu_update_presets (manager, merge_id, ui_path,
"Delete", "delete",
tool_info->options_presets);
GIMP_CONTAINER (tool_info->presets));
gtk_ui_manager_ensure_update (GTK_UI_MANAGER (manager));
}

View File

@ -86,7 +86,7 @@ gimp_font_list_new (gdouble xresolution,
g_return_val_if_fail (yresolution > 0.0, NULL);
list = g_object_new (GIMP_TYPE_FONT_LIST,
"children_type", GIMP_TYPE_FONT,
"children-type", GIMP_TYPE_FONT,
"policy", GIMP_CONTAINER_POLICY_STRONG,
NULL);

View File

@ -35,9 +35,9 @@
#include "core/gimp.h"
#include "core/gimp-contexts.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
#include "core/gimptooloptions.h"
#include "core/gimptoolpresets.h"
#include "gimp-tools.h"
#include "gimptooloptions-gui.h"
@ -329,30 +329,8 @@ gimp_tools_restore (Gimp *gimp)
g_object_set_data (G_OBJECT (tool_info->tool_options),
"gimp-tool-options-gui", options_gui);
if (tool_info->options_presets)
{
GList *list;
filename = gimp_tool_options_build_filename (tool_info->tool_options,
"presets");
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
gimp_config_deserialize_file (GIMP_CONFIG (tool_info->options_presets),
filename,
gimp, NULL);
g_free (filename);
gimp_list_reverse (GIMP_LIST (tool_info->options_presets));
for (list = GIMP_LIST (tool_info->options_presets)->list;
list;
list = g_list_next (list))
{
g_object_set (list->data, "tool-info", tool_info, NULL);
}
}
if (tool_info->presets)
gimp_tool_presets_load (tool_info->presets, gimp->be_verbose, NULL);
}
}
@ -378,30 +356,8 @@ gimp_tools_save (Gimp *gimp,
if (save_tool_options && (! tool_options_deleted || always_save))
gimp_tool_options_serialize (tool_info->tool_options, NULL, NULL);
if (tool_info->options_presets)
{
gchar *header;
gchar *footer;
filename = gimp_tool_options_build_filename (tool_info->tool_options,
"presets");
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
header = g_strdup_printf ("GIMP %s options presets",
GIMP_OBJECT (tool_info)->name);
footer = g_strdup_printf ("end of %s options presets",
GIMP_OBJECT (tool_info)->name);
gimp_config_serialize_to_file (GIMP_CONFIG (tool_info->options_presets),
filename, header, footer,
NULL, NULL);
g_free (filename);
g_free (header);
g_free (footer);
}
if (tool_info->presets)
gimp_tool_presets_save (tool_info->presets, gimp->be_verbose, NULL);
}
filename = gimp_personal_rc_file ("toolrc");
@ -433,8 +389,8 @@ gimp_tools_clear (Gimp *gimp,
GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data);
gchar *filename;
filename = gimp_tool_options_build_filename (tool_info->tool_options,
NULL);
filename =
gimp_tool_options_build_filename (GIMP_OBJECT (tool_info)->name, NULL);
if (g_unlink (filename) != 0 && errno != ENOENT)
{

View File

@ -363,7 +363,7 @@ gimp_tool_options_editor_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
GimpToolOptionsEditor *editor)
{
GimpContainer *presets;
GimpToolPresets *presets;
GtkWidget *options_gui;
if (tool_info && tool_info->tool_options == editor->visible_tool_options)
@ -371,7 +371,7 @@ gimp_tool_options_editor_tool_changed (GimpContext *context,
if (editor->visible_tool_options)
{
presets = editor->visible_tool_options->tool_info->options_presets;
presets = editor->visible_tool_options->tool_info->presets;
if (presets)
g_signal_handlers_disconnect_by_func (presets,
@ -389,7 +389,7 @@ gimp_tool_options_editor_tool_changed (GimpContext *context,
if (tool_info && tool_info->tool_options)
{
presets = tool_info->options_presets;
presets = tool_info->presets;
if (presets)
{
@ -420,7 +420,8 @@ gimp_tool_options_editor_tool_changed (GimpContext *context,
presets = NULL;
}
gimp_tool_options_editor_presets_changed (presets, NULL, editor);
gimp_tool_options_editor_presets_changed (GIMP_CONTAINER (presets),
NULL, editor);
gimp_docked_title_changed (GIMP_DOCKED (editor));
}
@ -440,7 +441,7 @@ gimp_tool_options_editor_presets_changed (GimpContainer *container,
save_sensitive = TRUE;
reset_sensitive = TRUE;
if (gimp_container_num_children (container))
if (gimp_container_num_children (container) > 0)
{
restore_sensitive = TRUE;
delete_sensitive = TRUE;

View File

@ -266,6 +266,7 @@ gimp_tool_get_type
gimp_tool_info_get_type
gimp_tool_options_editor_get_type
gimp_tool_options_get_type
gimp_tool_presets_get_type
gimp_tool_view_get_type
gimp_transform_options_get_type
gimp_transform_tool_get_type