nautilus-adapter-embed-strategy.c 5.45 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
31
32
33
34
35
36
37
38
39
40
41
42
43
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */

/*
 * Nautilus
 *
 * Copyright (C) 2000 Eazel, Inc.
 *
 * Nautilus 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.
 *
 * Nautilus 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; see the file COPYING.  If not,
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Author: Maciej Stachowiak <mjs@eazel.com>
 */


/* nautilus-adapter-embed-strategy.h
 */


#include <config.h>

#include "nautilus-adapter-embed-strategy.h"
#include "nautilus-adapter-embed-strategy-private.h"
#include "nautilus-adapter-control-embed-strategy.h"
#include "nautilus-adapter-embeddable-embed-strategy.h"

#include <gtk/gtkobject.h>
#include <gtk/gtksignal.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
#include <stdio.h>

enum {
44
45
	ACTIVATE,
	DEACTIVATE,
46
47
48
49
50
51
52
53
54
55
56
57
58
59
	OPEN_LOCATION,
	LAST_SIGNAL
};

static guint signals[LAST_SIGNAL];


static void nautilus_adapter_embed_strategy_initialize_class (NautilusAdapterEmbedStrategyClass *klass);
static void nautilus_adapter_embed_strategy_initialize       (NautilusAdapterEmbedStrategy      *strategy);
static void nautilus_adapter_embed_strategy_destroy          (GtkObject                        *object);

NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusAdapterEmbedStrategy, nautilus_adapter_embed_strategy, GTK_TYPE_OBJECT)

NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (nautilus_adapter_embed_strategy, get_widget)
60
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (nautilus_adapter_embed_strategy, get_zoomable)
61
62
63
64
65
66
67
68
69
70

static void
nautilus_adapter_embed_strategy_initialize_class (NautilusAdapterEmbedStrategyClass *klass)
{
	GtkObjectClass *object_class;

	object_class = (GtkObjectClass *) klass;

	object_class->destroy = nautilus_adapter_embed_strategy_destroy;

71
72
73
74
75
76
77
78
79
80
81
82
83
84
	signals[ACTIVATE] =
		gtk_signal_new ("avtivate",
			       GTK_RUN_LAST,
			       object_class->type,
			       GTK_SIGNAL_OFFSET (NautilusAdapterEmbedStrategyClass, activate),
			       gtk_marshal_NONE__POINTER,
			       GTK_TYPE_POINTER, 0);
	signals[DEACTIVATE] =
		gtk_signal_new ("deavtivate",
			       GTK_RUN_LAST,
			       object_class->type,
			       GTK_SIGNAL_OFFSET (NautilusAdapterEmbedStrategyClass, deactivate),
			       gtk_marshal_NONE__NONE,
			       GTK_TYPE_NONE, 0);
85
86
87
88
89
90
91
92
93
94
95
	signals[OPEN_LOCATION] =
		gtk_signal_new ("open_location",
			       GTK_RUN_LAST,
			       object_class->type,
			       GTK_SIGNAL_OFFSET (NautilusAdapterEmbedStrategyClass, open_location),
			       gtk_marshal_NONE__STRING,
			       GTK_TYPE_STRING, 0);
	
	gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);

	NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, nautilus_adapter_embed_strategy, get_widget);
96
	NAUTILUS_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, nautilus_adapter_embed_strategy, get_zoomable);
97
98
99
100
101
102
103
104
105
106
107
108
109
110
}

static void
nautilus_adapter_embed_strategy_initialize (NautilusAdapterEmbedStrategy *strategy)
{
}

static void
nautilus_adapter_embed_strategy_destroy (GtkObject *object)
{
	NautilusAdapterEmbedStrategy *strategy;

	strategy = NAUTILUS_ADAPTER_EMBED_STRATEGY (object);

111
	NAUTILUS_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
112
113
114
115
116
}



NautilusAdapterEmbedStrategy *
117
nautilus_adapter_embed_strategy_get (Bonobo_Unknown component)
118
119
120
121
122
123
124
{
	Bonobo_Control    control;
	Bonobo_Embeddable embeddable;
	CORBA_Environment ev;

	CORBA_exception_init (&ev);

125
126
	control = Bonobo_Unknown_queryInterface (component,
						 "IDL:Bonobo/Control:1.0", &ev);
127
128
129
130
131
	

	if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (control, &ev)) {
		CORBA_exception_free (&ev);
		
132
		return nautilus_adapter_control_embed_strategy_new (control, CORBA_OBJECT_NIL);
133
134
	}

135
136
	embeddable = Bonobo_Unknown_queryInterface (component,
						    "IDL:Bonobo/Embeddable:1.0", &ev);
137
138
139
140
	
	if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (embeddable, &ev)) {
		CORBA_exception_free (&ev);
		
141
		return nautilus_adapter_embeddable_embed_strategy_new (embeddable, CORBA_OBJECT_NIL);		
142
143
144
145
146
147
148
149
150
151
	}

	CORBA_exception_free (&ev);

	return NULL;
}

GtkWidget *
nautilus_adapter_embed_strategy_get_widget (NautilusAdapterEmbedStrategy *strategy)
{
152
153
154
	return NAUTILUS_CALL_METHOD_WITH_RETURN_VALUE
		(NAUTILUS_ADAPTER_EMBED_STRATEGY_CLASS, strategy,
		 get_widget, (strategy));
155
156
}

157
158
159
BonoboObject *
nautilus_adapter_embed_strategy_get_zoomable (NautilusAdapterEmbedStrategy *strategy)
{
160
161
162
	return NAUTILUS_CALL_METHOD_WITH_RETURN_VALUE
		(NAUTILUS_ADAPTER_EMBED_STRATEGY_CLASS, strategy,
		 get_zoomable, (strategy));
163
164
}

165

166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
void 
nautilus_adapter_embed_strategy_activate (NautilusAdapterEmbedStrategy *strategy,
					  Bonobo_UIContainer            ui_container)
{
	gtk_signal_emit (GTK_OBJECT (strategy),
			 signals[ACTIVATE],
			 ui_container);
}

void 
nautilus_adapter_embed_strategy_deactivate (NautilusAdapterEmbedStrategy *strategy)
{
	gtk_signal_emit (GTK_OBJECT (strategy),
			 signals[DEACTIVATE]);
}

182
183
184
185
186
187
188
189
190
void 
nautilus_adapter_embed_strategy_emit_open_location (NautilusAdapterEmbedStrategy *strategy,
						    const char                   *uri)
{
	gtk_signal_emit (GTK_OBJECT (strategy),
			 signals[OPEN_LOCATION],
			 uri);
}