Commit 1fed79d7 authored by Maciej Stachowiak's avatar Maciej Stachowiak

Remove request_* calls from public API (they are just an implementation

	* src/ntl-view.h: Remove request_* calls from public API (they are
	just an implementation detail of the fact that NautilusView
	implements a Nautilus:ViewFrame CORBA server - the nautilus app
	should not need to call these).

	* src/ntl-view.c: Split all the three way conditional stuff out so
	there is a separate function for each branch of the condition. Not
	a big win yet, but will provide opportunities for more
	refactoring.

	* src/ntl-view-frame-svr.c, ntl-view-frame-svr.h: Move
	implementation of Nautilus:ViewFrame CORBA server here as much as
	possible.
	* src/ntl-view.c: Remove it from here.
	* src/nautilus.h: #include ntl-view-frame-svr.h
	* src/Makefile.am: add ntl-view-frame-svr.[ch] to build.

	* src/ntl-window.c: Add myself to About box (pout).
parent 9c9fbb1c
......@@ -2,6 +2,25 @@
* components/html/ntl-web-browser.c: Fix warnings.
* src/ntl-view.h: Remove request_* calls from public API (they are
just an implementation detail of the fact that NautilusView
implements a Nautilus:ViewFrame CORBA server - the nautilus app
should not need to call these).
* src/ntl-view.c: Split all the three way conditional stuff out so
there is a separate function for each branch of the condition. Not
a big win yet, but will provide opportunities for more
refactoring.
* src/ntl-view-frame-svr.c, ntl-view-frame-svr.h: Move
implementation of Nautilus:ViewFrame CORBA server here as much as
possible.
* src/ntl-view.c: Remove it from here.
* src/nautilus.h: #include ntl-view-frame-svr.h
* src/Makefile.am: add ntl-view-frame-svr.[ch] to build.
* src/ntl-window.c: Add myself to About box (pout).
1999-12-20 Elliot Lee <sopwith@redhat.com>
* configure.in, components/Makefile.am: Add HTML component to build.
......
......@@ -38,6 +38,8 @@ nautilus_SOURCES= \
ntl-uri-map.c \
ntl-view.h \
ntl-view.c \
ntl-view-frame-svr.h \
ntl-view-frame-svr.c \
ntl-window.h \
ntl-window.c \
ntl-window-msgs.c \
......
......@@ -877,6 +877,7 @@ nautilus_window_about_cb (GtkWidget *widget,
"Darin Adler",
"Elliot Lee",
"Ettore Perazzoli",
"Maciej Stachowiak",
"John Sullivan",
NULL
};
......
......@@ -877,6 +877,7 @@ nautilus_window_about_cb (GtkWidget *widget,
"Darin Adler",
"Elliot Lee",
"Ettore Perazzoli",
"Maciej Stachowiak",
"John Sullivan",
NULL
};
......
......@@ -877,6 +877,7 @@ nautilus_window_about_cb (GtkWidget *widget,
"Darin Adler",
"Elliot Lee",
"Ettore Perazzoli",
"Maciej Stachowiak",
"John Sullivan",
NULL
};
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Nautilus
*
* Copyright (C) 1999 Red Hat, Inc.
*
* This library 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 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Author: Elliot Lee <sopwith@redhat.com>
*
*/
/* ntl-view-frame-svr.c: CORBA server implementation of the object
representing a data view frame. */
#include "nautilus.h"
typedef struct {
POA_Nautilus_ViewFrame servant;
gpointer gnome_object;
NautilusView *view;
} impl_POA_Nautilus_ViewFrame;
static Nautilus_ViewWindow
impl_Nautilus_ViewFrame__get_main_window(impl_POA_Nautilus_ViewFrame *servant,
CORBA_Environment *ev);
static void
impl_Nautilus_ViewFrame_request_location_change(impl_POA_Nautilus_ViewFrame * servant,
Nautilus_NavigationRequestInfo * navinfo,
CORBA_Environment * ev);
static void
impl_Nautilus_ViewFrame_request_selection_change(impl_POA_Nautilus_ViewFrame * servant,
Nautilus_SelectionRequestInfo * selinfo,
CORBA_Environment * ev);
static void
impl_Nautilus_ViewFrame_request_status_change(impl_POA_Nautilus_ViewFrame * servant,
Nautilus_StatusRequestInfo * statinfo,
CORBA_Environment * ev);
static void
nautilus_view_request_location_change(NautilusView *view,
Nautilus_NavigationRequestInfo *loc);
static void
nautilus_view_request_selection_change (NautilusView *view,
Nautilus_SelectionRequestInfo *loc);
static void
nautilus_view_request_status_change (NautilusView *view,
Nautilus_StatusRequestInfo *loc);
POA_Nautilus_ViewFrame__epv impl_Nautilus_ViewFrame_epv =
{
NULL, /* _private */
(void(*))&impl_Nautilus_ViewFrame__get_main_window,
(void(*))&impl_Nautilus_ViewFrame_request_status_change,
(void(*))&impl_Nautilus_ViewFrame_request_location_change,
(void(*))&impl_Nautilus_ViewFrame_request_selection_change
};
static PortableServer_ServantBase__epv base_epv = { NULL, NULL, NULL };
POA_Nautilus_ViewFrame__vepv impl_Nautilus_ViewFrame_vepv =
{
&base_epv,
NULL,
&impl_Nautilus_ViewFrame_epv
};
static void
impl_Nautilus_ViewFrame__destroy(GnomeObject *obj, impl_POA_Nautilus_ViewFrame *servant)
{
PortableServer_ObjectId *objid;
CORBA_Environment ev;
NautilusViewClass *klass;
void (*servant_destroy_func)(PortableServer_Servant, CORBA_Environment *);
klass = NAUTILUS_VIEW_CLASS(GTK_OBJECT(servant->view)->klass);
CORBA_exception_init(&ev);
objid = PortableServer_POA_servant_to_id(bonobo_poa(), servant, &ev);
PortableServer_POA_deactivate_object(bonobo_poa(), objid, &ev);
CORBA_free(objid);
obj->servant = NULL;
servant_destroy_func = klass->servant_destroy_func;
servant_destroy_func((PortableServer_Servant) servant, &ev);
g_free(servant);
CORBA_exception_free(&ev);
}
GnomeObject *
impl_Nautilus_ViewFrame__create(NautilusView *view, CORBA_Environment * ev)
{
GnomeObject *retval;
impl_POA_Nautilus_ViewFrame *newservant;
NautilusViewClass *klass;
void (*servant_init_func)(PortableServer_Servant, CORBA_Environment *);
klass = NAUTILUS_VIEW_CLASS(GTK_OBJECT(view)->klass);
newservant = g_new0(impl_POA_Nautilus_ViewFrame, 1);
newservant->servant.vepv = klass->vepv;
if(!newservant->servant.vepv->GNOME_Unknown_epv)
newservant->servant.vepv->GNOME_Unknown_epv = gnome_object_get_epv();
newservant->view = view;
servant_init_func = klass->servant_init_func;
servant_init_func((PortableServer_Servant) newservant, ev);
retval = gnome_object_new_from_servant(newservant);
gtk_signal_connect(GTK_OBJECT(retval), "destroy", GTK_SIGNAL_FUNC(impl_Nautilus_ViewFrame__destroy), newservant);
return retval;
}
static Nautilus_ViewWindow
impl_Nautilus_ViewFrame__get_main_window(impl_POA_Nautilus_ViewFrame *servant,
CORBA_Environment *ev)
{
return CORBA_Object_duplicate(gnome_object_corba_objref(NAUTILUS_WINDOW(servant->view->main_window)->ntl_viewwindow), ev);
}
static void
impl_Nautilus_ViewFrame_request_location_change(impl_POA_Nautilus_ViewFrame * servant,
Nautilus_NavigationRequestInfo * navinfo,
CORBA_Environment * ev)
{
NautilusView *view;
view = servant->view;
g_return_if_fail (view != NULL);
g_return_if_fail (NAUTILUS_IS_VIEW (view));
g_return_if_fail (NAUTILUS_VIEW (view)->main_window != NULL);
nautilus_window_request_location_change(NAUTILUS_WINDOW(view->main_window), navinfo, GTK_WIDGET(view));
}
static void
impl_Nautilus_ViewFrame_request_selection_change(impl_POA_Nautilus_ViewFrame * servant,
Nautilus_SelectionRequestInfo * selinfo,
CORBA_Environment * ev)
{
nautilus_window_request_selection_change(NAUTILUS_WINDOW(servant->view->main_window),
selinfo,
GTK_WIDGET(servant->view));
}
static void
impl_Nautilus_ViewFrame_request_status_change(impl_POA_Nautilus_ViewFrame * servant,
Nautilus_StatusRequestInfo * statinfo,
CORBA_Environment * ev)
{
nautilus_window_request_status_change(NAUTILUS_WINDOW(servant->view->main_window),
statinfo,
GTK_WIDGET(servant->view));
}
......@@ -40,125 +40,6 @@ enum {
ARG_MAIN_WINDOW
};
typedef struct {
POA_Nautilus_ViewFrame servant;
gpointer gnome_object;
NautilusView *view;
} impl_POA_Nautilus_ViewFrame;
static Nautilus_ViewWindow
impl_Nautilus_ViewFrame__get_main_window(impl_POA_Nautilus_ViewFrame *servant,
CORBA_Environment *ev);
static void
impl_Nautilus_ViewFrame_request_location_change(impl_POA_Nautilus_ViewFrame * servant,
Nautilus_NavigationRequestInfo * navinfo,
CORBA_Environment * ev);
static void
impl_Nautilus_ViewFrame_request_selection_change(impl_POA_Nautilus_ViewFrame * servant,
Nautilus_SelectionRequestInfo * selinfo,
CORBA_Environment * ev);
static void
impl_Nautilus_ViewFrame_request_status_change(impl_POA_Nautilus_ViewFrame * servant,
Nautilus_StatusRequestInfo * statinfo,
CORBA_Environment * ev);
POA_Nautilus_ViewFrame__epv impl_Nautilus_ViewFrame_epv =
{
NULL, /* _private */
(void(*))&impl_Nautilus_ViewFrame__get_main_window,
(void(*))&impl_Nautilus_ViewFrame_request_status_change,
(void(*))&impl_Nautilus_ViewFrame_request_location_change,
(void(*))&impl_Nautilus_ViewFrame_request_selection_change
};
static PortableServer_ServantBase__epv base_epv = { NULL, NULL, NULL };
static POA_Nautilus_ViewFrame__vepv impl_Nautilus_ViewFrame_vepv =
{
&base_epv,
NULL,
&impl_Nautilus_ViewFrame_epv
};
static void
impl_Nautilus_ViewFrame__destroy(GnomeObject *obj, impl_POA_Nautilus_ViewFrame *servant)
{
PortableServer_ObjectId *objid;
CORBA_Environment ev;
NautilusViewClass *klass;
void (*servant_destroy_func)(PortableServer_Servant, CORBA_Environment *);
klass = NAUTILUS_VIEW_CLASS(GTK_OBJECT(servant->view)->klass);
CORBA_exception_init(&ev);
objid = PortableServer_POA_servant_to_id(bonobo_poa(), servant, &ev);
PortableServer_POA_deactivate_object(bonobo_poa(), objid, &ev);
CORBA_free(objid);
obj->servant = NULL;
servant_destroy_func = klass->servant_destroy_func;
servant_destroy_func((PortableServer_Servant) servant, &ev);
g_free(servant);
CORBA_exception_free(&ev);
}
static GnomeObject *
impl_Nautilus_ViewFrame__create(NautilusView *view, CORBA_Environment * ev)
{
GnomeObject *retval;
impl_POA_Nautilus_ViewFrame *newservant;
NautilusViewClass *klass;
void (*servant_init_func)(PortableServer_Servant, CORBA_Environment *);
klass = NAUTILUS_VIEW_CLASS(GTK_OBJECT(view)->klass);
newservant = g_new0(impl_POA_Nautilus_ViewFrame, 1);
newservant->servant.vepv = klass->vepv;
if(!newservant->servant.vepv->GNOME_Unknown_epv)
newservant->servant.vepv->GNOME_Unknown_epv = gnome_object_get_epv();
newservant->view = view;
servant_init_func = klass->servant_init_func;
servant_init_func((PortableServer_Servant) newservant, ev);
retval = gnome_object_new_from_servant(newservant);
gtk_signal_connect(GTK_OBJECT(retval), "destroy", GTK_SIGNAL_FUNC(impl_Nautilus_ViewFrame__destroy), newservant);
return retval;
}
static Nautilus_ViewWindow
impl_Nautilus_ViewFrame__get_main_window(impl_POA_Nautilus_ViewFrame *servant,
CORBA_Environment *ev)
{
return CORBA_Object_duplicate(gnome_object_corba_objref(NAUTILUS_WINDOW(servant->view->main_window)->ntl_viewwindow), ev);
}
static void
impl_Nautilus_ViewFrame_request_location_change(impl_POA_Nautilus_ViewFrame * servant,
Nautilus_NavigationRequestInfo * navinfo,
CORBA_Environment * ev)
{
nautilus_view_request_location_change(servant->view, navinfo);
}
static void
impl_Nautilus_ViewFrame_request_selection_change(impl_POA_Nautilus_ViewFrame * servant,
Nautilus_SelectionRequestInfo * selinfo,
CORBA_Environment * ev)
{
nautilus_view_request_selection_change(servant->view, selinfo);
}
static void
impl_Nautilus_ViewFrame_request_status_change(impl_POA_Nautilus_ViewFrame * servant,
Nautilus_StatusRequestInfo * statinfo,
CORBA_Environment * ev)
{
nautilus_view_request_status_change(servant->view, statinfo);
}
static void nautilus_view_init (NautilusView *view);
static void nautilus_view_constructed(NautilusView *view);
......@@ -350,31 +231,6 @@ nautilus_view_construct_arg_set(NautilusView *view)
klass->view_constructed(view);
}
void
nautilus_view_request_location_change(NautilusView *view,
Nautilus_NavigationRequestInfo *loc)
{
g_return_if_fail (view != NULL);
g_return_if_fail (NAUTILUS_IS_VIEW (view));
g_return_if_fail (NAUTILUS_VIEW (view)->main_window != NULL);
nautilus_window_request_location_change(NAUTILUS_WINDOW(view->main_window), loc, GTK_WIDGET(view));
}
void
nautilus_view_request_selection_change (NautilusView *view,
Nautilus_SelectionRequestInfo *loc)
{
nautilus_window_request_selection_change(NAUTILUS_WINDOW(view->main_window), loc, GTK_WIDGET(view));
}
void
nautilus_view_request_status_change (NautilusView *view,
Nautilus_StatusRequestInfo *loc)
{
nautilus_window_request_status_change(NAUTILUS_WINDOW(view->main_window), loc, GTK_WIDGET(view));
}
static void
nautilus_view_size_request (GtkWidget *widget,
GtkRequisition *requisition)
......@@ -419,12 +275,143 @@ nautilus_view_activate_uri(GnomeControlFrame *frame, const char *uri, gboolean r
memset(&nri, 0, sizeof(nri));
nri.requested_uri = (char *)uri;
nautilus_view_request_location_change(view, &nri);
nautilus_window_request_location_change(NAUTILUS_WINDOW(view->main_window), &nri, GTK_WIDGET(view));
}
static void
destroy_nautilus_view(NautilusView *view)
{
CORBA_Environment ev;
CORBA_exception_init(&ev);
CORBA_Object_release(view->u.nautilus_view_info.view_client, &ev);
gnome_object_destroy(view->u.nautilus_view_info.control_frame);
}
static void
destroy_bonobo_subdoc_view(NautilusView *view)
{
gnome_object_destroy(view->u.bonobo_subdoc_info.container);
}
static void
destroy_bonobo_control_view(NautilusView *view)
{
gnome_object_destroy(view->u.bonobo_control_info.control_frame);
}
static gboolean
bonobo_control_try_load_client(NautilusView *view, CORBA_Object obj)
{
GNOME_Control control;
CORBA_Environment ev;
CORBA_exception_init(&ev);
control = (GNOME_Control) obj;
view->u.nautilus_view_info.control_frame = GNOME_OBJECT(gnome_control_frame_new());
gnome_object_add_interface(GNOME_OBJECT(view->u.bonobo_control_info.control_frame), view->view_frame);
gnome_control_frame_bind_to_control(GNOME_CONTROL_FRAME(view->u.bonobo_control_info.control_frame),
control);
GNOME_Unknown_unref(control, &ev);
view->client_widget =
gnome_control_frame_get_widget(GNOME_CONTROL_FRAME(view->u.bonobo_control_info.control_frame));
view->type = NV_BONOBO_CONTROL;
gtk_signal_connect(GTK_OBJECT(view->u.bonobo_control_info.control_frame),
"activate_uri", GTK_SIGNAL_FUNC(nautilus_view_activate_uri), view);
CORBA_exception_free(&ev);
return TRUE;
}
static gboolean
bonobo_subdoc_try_load_client(NautilusView *view, CORBA_Object obj)
{
CORBA_Environment ev;
CORBA_exception_init(&ev);
view->type = NV_BONOBO_SUBDOC;
view->u.bonobo_subdoc_info.container = GNOME_OBJECT(gnome_container_new());
gnome_object_add_interface(GNOME_OBJECT(view->u.bonobo_subdoc_info.container), view->view_frame);
view->u.bonobo_subdoc_info.client_site =
GNOME_OBJECT(gnome_client_site_new(GNOME_CONTAINER(view->u.bonobo_subdoc_info.container)));
gnome_client_site_bind_embeddable(GNOME_CLIENT_SITE(view->u.bonobo_subdoc_info.client_site),
view->client_object);
gnome_container_add(GNOME_CONTAINER(view->u.bonobo_subdoc_info.container), view->u.bonobo_subdoc_info.client_site);
view->u.bonobo_subdoc_info.view_frame =
GNOME_OBJECT(gnome_client_site_new_view(GNOME_CLIENT_SITE(view->u.bonobo_subdoc_info.client_site)));
if(!view->u.bonobo_subdoc_info.view_frame)
{
gnome_object_destroy(GNOME_OBJECT(view->client_object));
gnome_object_destroy(view->u.bonobo_subdoc_info.container);
gnome_object_destroy(view->u.bonobo_subdoc_info.client_site);
GNOME_Unknown_unref(obj, &ev);
CORBA_Object_release(obj, &ev);
gnome_object_destroy(view->view_frame);
view->type = NV_NONE;
return FALSE;
}
view->client_widget = gnome_view_frame_get_wrapper(GNOME_VIEW_FRAME(view->u.bonobo_subdoc_info.view_frame));
CORBA_exception_free(&ev);
return TRUE;
}
static gboolean
nautilus_view_try_load_client(NautilusView *view, CORBA_Object obj)
{
GNOME_Control control;
CORBA_Environment ev;
CORBA_exception_init(&ev);
view->u.nautilus_view_info.view_client = obj;
view->type = NV_NAUTILUS_VIEW;
control =
GNOME_Unknown_query_interface(gnome_object_corba_objref(GNOME_OBJECT(view->client_object)), "IDL:GNOME/Control:1.0", &ev);
if(ev._major != CORBA_NO_EXCEPTION)
control = CORBA_OBJECT_NIL;
if(CORBA_Object_is_nil(control, &ev))
{
gnome_object_unref(GNOME_OBJECT(view->client_object));
GNOME_Unknown_unref(view->u.nautilus_view_info.view_client, &ev);
CORBA_Object_release(view->u.nautilus_view_info.view_client, &ev);
gnome_object_destroy(view->view_frame);
view->type = NV_NONE;
return FALSE;
}
view->u.nautilus_view_info.control_frame = GNOME_OBJECT(gnome_control_frame_new());
gnome_object_add_interface(GNOME_OBJECT(view->u.nautilus_view_info.control_frame), view->view_frame);
gnome_control_frame_bind_to_control(GNOME_CONTROL_FRAME(view->u.nautilus_view_info.control_frame), control);
GNOME_Unknown_unref(control, &ev);
view->client_widget = gnome_control_frame_get_widget(GNOME_CONTROL_FRAME(view->u.nautilus_view_info.control_frame));
CORBA_exception_free(&ev);
return TRUE;
}
gboolean /* returns TRUE if successful */
nautilus_view_load_client(NautilusView *view, const char *iid)
{
CORBA_Object obj;
CORBA_Environment ev;
g_return_val_if_fail(iid, FALSE);
......@@ -439,14 +426,13 @@ nautilus_view_load_client(NautilusView *view, const char *iid)
switch(view->type)
{
case NV_NAUTILUS_VIEW:
CORBA_Object_release(view->u.nautilus_view_info.view_client, &ev);
gnome_object_destroy(view->u.nautilus_view_info.control_frame);
destroy_nautilus_view(view);
break;
case NV_BONOBO_SUBDOC:
gnome_object_destroy(view->u.bonobo_subdoc_info.container);
destroy_bonobo_subdoc_view(view);
break;
case NV_BONOBO_CONTROL:
gnome_object_destroy(view->u.bonobo_control_info.control_frame);
destroy_bonobo_control_view(view);
break;
default:
break;
......@@ -462,111 +448,62 @@ nautilus_view_load_client(NautilusView *view, const char *iid)
view->view_frame = impl_Nautilus_ViewFrame__create(view, &ev);
/* Now figure out which type of embedded object it is: */
view->u.nautilus_view_info.view_client =
GNOME_Unknown_query_interface(gnome_object_corba_objref(GNOME_OBJECT(view->client_object)),
"IDL:Nautilus/View:1.0", &ev);
/* Is it a Nautilus View? */
obj = GNOME_Unknown_query_interface(gnome_object_corba_objref(GNOME_OBJECT(view->client_object)),
"IDL:Nautilus/View:1.0", &ev);
if(ev._major != CORBA_NO_EXCEPTION)
view->u.nautilus_view_info.view_client = CORBA_OBJECT_NIL;
obj = CORBA_OBJECT_NIL;
if(!CORBA_Object_is_nil(view->u.nautilus_view_info.view_client, &ev))
if(!CORBA_Object_is_nil(obj, &ev))
{
GNOME_Control control;
view->type = NV_NAUTILUS_VIEW;
control =
GNOME_Unknown_query_interface(gnome_object_corba_objref(GNOME_OBJECT(view->client_object)), "IDL:GNOME/Control:1.0", &ev);
if(ev._major != CORBA_NO_EXCEPTION)
control = CORBA_OBJECT_NIL;
if(CORBA_Object_is_nil(control, &ev))
if (!nautilus_view_try_load_client(view, obj))
{
gnome_object_unref(GNOME_OBJECT(view->client_object));
GNOME_Unknown_unref(view->u.nautilus_view_info.view_client, &ev);
CORBA_Object_release(view->u.nautilus_view_info.view_client, &ev);
gnome_object_destroy(view->view_frame);
view->type = NV_NONE;
return FALSE;
}
view->u.nautilus_view_info.control_frame = GNOME_OBJECT(gnome_control_frame_new());
gnome_object_add_interface(GNOME_OBJECT(view->u.nautilus_view_info.control_frame), view->view_frame);
gnome_control_frame_bind_to_control(GNOME_CONTROL_FRAME(view->u.nautilus_view_info.control_frame), control);
GNOME_Unknown_unref(control, &ev);
view->client_widget = gnome_control_frame_get_widget(GNOME_CONTROL_FRAME(view->u.nautilus_view_info.control_frame));
}
else
{
CORBA_Object tmp_objref;
tmp_objref =
/* Is it a Bonobo Embeddable? */
obj =
GNOME_Unknown_query_interface(gnome_object_corba_objref(GNOME_OBJECT(view->client_object)),
"IDL:GNOME/Embeddable:1.0", &ev);
if(ev._major != CORBA_NO_EXCEPTION)
tmp_objref = CORBA_OBJECT_NIL;
obj = CORBA_OBJECT_NIL;