2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-08-11 15:47:35 +08:00
|
|
|
* 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>
|
|
|
|
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-08-11 15:47:35 +08:00
|
|
|
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "core-types.h"
|
2002-03-28 07:15:00 +08:00
|
|
|
|
2008-03-24 19:11:15 +08:00
|
|
|
#include "config/gimpcoreconfig.h"
|
|
|
|
|
2003-01-25 01:38:24 +08:00
|
|
|
#include "gimp.h"
|
2002-05-15 19:05:32 +08:00
|
|
|
#include "gimpdocumentlist.h"
|
2001-08-11 15:47:35 +08:00
|
|
|
#include "gimpimagefile.h"
|
|
|
|
|
|
|
|
|
2008-03-24 19:11:15 +08:00
|
|
|
G_DEFINE_TYPE (GimpDocumentList, gimp_document_list, GIMP_TYPE_LIST)
|
2002-05-15 21:48:47 +08:00
|
|
|
|
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
static void
|
|
|
|
gimp_document_list_class_init (GimpDocumentListClass *klass)
|
2002-05-15 01:31:58 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-12-11 03:24:36 +08:00
|
|
|
gimp_document_list_init (GimpDocumentList *list)
|
2001-08-11 15:47:35 +08:00
|
|
|
{
|
2005-12-11 03:24:36 +08:00
|
|
|
}
|
2001-08-11 15:47:35 +08:00
|
|
|
|
2002-05-15 01:31:58 +08:00
|
|
|
GimpContainer *
|
2003-01-25 01:38:24 +08:00
|
|
|
gimp_document_list_new (Gimp *gimp)
|
2001-08-11 15:47:35 +08:00
|
|
|
{
|
2003-01-25 01:38:24 +08:00
|
|
|
GimpDocumentList *document_list;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
2002-05-15 01:31:58 +08:00
|
|
|
|
2002-05-15 19:05:32 +08:00
|
|
|
document_list = g_object_new (GIMP_TYPE_DOCUMENT_LIST,
|
2006-12-11 03:13:58 +08:00
|
|
|
"name", "document-list",
|
|
|
|
"children-type", GIMP_TYPE_IMAGEFILE,
|
2002-05-15 19:05:32 +08:00
|
|
|
"policy", GIMP_CONTAINER_POLICY_STRONG,
|
|
|
|
NULL);
|
2003-01-25 01:38:24 +08:00
|
|
|
|
|
|
|
document_list->gimp = gimp;
|
|
|
|
|
2002-05-15 19:05:32 +08:00
|
|
|
return GIMP_CONTAINER (document_list);
|
2001-08-11 15:47:35 +08:00
|
|
|
}
|
|
|
|
|
2002-04-19 20:05:47 +08:00
|
|
|
GimpImagefile *
|
2002-05-15 19:05:32 +08:00
|
|
|
gimp_document_list_add_uri (GimpDocumentList *document_list,
|
2004-05-14 08:01:11 +08:00
|
|
|
const gchar *uri,
|
|
|
|
const gchar *mime_type)
|
2001-08-11 15:47:35 +08:00
|
|
|
{
|
2008-03-24 19:11:15 +08:00
|
|
|
Gimp *gimp;
|
2001-08-11 15:47:35 +08:00
|
|
|
GimpImagefile *imagefile;
|
2002-05-15 01:31:58 +08:00
|
|
|
GimpContainer *container;
|
2001-08-11 15:47:35 +08:00
|
|
|
|
2002-05-15 19:05:32 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DOCUMENT_LIST (document_list), NULL);
|
2002-04-19 20:05:47 +08:00
|
|
|
g_return_val_if_fail (uri != NULL, NULL);
|
2001-08-11 15:47:35 +08:00
|
|
|
|
2008-03-24 19:11:15 +08:00
|
|
|
gimp = document_list->gimp;
|
|
|
|
|
2002-05-15 19:05:32 +08:00
|
|
|
container = GIMP_CONTAINER (document_list);
|
2002-05-15 01:31:58 +08:00
|
|
|
|
|
|
|
imagefile = (GimpImagefile *) gimp_container_get_child_by_name (container,
|
|
|
|
uri);
|
2001-08-11 15:47:35 +08:00
|
|
|
|
|
|
|
if (imagefile)
|
|
|
|
{
|
2002-05-15 01:31:58 +08:00
|
|
|
gimp_container_reorder (container, GIMP_OBJECT (imagefile), 0);
|
2001-08-11 15:47:35 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-24 19:11:15 +08:00
|
|
|
imagefile = gimp_imagefile_new (gimp, uri);
|
2002-05-15 01:31:58 +08:00
|
|
|
gimp_container_add (container, GIMP_OBJECT (imagefile));
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (imagefile);
|
2001-08-11 15:47:35 +08:00
|
|
|
}
|
2002-04-19 20:05:47 +08:00
|
|
|
|
2008-03-24 19:11:15 +08:00
|
|
|
gimp_imagefile_set_mime_type (imagefile, mime_type);
|
|
|
|
|
|
|
|
if (gimp->config->save_document_history)
|
|
|
|
gimp_recent_list_add_uri (gimp, uri, mime_type);
|
2004-05-14 08:01:11 +08:00
|
|
|
|
2002-04-19 20:05:47 +08:00
|
|
|
return imagefile;
|
2001-08-11 15:47:35 +08:00
|
|
|
}
|