app/core/gimp-templates.[ch] merge the migrated user templaterc with the

2004-11-23  Sven Neumann  <sven@gimp.org>

	* 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.
This commit is contained in:
Sven Neumann 2004-11-23 21:00:15 +00:00 committed by Sven Neumann
parent d8a5ca6c1b
commit 7eed9323db
4 changed files with 59 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2004-11-23 Sven Neumann <sven@gimp.org>
* 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 <mitch@gimp.org>
* app/widgets/gimpwidgets-utils.[ch]: added new function

View File

@ -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);
}

View File

@ -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__ */

View File

@ -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;
}