diff --git a/ChangeLog b/ChangeLog index 9472adb278..09286a587b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-11-23 Sven Neumann + + * app/core/gimp-templates.[ch] + * app/dialogs/user-install-dialog.c: merge the migrated user + templaterc with the system templaterc so the users who have used + gimp-2.0 before get our changes to the default templates. + 2004-11-23 Michael Natterer * app/widgets/gimpwidgets-utils.[ch]: added new function diff --git a/app/core/gimp-templates.c b/app/core/gimp-templates.c index 6de096d7cf..77233406bb 100644 --- a/app/core/gimp-templates.c +++ b/app/core/gimp-templates.c @@ -105,3 +105,37 @@ gimp_templates_save (Gimp *gimp) g_free (filename); } + + +/** + * gimp_templates_migrate: + * + * Migrating the templaterc from GIMP 2.0 to GIMP 2.2 needs this special + * hack since we changed the way that units are handled. This function + * merges the user's templaterc with the systemwide templaterc. The goal + * is to replace the unit for a couple of default templates with "pixels". + **/ +void +gimp_templates_migrate (void) +{ + GimpContainer *templates = gimp_list_new (GIMP_TYPE_TEMPLATE, TRUE); + gchar *filename = gimp_personal_rc_file ("templaterc"); + + if (gimp_config_deserialize_file (GIMP_CONFIG (templates), filename, + NULL, NULL)) + { + gchar *tmp = g_build_filename (gimp_sysconf_directory (), + "templaterc", NULL); + + gimp_config_deserialize_file (GIMP_CONFIG (templates), tmp, NULL, NULL); + + g_free (tmp); + + gimp_list_reverse (GIMP_LIST (templates)); + + gimp_config_serialize_to_file (GIMP_CONFIG (templates), filename, + NULL, NULL, NULL, NULL); + } + + g_free (filename); +} diff --git a/app/core/gimp-templates.h b/app/core/gimp-templates.h index dcca7593a2..df696ee19b 100644 --- a/app/core/gimp-templates.h +++ b/app/core/gimp-templates.h @@ -20,8 +20,10 @@ #define __GIMP_TEMPLATES_H__ -void gimp_templates_load (Gimp *gimp); -void gimp_templates_save (Gimp *gimp); +void gimp_templates_load (Gimp *gimp); +void gimp_templates_save (Gimp *gimp); + +void gimp_templates_migrate (void); #endif /* __GIMP_TEMPLATES_H__ */ diff --git a/app/dialogs/user-install-dialog.c b/app/dialogs/user-install-dialog.c index fa8a545fe3..9c1ccd25be 100644 --- a/app/dialogs/user-install-dialog.c +++ b/app/dialogs/user-install-dialog.c @@ -43,6 +43,8 @@ #include "config/gimpconfig-utils.h" #include "config/gimprc.h" +#include "core/gimp-templates.h" + #include "widgets/gimppropwidgets.h" #include "widgets/gimpwidgets-utils.h" @@ -339,39 +341,38 @@ user_install_response (GtkWidget *widget, gint response_id, GimpRc *gimprc) { - static gint notebook_index = GPL_PAGE; + static gint index = GPL_PAGE; if (response_id != GTK_RESPONSE_OK) { exit (EXIT_SUCCESS); } - switch (notebook_index) + switch (index) { case GPL_PAGE: if (oldgimp) - notebook_index = MIGRATION_PAGE; + index = MIGRATION_PAGE; else - notebook_index = TREE_PAGE; + index = TREE_PAGE; - user_install_notebook_set_page (GTK_NOTEBOOK (notebook), notebook_index); + user_install_notebook_set_page (GTK_NOTEBOOK (notebook), index); break; case MIGRATION_PAGE: if (migrate) { - notebook_index = TREE_PAGE; + index = TREE_PAGE; /* fallthrough */ } else { - user_install_notebook_set_page (GTK_NOTEBOOK (notebook), - ++notebook_index); + user_install_notebook_set_page (GTK_NOTEBOOK (notebook), ++index); break; } case TREE_PAGE: - user_install_notebook_set_page (GTK_NOTEBOOK (notebook), ++notebook_index); + user_install_notebook_set_page (GTK_NOTEBOOK (notebook), ++index); /* Creating the directories can take some time on NFS, so inform * the user and set the buttons insensitive @@ -395,7 +396,7 @@ user_install_response (GtkWidget *widget, _("Installation failed. " "Contact system administrator.")); - notebook_index = TUNING_PAGE; /* skip to last page */ + index = TUNING_PAGE; /* skip to last page */ } gtk_dialog_set_response_sensitive (GTK_DIALOG (widget), @@ -405,8 +406,7 @@ user_install_response (GtkWidget *widget, case LOG_PAGE: if (! migrate) { - user_install_notebook_set_page (GTK_NOTEBOOK (notebook), - ++notebook_index); + user_install_notebook_set_page (GTK_NOTEBOOK (notebook), ++index); user_install_tuning (gimprc); break; } @@ -1294,6 +1294,8 @@ user_install_migrate_files (const gchar *oldgimp, return FALSE; } + gimp_templates_migrate (); + return TRUE; }