From 6f1f65d514f4c209e85527b3c1fa6b5c4b0b35a0 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 18 May 2004 12:23:56 +0000 Subject: [PATCH] made the "visible" property serializable. 2004-05-18 Michael Natterer * app/core/gimptoolinfo.c: made the "visible" property serializable. * app/tools/gimp-tools.c: store the tools' order and visibility in a new config file called "toolrc". --- ChangeLog | 7 ++++++ app/core/gimptoolinfo.c | 9 ++++--- app/tools/gimp-tools.c | 52 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index a62d3181d8..ec4e85f748 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-05-18 Michael Natterer + + * app/core/gimptoolinfo.c: made the "visible" property serializable. + + * app/tools/gimp-tools.c: store the tools' order and visibility + in a new config file called "toolrc". + 2004-05-18 Sven Neumann * plug-ins/gimpressionist/brush.c: ported to GtkFileChooser. diff --git a/app/core/gimptoolinfo.c b/app/core/gimptoolinfo.c index dad4b2fd32..0ccc4a03c0 100644 --- a/app/core/gimptoolinfo.c +++ b/app/core/gimptoolinfo.c @@ -26,6 +26,8 @@ #include "base/temp-buf.h" +#include "config/gimpconfig-params.h" + #include "gimp.h" #include "gimpcontainer.h" #include "gimpcontext.h" @@ -103,11 +105,8 @@ gimp_tool_info_class_init (GimpToolInfoClass *klass) viewable_class->get_description = gimp_tool_info_get_description; - g_object_class_install_property (object_class, PROP_VISIBLE, - g_param_spec_boolean ("visible", - NULL, NULL, - TRUE, - G_PARAM_READWRITE)); + GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_VISIBLE, "visible", + NULL, TRUE, 0); } static void diff --git a/app/tools/gimp-tools.c b/app/tools/gimp-tools.c index 9ca8604aa6..3bee9ea1ea 100644 --- a/app/tools/gimp-tools.c +++ b/app/tools/gimp-tools.c @@ -180,7 +180,6 @@ gimp_tools_init (Gimp *gimp) { const gchar *identifier = gimp_object_get_name (list->data); - default_order = g_list_prepend (default_order, g_strdup (identifier)); } @@ -210,10 +209,48 @@ gimp_tools_exit (Gimp *gimp) void gimp_tools_restore (Gimp *gimp) { - GList *list; + GimpContainer *gimp_list; + gchar *filename; + GList *list; g_return_if_fail (GIMP_IS_GIMP (gimp)); + gimp_list = gimp_list_new (GIMP_TYPE_TOOL_INFO, GIMP_CONTAINER_POLICY_STRONG); + filename = gimp_personal_rc_file ("toolrc"); + + if (gimp_config_deserialize_file (GIMP_CONFIG (gimp_list), filename, + NULL, NULL)) + { + gint i; + + gimp_list_reverse (GIMP_LIST (gimp_list)); + + for (list = GIMP_LIST (gimp_list)->list, i = 0; + list; + list = g_list_next (list), i++) + { + const gchar *name; + GimpObject *object; + + name = gimp_object_get_name (list->data); + + object = gimp_container_get_child_by_name (gimp->tool_info_list, + name); + + if (object) + { + g_object_set (object, + "visible", GIMP_TOOL_INFO (list->data)->visible, + NULL); + + gimp_container_reorder (gimp->tool_info_list, object, i); + } + } + } + + g_free (filename); + g_object_unref (gimp_list); + for (list = GIMP_LIST (gimp->tool_info_list)->list; list; list = g_list_next (list)) @@ -274,7 +311,8 @@ gimp_tools_restore (Gimp *gimp) void gimp_tools_save (Gimp *gimp) { - GList *list; + GList *list; + gchar *filename; g_return_if_fail (GIMP_IS_GIMP (gimp)); @@ -309,6 +347,14 @@ gimp_tools_save (Gimp *gimp) g_free (footer); } } + + filename = gimp_personal_rc_file ("toolrc"); + gimp_config_serialize_to_file (GIMP_CONFIG (gimp->tool_info_list), + filename, + "GIMP toolrc", + "end of toolrc", + NULL, NULL); + g_free (filename); } GList * -- GitLab