mirror of https://github.com/GNOME/gimp.git
Bug 780015 - Filter settings are not properly restored after Gimp restart
Filters settings used to be serialized and deserialized only when a filter tool's GUI was shown, too late for the code that re-runs/re-shows filters with previous values. Move the entire loading/saving code to gimp-operation-config.c, even adding/removing the dummy separator item between timestamped automatic history and manually saved settings. Load the settings automatically when a settings container is requested, but still trigger saving from the few places the container is changed in the GUI; could also automate that later. This commit also moves all settings of filters that have their own tools from gimpdir/tool-options/ to gimpdir/filters/. Add compat code to try the old filename if the new doesn't exist, so files are migrated automatically. WIP, but this step already fixes the bug.
This commit is contained in:
parent
8cf53b40b7
commit
ee6c7ec7b7
|
@ -251,11 +251,15 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
|
|||
GimpContainer *container;
|
||||
GimpTool *active_tool;
|
||||
|
||||
settings = gimp_operation_config_new (procedure->original_name,
|
||||
settings = gimp_operation_config_new (gimp,
|
||||
procedure->original_name,
|
||||
gimp_viewable_get_icon_name (GIMP_VIEWABLE (procedure)),
|
||||
GIMP_TYPE_SETTINGS);
|
||||
|
||||
container = gimp_operation_config_get_container (G_TYPE_FROM_INSTANCE (settings));
|
||||
container =
|
||||
gimp_operation_config_get_container (gimp,
|
||||
G_TYPE_FROM_INSTANCE (settings),
|
||||
(GCompareFunc) gimp_settings_compare);
|
||||
|
||||
g_object_unref (settings);
|
||||
|
||||
|
@ -263,10 +267,15 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
|
|||
settings = gimp_container_get_child_by_index (container, 0);
|
||||
|
||||
/* only use the settings if they are automatically created "last used"
|
||||
* values, not if they were saved explicitly and have a zero timestamp
|
||||
* values, not if they were saved explicitly and have a zero timestamp;
|
||||
* and if they are not a separator.
|
||||
*/
|
||||
if (settings && GIMP_SETTINGS (settings)->time == 0)
|
||||
if (settings &&
|
||||
(GIMP_SETTINGS (settings)->time == 0 ||
|
||||
! gimp_object_get_name (settings)))
|
||||
{
|
||||
settings = NULL;
|
||||
}
|
||||
|
||||
if (run_mode == GIMP_RUN_WITH_LAST_VALS)
|
||||
{
|
||||
|
|
|
@ -73,7 +73,7 @@ gimp_gegl_init (Gimp *gimp)
|
|||
|
||||
gimp_babl_init ();
|
||||
|
||||
gimp_operations_init ();
|
||||
gimp_operations_init (gimp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -23,11 +23,14 @@
|
|||
#include <gegl.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
|
||||
#include "operations-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
|
||||
#include "core/gimplist.h"
|
||||
#include "core/gimpparamspecs-duplicate.h"
|
||||
#include "core/gimpviewable.h"
|
||||
|
@ -49,11 +52,14 @@ static void gimp_operation_config_node_notify (GeglNode *node,
|
|||
const GParamSpec *gegl_pspec,
|
||||
GObject *config);
|
||||
|
||||
static void gimp_operation_config_add_sep (GimpContainer *container);
|
||||
static void gimp_operation_config_remove_sep (GimpContainer *container);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
static GHashTable *
|
||||
gimp_operation_config_get_type_table (void)
|
||||
gimp_operation_config_get_type_table (Gimp *gimp)
|
||||
{
|
||||
static GHashTable *config_types = NULL;
|
||||
|
||||
|
@ -67,7 +73,7 @@ gimp_operation_config_get_type_table (void)
|
|||
}
|
||||
|
||||
static GHashTable *
|
||||
gimp_operation_config_get_container_table (void)
|
||||
gimp_operation_config_get_container_table (Gimp *gimp)
|
||||
{
|
||||
static GHashTable *config_containers = NULL;
|
||||
|
||||
|
@ -235,15 +241,17 @@ gimp_operation_config_config_iface_init (GimpConfigInterface *iface)
|
|||
/* public functions */
|
||||
|
||||
void
|
||||
gimp_operation_config_register (const gchar *operation,
|
||||
gimp_operation_config_register (Gimp *gimp,
|
||||
const gchar *operation,
|
||||
GType config_type)
|
||||
{
|
||||
GHashTable *config_types;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (operation != NULL);
|
||||
g_return_if_fail (g_type_is_a (config_type, GIMP_TYPE_OBJECT));
|
||||
|
||||
config_types = gimp_operation_config_get_type_table ();
|
||||
config_types = gimp_operation_config_get_type_table (gimp);
|
||||
|
||||
g_hash_table_insert (config_types,
|
||||
g_strdup (operation),
|
||||
|
@ -251,17 +259,19 @@ gimp_operation_config_register (const gchar *operation,
|
|||
}
|
||||
|
||||
GimpObject *
|
||||
gimp_operation_config_new (const gchar *operation,
|
||||
gimp_operation_config_new (Gimp *gimp,
|
||||
const gchar *operation,
|
||||
const gchar *icon_name,
|
||||
GType parent_type)
|
||||
{
|
||||
GHashTable *config_types;
|
||||
GType config_type;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (operation != NULL, NULL);
|
||||
g_return_val_if_fail (g_type_is_a (parent_type, GIMP_TYPE_OBJECT), NULL);
|
||||
|
||||
config_types = gimp_operation_config_get_type_table ();
|
||||
config_types = gimp_operation_config_get_type_table (gimp);
|
||||
|
||||
config_type = (GType) g_hash_table_lookup (config_types, operation);
|
||||
|
||||
|
@ -315,7 +325,7 @@ gimp_operation_config_new (const gchar *operation,
|
|||
g_type_class_unref (viewable_class);
|
||||
}
|
||||
|
||||
gimp_operation_config_register (operation, config_type);
|
||||
gimp_operation_config_register (gimp, operation, config_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,28 +333,144 @@ gimp_operation_config_new (const gchar *operation,
|
|||
}
|
||||
|
||||
GimpContainer *
|
||||
gimp_operation_config_get_container (GType config_type)
|
||||
gimp_operation_config_get_container (Gimp *gimp,
|
||||
GType config_type,
|
||||
GCompareFunc sort_func)
|
||||
{
|
||||
GHashTable *config_containers;
|
||||
GimpContainer *container;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (g_type_is_a (config_type, GIMP_TYPE_OBJECT), NULL);
|
||||
|
||||
config_containers = gimp_operation_config_get_container_table ();
|
||||
config_containers = gimp_operation_config_get_container_table (gimp);
|
||||
|
||||
container = g_hash_table_lookup (config_containers, (gpointer) config_type);
|
||||
|
||||
if (! container)
|
||||
{
|
||||
container = gimp_list_new (config_type, TRUE);
|
||||
gimp_list_set_sort_func (GIMP_LIST (container), sort_func);
|
||||
|
||||
g_hash_table_insert (config_containers,
|
||||
(gpointer) config_type, container);
|
||||
|
||||
gimp_operation_config_deserialize (gimp, container, NULL);
|
||||
|
||||
if (gimp_container_get_n_children (container) == 0)
|
||||
{
|
||||
gchar *basename;
|
||||
GFile *file;
|
||||
|
||||
basename = g_strconcat (g_type_name (config_type), ".settings", NULL);
|
||||
file = gimp_directory_file ("filters", basename, NULL);
|
||||
g_free (basename);
|
||||
|
||||
if (! g_file_query_exists (file, NULL))
|
||||
{
|
||||
GQuark quark = g_quark_from_static_string ("compat-file");
|
||||
|
||||
g_object_unref (file);
|
||||
|
||||
file = g_type_get_qdata (config_type, quark);
|
||||
|
||||
if (file)
|
||||
{
|
||||
g_object_ref (file);
|
||||
|
||||
gimp_operation_config_deserialize (gimp, container, file);
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
gimp_operation_config_add_sep (container);
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_operation_config_serialize (Gimp *gimp,
|
||||
GimpContainer *container,
|
||||
GFile *file)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (GIMP_IS_CONTAINER (container));
|
||||
g_return_if_fail (file == NULL || G_IS_FILE (file));
|
||||
|
||||
if (! file)
|
||||
{
|
||||
GType config_type = gimp_container_get_children_type (container);
|
||||
gchar *basename;
|
||||
|
||||
basename = g_strconcat (g_type_name (config_type), ".settings", NULL);
|
||||
file = gimp_directory_file ("filters", basename, NULL);
|
||||
g_free (basename);
|
||||
}
|
||||
|
||||
if (gimp->be_verbose)
|
||||
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
|
||||
|
||||
gimp_operation_config_remove_sep (container);
|
||||
|
||||
if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (container),
|
||||
file,
|
||||
"settings",
|
||||
"end of settings",
|
||||
NULL, &error))
|
||||
{
|
||||
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
gimp_operation_config_add_sep (container);
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_operation_config_deserialize (Gimp *gimp,
|
||||
GimpContainer *container,
|
||||
GFile *file)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (GIMP_IS_CONTAINER (container));
|
||||
g_return_if_fail (file == NULL || G_IS_FILE (file));
|
||||
|
||||
if (! file)
|
||||
{
|
||||
GType config_type = gimp_container_get_children_type (container);
|
||||
gchar *basename;
|
||||
|
||||
basename = g_strconcat (g_type_name (config_type), ".settings", NULL);
|
||||
file = gimp_directory_file ("filters", basename, NULL);
|
||||
g_free (basename);
|
||||
}
|
||||
|
||||
if (gimp->be_verbose)
|
||||
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
|
||||
|
||||
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (container),
|
||||
file,
|
||||
NULL, &error))
|
||||
{
|
||||
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
|
||||
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||
error->message);
|
||||
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_operation_config_sync_node (GimpObject *config,
|
||||
GeglNode *node)
|
||||
|
@ -611,3 +737,33 @@ gimp_operation_config_node_notify (GeglNode *node,
|
|||
g_signal_handler_unblock (config, handler);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_operation_config_add_sep (GimpContainer *container)
|
||||
{
|
||||
GimpObject *sep = g_object_get_data (G_OBJECT (container), "separator");
|
||||
|
||||
if (! sep)
|
||||
{
|
||||
sep = g_object_new (gimp_container_get_children_type (container),
|
||||
NULL);
|
||||
|
||||
gimp_container_add (container, sep);
|
||||
g_object_unref (sep);
|
||||
|
||||
g_object_set_data (G_OBJECT (container), "separator", sep);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_operation_config_remove_sep (GimpContainer *container)
|
||||
{
|
||||
GimpObject *sep = g_object_get_data (G_OBJECT (container), "separator");
|
||||
|
||||
if (sep)
|
||||
{
|
||||
gimp_container_remove (container, sep);
|
||||
|
||||
g_object_set_data (G_OBJECT (container), "separator", NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,25 @@
|
|||
#define __GIMP_OPERATION_CONFIG_H__
|
||||
|
||||
|
||||
void gimp_operation_config_register (const gchar *operation,
|
||||
void gimp_operation_config_register (Gimp *gimp,
|
||||
const gchar *operation,
|
||||
GType config_type);
|
||||
|
||||
GimpObject * gimp_operation_config_new (const gchar *operation,
|
||||
GimpObject * gimp_operation_config_new (Gimp *gimp,
|
||||
const gchar *operation,
|
||||
const gchar *icon_name,
|
||||
GType parent_type);
|
||||
GimpContainer * gimp_operation_config_get_container (GType config_type);
|
||||
|
||||
GimpContainer * gimp_operation_config_get_container (Gimp *gimp,
|
||||
GType config_type,
|
||||
GCompareFunc sort_func);
|
||||
|
||||
void gimp_operation_config_serialize (Gimp *gimp,
|
||||
GimpContainer *container,
|
||||
GFile *file);
|
||||
void gimp_operation_config_deserialize (Gimp *gimp,
|
||||
GimpContainer *container,
|
||||
GFile *file);
|
||||
|
||||
void gimp_operation_config_sync_node (GimpObject *config,
|
||||
GeglNode *node);
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
||||
#include "operations-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
|
@ -94,9 +96,21 @@
|
|||
#include "layer-modes/gimpoperationsplit.h"
|
||||
|
||||
|
||||
void
|
||||
gimp_operations_init (void)
|
||||
static void
|
||||
set_compat_file (GType type,
|
||||
const gchar *basename)
|
||||
{
|
||||
GFile *file = gimp_directory_file ("tool-options", basename, NULL);
|
||||
GQuark quark = g_quark_from_static_string ("compat-file");
|
||||
|
||||
g_type_set_qdata (type, quark, file);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_operations_init (Gimp *gimp)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
gimp_layer_modes_init ();
|
||||
|
||||
g_type_class_ref (GIMP_TYPE_OPERATION_BLEND);
|
||||
|
@ -154,16 +168,39 @@ gimp_operations_init (void)
|
|||
g_type_class_ref (GIMP_TYPE_OPERATION_REPLACE);
|
||||
g_type_class_ref (GIMP_TYPE_OPERATION_ANTI_ERASE);
|
||||
|
||||
gimp_operation_config_register ("gimp:brightness-contrast",
|
||||
gimp_operation_config_register (gimp,
|
||||
"gimp:brightness-contrast",
|
||||
GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG);
|
||||
gimp_operation_config_register ("gimp:color-balance",
|
||||
set_compat_file (GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG,
|
||||
"gimp-brightness-contrast-tool.settings");
|
||||
|
||||
gimp_operation_config_register (gimp,
|
||||
"gimp:color-balance",
|
||||
GIMP_TYPE_COLOR_BALANCE_CONFIG);
|
||||
gimp_operation_config_register ("gimp:colorize",
|
||||
set_compat_file (GIMP_TYPE_COLOR_BALANCE_CONFIG,
|
||||
"gimp-color-balance-tool.settings");
|
||||
|
||||
gimp_operation_config_register (gimp,
|
||||
"gimp:colorize",
|
||||
GIMP_TYPE_COLORIZE_CONFIG);
|
||||
gimp_operation_config_register ("gimp:curves",
|
||||
set_compat_file (GIMP_TYPE_COLORIZE_CONFIG,
|
||||
"gimp-colorize-tool.settings");
|
||||
|
||||
gimp_operation_config_register (gimp,
|
||||
"gimp:curves",
|
||||
GIMP_TYPE_CURVES_CONFIG);
|
||||
gimp_operation_config_register ("gimp:hue-saturation",
|
||||
set_compat_file (GIMP_TYPE_CURVES_CONFIG,
|
||||
"gimp-curves-tool.settings");
|
||||
|
||||
gimp_operation_config_register (gimp,
|
||||
"gimp:hue-saturation",
|
||||
GIMP_TYPE_HUE_SATURATION_CONFIG);
|
||||
gimp_operation_config_register ("gimp:levels",
|
||||
set_compat_file (GIMP_TYPE_HUE_SATURATION_CONFIG,
|
||||
"gimp-hue-saturation-tool.settings");
|
||||
|
||||
gimp_operation_config_register (gimp,
|
||||
"gimp:levels",
|
||||
GIMP_TYPE_LEVELS_CONFIG);
|
||||
set_compat_file (GIMP_TYPE_LEVELS_CONFIG,
|
||||
"gimp-levels-tool.settings");
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define __GIMP_OPERATIONS_H__
|
||||
|
||||
|
||||
void gimp_operations_init (void);
|
||||
void gimp_operations_init (Gimp *gimp);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATIONS_H__ */
|
||||
|
|
|
@ -62,7 +62,6 @@ static gboolean gimp_filter_tool_settings_export (GimpSettingsBox *box,
|
|||
GtkWidget *
|
||||
gimp_filter_tool_real_get_settings_ui (GimpFilterTool *filter_tool,
|
||||
GimpContainer *settings,
|
||||
GFile *settings_file,
|
||||
const gchar *import_dialog_title,
|
||||
const gchar *export_dialog_title,
|
||||
const gchar *file_dialog_help_id,
|
||||
|
@ -85,7 +84,6 @@ gimp_filter_tool_real_get_settings_ui (GimpFilterTool *filter_tool,
|
|||
*settings_box = gimp_settings_box_new (tool_info->gimp,
|
||||
filter_tool->config,
|
||||
settings,
|
||||
settings_file,
|
||||
import_dialog_title,
|
||||
export_dialog_title,
|
||||
file_dialog_help_id,
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
GtkWidget * gimp_filter_tool_real_get_settings_ui (GimpFilterTool *filter_tool,
|
||||
GimpContainer *settings,
|
||||
GFile *settings_file,
|
||||
const gchar *import_dialog_title,
|
||||
const gchar *export_dialog_title,
|
||||
const gchar *file_dialog_help_id,
|
||||
|
|
|
@ -133,6 +133,9 @@ static void gimp_filter_tool_dialog (GimpFilterTool *filter_to
|
|||
static void gimp_filter_tool_dialog_unmap (GtkWidget *dialog,
|
||||
GimpFilterTool *filter_tool);
|
||||
static void gimp_filter_tool_reset (GimpFilterTool *filter_tool);
|
||||
static GtkWidget * gimp_filter_tool_get_settings_ui
|
||||
(GimpFilterTool *filter_tool);
|
||||
|
||||
static void gimp_filter_tool_create_filter (GimpFilterTool *filter_tool);
|
||||
|
||||
static void gimp_filter_tool_flush (GimpDrawableFilter *filter,
|
||||
|
@ -374,33 +377,9 @@ gimp_filter_tool_initialize (GimpTool *tool,
|
|||
|
||||
if (filter_tool->config && klass->settings_name)
|
||||
{
|
||||
GType type = G_TYPE_FROM_INSTANCE (filter_tool->config);
|
||||
GimpContainer *settings;
|
||||
GFile *settings_file;
|
||||
GFile *default_folder;
|
||||
GtkWidget *settings_ui;
|
||||
|
||||
settings = gimp_operation_config_get_container (type);
|
||||
if (! gimp_list_get_sort_func (GIMP_LIST (settings)))
|
||||
gimp_list_set_sort_func (GIMP_LIST (settings),
|
||||
(GCompareFunc) gimp_settings_compare);
|
||||
|
||||
settings_file = gimp_tool_info_get_options_file (tool_info,
|
||||
".settings");
|
||||
default_folder = gimp_directory_file (klass->settings_name, NULL);
|
||||
|
||||
settings_ui = klass->get_settings_ui (filter_tool,
|
||||
settings,
|
||||
settings_file,
|
||||
klass->import_dialog_title,
|
||||
klass->export_dialog_title,
|
||||
filter_tool->help_id,
|
||||
default_folder,
|
||||
&filter_tool->settings_box);
|
||||
|
||||
g_object_unref (default_folder);
|
||||
g_object_unref (settings_file);
|
||||
|
||||
settings_ui = gimp_filter_tool_get_settings_ui (filter_tool);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), settings_ui, FALSE, FALSE, 0);
|
||||
gtk_widget_show (settings_ui);
|
||||
}
|
||||
|
@ -977,6 +956,36 @@ gimp_filter_tool_reset (GimpFilterTool *filter_tool)
|
|||
g_object_thaw_notify (filter_tool->config);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_filter_tool_get_settings_ui (GimpFilterTool *filter_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (filter_tool);
|
||||
GimpFilterToolClass *klass = GIMP_FILTER_TOOL_GET_CLASS (filter_tool);
|
||||
GType type = G_TYPE_FROM_INSTANCE (filter_tool->config);
|
||||
GimpContainer *settings;
|
||||
GFile *default_folder;
|
||||
GtkWidget *settings_ui;
|
||||
|
||||
settings =
|
||||
gimp_operation_config_get_container (tool->tool_info->gimp,
|
||||
type,
|
||||
(GCompareFunc) gimp_settings_compare);
|
||||
|
||||
default_folder = gimp_directory_file (klass->settings_name, NULL);
|
||||
|
||||
settings_ui = klass->get_settings_ui (filter_tool,
|
||||
settings,
|
||||
klass->import_dialog_title,
|
||||
klass->export_dialog_title,
|
||||
filter_tool->help_id,
|
||||
default_folder,
|
||||
&filter_tool->settings_box);
|
||||
|
||||
g_object_unref (default_folder);
|
||||
|
||||
return settings_ui;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_filter_tool_create_filter (GimpFilterTool *filter_tool)
|
||||
{
|
||||
|
@ -1313,7 +1322,8 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
|
|||
"operation", operation_name,
|
||||
NULL);
|
||||
filter_tool->config =
|
||||
G_OBJECT (gimp_operation_config_new (operation_name,
|
||||
G_OBJECT (gimp_operation_config_new (tool_info->gimp,
|
||||
operation_name,
|
||||
filter_tool->icon_name,
|
||||
GIMP_TYPE_SETTINGS));
|
||||
|
||||
|
|
|
@ -82,7 +82,6 @@ struct _GimpFilterToolClass
|
|||
|
||||
GtkWidget * (* get_settings_ui) (GimpFilterTool *filter_tool,
|
||||
GimpContainer *settings,
|
||||
GFile *settings_file,
|
||||
const gchar *import_dialog_title,
|
||||
const gchar *export_dialog_title,
|
||||
const gchar *file_dialog_help_id,
|
||||
|
|
|
@ -88,7 +88,6 @@ static void gimp_operation_tool_dialog (GimpFilterTool *filte
|
|||
static void gimp_operation_tool_reset (GimpFilterTool *filter_tool);
|
||||
static GtkWidget * gimp_operation_tool_get_settings_ui (GimpFilterTool *filter_tool,
|
||||
GimpContainer *settings,
|
||||
GFile *settings_file,
|
||||
const gchar *import_dialog_title,
|
||||
const gchar *export_dialog_title,
|
||||
const gchar *file_dialog_help_id,
|
||||
|
@ -320,7 +319,6 @@ gimp_operation_tool_reset (GimpFilterTool *filter_tool)
|
|||
static GtkWidget *
|
||||
gimp_operation_tool_get_settings_ui (GimpFilterTool *filter_tool,
|
||||
GimpContainer *settings,
|
||||
GFile *settings_file,
|
||||
const gchar *import_dialog_title,
|
||||
const gchar *export_dialog_title,
|
||||
const gchar *file_dialog_help_id,
|
||||
|
@ -329,23 +327,15 @@ gimp_operation_tool_get_settings_ui (GimpFilterTool *filter_tool,
|
|||
{
|
||||
GimpOperationTool *tool = GIMP_OPERATION_TOOL (filter_tool);
|
||||
GtkWidget *widget;
|
||||
gchar *basename;
|
||||
GFile *file;
|
||||
gchar *import_title;
|
||||
gchar *export_title;
|
||||
|
||||
basename = g_strconcat (G_OBJECT_TYPE_NAME (filter_tool->config),
|
||||
".settings", NULL);
|
||||
file = gimp_directory_file ("filters", basename, NULL);
|
||||
g_free (basename);
|
||||
|
||||
import_title = g_strdup_printf (_("Import '%s' Settings"), tool->title);
|
||||
export_title = g_strdup_printf (_("Export '%s' Settings"), tool->title);
|
||||
|
||||
widget =
|
||||
GIMP_FILTER_TOOL_CLASS (parent_class)->get_settings_ui (filter_tool,
|
||||
settings,
|
||||
file,
|
||||
import_title,
|
||||
export_title,
|
||||
file_dialog_help_id,
|
||||
|
@ -355,8 +345,6 @@ gimp_operation_tool_get_settings_ui (GimpFilterTool *filter_tool,
|
|||
g_free (import_title);
|
||||
g_free (export_title);
|
||||
|
||||
g_object_unref (file);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsettingsbox.c
|
||||
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
|
||||
* Copyright (C) 2008-2017 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
|
||||
|
@ -23,12 +23,13 @@
|
|||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "operations/gimp-operation-config.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimplist.h"
|
||||
#include "core/gimpmarshal.h"
|
||||
|
@ -56,8 +57,7 @@ enum
|
|||
PROP_0,
|
||||
PROP_GIMP,
|
||||
PROP_CONFIG,
|
||||
PROP_CONTAINER,
|
||||
PROP_FILE
|
||||
PROP_CONTAINER
|
||||
};
|
||||
|
||||
|
||||
|
@ -75,7 +75,6 @@ struct _GimpSettingsBoxPrivate
|
|||
Gimp *gimp;
|
||||
GObject *config;
|
||||
GimpContainer *container;
|
||||
GFile *file;
|
||||
|
||||
gchar *import_dialog_title;
|
||||
gchar *export_dialog_title;
|
||||
|
@ -100,8 +99,6 @@ static void gimp_settings_box_get_property (GObject *object,
|
|||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_settings_box_deserialize (GimpSettingsBox *box);
|
||||
static void gimp_settings_box_serialize (GimpSettingsBox *box);
|
||||
static GtkWidget *
|
||||
gimp_settings_box_menu_item_add (GimpSettingsBox *box,
|
||||
const gchar *icon_name,
|
||||
|
@ -218,13 +215,6 @@ gimp_settings_box_class_init (GimpSettingsBoxClass *klass)
|
|||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_FILE,
|
||||
g_param_spec_object ("file",
|
||||
NULL, NULL,
|
||||
G_TYPE_FILE,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_type_class_add_private (klass, sizeof (GimpSettingsBoxPrivate));
|
||||
}
|
||||
|
||||
|
@ -252,10 +242,6 @@ gimp_settings_box_constructed (GObject *object)
|
|||
g_assert (GIMP_IS_GIMP (private->gimp));
|
||||
g_assert (GIMP_IS_CONFIG (private->config));
|
||||
g_assert (GIMP_IS_CONTAINER (private->container));
|
||||
g_assert (G_IS_FILE (private->file));
|
||||
|
||||
if (gimp_container_get_n_children (private->container) == 0)
|
||||
gimp_settings_box_deserialize (box);
|
||||
|
||||
private->combo = gimp_container_combo_box_new (private->container,
|
||||
gimp_get_user_context (private->gimp),
|
||||
|
@ -352,12 +338,6 @@ gimp_settings_box_finalize (GObject *object)
|
|||
private->container = NULL;
|
||||
}
|
||||
|
||||
if (private->file)
|
||||
{
|
||||
g_object_unref (private->file);
|
||||
private->file = NULL;
|
||||
}
|
||||
|
||||
if (private->last_file)
|
||||
{
|
||||
g_object_unref (private->last_file);
|
||||
|
@ -423,10 +403,6 @@ gimp_settings_box_set_property (GObject *object,
|
|||
private->container = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
case PROP_FILE:
|
||||
private->file = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -455,86 +431,12 @@ gimp_settings_box_get_property (GObject *object,
|
|||
g_value_set_object (value, private->container);
|
||||
break;
|
||||
|
||||
case PROP_FILE:
|
||||
g_value_set_object (value, private->file);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_separator_add (GimpContainer *container)
|
||||
{
|
||||
GimpObject *sep = g_object_new (gimp_container_get_children_type (container),
|
||||
NULL);
|
||||
|
||||
gimp_container_add (container, sep);
|
||||
g_object_unref (sep);
|
||||
|
||||
g_object_set_data (G_OBJECT (container), "separator", sep);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_separator_remove (GimpContainer *container)
|
||||
{
|
||||
GimpObject *sep = g_object_get_data (G_OBJECT (container), "separator");
|
||||
|
||||
gimp_container_remove (container, sep);
|
||||
|
||||
g_object_set_data (G_OBJECT (container), "separator", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_deserialize (GimpSettingsBox *box)
|
||||
{
|
||||
GimpSettingsBoxPrivate *private = GET_PRIVATE (box);
|
||||
GError *error = NULL;
|
||||
|
||||
if (private->gimp->be_verbose)
|
||||
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (private->file));
|
||||
|
||||
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (private->container),
|
||||
private->file,
|
||||
NULL, &error))
|
||||
{
|
||||
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
|
||||
gimp_message_literal (private->gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||
error->message);
|
||||
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
gimp_settings_box_separator_add (private->container);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_settings_box_serialize (GimpSettingsBox *box)
|
||||
{
|
||||
GimpSettingsBoxPrivate *private = GET_PRIVATE (box);
|
||||
GError *error = NULL;
|
||||
|
||||
gimp_settings_box_separator_remove (private->container);
|
||||
|
||||
if (private->gimp->be_verbose)
|
||||
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (private->file));
|
||||
|
||||
if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (private->container),
|
||||
private->file,
|
||||
"settings",
|
||||
"end of settings",
|
||||
NULL, &error))
|
||||
{
|
||||
gimp_message_literal (private->gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
gimp_settings_box_separator_add (private->container);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
gimp_settings_box_menu_item_add (GimpSettingsBox *box,
|
||||
const gchar *icon_name,
|
||||
|
@ -735,7 +637,7 @@ gimp_settings_box_favorite_callback (GtkWidget *query_box,
|
|||
gimp_container_add (private->container, GIMP_OBJECT (config));
|
||||
g_object_unref (config);
|
||||
|
||||
gimp_settings_box_serialize (box);
|
||||
gimp_operation_config_serialize (private->gimp, private->container, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -950,7 +852,6 @@ GtkWidget *
|
|||
gimp_settings_box_new (Gimp *gimp,
|
||||
GObject *config,
|
||||
GimpContainer *container,
|
||||
GFile *file,
|
||||
const gchar *import_dialog_title,
|
||||
const gchar *export_dialog_title,
|
||||
const gchar *file_dialog_help_id,
|
||||
|
@ -963,7 +864,6 @@ gimp_settings_box_new (Gimp *gimp,
|
|||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONFIG (config), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
|
||||
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
||||
g_return_val_if_fail (default_folder == NULL || G_IS_FILE (default_folder),
|
||||
NULL);
|
||||
g_return_val_if_fail (last_file == NULL || G_IS_FILE (last_file), NULL);
|
||||
|
@ -972,7 +872,6 @@ gimp_settings_box_new (Gimp *gimp,
|
|||
"gimp", gimp,
|
||||
"config", config,
|
||||
"container", container,
|
||||
"file", file,
|
||||
NULL);
|
||||
|
||||
private = GET_PRIVATE (box);
|
||||
|
@ -1037,7 +936,7 @@ gimp_settings_box_add_current (GimpSettingsBox *box,
|
|||
|
||||
gimp_settings_box_truncate_list (box, max_recent);
|
||||
|
||||
gimp_settings_box_serialize (box);
|
||||
gimp_operation_config_serialize (private->gimp, private->container, NULL);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
|
|
@ -57,7 +57,6 @@ GType gimp_settings_box_get_type (void) G_GNUC_CONST;
|
|||
GtkWidget * gimp_settings_box_new (Gimp *gimp,
|
||||
GObject *config,
|
||||
GimpContainer *container,
|
||||
GFile *file,
|
||||
const gchar *import_dialog_title,
|
||||
const gchar *export_dialog_title,
|
||||
const gchar *file_dialog_help_id,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsettingseditor.c
|
||||
* Copyright (C) 2008-2011 Michael Natterer <mitch@gimp.org>
|
||||
* Copyright (C) 2008-2017 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
|
||||
|
@ -31,8 +31,10 @@
|
|||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "operations/gimp-operation-config.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimplist.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpviewable.h"
|
||||
|
||||
#include "gimpcontainertreestore.h"
|
||||
|
@ -360,6 +362,8 @@ gimp_settings_editor_delete_clicked (GtkWidget *widget,
|
|||
|
||||
gimp_container_view_select_item (GIMP_CONTAINER_VIEW (private->view),
|
||||
GIMP_VIEWABLE (new));
|
||||
|
||||
gimp_operation_config_serialize (private->gimp, private->container, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,6 +413,9 @@ gimp_settings_editor_name_edited (GtkCellRendererText *cell,
|
|||
|
||||
/* set name after time so the object is reordered correctly */
|
||||
gimp_object_take_name (object, name);
|
||||
|
||||
gimp_operation_config_serialize (private->gimp, private->container,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue