main.c 2.89 KB
Newer Older
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
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* 
 * Copyright (C) 2000 Eazel, Inc
 *
 * 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.
 *
 * Author: Maciej Stachowiak
 */

/* main.c - main function and object activation function for loser
   sidebar view component that fails on command. */

#include <config.h>

#include "nautilus-sidebar-loser.h"

#include <gnome.h>
31
#include <bonobo-activation/bonobo-activation.h>
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <bonobo.h>

static int object_count = 0;

static void
loser_object_destroyed(GtkObject *obj)
{
	object_count--;
	if (object_count <= 0) {
		gtk_main_quit ();
	}
}

static BonoboObject *
loser_make_object (BonoboGenericFactory *factory, 
		    const char *iid, 
		    void *closure)
{
	NautilusSidebarLoser *view;
51
	NautilusView *nautilus_view;
52
53
54
55
56
57
58

	nautilus_sidebar_loser_maybe_fail ("pre-make-object");

	if (strcmp (iid, "OAFIID:nautilus_sidebar_loser:07bfdd1d-7abc-4412-98ab-441b226a10d0")) {
		return NULL;
	}

59
	view = NAUTILUS_SIDEBAR_LOSER (g_object_new (NAUTILUS_TYPE_SIDEBAR_LOSER, NULL));
60
61
62

	object_count++;

Darin Adler's avatar
Darin Adler committed
63
	nautilus_view = nautilus_sidebar_loser_get_nautilus_view (view);
64

65
	g_signal_connect (nautilus_view, "destroy", loser_object_destroyed, NULL);
66
67
68

	nautilus_sidebar_loser_maybe_fail ("post-make-object");

69
	return BONOBO_OBJECT (nautilus_view);
70
71
72
73
74
75
76
}

int main(int argc, char *argv[])
{
	BonoboGenericFactory *factory;
	CORBA_ORB orb;
	CORBA_Environment ev;
77
	char *registration_id;
78
79
80
81
82

	CORBA_exception_init(&ev);

	nautilus_sidebar_loser_maybe_fail ("pre-init");

83
84
	gnomelib_register_popt_table (bonobo_activation_popt_options, bonobo_activation_get_popt_table_name ());
	orb = bonobo_activation_init (argc, argv);
85
86
87

        gnome_init ("nautilus-sidebar-loser", VERSION, 
		    argc, argv); 
88
89
90
91
92
	
	bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL);

	nautilus_sidebar_loser_maybe_fail ("post-init");

93

94
        registration_id = bonobo_activation_make_registration_id ("OAFIID:nautilus_sidebar_loser_factory:5d9aadfa-a8a4-4ec0-8332-d6f806c211fa", getenv ("DISPLAY"));
95
96
97
98
99
	factory = bonobo_generic_factory_new_multi (registration_id, 
						    loser_make_object,
						    NULL);
	g_free (registration_id);

100
101
102
103
104
105
106
107
108

	nautilus_sidebar_loser_maybe_fail ("post-factory-init");

	do {
		bonobo_main ();
	} while (object_count > 0);
	
	return 0;
}