app: factor out duplicated code in gimp-operation-config.c

This commit is contained in:
Michael Natterer 2017-03-24 11:52:41 +01:00
parent 70d428591f
commit 766d1aa954
1 changed files with 30 additions and 27 deletions

View File

@ -52,6 +52,7 @@ static void gimp_operation_config_node_notify (GeglNode *node,
const GParamSpec *gegl_pspec,
GObject *config);
static GFile * gimp_operation_config_get_file (GType config_type);
static void gimp_operation_config_add_sep (GimpContainer *container);
static void gimp_operation_config_remove_sep (GimpContainer *container);
@ -359,12 +360,7 @@ gimp_operation_config_get_container (Gimp *gimp,
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);
GFile *file = gimp_operation_config_get_file (config_type);
if (! g_file_query_exists (file, NULL))
{
@ -411,11 +407,8 @@ gimp_operation_config_serialize (Gimp *gimp,
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);
file = gimp_operation_config_get_file (config_type);
}
if (gimp->be_verbose)
@ -453,11 +446,8 @@ gimp_operation_config_deserialize (Gimp *gimp,
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);
file = gimp_operation_config_get_file (config_type);
}
if (gimp->be_verbose)
@ -744,6 +734,19 @@ gimp_operation_config_node_notify (GeglNode *node,
}
}
static GFile *
gimp_operation_config_get_file (GType config_type)
{
GFile *file;
gchar *basename;
basename = g_strconcat (g_type_name (config_type), ".settings", NULL);
file = gimp_directory_file ("filters", basename, NULL);
g_free (basename);
return file;
}
static void
gimp_operation_config_add_sep (GimpContainer *container)
{