Commit 7fc60b36 authored by Elliot Lee's avatar Elliot Lee
Browse files

Implement IDL:Nautilus/Application:1.0 interface and NautilusApp



* src/nautilus.goad, src/ntl-app.[ch], src/ntl-main.c: Implement
IDL:Nautilus/Application:1.0 interface and NautilusApp GtkObject.
* src/nautilus-window-menus.c, src/ntl-window.[ch], src/ntl-window: Change to match above.
* src/ntl-view-frame-svr.c: Implement _get_application()
operation.
parent dae237b6
2000-03-02 Elliot Lee <sopwith@redhat.com>
* src/nautilus.goad, src/ntl-app.[ch], src/ntl-main.c: Implement
IDL:Nautilus/Application:1.0 interface and NautilusApp GtkObject.
* src/nautilus-window-menus.c, src/ntl-window.[ch], src/ntl-window: Change to match above.
* src/ntl-view-frame-svr.c: Implement _get_application()
operation.
2000-03-01 Andy Hertzfeld <andy@eazel.com>
* libnautilus/nautilus_icon_factory.c:
......
......@@ -6,18 +6,18 @@
* Copyright (C) 1999, 2000 Red Hat, Inc.
* Copyright (C) 2000 Eazel, Inc.
*
* This library is free software; you can redistribute it and/or
* 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 library is distributed in the hope that it will be useful,
* 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 library; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Author: Elliot Lee <sopwith@redhat.com>,
......@@ -26,89 +26,233 @@
#include "nautilus.h"
#include <libnautilus/libnautilus.h>
#include <bonobo.h>
#include "file-manager/fm-directory-view-icons.h"
#include "file-manager/fm-directory-view-list.h"
static int window_count = 0;
typedef struct {
POA_Nautilus_Application servant;
NautilusApp *app;
Nautilus_ViewWindowList attr_view_windows;
} impl_POA_Nautilus_Application;
static BonoboObject *
nautilus_make_object(BonoboGenericFactory *gfact, const char *goad_id, gpointer closure)
static Nautilus_ViewWindowList *
impl_Nautilus_Application__get_view_windows(impl_POA_Nautilus_Application* servant,
CORBA_Environment * ev);
static Nautilus_ViewWindow
impl_Nautilus_Application_new_view_window(impl_POA_Nautilus_Application *servant,
CORBA_Environment * ev);
static CORBA_boolean
impl_Nautilus_Application_supports(impl_POA_Nautilus_Application * servant,
CORBA_char *obj_goad_id,
CORBA_Environment * ev);
static CORBA_Object
impl_Nautilus_Application_create_object(impl_POA_Nautilus_Application *servant,
CORBA_char * goad_id,
GNOME_stringlist * params,
CORBA_Environment * ev);
static POA_Nautilus_Application__epv impl_Nautilus_Application_epv = {
NULL, /* _private */
(gpointer) &impl_Nautilus_Application__get_view_windows,
(gpointer) &impl_Nautilus_Application_new_view_window
};
static POA_GNOME_GenericFactory__epv impl_Nautilus_Application_GNOME_GenericFactory_epv = {
NULL, /* _private */
(gpointer) &impl_Nautilus_Application_supports,
(gpointer) &impl_Nautilus_Application_create_object
};
static PortableServer_ServantBase__epv impl_Nautilus_Application_base_epv = {
NULL, /* _private data */
NULL, /* finalize routine */
NULL, /* default_POA routine */
};
static POA_Nautilus_Application__vepv impl_Nautilus_Application_vepv = {
&impl_Nautilus_Application_base_epv,
&impl_Nautilus_Application_GNOME_GenericFactory_epv,
NULL,
&impl_Nautilus_Application_epv,
};
static Nautilus_ViewWindowList *
impl_Nautilus_Application__get_view_windows(impl_POA_Nautilus_Application *
servant, CORBA_Environment * ev)
{
FMDirectoryView *dir_view;
NautilusContentViewFrame *view_frame;
g_return_val_if_fail (strcmp (goad_id, "ntl_file_manager_icon_view") == 0 ||
strcmp (goad_id, "ntl_file_manager_list_view") == 0, NULL);
Nautilus_ViewWindowList *retval;
return retval;
}
static Nautilus_ViewWindow
impl_Nautilus_Application_new_view_window(impl_POA_Nautilus_Application *servant, CORBA_Environment * ev)
{
NautilusWindow *win;
win = nautilus_app_create_window(servant->app);
return CORBA_Object_duplicate(bonobo_object_corba_objref(BONOBO_OBJECT(win)), ev);
}
static CORBA_boolean
impl_Nautilus_Application_supports(impl_POA_Nautilus_Application * servant,
CORBA_char * obj_goad_id,
CORBA_Environment * ev)
{
return (!strcmp(obj_goad_id, "ntl_file_manager_icon_view")
|| !strcmp(obj_goad_id, "ntl_file_manager_list_view"));
}
static CORBA_Object
impl_Nautilus_Application_create_object(impl_POA_Nautilus_Application *servant,
CORBA_char * goad_id,
GNOME_stringlist * params,
CORBA_Environment * ev)
{
FMDirectoryView *dir_view;
NautilusContentViewFrame *view_frame;
if(!impl_Nautilus_Application_supports(servant, goad_id, ev))
return CORBA_OBJECT_NIL;
if (strcmp (goad_id, "ntl_file_manager_icon_view") == 0)
dir_view = FM_DIRECTORY_VIEW (gtk_object_new (fm_directory_view_icons_get_type (), NULL));
else
dir_view = FM_DIRECTORY_VIEW (gtk_object_new (fm_directory_view_list_get_type (), NULL));
if (strcmp (goad_id, "ntl_file_manager_icon_view") == 0)
dir_view = FM_DIRECTORY_VIEW (gtk_object_new (fm_directory_view_icons_get_type (), NULL));
else if (strcmp (goad_id, "ntl_file_manager_list_view") == 0)
dir_view = FM_DIRECTORY_VIEW (gtk_object_new (fm_directory_view_list_get_type (), NULL));
else
dir_view = NULL;
g_return_val_if_fail(dir_view, NULL);
g_return_val_if_fail(dir_view, CORBA_OBJECT_NIL);
view_frame = fm_directory_view_get_view_frame (dir_view);
view_frame = fm_directory_view_get_view_frame (dir_view);
return BONOBO_OBJECT (view_frame);
return CORBA_Object_duplicate(bonobo_object_corba_objref(BONOBO_OBJECT(view_frame)), ev);
}
/**
* nautilus_app_exiting:
*
* Called after the main event loop has finished, just before the
* program ends. Don't call from anywhere else.
**/
void
nautilus_app_exiting()
static CORBA_Object
impl_Nautilus_Application__create(PortableServer_POA poa,
NautilusApp *app,
CORBA_Environment * ev)
{
impl_POA_Nautilus_Application *newservant;
newservant = g_new0(impl_POA_Nautilus_Application, 1);
newservant->servant.vepv = &impl_Nautilus_Application_vepv;
newservant->servant.vepv->Bonobo_Unknown_epv = NAUTILUS_APP_CLASS(GTK_OBJECT(app)->klass)->unknown_epv;
POA_Nautilus_Application__init((PortableServer_Servant) newservant, ev);
return bonobo_object_activate_servant(BONOBO_OBJECT(app), newservant);
}
static void nautilus_app_init (NautilusApp *app);
static void nautilus_app_class_init (NautilusAppClass *klass);
static void nautilus_app_destroy (GtkObject *object);
static GtkObjectClass *app_parent_class = NULL;
GtkType
nautilus_app_get_type (void)
{
static GtkType App_type = 0;
if (!App_type)
{
static const GtkTypeInfo App_info =
{
"NautilusApp",
sizeof (NautilusApp),
sizeof (NautilusAppClass),
(GtkClassInitFunc) nautilus_app_class_init,
(GtkObjectInitFunc) nautilus_app_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
App_type = gtk_type_unique (bonobo_object_get_type (), &App_info);
}
return App_type;
}
static void
nautilus_app_class_init (NautilusAppClass *klass)
{
GtkObjectClass *object_class;
klass->unknown_epv = bonobo_object_get_epv();
object_class = (GtkObjectClass*) klass;
object_class->destroy = nautilus_app_destroy;
app_parent_class = gtk_type_class (gtk_object_get_type ());
}
static void
nautilus_app_init (NautilusApp *app)
{
CORBA_Environment ev;
CORBA_Object objref;
CORBA_exception_init(&ev);
objref = impl_Nautilus_Application__create(bonobo_poa(), app, &ev);
goad_server_register(NULL, objref, "ntl_file_manager_factory", NULL, &ev);
bonobo_object_construct(BONOBO_OBJECT(app), objref);
CORBA_exception_free(&ev);
}
GtkObject *
nautilus_app_new (void)
{
return gtk_object_new(nautilus_app_get_type(), NULL);
}
static void
nautilus_app_destroy(GtkObject *object)
{
/* Do those things that gotta be done just once before quitting */
nautilus_prefs_save();
nautilus_bookmarks_exiting();
GTK_OBJECT_CLASS(app_parent_class)->destroy(object);
}
void
nautilus_app_init(const char *initial_url)
nautilus_app_startup(NautilusApp *app, const char *initial_url)
{
NautilusWindow *mainwin;
nautilus_navinfo_init();
nautilus_prefs_load();
/* Create our CORBA objects */
bonobo_generic_factory_new_multi("ntl_file_manager_factory", nautilus_make_object, NULL);
/* Set default configuration */
mainwin = nautilus_app_create_window();
mainwin = nautilus_app_create_window(app);
bonobo_activate();
nautilus_window_set_initial_state(mainwin, initial_url);
}
static void
nautilus_app_destroy_window(GtkObject *obj)
nautilus_app_destroy_window(GtkObject *obj, NautilusApp *app)
{
window_count--;
app->windows = g_slist_remove(app->windows, obj);
if(window_count <= 0)
{
gtk_main_quit();
}
if(!app->windows)
gtk_main_quit();
}
NautilusWindow *
nautilus_app_create_window(void)
nautilus_app_create_window(NautilusApp *app)
{
GtkWidget *win = gtk_widget_new(nautilus_window_get_type(), "app_id", "nautilus", NULL);
window_count++;
gtk_signal_connect(GTK_OBJECT(win), "destroy", nautilus_app_destroy_window, NULL);
gtk_signal_connect(GTK_OBJECT(win), "destroy", nautilus_app_destroy_window, app);
/* Do not yet show the window. It will be shown later on if it can
* successfully display its initial uri. Otherwise it will be destroyed
* without ever having seen the light of day.
*/
app->windows = g_slist_prepend(app->windows, win);
return NAUTILUS_WINDOW(win);
}
/* ntl-app.h
* Copyright (C) 2000 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 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. */
#ifndef NTL_APP_H
#define NTL_APP_H 1
#include "ntl-window.h"
void nautilus_app_exiting(void);
void nautilus_app_init(const char *initial_url);
NautilusWindow *nautilus_app_create_window(void);
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define NAUTILUS_TYPE_APP (nautilus_app_get_type ())
#define NAUTILUS_APP(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_APP, NautilusApp))
#define NAUTILUS_APP_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_APP, NautilusAppClass))
#define NAUTILUS_IS_APP(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_APP))
#define NAUTILUS_IS_APP_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), NAUTILUS_TYPE_APP))
typedef struct {
BonoboObject parent;
GSList *windows;
} NautilusApp;
typedef struct {
BonoboObjectClass parent_class;
gpointer servant;
gpointer unknown_epv;
} NautilusAppClass;
GtkType nautilus_app_get_type (void);
GtkObject *nautilus_app_new (void);
void nautilus_app_startup(NautilusApp *app, const char *initial_url);
NautilusWindow *nautilus_app_create_window(NautilusApp *app);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
......@@ -79,11 +79,14 @@ main(int argc, char *argv[])
nautilus_exit_if_self_checks_failed ();
} else {
#endif
NautilusApp *app;
app = NAUTILUS_APP(nautilus_app_new());
/* Run the nautilus application. */
nautilus_app_init (args ? args[0] : NULL);
nautilus_app_startup (app, args ? args[0] : NULL);
bonobo_main();
nautilus_app_exiting();
gtk_object_unref(GTK_OBJECT(app));
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
}
......
......@@ -83,7 +83,7 @@ file_menu_new_window_cb (GtkWidget *widget,
current_mainwin = NAUTILUS_WINDOW(data);
new_mainwin = nautilus_app_create_window();
new_mainwin = nautilus_app_create_window(NAUTILUS_APP(current_mainwin->app));
nautilus_window_goto_uri(new_mainwin,
nautilus_window_get_requested_uri(current_mainwin));
......
......@@ -111,7 +111,7 @@ static Nautilus_Application
impl_Nautilus_ViewWindow__get_application (impl_POA_Nautilus_ViewWindow *servant,
CORBA_Environment *ev)
{
return CORBA_OBJECT_NIL;
return CORBA_Object_duplicate(bonobo_object_corba_objref(servant->window->app), ev);
}
static void
......@@ -276,6 +276,7 @@ gtk_marshal_NONE__BOXED_OBJECT (GtkObject * object,
enum {
ARG_0,
ARG_APP_ID,
ARG_APP,
ARG_CONTENT_VIEW
};
......@@ -605,6 +606,9 @@ nautilus_window_set_arg (GtkObject *object,
if(!old_app_name)
nautilus_window_constructed(NAUTILUS_WINDOW(object));
break;
case ARG_APP:
window->app = BONOBO_OBJECT(GTK_VALUE_OBJECT(*arg));
break;
case ARG_CONTENT_VIEW:
nautilus_window_real_set_content_view (window, (NautilusView *)GTK_VALUE_OBJECT(*arg));
break;
......@@ -622,6 +626,9 @@ nautilus_window_get_arg (GtkObject *object,
case ARG_APP_ID:
GTK_VALUE_STRING(*arg) = app->name;
break;
case ARG_APP:
GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(NAUTILUS_WINDOW(object)->app);
break;
case ARG_CONTENT_VIEW:
GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(((NautilusWindow *)object)->content_view);
break;
......@@ -648,9 +655,9 @@ static void nautilus_window_destroy (NautilusWindow *window)
}
GtkWidget *
nautilus_window_new(const char *app_id)
nautilus_window_new(const char *app_id, BonoboObject *app)
{
return GTK_WIDGET (gtk_object_new (nautilus_window_get_type(), "app_id", app_id, NULL));
return GTK_WIDGET (gtk_object_new (nautilus_window_get_type(), "app_id", app_id, "app", app, NULL));
}
void
......
......@@ -61,6 +61,7 @@ struct _NautilusWindow {
/** CORBA-related elements **/
BonoboObject *ntl_viewwindow;
BonoboUIHandler *uih;
BonoboObject *app;
/** State information **/
......@@ -109,7 +110,7 @@ struct _NautilusWindow {
};
GtkType nautilus_window_get_type (void);
GtkWidget *nautilus_window_new (const char *app_id);
GtkWidget *nautilus_window_new (const char *app_id, BonoboObject *app);
void nautilus_window_close (NautilusWindow *window);
void nautilus_window_set_content_view (NautilusWindow *window,
NautilusView *content_view);
......
......@@ -111,7 +111,7 @@ static Nautilus_Application
impl_Nautilus_ViewWindow__get_application (impl_POA_Nautilus_ViewWindow *servant,
CORBA_Environment *ev)
{
return CORBA_OBJECT_NIL;
return CORBA_Object_duplicate(bonobo_object_corba_objref(servant->window->app), ev);
}
static void
......@@ -276,6 +276,7 @@ gtk_marshal_NONE__BOXED_OBJECT (GtkObject * object,
enum {
ARG_0,
ARG_APP_ID,
ARG_APP,
ARG_CONTENT_VIEW
};
......@@ -605,6 +606,9 @@ nautilus_window_set_arg (GtkObject *object,
if(!old_app_name)
nautilus_window_constructed(NAUTILUS_WINDOW(object));
break;
case ARG_APP:
window->app = BONOBO_OBJECT(GTK_VALUE_OBJECT(*arg));
break;
case ARG_CONTENT_VIEW:
nautilus_window_real_set_content_view (window, (NautilusView *)GTK_VALUE_OBJECT(*arg));
break;
......@@ -622,6 +626,9 @@ nautilus_window_get_arg (GtkObject *object,
case ARG_APP_ID:
GTK_VALUE_STRING(*arg) = app->name;
break;
case ARG_APP:
GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(NAUTILUS_WINDOW(object)->app);
break;
case ARG_CONTENT_VIEW:
GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(((NautilusWindow *)object)->content_view);
break;
......@@ -648,9 +655,9 @@ static void nautilus_window_destroy (NautilusWindow *window)
}
GtkWidget *
nautilus_window_new(const char *app_id)
nautilus_window_new(const char *app_id, BonoboObject *app)
{
return GTK_WIDGET (gtk_object_new (nautilus_window_get_type(), "app_id", app_id, NULL));
return GTK_WIDGET (gtk_object_new (nautilus_window_get_type(), "app_id", app_id, "app", app, NULL));
}
void
......
......@@ -61,6 +61,7 @@ struct _NautilusWindow {
/** CORBA-related elements **/
BonoboObject *ntl_viewwindow;
BonoboUIHandler *uih;
BonoboObject *app;
/** State information **/
......@@ -109,7 +110,7 @@ struct _NautilusWindow {
};
GtkType nautilus_window_get_type (void);
GtkWidget *nautilus_window_new (const char *app_id);
GtkWidget *nautilus_window_new (const char *app_id, BonoboObject *app);
void nautilus_window_close (NautilusWindow *window);
void nautilus_window_set_content_view (NautilusWindow *window,
NautilusView *content_view);
......
......@@ -111,7 +111,7 @@ static Nautilus_Application
impl_Nautilus_ViewWindow__get_application (impl_POA_Nautilus_ViewWindow *servant,
CORBA_Environment *ev)
{
return CORBA_OBJECT_NIL;
return CORBA_Object_duplicate(bonobo_object_corba_objref(servant->window->app), ev);
}
static void
......@@ -276,6 +276,7 @@ gtk_marshal_NONE__BOXED_OBJECT (GtkObject * object,
enum {
ARG_0,
ARG_APP_ID,
ARG_APP,
ARG_CONTENT_VIEW
};
......@@ -605,6 +606,9 @@ nautilus_window_set_arg (GtkObject *object,
if(!old_app_name)
nautilus_window_constructed(NAUTILUS_WINDOW(object));
break;
case ARG_APP:
window->app = BONOBO_OBJECT(GTK_VALUE_OBJECT(*arg));
break;
case ARG_CONTENT_VIEW:
nautilus_window_real_set_content_view (window, (NautilusView *)GTK_VALUE_OBJECT(*arg));
break;
......@@ -622,6 +626,9 @@ nautilus_window_get_arg (GtkObject *object,
case ARG_APP_ID:
GTK_VALUE_STRING(*arg) = app->name;
break;
case ARG_APP:
GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(NAUTILUS_WINDOW(object)->app);
break;
case ARG_CONTENT_VIEW:
GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(((NautilusWindow *)object)->content_view);
break;
......@@ -648,9 +655,9 @@ static void nautilus_window_destroy (NautilusWindow *window)
}
GtkWidget *
nautilus_window_new(const char *app_id)
nautilus_window_new(const char *app_id, BonoboObject *app)
{
return GTK_WIDGET (gtk_object_new (nautilus_window_get_type(), "app_id", app_id, NULL));
return GTK_WIDGET (gtk_object_new (nautilus_window_get_type(), "app_id", app_id, "app", app, NULL));
}
void
......
......@@ -61,6 +61,7 @@ struct _NautilusWindow {
/** CORBA-related elements **/
BonoboObject *ntl_viewwindow;
BonoboUIHandler *uih;
BonoboObject *app;
/** State information **/
......@@ -109,7 +110,7 @@ struct _NautilusWindow {
};
GtkType nautilus_window_get_type (void);
GtkWidget *nautilus_window_new (const char *app_id);
GtkWidget *nautilus_window_new (const char *app_id, BonoboObject *app);
void nautilus_window_close (NautilusWindow *window);
void nautilus_window_set_content_view (NautilusWindow *window,
NautilusView *content_view);
......
......@@ -162,7 +162,3 @@ impl_Nautilus_ViewFrame_request_progress_change(impl_POA_Nautilus_ViewFrame * se
{
nautilus_view_request_progress_change(servant->view, proginfo);
}
......@@ -472,7 +472,7 @@ nautilus_window_request_location_change(NautilusWindow *window,
{
NautilusWindow *new_window;
new_window = nautilus_app_create_window ();
new_window = nautilus_app_create_window (NAUTILUS_APP(window->app));
nautilus_window_set_initial_state (new_window, loc->requested_uri);
}
else
......
......@@ -83,7 +83,7 @@ file_menu_new_window_cb (GtkWidget *widget,
current_mainwin = NAUTILUS_WINDOW(data);
new_mainwin = nautilus_app_create_window();
new_mainwin = nautilus_app_create_window(NAUTILUS_APP(current_mainwin->app));
nautilus_window_goto_uri(new_mainwin,
nautilus_window_get_requested_uri(current_mainwin));
......
......@@ -111,7 +111,7 @@ static Nautilus_Application