summaryrefslogtreecommitdiff
path: root/test/test-nautilus-async-activation.c
blob: c3abb9f4ecfef9f89bf791264f92e5e6a5b4bf09 (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; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* 
   Copyright (C) 2000 Eazel

   The Gnome 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.

   The Gnome 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 the Gnome Library; see the file COPYING.LIB.  If not,
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.

   Author: Mathieu Lacage <mathieu@eazel.com>
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <gtk/gtk.h>
#include <libnautilus-private/nautilus-bonobo-extensions.h>
#include <bonobo/bonobo-widget.h>
#include <bonobo/bonobo-main.h>
#include <liboaf/oaf-mainloop.h>

#define IID "OAFIID:bonobo_calculator:fab8c2a7-9576-437c-aa3a-a8617408970f"

static void
activation_callback (NautilusBonoboActivationHandle *handle,
		     Bonobo_Unknown activated_object,
		     gpointer callback_data)
{
	GtkWidget *window;
	GtkWidget *control;

	window = GTK_WIDGET (callback_data);

	if (activated_object == CORBA_OBJECT_NIL) {
		g_print ("activation failed\n");
	} else {
		control = bonobo_widget_new_control_from_objref (activated_object,
								 CORBA_OBJECT_NIL);
		gtk_container_add (GTK_CONTAINER (window), control);
		gtk_widget_show (GTK_WIDGET (control));
		
		g_print ("activation suceeded\n");
	}
}

int
main (int argc, char *argv[])
{
	GtkWidget *window;
	NautilusBonoboActivationHandle *handle;

	gtk_init (&argc, &argv);
	bonobo_activation_init (argc, argv);
	bonobo_init (bonobo_orb (), 
		     bonobo_poa (), 
		     bonobo_poa_manager ());

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	g_signal_connect (G_OBJECT (window), "destroy",
			    gtk_main_quit, NULL);
	gtk_widget_show_all (GTK_WIDGET (window));
	
	
	handle = nautilus_bonobo_activate_from_id (IID, activation_callback, window);
#if 0
	nautilus_bonobo_activate_stop (handle);
#endif
	bonobo_main ();

	return 0;
}