CORBA overhaul, part 1. This will not compile. HAH. I'm taking it home - Federico

This commit is contained in:
Miguel de Icaza 1999-09-09 00:37:02 +00:00
parent e3c47b8cde
commit 77ae49ad81
7 changed files with 334 additions and 41 deletions

View File

@ -1,3 +1,9 @@
1999-09-08 Federico Mena Quintero <federico@redhat.com>
* idl/FileManager.idl: Changed names, and put everything under a
FileManager module. Added a Desktop interface and some methods to
the WindowFactory interface.
1999-09-08 Kjartan Maraas <kmaraas@online.no>
* doc-gnome/*: Shiny new docs from users-guide.

View File

@ -1,3 +1,17 @@
1999-09-08 Federico Mena Quintero <federico@redhat.com>
* gcorba.c: Major re-arrangement and beautifying. Use nicer and
shorter identifier names.
(WindowFactory_rescan_directory): New method to rescan all the
panels that pertain to the specified directory.
(WindowFactory_close_invalid_windows): New method to close all the
panels that have unreachable directories.
(WindowFactory_get_windows_by_directory): New method to get a
sequence of all the panels that are showing the specified directory.
* gmc.gnorba: Fixed the GOAD IDs to be something non-ad-hoc.
Added the Desktop interface.
1999-09-06 Federico Mena Quintero <federico@redhat.com>
* gtkdtree.c (gtk_dtree_size_allocate): Do the "visibility" test

View File

@ -16,30 +16,277 @@
#include "gcorba.h"
#include "global.h"
#include "gmain.h"
#include "gscreen.h"
#include "main.h"
/*** Global variables ***/
/* The ORB for the whole program */
CORBA_ORB orb = CORBA_OBJECT_NIL;
/*** Local variables ***/
/* The POA */
PortableServer_POA poa;
/* Reference to the server object */
static CORBA_Object gmc_server;
/*** App-specific servant structures ***/
/* Desktop servant */
typedef struct {
POA_GNOME_FileManagerWindow servant;
PortableServer_POA poa;
POA_GNOME_FileManager_Desktop servant;
} DesktopServant;
static POA_GNOME_FileManager_Desktop__epv desktop_epv;
static POA_GNOME_FileManager_Desktop__vepv desktop_vepv;
/* Window servant */
typedef struct {
POA_GNOME_FileManager_Window servant;
WPanel *panel;
} impl_POA_GNOME_FileManagerWindow;
} WindowServant;
static POA_GNOME_FileManager_Window__epv window_epv;
static POA_GNOME_FileManager_Window__vepv window_vepv;
/* WindowFactory servant */
typedef struct {
POA_GNOME_FileManagerFactory servant;
PortableServer_POA poa;
} impl_POA_GNOME_FileManagerFactory;
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;
}
}
/*** Implementation stub prototypes ***/
@ -208,7 +455,7 @@ impl_GNOME_FileManagerFactory_supports (impl_POA_GNOME_FileManagerFactory *serva
const CORBA_char *obj_goad_id,
CORBA_Environment *ev)
{
if (strcmp (obj_goad_id, "gmc_filemanager_window") == 0)
if (strcmp (obj_goad_id, "IDL:GNOME:FileManagerWindow:1.0") == 0)
return CORBA_TRUE;
else
return CORBA_FALSE;
@ -220,7 +467,7 @@ impl_GNOME_FileManagerFactory_create_object (impl_POA_GNOME_FileManagerFactory *
const GNOME_stringlist *params,
CORBA_Environment *ev)
{
if (strcmp (goad_id, "gmc_filemanager_window") != 0) {
if (strcmp (goad_id, "IDL:GNOME:FileManagerWindow:1.0") != 0) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_GenericFactory_CannotActivate,
NULL);
@ -299,7 +546,7 @@ create_server (void)
if (ev._major != CORBA_NO_EXCEPTION)
goto out;
gmc_server = impl_GNOME_FileManagerFactory__create (poa, NULL, &ev);
window_factory_server = impl_GNOME_FileManagerFactory__create (poa, NULL, &ev);
if (ev._major != CORBA_NO_EXCEPTION)
goto out;
@ -309,8 +556,8 @@ create_server (void)
/* Register the server and see if it was already there */
v = goad_server_register (CORBA_OBJECT_NIL, gmc_server,
"gmc_filemanager_factory", "server", &ev);
v = goad_server_register (CORBA_OBJECT_NIL, window_factory_server,
"IDL:GNOME:FileManager:WindowFactory:1.0", "server", &ev);
switch (v) {
case 0:
corba_have_server = FALSE;
@ -336,20 +583,21 @@ create_server (void)
* corba_init_server:
* @void:
*
* Initializes the CORBA factory object for gmc. Returns whether initialization
* was successful or not, and sets the global corba_have_server variable.
* Initializes the CORBA server for GMC. Returns whether initialization was
* successful or not, and sets the global corba_have_server variable.
*
* Return value: TRUE if successful, FALSE otherwise.
**/
int
corba_init_server (void)
{
gmc_server = goad_server_activate_with_id (NULL,
"gmc_filemanager_factory",
GOAD_ACTIVATE_EXISTING_ONLY,
NULL);
window_factory_server = goad_server_activate_with_id (
NULL,
"IDL:GNOME:FileManager:WindowFactory:1.0",
GOAD_ACTIVATE_EXISTING_ONLY,
NULL);
if (gmc_server != CORBA_OBJECT_NIL) {
if (window_factory_server != CORBA_OBJECT_NIL) {
corba_have_server = TRUE;
return TRUE;
} else
@ -374,6 +622,6 @@ corba_create_window (const char *dir)
}
CORBA_exception_init (&ev);
GNOME_FileManagerFactory_create_window (gmc_server, dir, &ev);
GNOME_FileManagerFactory_create_window (window_factory_server, dir, &ev);
CORBA_exception_free (&ev);
}

View File

@ -1,11 +1,17 @@
[gmc_filemanager_factory]
[IDL:GNOME:FileManager:WindowFactory:1.0]
type=exe
repo_id=IDL:GNOME/FileManagerFactory:1.0 IDL:GNOME/GenericFactory:1.0
description=GNOME Midnight Commander
repo_id=IDL:GNOME/FileManager/WindowFactory:1.0 IDL:GNOME/GenericFactory:1.0
description=Directory window factory
location_info=gmc
[gmc_filemanager_window]
[IDL:GNOME:FileManager:Window:1.0]
type=factory
repo_id=IDL:GNOME/FileManagerWindow:1.0
description=File manager window
location_info=gmc_filemanager_factory
repo_id=IDL:GNOME/FileManager/Window:1.0
description=Directory window
location_info=IDL:GNOME:FileManager:WindowFactory:1.0
[IDL:GNOME:FileManager:Desktop:1.0]
type=factory
repo_id=IDL:GNOME/FileManager/Desktop:1.0
description=Desktop
location_info=IDL:GNOME:FileManager:WindowFactory:1.0

View File

@ -1,15 +1,30 @@
#include <gnome-factory.idl>
module GNOME {
exception POSIX_ERROR { string errorstr; };
module FileManager {
exception POSIX_ERROR { string errorstr; };
interface FileManagerWindow {
/* not much yet */
oneway void close();
};
interface Desktop {
void rescan ();
void rescan_devices ();
};
interface FileManagerFactory : GenericFactory {
FileManagerWindow create_window(in string dir)
raises (POSIX_ERROR);
};
interface Window {
/* not much yet */
oneway void close ();
};
interface WindowFactory : ::GNOME::GenericFactory {
typedef sequence<Window> WindowSeq;
/* This is the desktop object */
readonly attribute Desktop the_desktop;
Window create_window (in string dir)
raises (POSIX_ERROR);
void rescan_directory (in string dir);
void close_invalid_windows ();
WindowSeq get_windows_by_directory (in string dir);
};
};
};

View File

@ -174,6 +174,9 @@ typedef struct {
void *panel_listbox; /* container for the list */
int is_a_desktop_panel;
/* CORBA servant */
void *servant;
#endif
} WPanel;

View File

@ -1018,6 +1018,7 @@ panel_new (char *panel_name)
panel->drag_tree_row = -1;
panel->is_a_desktop_panel = FALSE;
panel->id = panel_id++;
panel->servant = NULL;
#endif
panel->panel_name = g_strdup (panel_name);