summaryrefslogtreecommitdiff
path: root/libnautilus-extensions/nautilus-metafile-factory.c
blob: 2686f278ce0fafe677c769ecdcc78d891e1c775b (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* -*- Mode: IDL; 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 <libnautilus-extensions/nautilus-gtk-macros.h>
#include <libnautilus-extensions/nautilus-bonobo-extensions.h>
#include <libnautilus/nautilus-bonobo-workarounds.h>

struct NautilusMetafileFactoryDetails {
};

static void nautilus_metafile_factory_init       (NautilusMetafileFactory      *factory);
static void nautilus_metafile_factory_class_init (NautilusMetafileFactoryClass *klass);

static void destroy (GtkObject *factory);

static Nautilus_Metafile corba_open (PortableServer_Servant  servant,
				     const Nautilus_URI      directory,
				     CORBA_Environment      *ev);

NAUTILUS_BONOBO_X_BOILERPLATE (NautilusMetafileFactory, Nautilus_MetafileFactory, BONOBO_X_OBJECT_TYPE, nautilus_metafile_factory)

static void
nautilus_metafile_factory_class_init (NautilusMetafileFactoryClass *klass)
{
	GTK_OBJECT_CLASS (klass)->destroy = destroy;

	klass->epv.open = corba_open;
}

static void
nautilus_metafile_factory_init (NautilusMetafileFactory *factory)
{
	factory->details = g_new0 (NautilusMetafileFactoryDetails, 1);
}

static void
destroy (GtkObject *object)
{
	NautilusMetafileFactory *factory;

	factory = NAUTILUS_METAFILE_FACTORY (object);
	g_free (factory->details);

	NAUTILUS_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
}

static NautilusMetafileFactory *
nautilus_metafile_factory_new (void)
{
	NautilusMetafileFactory *metafile_factory;
	metafile_factory = NAUTILUS_METAFILE_FACTORY (gtk_object_new (NAUTILUS_TYPE_METAFILE_FACTORY, NULL));
	return metafile_factory;
}

static NautilusMetafileFactory *the_factory;

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

NautilusMetafileFactory *
nautilus_metafile_factory_get_instance (void)
{
	if (the_factory == NULL) {
		the_factory = nautilus_metafile_factory_new ();
		g_atexit (free_factory_instance);
	}
	
	bonobo_object_ref (BONOBO_OBJECT (the_factory));
	
	return the_factory;
}

static Nautilus_Metafile
corba_open (PortableServer_Servant  servant,
	    const Nautilus_URI      directory,
	    CORBA_Environment      *ev)
{
	BonoboObject *object;
	object = BONOBO_OBJECT (nautilus_metafile_get (directory));
	return CORBA_Object_duplicate (bonobo_object_corba_objref (object), ev);
}