1999-03-30 10:09:56 +04:00
|
|
|
|
/* CORBA support for the Midhignt Commander
|
1998-12-14 07:14:16 +03:00
|
|
|
|
*
|
1999-03-30 10:09:56 +04:00
|
|
|
|
* Copyright (C) 1999 The Free Sofware Foundation
|
|
|
|
|
*
|
|
|
|
|
* Authors: Miguel de Icaza <miguel@nuclecu.unam.mx>
|
|
|
|
|
* Federico Mena <federico@nuclecu.unam.mx>
|
|
|
|
|
* Elliot Lee <sopwith@cuc.edu>
|
1998-12-14 07:14:16 +03:00
|
|
|
|
*/
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
1998-12-14 07:14:16 +03:00
|
|
|
|
#include <config.h>
|
1999-03-30 10:09:56 +04:00
|
|
|
|
#include "panel.h"
|
1999-04-06 01:38:50 +04:00
|
|
|
|
#include "../vfs/vfs.h"
|
1998-12-14 07:14:16 +03:00
|
|
|
|
#include <libgnorba/gnorba.h>
|
1998-12-14 08:15:48 +03:00
|
|
|
|
#include "FileManager.h"
|
1999-02-10 04:50:08 +03:00
|
|
|
|
#include "gcmd.h"
|
1998-12-14 07:14:16 +03:00
|
|
|
|
#include "gcorba.h"
|
1999-03-30 10:09:56 +04:00
|
|
|
|
#include "global.h"
|
|
|
|
|
#include "gmain.h"
|
1999-09-09 04:37:02 +04:00
|
|
|
|
#include "gscreen.h"
|
1999-06-23 01:02:08 +04:00
|
|
|
|
#include "main.h"
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
/* The ORB for the whole program */
|
1999-03-30 10:09:56 +04:00
|
|
|
|
CORBA_ORB orb = CORBA_OBJECT_NIL;
|
1998-12-14 07:14:16 +03:00
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
/* The POA */
|
|
|
|
|
PortableServer_POA poa;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
/* Desktop servant */
|
|
|
|
|
typedef struct {
|
|
|
|
|
POA_GNOME_FileManager_Desktop servant;
|
|
|
|
|
} DesktopServant;
|
|
|
|
|
|
|
|
|
|
static POA_GNOME_FileManager_Desktop__epv desktop_epv;
|
|
|
|
|
static POA_GNOME_FileManager_Desktop__vepv desktop_vepv;
|
1998-12-14 07:14:16 +03:00
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
/* Window servant */
|
1998-12-14 08:15:48 +03:00
|
|
|
|
typedef struct {
|
1999-09-09 04:37:02 +04:00
|
|
|
|
POA_GNOME_FileManager_Window servant;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
|
|
|
|
WPanel *panel;
|
1999-09-09 04:37:02 +04:00
|
|
|
|
} WindowServant;
|
|
|
|
|
|
|
|
|
|
static POA_GNOME_FileManager_Window__epv window_epv;
|
|
|
|
|
static POA_GNOME_FileManager_Window__vepv window_vepv;
|
|
|
|
|
|
|
|
|
|
/* WindowFactory servant */
|
1998-12-14 08:15:48 +03:00
|
|
|
|
|
|
|
|
|
typedef struct {
|
1999-09-09 04:37:02 +04:00
|
|
|
|
POA_GNOME_FileManager_WindowFactory servant;
|
|
|
|
|
} WindowFactoryServant;
|
|
|
|
|
|
|
|
|
|
static POA_GNOME_FileManager_WindowFactory__epv window_factory_epv;
|
|
|
|
|
static POA_GNOME_FileManager_WindowFactory__vepv window_factory_vepv;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* References to the window factory and desktop server objects */
|
|
|
|
|
|
|
|
|
|
static CORBA_Object window_factory_server = CORBA_OBJECT_NIL;
|
|
|
|
|
static CORBA_Object desktop_server = CORBA_OBJECT_NIL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Window implementation */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* WindowFactory implementation */
|
|
|
|
|
|
|
|
|
|
/* WindowFactory::the_desktop attribute getter */
|
|
|
|
|
static GNOME_FileManager_Desktop
|
|
|
|
|
WindowFactory_get_the_desktop (PortableServer_Servant servant,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
g_assert (desktop_server != CORBA_OBJECT_NIL);
|
|
|
|
|
|
|
|
|
|
return CORBA_Object_duplicate (desktop_server, ev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Called when a panel created through CORBA is destroyed */
|
|
|
|
|
static void
|
|
|
|
|
panel_destroyed (GtkObject *object, gpointer data)
|
|
|
|
|
{
|
|
|
|
|
WindowServant *ws;
|
|
|
|
|
CORBA_Environment ev;
|
|
|
|
|
|
|
|
|
|
ws = data;
|
|
|
|
|
|
|
|
|
|
CORBA_exception_init (&ev);
|
|
|
|
|
window_destroy (ws, &ev);
|
|
|
|
|
CORBA_exception_free (&ev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns a servant for a panel, creating one if necessary */
|
|
|
|
|
static WindowServant *
|
|
|
|
|
window_servant_from_panel (WPanel *panel, CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
WindowServant *ws;
|
|
|
|
|
PortableServer_ObjectId *objid;
|
|
|
|
|
|
|
|
|
|
if (panel->servant)
|
|
|
|
|
return panel->servant;
|
|
|
|
|
|
|
|
|
|
ws = g_new0 (WindowServant, 1);
|
|
|
|
|
ws->servant.vepv = &window_vepv;
|
|
|
|
|
|
|
|
|
|
POA_GNOME_FileManager_Window__init ((PortableServer_Servant) ws, ev);
|
|
|
|
|
objid = PortableServer_POA_activate_object (poa, ws, ev);
|
|
|
|
|
CORBA_free (objid);
|
|
|
|
|
|
|
|
|
|
ws->panel = panel;
|
|
|
|
|
panel->servant = ws;
|
|
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (panel->xwindow), "destroy",
|
|
|
|
|
(GtkSignalFunc) panel_destroyed,
|
|
|
|
|
ws);
|
|
|
|
|
|
|
|
|
|
return ws;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* WindowFactory::create_window method */
|
|
|
|
|
static GNOME_FileManager_Window
|
|
|
|
|
WindowFactory_create_window (PortableServer_Servant servant,
|
|
|
|
|
CORBA_char *dir,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
WPanel *panel;
|
|
|
|
|
WindowServant *ws;
|
|
|
|
|
|
|
|
|
|
panel = new_panel_at (dir);
|
|
|
|
|
ws = window_servant_from_panel (panel, ev);
|
|
|
|
|
|
|
|
|
|
return PortableServer_POA_servant_to_reference (poa, ws, ev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* WindowFactory::rescan_directory method */
|
|
|
|
|
static void
|
|
|
|
|
WindowFactory_rescan_directory (PortableServer_Servant servant,
|
|
|
|
|
CORBA_char *dir,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
PanelContainer *pc;
|
|
|
|
|
GList *l;
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
|
|
/* We do a blind compare against the panel's cwd */
|
|
|
|
|
|
|
|
|
|
len = strlen (dir);
|
|
|
|
|
if (dir[len - 1] == PATH_SEP)
|
|
|
|
|
len--;
|
|
|
|
|
|
|
|
|
|
for (l = containers; l; l = l->next) {
|
|
|
|
|
pc = l->data;
|
|
|
|
|
|
|
|
|
|
if (strncmp (dir, pc->panel->cwd, len) == 0
|
|
|
|
|
&& (pc->panel->cwd[len] == 0 || pc->panel->cwd[len] == PATH_SEP))
|
|
|
|
|
update_one_panel_widget (pc->panel, UP_RELOAD, UP_KEEPSEL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* WindowFactory::close_invalid_windows method */
|
|
|
|
|
static void
|
|
|
|
|
WindowFactory_close_invalid_windows (PortableServer_Servant servant,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
PanelContainer *pc;
|
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
|
|
/* To see if a panel is valid or not, we try to cd to its cwd. If this
|
|
|
|
|
* fails, then we destroy the panel's window.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
for (l = containers; l; l = l->next) {
|
|
|
|
|
pc = l->data;
|
|
|
|
|
|
|
|
|
|
if (mc_chdir (pc->panel->cwd) != 0)
|
|
|
|
|
gnome_close_panel (pc->panel->xwindow, pc->panel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Creates an object reference for a panel */
|
|
|
|
|
static GNOME_FileManagerWindow
|
|
|
|
|
window_reference_from_panel (WPanel *panel, CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
WindowServant *ws;
|
|
|
|
|
|
|
|
|
|
ws = window_servant_from_panel (panel, ev);
|
|
|
|
|
return PortableServer_POA_servant_to_reference (poa, ws, ev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* WindowFactory::get_window_by_directory method */
|
|
|
|
|
static GNOME_FileManager_WindowFactory_WindowSeq *
|
|
|
|
|
WindowFactory_get_windows_by_directory (PortableServer_Servant servant,
|
|
|
|
|
CORBA_char *dir,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
GNOME_FileManager_WindowFactory_WindowSeq *seq;
|
|
|
|
|
PanelContainer *pc;
|
|
|
|
|
GList *l;
|
|
|
|
|
int n, i;
|
|
|
|
|
|
|
|
|
|
/* We return a sequence of the windows that match the specified
|
|
|
|
|
* directory.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Count 'em */
|
|
|
|
|
n = 0;
|
|
|
|
|
for (l = containers; l; l = l->next) {
|
|
|
|
|
pc = l->data;
|
|
|
|
|
|
|
|
|
|
if (strcmp (pc->panel->cwd, dir) == 0)
|
|
|
|
|
n++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
seq = GNOME_FileManager_WindowFactory_WindowSeq__alloc ();
|
|
|
|
|
seq->_buffer = CORBA_sequence_GNOME_FileManager_Window_allocbuf (n);
|
|
|
|
|
|
|
|
|
|
for (l = containers, i = 0; l; l = l->next, i++) {
|
|
|
|
|
pc = l->data;
|
|
|
|
|
|
|
|
|
|
if (strcmp (pc->panel->cwd, dir) == 0)
|
|
|
|
|
seq->_buffer[i] = window_reference_from_panel (pc->panel, ev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return seq;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* WindowFactory GenericFactory::supports method */
|
|
|
|
|
static CORBA_boolean
|
|
|
|
|
WindowFactory_supports (PortableServer_Servant servant,
|
|
|
|
|
CORBA_char *obj_goad_id,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (obj_goad_id, "IDL:GNOME:FileManager:Window:1.0") == 0
|
|
|
|
|
|| strcmp (obj_goad_id, "IDL:GNOME:FileManager:Desktop:1.0") == 0)
|
|
|
|
|
return CORBA_TRUE;
|
|
|
|
|
else
|
|
|
|
|
return CORBA_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* WindowFactory GenericFactory::create_object method */
|
|
|
|
|
static CORBA_Object
|
|
|
|
|
WindowFactory_create_object (PortableServer_Servant servant,
|
|
|
|
|
CORBA_char *goad_id,
|
|
|
|
|
GNOME_stringlist *params,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (goad_id, "IDL:GNOME:FileManager:Window:1.0") != 0)
|
|
|
|
|
return WindowFactory_create_window (
|
|
|
|
|
servant,
|
|
|
|
|
params->_length != 0 ? params->_buffer[0] : home_dir,
|
|
|
|
|
ev);
|
|
|
|
|
else if (strcmp (obj_goad_id, "IDL:GNOME:FileManager:Desktop:1.0") == 0) {
|
|
|
|
|
/* FIXME */
|
|
|
|
|
} else {
|
|
|
|
|
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
|
|
|
|
|
ex_GNOME_GenericFactory_CannotActivate,
|
|
|
|
|
NULL);
|
|
|
|
|
return CORBA_OBJECT_NIL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1998-12-14 08:15:48 +03:00
|
|
|
|
|
|
|
|
|
/*** Implementation stub prototypes ***/
|
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
static void impl_GNOME_FileManagerWindow__destroy (impl_POA_GNOME_FileManagerWindow *servant,
|
|
|
|
|
CORBA_Environment *ev);
|
|
|
|
|
static void impl_GNOME_FileManagerWindow_close (impl_POA_GNOME_FileManagerWindow *servant,
|
|
|
|
|
CORBA_Environment *ev);
|
|
|
|
|
|
|
|
|
|
static void impl_GNOME_FileManagerFactory__destroy (impl_POA_GNOME_FileManagerFactory *servant,
|
|
|
|
|
CORBA_Environment *ev);
|
|
|
|
|
|
|
|
|
|
static CORBA_boolean impl_GNOME_FileManagerFactory_supports (
|
|
|
|
|
impl_POA_GNOME_FileManagerFactory *servant,
|
|
|
|
|
const CORBA_char *obj_goad_id,
|
|
|
|
|
CORBA_Environment *ev);
|
|
|
|
|
|
|
|
|
|
static CORBA_Object impl_GNOME_FileManagerFactory_create_object (
|
|
|
|
|
impl_POA_GNOME_FileManagerFactory *servant,
|
|
|
|
|
const CORBA_char *goad_id,
|
|
|
|
|
const GNOME_stringlist *params,
|
|
|
|
|
CORBA_Environment *ev);
|
|
|
|
|
|
|
|
|
|
static GNOME_FileManagerWindow impl_GNOME_FileManagerFactory_create_window (
|
|
|
|
|
impl_POA_GNOME_FileManagerFactory * servant,
|
|
|
|
|
const CORBA_char * dir,
|
|
|
|
|
CORBA_Environment * ev);
|
1998-12-14 08:15:48 +03:00
|
|
|
|
|
|
|
|
|
/*** epv structures ***/
|
|
|
|
|
|
|
|
|
|
static PortableServer_ServantBase__epv impl_GNOME_FileManagerWindow_base_epv =
|
|
|
|
|
{
|
1999-03-30 10:09:56 +04:00
|
|
|
|
NULL, /* _private data */
|
|
|
|
|
NULL, /* finalize routine */
|
|
|
|
|
NULL, /* default_POA routine */
|
1998-12-14 08:15:48 +03:00
|
|
|
|
};
|
1998-12-31 04:18:31 +03:00
|
|
|
|
|
1998-12-14 08:15:48 +03:00
|
|
|
|
static POA_GNOME_FileManagerWindow__epv impl_GNOME_FileManagerWindow_epv =
|
|
|
|
|
{
|
1999-03-30 10:09:56 +04:00
|
|
|
|
NULL, /* _private */
|
|
|
|
|
(gpointer) &impl_GNOME_FileManagerWindow_close,
|
|
|
|
|
|
1998-12-14 08:15:48 +03:00
|
|
|
|
};
|
1998-12-31 04:18:31 +03:00
|
|
|
|
|
1998-12-14 08:15:48 +03:00
|
|
|
|
static PortableServer_ServantBase__epv impl_GNOME_FileManagerFactory_base_epv =
|
|
|
|
|
{
|
1999-03-30 10:09:56 +04:00
|
|
|
|
NULL, /* _private data */
|
|
|
|
|
NULL, /* finalize routine */
|
|
|
|
|
NULL, /* default_POA routine */
|
1998-12-14 07:14:16 +03:00
|
|
|
|
};
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
1998-12-14 08:15:48 +03:00
|
|
|
|
static POA_GNOME_FileManagerFactory__epv impl_GNOME_FileManagerFactory_epv =
|
|
|
|
|
{
|
1999-03-30 10:09:56 +04:00
|
|
|
|
NULL, /* _private */
|
|
|
|
|
(gpointer) &impl_GNOME_FileManagerFactory_create_window,
|
1998-12-14 08:15:48 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static POA_GNOME_GenericFactory__epv impl_GNOME_FileManagerFactory_GNOME_GenericFactory_epv =
|
|
|
|
|
{
|
1999-03-30 10:09:56 +04:00
|
|
|
|
NULL, /* _private */
|
|
|
|
|
(gpointer) &impl_GNOME_FileManagerFactory_supports,
|
|
|
|
|
(gpointer) &impl_GNOME_FileManagerFactory_create_object
|
1998-12-14 08:15:48 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*** vepv structures ***/
|
|
|
|
|
|
|
|
|
|
static POA_GNOME_FileManagerWindow__vepv impl_GNOME_FileManagerWindow_vepv =
|
|
|
|
|
{
|
1998-12-31 04:18:31 +03:00
|
|
|
|
&impl_GNOME_FileManagerWindow_base_epv,
|
1999-03-30 10:09:56 +04:00
|
|
|
|
&impl_GNOME_FileManagerWindow_epv
|
1998-12-14 08:15:48 +03:00
|
|
|
|
};
|
1998-12-31 04:18:31 +03:00
|
|
|
|
|
1998-12-14 08:15:48 +03:00
|
|
|
|
static POA_GNOME_FileManagerFactory__vepv impl_GNOME_FileManagerFactory_vepv =
|
|
|
|
|
{
|
1998-12-31 04:18:31 +03:00
|
|
|
|
&impl_GNOME_FileManagerFactory_base_epv,
|
|
|
|
|
&impl_GNOME_FileManagerFactory_GNOME_GenericFactory_epv,
|
1999-03-30 10:09:56 +04:00
|
|
|
|
&impl_GNOME_FileManagerFactory_epv
|
1998-12-14 08:15:48 +03:00
|
|
|
|
};
|
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
/*** Stub implementations ***/
|
|
|
|
|
|
1999-07-02 03:15:08 +04:00
|
|
|
|
static GNOME_FileManagerWindow
|
1999-03-30 10:09:56 +04:00
|
|
|
|
impl_GNOME_FileManagerWindow__create(PortableServer_POA poa,
|
|
|
|
|
impl_POA_GNOME_FileManagerWindow **servant,
|
|
|
|
|
CORBA_Environment *ev)
|
1998-12-31 04:18:31 +03:00
|
|
|
|
{
|
1999-03-30 10:09:56 +04:00
|
|
|
|
GNOME_FileManagerWindow retval;
|
|
|
|
|
impl_POA_GNOME_FileManagerWindow *newservant;
|
|
|
|
|
PortableServer_ObjectId *objid;
|
|
|
|
|
|
|
|
|
|
newservant = g_new0 (impl_POA_GNOME_FileManagerWindow, 1);
|
|
|
|
|
newservant->servant.vepv = &impl_GNOME_FileManagerWindow_vepv;
|
|
|
|
|
newservant->poa = poa;
|
|
|
|
|
POA_GNOME_FileManagerWindow__init ((PortableServer_Servant) newservant, ev);
|
|
|
|
|
objid = PortableServer_POA_activate_object (poa, newservant, ev);
|
|
|
|
|
CORBA_free (objid);
|
|
|
|
|
retval = PortableServer_POA_servant_to_reference (poa, newservant, ev);
|
1998-12-14 09:45:07 +03:00
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
if (servant)
|
|
|
|
|
*servant = newservant;
|
1998-12-14 09:45:07 +03:00
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
return retval;
|
|
|
|
|
}
|
1998-12-14 07:14:16 +03:00
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
/* You shouldn't call this routine directly without first deactivating the servant... */
|
1998-12-14 08:15:48 +03:00
|
|
|
|
static void
|
1999-03-30 10:09:56 +04:00
|
|
|
|
impl_GNOME_FileManagerWindow__destroy(impl_POA_GNOME_FileManagerWindow *servant,
|
|
|
|
|
CORBA_Environment *ev)
|
1998-12-14 07:14:16 +03:00
|
|
|
|
{
|
1998-12-14 09:45:07 +03:00
|
|
|
|
PortableServer_ObjectId *objid;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
|
|
|
|
objid = PortableServer_POA_servant_to_id (servant->poa, servant, ev);
|
|
|
|
|
PortableServer_POA_deactivate_object (servant->poa, objid, ev);
|
1999-02-10 23:01:13 +03:00
|
|
|
|
CORBA_free (objid);
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
|
|
|
|
POA_GNOME_FileManagerWindow__fini ((PortableServer_Servant) servant, ev);
|
1998-12-14 09:45:07 +03:00
|
|
|
|
g_free(servant);
|
1998-12-14 07:14:16 +03:00
|
|
|
|
}
|
|
|
|
|
|
1998-12-14 08:15:48 +03:00
|
|
|
|
static void
|
1999-03-30 10:09:56 +04:00
|
|
|
|
impl_GNOME_FileManagerWindow_close(impl_POA_GNOME_FileManagerWindow *servant,
|
|
|
|
|
CORBA_Environment *ev)
|
1998-12-14 07:14:16 +03:00
|
|
|
|
{
|
1999-03-30 10:09:56 +04:00
|
|
|
|
gnome_close_panel (GTK_WIDGET (servant->panel->xwindow), servant->panel);
|
1998-12-14 07:14:16 +03:00
|
|
|
|
}
|
|
|
|
|
|
1999-07-02 03:15:08 +04:00
|
|
|
|
static GNOME_FileManagerFactory
|
1999-03-30 10:09:56 +04:00
|
|
|
|
impl_GNOME_FileManagerFactory__create(PortableServer_POA poa,
|
|
|
|
|
impl_POA_GNOME_FileManagerFactory **servant,
|
|
|
|
|
CORBA_Environment *ev)
|
1998-12-14 08:15:48 +03:00
|
|
|
|
{
|
1999-03-30 10:09:56 +04:00
|
|
|
|
GNOME_FileManagerFactory retval;
|
|
|
|
|
impl_POA_GNOME_FileManagerFactory *newservant;
|
1998-12-14 09:45:07 +03:00
|
|
|
|
PortableServer_ObjectId *objid;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
|
|
|
|
newservant = g_new0 (impl_POA_GNOME_FileManagerFactory, 1);
|
|
|
|
|
newservant->servant.vepv = &impl_GNOME_FileManagerFactory_vepv;
|
1998-12-14 09:45:07 +03:00
|
|
|
|
newservant->poa = poa;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
POA_GNOME_FileManagerFactory__init ((PortableServer_Servant) newservant, ev);
|
|
|
|
|
objid = PortableServer_POA_activate_object (poa, newservant, ev);
|
|
|
|
|
CORBA_free (objid);
|
|
|
|
|
retval = PortableServer_POA_servant_to_reference (poa, newservant, ev);
|
|
|
|
|
|
|
|
|
|
if (servant)
|
|
|
|
|
*servant = newservant;
|
|
|
|
|
|
1998-12-14 09:45:07 +03:00
|
|
|
|
return retval;
|
1998-12-14 08:15:48 +03:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
/* You shouldn't call this routine directly without first deactivating the servant... */
|
|
|
|
|
static void
|
|
|
|
|
impl_GNOME_FileManagerFactory__destroy(impl_POA_GNOME_FileManagerFactory *servant,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
PortableServer_ObjectId *objid;
|
|
|
|
|
|
|
|
|
|
objid = PortableServer_POA_servant_to_id (servant->poa, servant, ev);
|
|
|
|
|
PortableServer_POA_deactivate_object (servant->poa, objid, ev);
|
|
|
|
|
CORBA_free (objid);
|
|
|
|
|
|
|
|
|
|
POA_GNOME_FileManagerFactory__fini ((PortableServer_Servant) servant, ev);
|
|
|
|
|
g_free (servant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static CORBA_boolean
|
|
|
|
|
impl_GNOME_FileManagerFactory_supports (impl_POA_GNOME_FileManagerFactory *servant,
|
|
|
|
|
const CORBA_char *obj_goad_id,
|
|
|
|
|
CORBA_Environment *ev)
|
1998-12-14 08:15:48 +03:00
|
|
|
|
{
|
1999-09-09 04:37:02 +04:00
|
|
|
|
if (strcmp (obj_goad_id, "IDL:GNOME:FileManagerWindow:1.0") == 0)
|
1999-03-30 10:09:56 +04:00
|
|
|
|
return CORBA_TRUE;
|
|
|
|
|
else
|
|
|
|
|
return CORBA_FALSE;
|
1998-12-14 08:15:48 +03:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
static CORBA_Object
|
|
|
|
|
impl_GNOME_FileManagerFactory_create_object (impl_POA_GNOME_FileManagerFactory *servant,
|
|
|
|
|
const CORBA_char *goad_id,
|
|
|
|
|
const GNOME_stringlist *params,
|
|
|
|
|
CORBA_Environment *ev)
|
1998-12-14 08:15:48 +03:00
|
|
|
|
{
|
1999-09-09 04:37:02 +04:00
|
|
|
|
if (strcmp (goad_id, "IDL:GNOME:FileManagerWindow:1.0") != 0) {
|
1999-03-30 10:09:56 +04:00
|
|
|
|
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
|
|
|
|
|
ex_GNOME_GenericFactory_CannotActivate,
|
|
|
|
|
NULL);
|
|
|
|
|
return CORBA_OBJECT_NIL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return impl_GNOME_FileManagerFactory_create_window (
|
|
|
|
|
servant,
|
|
|
|
|
params->_length ? params->_buffer[0] : home_dir,
|
|
|
|
|
ev);
|
1998-12-14 08:15:48 +03:00
|
|
|
|
}
|
1998-12-14 07:14:16 +03:00
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
/* Callback used when a panel is destroyed */
|
|
|
|
|
static void
|
|
|
|
|
panel_destroyed (GtkObject *object, gpointer data)
|
1999-01-28 07:37:47 +03:00
|
|
|
|
{
|
1999-03-30 10:09:56 +04:00
|
|
|
|
impl_POA_GNOME_FileManagerWindow *servant;
|
1999-01-28 07:37:47 +03:00
|
|
|
|
CORBA_Environment ev;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
|
|
|
|
servant = data;
|
|
|
|
|
|
1999-01-28 07:37:47 +03:00
|
|
|
|
CORBA_exception_init (&ev);
|
1999-03-30 10:09:56 +04:00
|
|
|
|
impl_GNOME_FileManagerWindow__destroy (servant, &ev);
|
|
|
|
|
CORBA_exception_free (&ev);
|
|
|
|
|
}
|
1999-01-28 07:37:47 +03:00
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
static GNOME_FileManagerWindow
|
|
|
|
|
impl_GNOME_FileManagerFactory_create_window(impl_POA_GNOME_FileManagerFactory *servant,
|
|
|
|
|
const CORBA_char *dir,
|
|
|
|
|
CORBA_Environment *ev)
|
|
|
|
|
{
|
|
|
|
|
GNOME_FileManagerWindow retval;
|
|
|
|
|
impl_POA_GNOME_FileManagerWindow *newservant;
|
|
|
|
|
WPanel *panel;
|
1999-01-28 07:37:47 +03:00
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
retval = impl_GNOME_FileManagerWindow__create (servant->poa,
|
|
|
|
|
&newservant,
|
|
|
|
|
ev);
|
1999-01-28 07:37:47 +03:00
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
panel = new_panel_at ((dir && *dir) ? dir : home_dir);
|
|
|
|
|
newservant->panel = panel;
|
1999-01-28 07:37:47 +03:00
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
gtk_signal_connect (GTK_OBJECT (panel->xwindow), "destroy",
|
|
|
|
|
(GtkSignalFunc) panel_destroyed,
|
|
|
|
|
newservant);
|
|
|
|
|
|
|
|
|
|
return retval;
|
1999-01-28 07:37:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
/*** Public non-implementation functions ***/
|
|
|
|
|
|
|
|
|
|
/* Creates the CORBA server */
|
|
|
|
|
static int
|
|
|
|
|
create_server (void)
|
1998-12-14 07:14:16 +03:00
|
|
|
|
{
|
1998-12-14 09:45:07 +03:00
|
|
|
|
CORBA_Environment ev;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
PortableServer_POA poa;
|
|
|
|
|
PortableServer_POAManager poa_manager;
|
|
|
|
|
int retval;
|
|
|
|
|
int v;
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
1998-12-14 07:14:16 +03:00
|
|
|
|
CORBA_exception_init (&ev);
|
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
/* Get the POA and create the server */
|
1998-12-14 08:15:48 +03:00
|
|
|
|
|
1999-02-10 04:50:08 +03:00
|
|
|
|
poa = (PortableServer_POA) CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev);
|
1999-03-30 10:09:56 +04:00
|
|
|
|
if (ev._major != CORBA_NO_EXCEPTION)
|
|
|
|
|
goto out;
|
1998-12-14 07:14:16 +03:00
|
|
|
|
|
|
|
|
|
poa_manager = PortableServer_POA__get_the_POAManager (poa, &ev);
|
1999-03-30 10:09:56 +04:00
|
|
|
|
if (ev._major != CORBA_NO_EXCEPTION)
|
|
|
|
|
goto out;
|
|
|
|
|
|
1998-12-14 07:14:16 +03:00
|
|
|
|
PortableServer_POAManager_activate (poa_manager, &ev);
|
1999-03-30 10:09:56 +04:00
|
|
|
|
if (ev._major != CORBA_NO_EXCEPTION)
|
|
|
|
|
goto out;
|
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
window_factory_server = impl_GNOME_FileManagerFactory__create (poa, NULL, &ev);
|
1999-03-30 10:09:56 +04:00
|
|
|
|
if (ev._major != CORBA_NO_EXCEPTION)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
CORBA_Object_release ((CORBA_Object) poa, &ev);
|
|
|
|
|
if (ev._major != CORBA_NO_EXCEPTION)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/* Register the server and see if it was already there */
|
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
v = goad_server_register (CORBA_OBJECT_NIL, window_factory_server,
|
|
|
|
|
"IDL:GNOME:FileManager:WindowFactory:1.0", "server", &ev);
|
1999-03-30 10:09:56 +04:00
|
|
|
|
switch (v) {
|
|
|
|
|
case 0:
|
|
|
|
|
corba_have_server = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case -2:
|
|
|
|
|
corba_have_server = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
goto out;
|
1998-12-14 07:14:16 +03:00
|
|
|
|
}
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
/* Done */
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
return retval;
|
1999-01-28 07:37:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
/**
|
|
|
|
|
* corba_init_server:
|
1999-07-02 03:15:08 +04:00
|
|
|
|
* @void:
|
|
|
|
|
*
|
1999-09-09 04:37:02 +04:00
|
|
|
|
* Initializes the CORBA server for GMC. Returns whether initialization was
|
|
|
|
|
* successful or not, and sets the global corba_have_server variable.
|
1999-07-02 03:15:08 +04:00
|
|
|
|
*
|
1999-03-30 10:09:56 +04:00
|
|
|
|
* Return value: TRUE if successful, FALSE otherwise.
|
|
|
|
|
**/
|
|
|
|
|
int
|
|
|
|
|
corba_init_server (void)
|
|
|
|
|
{
|
1999-09-09 04:37:02 +04:00
|
|
|
|
window_factory_server = goad_server_activate_with_id (
|
|
|
|
|
NULL,
|
|
|
|
|
"IDL:GNOME:FileManager:WindowFactory:1.0",
|
|
|
|
|
GOAD_ACTIVATE_EXISTING_ONLY,
|
|
|
|
|
NULL);
|
1999-03-30 10:09:56 +04:00
|
|
|
|
|
1999-09-09 04:37:02 +04:00
|
|
|
|
if (window_factory_server != CORBA_OBJECT_NIL) {
|
1999-03-30 10:09:56 +04:00
|
|
|
|
corba_have_server = TRUE;
|
|
|
|
|
return TRUE;
|
|
|
|
|
} else
|
|
|
|
|
return create_server ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* corba_create_window:
|
1999-07-02 03:15:08 +04:00
|
|
|
|
* @dir: The directory in which to create the window, or NULL for the cwd.
|
|
|
|
|
*
|
1999-03-30 10:09:56 +04:00
|
|
|
|
* Creates a GMC window using a CORBA call to the server.
|
|
|
|
|
**/
|
1999-01-28 07:37:47 +03:00
|
|
|
|
void
|
1999-07-02 03:15:08 +04:00
|
|
|
|
corba_create_window (const char *dir)
|
1999-01-28 07:37:47 +03:00
|
|
|
|
{
|
|
|
|
|
CORBA_Environment ev;
|
1999-03-30 10:09:56 +04:00
|
|
|
|
char cwd[MC_MAXPATHLEN];
|
1999-07-02 03:15:08 +04:00
|
|
|
|
|
|
|
|
|
if (dir == NULL) {
|
1999-06-23 01:02:08 +04:00
|
|
|
|
mc_get_current_wd (cwd, MC_MAXPATHLEN);
|
1999-07-02 03:15:08 +04:00
|
|
|
|
dir = cwd;
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-30 10:09:56 +04:00
|
|
|
|
CORBA_exception_init (&ev);
|
1999-09-09 04:37:02 +04:00
|
|
|
|
GNOME_FileManagerFactory_create_window (window_factory_server, dir, &ev);
|
1999-01-28 07:37:47 +03:00
|
|
|
|
CORBA_exception_free (&ev);
|
1998-12-14 07:14:16 +03:00
|
|
|
|
}
|