summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-metafile-factory.c
blob: eadd693360e91bc2d49ff13ef6c017dffde6870c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */

/* nautilus-metafile.c - server side of Nautilus::MetafileFactory
 *
 * Copyright (C) 2001 Eazel, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <config.h>
#include "nautilus-metafile-factory.h"

#include "nautilus-metafile.h"
#include <bonobo/bonobo-macros.h>
#include <eel/eel-debug.h>

static NautilusMetafileFactory *the_factory;

BONOBO_CLASS_BOILERPLATE_FULL (NautilusMetafileFactory, nautilus_metafile_factory,
			       Nautilus_MetafileFactory,
			       BonoboObject, BONOBO_OBJECT_TYPE)

static void
nautilus_metafile_factory_instance_init (NautilusMetafileFactory *factory)
{
}

static NautilusMetafileFactory *
nautilus_metafile_factory_new (void)
{
	return NAUTILUS_METAFILE_FACTORY
		(g_object_new (NAUTILUS_TYPE_METAFILE_FACTORY, NULL));
}

static Nautilus_Metafile
corba_open (PortableServer_Servant servant,
	    const CORBA_char *directory,
	    CORBA_Environment *ev)
{
	NautilusMetafile *metafile;

	metafile = nautilus_metafile_get (directory);

	return CORBA_Object_duplicate (BONOBO_OBJREF (metafile), ev);
}

static void
nautilus_metafile_factory_class_init (NautilusMetafileFactoryClass *class)
{
	class->epv.open = corba_open;
}

static void
free_factory_instance (void)
{
	bonobo_object_unref (the_factory);
	the_factory = NULL;
}

NautilusMetafileFactory *
nautilus_metafile_factory_get_instance (void)
{
	if (the_factory == NULL) {
		the_factory = nautilus_metafile_factory_new ();
		eel_debug_call_at_shutdown (free_factory_instance);
	}

	return the_factory;
}