diff --git a/app/core/gimp.c b/app/core/gimp.c index b820bc40e7..d7f4dea35f 100644 --- a/app/core/gimp.c +++ b/app/core/gimp.c @@ -540,10 +540,6 @@ gimp_real_initialize (Gimp *gimp, status_callback (_("Initialization"), NULL, 0.0); - /* set the last values used to default values */ - gimp->image_new_last_template = - gimp_config_duplicate (GIMP_CONFIG (gimp->config->default_image)); - /* add data objects that need the user context */ gimp_data_factories_add_builtin (gimp); @@ -1118,6 +1114,37 @@ gimp_get_tool_info (Gimp *gimp, return (GimpToolInfo *) info; } +void +gimp_set_last_template (Gimp *gimp, + GimpTemplate *template) +{ + GimpTemplate *last_template; + + g_return_if_fail (GIMP_IS_GIMP (gimp)); + g_return_if_fail (GIMP_IS_TEMPLATE (template)); + + last_template = gimp_get_last_template (gimp); + + gimp_config_sync (G_OBJECT (template), + G_OBJECT (last_template), 0); +} + +GimpTemplate * +gimp_get_last_template (Gimp *gimp) +{ + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + + if (! gimp->image_new_last_template) + { + /* set the last values used to default values */ + gimp->image_new_last_template = + gimp_config_duplicate (GIMP_CONFIG (gimp->config->default_image)); + } + + return gimp->image_new_last_template; +} + + /** * gimp_message: * @gimp: a pointer to the %Gimp object diff --git a/app/core/gimp.h b/app/core/gimp.h index 377b3f0838..ef4796bca1 100644 --- a/app/core/gimp.h +++ b/app/core/gimp.h @@ -225,6 +225,10 @@ GimpContext * gimp_get_user_context (Gimp *gimp); GimpToolInfo * gimp_get_tool_info (Gimp *gimp, const gchar *tool_name); +void gimp_set_last_template (Gimp *gimp, + GimpTemplate *_template); +GimpTemplate * gimp_get_last_template (Gimp *gimp); + void gimp_message (Gimp *gimp, GObject *handler, GimpMessageSeverity severity, diff --git a/app/core/gimpimage-new.c b/app/core/gimpimage-new.c index 4bb869ad00..d10d1a3523 100644 --- a/app/core/gimpimage-new.c +++ b/app/core/gimpimage-new.c @@ -87,7 +87,11 @@ gimp_image_new_get_last_template (Gimp *gimp, } else { - gimp_config_sync (G_OBJECT (gimp->image_new_last_template), + GimpTemplate *last_template; + + last_template = gimp_get_last_template (gimp); + + gimp_config_sync (G_OBJECT (last_template), G_OBJECT (template), 0); } @@ -101,8 +105,7 @@ gimp_image_new_set_last_template (Gimp *gimp, g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_TEMPLATE (template)); - gimp_config_sync (G_OBJECT (template), - G_OBJECT (gimp->image_new_last_template), 0); + gimp_set_last_template (gimp, template); } GimpImage *