app: For testing, support to override names of "sessionrc" and "dockrc"

Allow tests to specify specific sessionrc and dockrc files to use, so
they can share other files in the testing gimpdirc.
This commit is contained in:
Martin Nordholts 2011-05-16 07:11:44 +02:00
parent 3efa2062c5
commit 091360fac4
2 changed files with 34 additions and 15 deletions

View File

@ -464,21 +464,33 @@ dialogs_ensure_factory_entry_on_recent_dock (GimpSessionInfo *info)
}
}
static char *
dialogs_get_dockrc_filepath (void)
{
const gchar *filename;
filename = g_getenv ("GIMP_TESTING_DOCKRC_NAME");
if (! filename)
filename = "dockrc";
return gimp_personal_rc_file (filename);
}
void
dialogs_load_recent_docks (Gimp *gimp)
{
gchar *filename;
char *filepath;
GError *error = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("dockrc");
filepath = dialogs_get_dockrc_filepath ();
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filepath));
if (! gimp_config_deserialize_file (GIMP_CONFIG (global_recent_docks),
filename,
filepath,
NULL, &error))
{
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
@ -496,24 +508,24 @@ dialogs_load_recent_docks (Gimp *gimp)
gimp_list_reverse (GIMP_LIST (global_recent_docks));
g_free (filename);
g_free (filepath);
}
void
dialogs_save_recent_docks (Gimp *gimp)
{
gchar *filename;
gchar *filepath;
GError *error = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("dockrc");
filepath = dialogs_get_dockrc_filepath ();
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filepath));
if (! gimp_config_serialize_to_file (GIMP_CONFIG (global_recent_docks),
filename,
filepath,
"recently closed docks",
"end of recently closed docks",
NULL, &error))
@ -522,7 +534,7 @@ dialogs_save_recent_docks (Gimp *gimp)
g_clear_error (&error);
}
g_free (filename);
g_free (filepath);
}
GtkWidget *

View File

@ -364,15 +364,22 @@ session_clear (Gimp *gimp,
static gchar *
session_filename (Gimp *gimp)
{
gchar *filename = gimp_personal_rc_file ("sessionrc");
const gchar *filename;
gchar *filepath;
filename = g_getenv ("GIMP_TESTING_SESSIONRC_NAME");
if (! filename)
filename = "sessionrc";
filepath = gimp_personal_rc_file (filename);
if (gimp->session_name)
{
gchar *tmp = g_strconcat (filename, ".", gimp->session_name, NULL);
gchar *tmp = g_strconcat (filepath, ".", gimp->session_name, NULL);
g_free (filename);
filename = tmp;
g_free (filepath);
filepath = tmp;
}
return filename;
return filepath;
}