2001-08-11 15:47:35 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include <glib-object.h>
|
|
|
|
|
2001-08-11 15:47:35 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-08-11 15:47:35 +08:00
|
|
|
|
|
|
|
#include "core-types.h"
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpcoreconfig.h"
|
2002-05-15 01:31:58 +08:00
|
|
|
|
2002-05-15 19:05:32 +08:00
|
|
|
#include "gimp.h"
|
|
|
|
#include "gimp-documents.h"
|
|
|
|
#include "gimpdocumentlist.h"
|
2002-05-15 01:31:58 +08:00
|
|
|
|
2001-08-11 15:47:35 +08:00
|
|
|
|
2002-05-15 19:05:32 +08:00
|
|
|
/* functions to load and save the gimp documents files */
|
2001-08-11 15:47:35 +08:00
|
|
|
|
|
|
|
void
|
2002-05-15 19:05:32 +08:00
|
|
|
gimp_documents_load (Gimp *gimp)
|
2001-08-11 15:47:35 +08:00
|
|
|
{
|
2002-05-15 01:31:58 +08:00
|
|
|
gchar *filename;
|
|
|
|
GError *error = NULL;
|
2001-08-11 15:47:35 +08:00
|
|
|
|
2002-05-15 19:05:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
g_return_if_fail (GIMP_IS_DOCUMENT_LIST (gimp->documents));
|
2001-08-11 15:47:35 +08:00
|
|
|
|
2002-05-15 01:31:58 +08:00
|
|
|
filename = gimp_personal_rc_file ("documents");
|
2001-08-11 15:47:35 +08:00
|
|
|
|
2005-11-07 06:01:25 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
if (! gimp_config_deserialize_file (GIMP_CONFIG (gimp->documents),
|
2006-04-12 20:49:29 +08:00
|
|
|
filename,
|
|
|
|
GINT_TO_POINTER (gimp->config->thumbnail_size),
|
|
|
|
&error))
|
2002-05-15 01:31:58 +08:00
|
|
|
{
|
2002-05-15 19:59:51 +08:00
|
|
|
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
|
2002-05-15 01:31:58 +08:00
|
|
|
g_error_free (error);
|
|
|
|
}
|
2001-08-11 15:47:35 +08:00
|
|
|
|
2002-05-15 01:31:58 +08:00
|
|
|
g_free (filename);
|
|
|
|
}
|
2001-08-11 15:47:35 +08:00
|
|
|
|
2002-05-15 01:31:58 +08:00
|
|
|
void
|
2002-05-15 19:05:32 +08:00
|
|
|
gimp_documents_save (Gimp *gimp)
|
2002-05-15 01:31:58 +08:00
|
|
|
{
|
2002-05-15 19:05:32 +08:00
|
|
|
const gchar *header =
|
2003-03-06 04:21:50 +08:00
|
|
|
"GIMP documents\n"
|
|
|
|
"\n"
|
|
|
|
"This file will be entirely rewritten every time you quit the gimp.";
|
2002-05-15 19:05:32 +08:00
|
|
|
const gchar *footer =
|
2003-03-06 04:21:50 +08:00
|
|
|
"end of documents";
|
2002-05-15 19:05:32 +08:00
|
|
|
|
2002-05-15 01:31:58 +08:00
|
|
|
gchar *filename;
|
|
|
|
GError *error = NULL;
|
2001-08-11 15:47:35 +08:00
|
|
|
|
2002-05-15 19:05:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
g_return_if_fail (GIMP_IS_DOCUMENT_LIST (gimp->documents));
|
2001-08-11 15:47:35 +08:00
|
|
|
|
2002-05-15 01:31:58 +08:00
|
|
|
filename = gimp_personal_rc_file ("documents");
|
|
|
|
|
2005-11-07 06:01:25 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
if (! gimp_config_serialize_to_file (GIMP_CONFIG (gimp->documents),
|
2006-04-12 20:49:29 +08:00
|
|
|
filename,
|
|
|
|
header, footer, NULL,
|
|
|
|
&error))
|
2001-08-11 15:47:35 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
|
2002-05-15 01:31:58 +08:00
|
|
|
g_error_free (error);
|
2001-08-11 15:47:35 +08:00
|
|
|
}
|
|
|
|
|
2002-05-15 01:31:58 +08:00
|
|
|
g_free (filename);
|
2001-08-11 15:47:35 +08:00
|
|
|
}
|