From b3bb157ad530be24014cf8fbc0aa7c0a26a23b3b Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Tue, 30 Mar 1999 06:09:56 +0000 Subject: [PATCH] These are a bunch of changes to fix CORBA and session management. They are almost complete (i.e. to handle all nitty gritty cases), but they seem to be working OK right now. SM should be much more stable now. Please tell me if you find any weird behavior - Federico 1999-03-30 Federico Mena Quintero * gdesktop-icon.c (desktop_icon_realize): Remove the WM_CLIENT_LEADER property from icon windows so that window managers will not store SM information for them. * gnome-open-dialog.c: Added missing #includes. * gdesktop-init.c (desktop_init_at): Removed an unused variable. * gdesktop.h: Added some missing prototypes. * gmain.h: Added some missing prototypes. * Makefile.in: Added gsession.[ch] to the list of sources. * gmain.c (create_panels): Consider whether we have a CORBA server and session management. * gdesktop.c: #include "gdesktop-init.h" * gdesktop.c: Added a missing cast to GNOME_DIALOG. * gmain.c (create_panels): Removed the run_desktop global variable. * glayout.c (create_container): Set the wmclass of the panel to include its unique ID. * gsession.[ch]: New file with the functions that deal with session management. * glayout.c (gnome_exit): Use session_set_restart(). * gcorba.c (corba_init): Now returns an int with an error value. (corba_init_server): Initialize the server properly. Fixed all the object implementation code. (corba_create_window): New function used to create a window with the CORBA server. * gmain.c (gnome_check_super_user): Now the check for running as root is done here. There should be no GUI code in src/. 1999-03-30 Federico Mena Quintero * dlg.c (dlg_run_done): Do not call the callback of a NULL current widget. * setup.h: Added missing prototype for setup_init(). * filegui.c (check_progress_buttons): Added a missing return value. * dlg.c (remove_widget): Added a missing return value. * main.c: Removed the global directory_list variable. Removed the main_corba_register_server() function. * main.h: Removed the global run_desktop variable. * panel.h: Now the panel structure has a unique numerical ID used for session management. * screen.c (panel_new): Maintain a unique ID for each panel. * main.c (maybe_display_linksdir): Handle display of the desktop init dir here. (main): Call gnome_check_super_user(). (init_corba_with_args): Call corba_init_server(). * main.c (init_corba_with_args): Do CORBA initialization here. Also removed the global force_activation option. 1999-03-30 Federico Mena Quintero * vfs.c (vfs_add_current_stamps): Only do stamping of the panels if they exist. * mcserv.c: #include (get_client): Put `#ifdef __EMX__' around an otherwise-unused variable. * utilvfs.c (vfs_split_url): Fix NULL <-> 0 confusion when comparing characters. * ftpfs.c (retrieve_dir): Removed unused variable dot_dot_found. * extfs.c (extfs_init): Assign `key' to c, not `&key'. --- gnome/ChangeLog | 42 +++ gnome/Makefile.in | 197 ++++++------ gnome/gcorba.c | 478 +++++++++++++++++------------ gnome/gcorba.h | 18 +- gnome/gdesktop-icon.c | 8 + gnome/gdesktop-init.c | 9 +- gnome/gdesktop.c | 19 +- gnome/gdesktop.h | 4 +- gnome/gdnd.c | 1 + gnome/glayout.c | 35 ++- gnome/gmain.c | 156 +++++----- gnome/gmain.h | 5 + gnome/gnome-file-property-dialog.c | 2 +- gnome/gnome-open-dialog.c | 3 + gnome/gscreen.c | 5 +- gnome/gtkdtree.c | 1 + gnome/gtools.c | 19 +- gnome/gwidget.c | 6 + src/ChangeLog | 30 ++ src/dlg.c | 6 +- src/filegui.c | 2 +- src/main.c | 104 ++++--- src/main.h | 4 +- src/panel.h | 3 + src/screen.c | 16 +- src/setup.h | 1 + vfs/ChangeLog | 16 + vfs/extfs.c | 8 +- vfs/ftpfs.c | 1 - vfs/mcserv.c | 3 + vfs/utilvfs.c | 2 +- vfs/vfs.c | 14 +- 32 files changed, 732 insertions(+), 486 deletions(-) diff --git a/gnome/ChangeLog b/gnome/ChangeLog index a8dc1787d..1324a105a 100644 --- a/gnome/ChangeLog +++ b/gnome/ChangeLog @@ -1,3 +1,45 @@ +1999-03-30 Federico Mena Quintero + + * gdesktop-icon.c (desktop_icon_realize): Remove the + WM_CLIENT_LEADER property from icon windows so that window + managers will not store SM information for them. + + * gnome-open-dialog.c: Added missing #includes. + + * gdesktop-init.c (desktop_init_at): Removed an unused variable. + + * gdesktop.h: Added some missing prototypes. + + * gmain.h: Added some missing prototypes. + + * Makefile.in: Added gsession.[ch] to the list of sources. + + * gmain.c (create_panels): Consider whether we have a CORBA server + and session management. + + * gdesktop.c: #include "gdesktop-init.h" + * gdesktop.c: Added a missing cast to GNOME_DIALOG. + + * gmain.c (create_panels): Removed the run_desktop global + variable. + + * glayout.c (create_container): Set the wmclass of the panel to + include its unique ID. + + * gsession.[ch]: New file with the functions that deal with + session management. + + * glayout.c (gnome_exit): Use session_set_restart(). + + * gcorba.c (corba_init): Now returns an int with an error value. + (corba_init_server): Initialize the server properly. + Fixed all the object implementation code. + (corba_create_window): New function used to create a window with + the CORBA server. + + * gmain.c (gnome_check_super_user): Now the check for running as + root is done here. There should be no GUI code in src/. + 1999-03-29 Jonathan Blandford * gdesktop.c (create_desktop_dir): improved wording. diff --git a/gnome/Makefile.in b/gnome/Makefile.in index 922dee3aa..682af29a3 100644 --- a/gnome/Makefile.in +++ b/gnome/Makefile.in @@ -27,69 +27,71 @@ PIXMAPS = \ dir-close.xpm \ dir-open.xpm -GNOMESRCS = \ - gaction.c \ - gcache.c \ - gcliplabel.c \ - gcustom-layout.c\ - gcmd.c \ - gcorba.c \ - gdesktop-icon.c \ - gdesktop-init.c \ - gdesktop.c \ - gdialogs.c \ - gdnd.c \ - ghelp.c \ - gicon.c \ - ginfo.c \ - gkey.c \ - glayout.c \ - gmain.c \ - gmount.c \ - gmc-chargrid.c \ - gmenu.c \ - gmetadata.c \ - gpageprop.c \ - gpopup2.c \ - gprefs.c \ - gprint.c \ - gprop.c \ - gnome-file-property-dialog.c \ - gnome-open-dialog.c \ - gscreen.c \ - gtools.c \ - gtkdtree.c \ - gtree.c \ - gutil.c \ - gview.c \ +GNOMESRCS = \ + gaction.c \ + gcache.c \ + gcliplabel.c \ + gcustom-layout.c \ + gcmd.c \ + gcorba.c \ + gdesktop-icon.c \ + gdesktop-init.c \ + gdesktop.c \ + gdialogs.c \ + gdnd.c \ + ghelp.c \ + gicon.c \ + ginfo.c \ + gkey.c \ + glayout.c \ + gmain.c \ + gmount.c \ + gmc-chargrid.c \ + gmenu.c \ + gmetadata.c \ + gpageprop.c \ + gpopup2.c \ + gprefs.c \ + gprint.c \ + gprop.c \ + gnome-file-property-dialog.c \ + gnome-open-dialog.c \ + gscreen.c \ + gsession.c \ + gtools.c \ + gtkdtree.c \ + gtree.c \ + gutil.c \ + gview.c \ gwidget.c -GNOMEHDRS = \ - gcache.h \ - gcliplabel.h \ - gcmd.h \ - gconf.h \ - gcorba.h \ - gcustom-layout.h\ - gdesktop-icon.h \ - gdesktop-init.h \ - gdesktop.h \ - gdnd.h \ - gicon.h \ - gmain.h \ - gmount.h \ - gmc-chargrid.h \ - gmetadata.h \ - gpageprop.h \ - gpopup.h \ - gprefs.h \ - gprint.h \ - gprop.h \ - gnome-file-property-dialog.h \ - gnome-open-dialog.h \ - gscreen.h \ - gtkdtree.h \ - gtree.h \ +GNOMEHDRS = \ + gcache.h \ + gcliplabel.h \ + gcmd.h \ + gconf.h \ + gcorba.h \ + gcustom-layout.h \ + gdesktop-icon.h \ + gdesktop-init.h \ + gdesktop.h \ + gdnd.h \ + gicon.h \ + gmain.h \ + gmount.h \ + gmc-chargrid.h \ + gmetadata.h \ + gpageprop.h \ + gpopup.h \ + gprefs.h \ + gprint.h \ + gprop.h \ + gnome-file-property-dialog.h \ + gnome-open-dialog.h \ + gscreen.h \ + gsession.h \ + gtkdtree.h \ + gtree.h \ gwidget.h ICONS = \ @@ -134,44 +136,45 @@ CORBAOBJS = \ FileManager-stubs.o \ FileManager-common.o -OBJS = \ - $(LOBJS) \ - $(OOBJS) \ - gaction.o \ - gcache.o \ - gcliplabel.o \ - gcmd.o \ - gcustom-layout.o\ - gdesktop-icon.o \ - gdesktop-init.o \ - gdesktop.o \ - gdnd.o \ - ghelp.o \ - gicon.o \ - ginfo.o \ - gkey.o \ - glayout.o \ - gmain.o \ - gmount.o \ - gmc-chargrid.o \ - gmenu.o \ - gmetadata.o \ - gpageprop.o \ - gpopup2.o \ - gprefs.o \ - gprint.o \ - gprop.o \ - gnome-file-property-dialog.o \ - gnome-open-dialog.o \ - gscreen.o \ - gtools.o \ - gtree.o \ - gutil.o \ - gview.o \ - gtkdtree.o \ +OBJS = \ + $(LOBJS) \ + $(OOBJS) \ + gaction.o \ + gcache.o \ + gcliplabel.o \ + gcmd.o \ + gcustom-layout.o \ + gdesktop-icon.o \ + gdesktop-init.o \ + gdesktop.o \ + gdnd.o \ + ghelp.o \ + gicon.o \ + ginfo.o \ + gkey.o \ + glayout.o \ + gmain.o \ + gmount.o \ + gmc-chargrid.o \ + gmenu.o \ + gmetadata.o \ + gpageprop.o \ + gpopup2.o \ + gprefs.o \ + gprint.o \ + gprop.o \ + gnome-file-property-dialog.o \ + gnome-open-dialog.o \ + gscreen.o \ + gsession.o \ + gtools.o \ + gtree.o \ + gutil.o \ + gview.o \ + gtkdtree.o \ gwidget.o -NORMALOBJS = \ +NORMALOBJS = \ main.o CORBA_GENERATED = \ diff --git a/gnome/gcorba.c b/gnome/gcorba.c index 45b150b88..9e3d28cb8 100644 --- a/gnome/gcorba.c +++ b/gnome/gcorba.c @@ -1,36 +1,37 @@ -/* - * gcorba.c: CORBA support code for the GNOME Midnight Commander +/* CORBA support for the Midhignt Commander * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * Elliot Lee (sopwith@cuc.edu) + * Copyright (C) 1999 The Free Sofware Foundation + * + * Authors: Miguel de Icaza + * Federico Mena + * Elliot Lee */ + #include -#include -#include -#include "FileManager.h" -#include -#include "x.h" -#include -#include -#include "dir.h" -#include "global.h" #include "panel.h" -#include "gscreen.h" -#include "main.h" -#include "gmain.h" +#include +#include "FileManager.h" #include "gcmd.h" #include "gcorba.h" +#include "global.h" +#include "gmain.h" -PortableServer_POA poa; -PortableServer_POAManager poa_manager; -CORBA_ORB orb; +/*** Global variables ***/ + +CORBA_ORB orb = CORBA_OBJECT_NIL; + +/*** Local variables ***/ + +/* Reference to the server object */ +static CORBA_Object gmc_server; + +/*** App-specific servant structures ***/ typedef struct { POA_GNOME_FileManagerWindow servant; PortableServer_POA poa; - - WPanel *mywin; + + WPanel *panel; } impl_POA_GNOME_FileManagerWindow; typedef struct { @@ -40,55 +41,64 @@ typedef struct { /*** Implementation stub prototypes ***/ -static void -impl_GNOME_FileManagerWindow_close (impl_POA_GNOME_FileManagerWindow * servant, - CORBA_Environment * ev); +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); -GNOME_FileManagerWindow -impl_GNOME_FileManagerFactory_create_window (impl_POA_GNOME_FileManagerFactory * servant, - CORBA_char * dir, - CORBA_Environment * ev); +static void impl_GNOME_FileManagerFactory__destroy (impl_POA_GNOME_FileManagerFactory *servant, + CORBA_Environment *ev); -CORBA_boolean -impl_GNOME_FileManagerFactory_supports (impl_POA_GNOME_FileManagerFactory * servant, - CORBA_char * obj_goad_id, - CORBA_Environment * ev); -CORBA_Object -impl_GNOME_FileManagerFactory_create_object (impl_POA_GNOME_FileManagerFactory * servant, - CORBA_char * goad_id, - GNOME_stringlist * params, - 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); /*** epv structures ***/ static PortableServer_ServantBase__epv impl_GNOME_FileManagerWindow_base_epv = { - NULL, NULL, NULL + NULL, /* _private data */ + NULL, /* finalize routine */ + NULL, /* default_POA routine */ }; static POA_GNOME_FileManagerWindow__epv impl_GNOME_FileManagerWindow_epv = { - NULL, /* _private */ - (gpointer) & impl_GNOME_FileManagerWindow_close, + NULL, /* _private */ + (gpointer) &impl_GNOME_FileManagerWindow_close, + }; static PortableServer_ServantBase__epv impl_GNOME_FileManagerFactory_base_epv = { - NULL, /* _private data */ - NULL, - NULL /* default_POA routine */ + NULL, /* _private data */ + NULL, /* finalize routine */ + NULL, /* default_POA routine */ }; + static POA_GNOME_FileManagerFactory__epv impl_GNOME_FileManagerFactory_epv = { - NULL, /* _private */ - (gpointer) & impl_GNOME_FileManagerFactory_create_window, + NULL, /* _private */ + (gpointer) &impl_GNOME_FileManagerFactory_create_window, }; static POA_GNOME_GenericFactory__epv impl_GNOME_FileManagerFactory_GNOME_GenericFactory_epv = { - NULL, /* _private */ - (gpointer) & impl_GNOME_FileManagerFactory_supports, - (gpointer) & impl_GNOME_FileManagerFactory_create_object, + NULL, /* _private */ + (gpointer) &impl_GNOME_FileManagerFactory_supports, + (gpointer) &impl_GNOME_FileManagerFactory_create_object }; /*** vepv structures ***/ @@ -96,205 +106,269 @@ static POA_GNOME_GenericFactory__epv impl_GNOME_FileManagerFactory_GNOME_Generic static POA_GNOME_FileManagerWindow__vepv impl_GNOME_FileManagerWindow_vepv = { &impl_GNOME_FileManagerWindow_base_epv, - &impl_GNOME_FileManagerWindow_epv, + &impl_GNOME_FileManagerWindow_epv }; static POA_GNOME_FileManagerFactory__vepv impl_GNOME_FileManagerFactory_vepv = { &impl_GNOME_FileManagerFactory_base_epv, &impl_GNOME_FileManagerFactory_GNOME_GenericFactory_epv, - &impl_GNOME_FileManagerFactory_epv, + &impl_GNOME_FileManagerFactory_epv }; -impl_POA_GNOME_FileManagerFactory poa_filemanagerfactory_servant = -{ - { NULL, &impl_GNOME_FileManagerFactory_vepv}, NULL -}; - -GNOME_FileManagerFactory filemanagerfactory_server; - /*** Stub implementations ***/ -static void -do_window_close(GtkWidget *widget, gpointer _servant) -{ - CORBA_Environment ev; - PortableServer_ObjectId *objid; - impl_POA_GNOME_FileManagerWindow *servant = _servant; - - CORBA_exception_init(&ev); - objid = PortableServer_POA_servant_to_id (servant->poa, _servant, &ev); - PortableServer_POA_deactivate_object (servant->poa, objid, &ev); -#if 1 -#warning Remove this ifdef when the new ORBit is released. - g_warning ("Developer Warning: when a new ORBIt is released, remove this code\n"); -#else - CORBA_free (objid); -#endif - POA_GNOME_FileManagerWindow__fini(_servant, &ev); - - g_free(servant); - CORBA_exception_free(&ev); -} - -static void -impl_GNOME_FileManagerWindow_close (impl_POA_GNOME_FileManagerWindow * servant, CORBA_Environment * ev) -{ - gnome_close_panel (GTK_WIDGET (servant->mywin->widget.wdata), servant->mywin); -} - -GNOME_FileManagerWindow -impl_GNOME_FileManagerFactory_create_window (impl_POA_GNOME_FileManagerFactory * servant, - CORBA_char * dir, - CORBA_Environment * ev) +static GNOME_FileManagerWindow +impl_GNOME_FileManagerWindow__create(PortableServer_POA poa, + impl_POA_GNOME_FileManagerWindow **servant, + CORBA_Environment *ev) { GNOME_FileManagerWindow retval; impl_POA_GNOME_FileManagerWindow *newservant; PortableServer_ObjectId *objid; - - newservant = g_new0(impl_POA_GNOME_FileManagerWindow, 1); + + newservant = g_new0 (impl_POA_GNOME_FileManagerWindow, 1); newservant->servant.vepv = &impl_GNOME_FileManagerWindow_vepv; newservant->poa = poa; - newservant->mywin = new_panel_at ((dir && *dir) ? dir : home_dir); - - gtk_signal_connect(GTK_OBJECT(newservant->mywin->xwindow), - "destroy", do_window_close, - newservant); - - 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); - + 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); + + if (servant) + *servant = newservant; + return retval; } -CORBA_boolean -impl_GNOME_FileManagerFactory_supports (impl_POA_GNOME_FileManagerFactory * servant, - CORBA_char * obj_goad_id, - CORBA_Environment * ev) +/* You shouldn't call this routine directly without first deactivating the servant... */ +static void +impl_GNOME_FileManagerWindow__destroy(impl_POA_GNOME_FileManagerWindow *servant, + CORBA_Environment *ev) { - return !strcmp(obj_goad_id, "gmc_filemanager_window"); + 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_FileManagerWindow__fini ((PortableServer_Servant) servant, ev); + g_free(servant); } -CORBA_Object -impl_GNOME_FileManagerFactory_create_object(impl_POA_GNOME_FileManagerFactory * servant, - CORBA_char * goad_id, - GNOME_stringlist * params, - CORBA_Environment * ev) +static void +impl_GNOME_FileManagerWindow_close(impl_POA_GNOME_FileManagerWindow *servant, + CORBA_Environment *ev) { - if(!strcmp(goad_id, "gmc_filemanager_window")) - return impl_GNOME_FileManagerFactory_create_window( - servant, - params->_length ? params->_buffer [0] : home_dir, ev); - - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_GenericFactory_CannotActivate, - NULL); - - return CORBA_OBJECT_NIL; + gnome_close_panel (GTK_WIDGET (servant->panel->xwindow), servant->panel); } -int -try_to_activate_running_copy (void) +static GNOME_FileManagerFactory +impl_GNOME_FileManagerFactory__create(PortableServer_POA poa, + impl_POA_GNOME_FileManagerFactory **servant, + CORBA_Environment *ev) { - CORBA_Object name_service; - CORBA_Environment ev; - CosNaming_NameComponent nc[3] = {{"GNOME", "subcontext"}, - {"Servers", "subcontext"}, - {"gmc_filemanager_factory", "object"}}; - CosNaming_Name nom = {0, 3, nc, CORBA_FALSE}; - CORBA_Object retval = CORBA_OBJECT_NIL; - - CORBA_exception_init (&ev); - - name_service = gnome_name_service_get(); - if (name_service == CORBA_OBJECT_NIL) - goto out; + GNOME_FileManagerFactory retval; + impl_POA_GNOME_FileManagerFactory *newservant; + PortableServer_ObjectId *objid; - retval = CosNaming_NamingContext_resolve (name_service, &nom, &ev); - if (ev._major == CORBA_USER_EXCEPTION - && strcmp(CORBA_exception_id(&ev), ex_CosNaming_NamingContext_NotFound) == 0){ - retval = CORBA_OBJECT_NIL; - goto out; + newservant = g_new0 (impl_POA_GNOME_FileManagerFactory, 1); + newservant->servant.vepv = &impl_GNOME_FileManagerFactory_vepv; + newservant->poa = poa; + 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; + + return retval; +} + +/* 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) +{ + if (strcmp (obj_goad_id, "gmc_filemanager_window") == 0) + return CORBA_TRUE; + else + return CORBA_FALSE; +} + +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) +{ + if (strcmp (goad_id, "gmc_filemanager_window") != 0) { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_GNOME_GenericFactory_CannotActivate, + NULL); + return CORBA_OBJECT_NIL; } - if (CORBA_Object_is_nil (retval, &ev)) - goto out; - - GNOME_FileManagerFactory_create_window (retval, home_dir, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - retval = CORBA_OBJECT_NIL; -out: - CORBA_exception_free (&ev); - CORBA_Object_release (name_service, &ev); - return retval != CORBA_OBJECT_NIL; + return impl_GNOME_FileManagerFactory_create_window ( + servant, + params->_length ? params->_buffer[0] : home_dir, + ev); } -void -corba_init (void) +/* Callback used when a panel is destroyed */ +static void +panel_destroyed (GtkObject *object, gpointer data) +{ + impl_POA_GNOME_FileManagerWindow *servant; + CORBA_Environment ev; + + servant = data; + + CORBA_exception_init (&ev); + impl_GNOME_FileManagerWindow__destroy (servant, &ev); + CORBA_exception_free (&ev); +} + +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; + + retval = impl_GNOME_FileManagerWindow__create (servant->poa, + &newservant, + ev); + + panel = new_panel_at ((dir && *dir) ? dir : home_dir); + newservant->panel = panel; + + gtk_signal_connect (GTK_OBJECT (panel->xwindow), "destroy", + (GtkSignalFunc) panel_destroyed, + newservant); + + return retval; +} + +/*** Public non-implementation functions ***/ + +/* Creates the CORBA server */ +static int +create_server (void) { CORBA_Environment ev; - + PortableServer_POA poa; + PortableServer_POAManager poa_manager; + int retval; + int v; + + retval = FALSE; CORBA_exception_init (&ev); - orb = gnome_CORBA_ORB (); + /* Get the POA and create the server */ poa = (PortableServer_POA) CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev); - if (ev._major != CORBA_NO_EXCEPTION){ - printf ("Can not resolve initial reference to RootPOA"); - return; - } + if (ev._major != CORBA_NO_EXCEPTION) + goto out; poa_manager = PortableServer_POA__get_the_POAManager (poa, &ev); - if (ev._major != CORBA_NO_EXCEPTION){ - printf ("Can not get the POAmanager"); - return; - } - + if (ev._major != CORBA_NO_EXCEPTION) + goto out; + PortableServer_POAManager_activate (poa_manager, &ev); - if (ev._major != CORBA_NO_EXCEPTION){ - printf ("Can not get the POAmanager"); - return; + if (ev._major != CORBA_NO_EXCEPTION) + goto out; + + gmc_server = impl_GNOME_FileManagerFactory__create (poa, NULL, &ev); + 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 */ + + v = goad_server_register (CORBA_OBJECT_NIL, gmc_server, + "gmc_filemanager_factory", "server", &ev); + switch (v) { + case 0: + corba_have_server = FALSE; + break; + + case -2: + corba_have_server = FALSE; + break; + + default: + goto out; } + + retval = TRUE; + + /* Done */ + + out: + return retval; } +/** + * 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. + * + * 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); + + if (gmc_server != CORBA_OBJECT_NIL) { + corba_have_server = TRUE; + return TRUE; + } else + return create_server (); +} + +/** + * corba_create_window: + * @void: + * + * Creates a GMC window using a CORBA call to the server. + **/ void -corba_register_server (void) +corba_create_window (void) { CORBA_Environment ev; - int v; - + char cwd[MC_MAXPATHLEN]; + + mc_get_current_wd (cwd, MC_MAXPATHLEN); + CORBA_exception_init (&ev); - - /* - * Initialize the Factory Object - */ - POA_GNOME_FileManagerFactory__init ( - (POA_GNOME_FileManagerFactory*)&poa_filemanagerfactory_servant, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION){ - CORBA_exception_free (&ev); - printf ("Can not initialize FileManagerFactory object\n"); - return; - } - - /* Activate the object */ - CORBA_free (PortableServer_POA_activate_object - (poa, &poa_filemanagerfactory_servant, &ev)); - - /* Get a refeerence to te object */ - filemanagerfactory_server = PortableServer_POA_servant_to_reference ( - poa, &poa_filemanagerfactory_servant, &ev); - - v = goad_server_register ( - NULL, filemanagerfactory_server, - "gmc_filemanager_factory", "server", &ev); - + GNOME_FileManagerFactory_create_window (gmc_server, cwd, &ev); CORBA_exception_free (&ev); - if (v != 0) - return; - } diff --git a/gnome/gcorba.h b/gnome/gcorba.h index 52794c0d6..7fbf39e3a 100644 --- a/gnome/gcorba.h +++ b/gnome/gcorba.h @@ -1,8 +1,24 @@ +/* CORBA support for the Midhignt Commander + * + * Copyright (C) 1999 The Free Sofware Foundation + * + * Authors: Miguel de Icaza + * Federico Mena + * Elliot Lee + */ + #ifndef __GCORBA_H #define __GCORBA_H +#include + + +/* The ORB */ extern CORBA_ORB orb; -void corba_register_server (void); + +int corba_init_server (void); +void corba_create_window (void); + #endif diff --git a/gnome/gdesktop-icon.c b/gnome/gdesktop-icon.c index 2ae027b12..eb104012f 100644 --- a/gnome/gdesktop-icon.c +++ b/gnome/gdesktop-icon.c @@ -157,6 +157,14 @@ desktop_icon_realize (GtkWidget *widget) gdk_window_set_decorations (widget->window, 0); gdk_window_set_functions (widget->window, 0); + + /* Remove the client leader property so that the window manager will not + * save SM information for icons. + */ + + gdk_property_delete (widget->window, gdk_atom_intern ("WM_CLIENT_LEADER", FALSE)); + + /* Set the proper GNOME hints */ gnome_win_hints_init (); diff --git a/gnome/gdesktop-init.c b/gnome/gdesktop-init.c index 5c76e7d05..dcf1f318a 100644 --- a/gnome/gdesktop-init.c +++ b/gnome/gdesktop-init.c @@ -82,8 +82,7 @@ desktop_init_at (const char *dir) DIR *d; struct dirent *dent; const int links_extlen = sizeof (".links")-1; - struct stat s; - + d = opendir (dir); if (!d) return; @@ -100,7 +99,7 @@ desktop_init_at (const char *dir) if (access (fname, X_OK) == 0){ char *desktop_quoted; char *command; - + desktop_quoted = name_quote (desktop_directory, 0); command = g_strconcat (fname, " --desktop-dir", desktop_quoted, NULL); g_free (desktop_quoted); @@ -115,12 +114,12 @@ desktop_init_at (const char *dir) g_free (fname); continue; } - + if (strcmp (dent->d_name + len - links_extlen, ".links")){ g_free (fname); continue; } - + desktop_load_init_from (fname); } } diff --git a/gnome/gdesktop.c b/gnome/gdesktop.c index 7f00c5cb7..eaa622345 100644 --- a/gnome/gdesktop.c +++ b/gnome/gdesktop.c @@ -20,6 +20,7 @@ #include "gconf.h" #include "gdesktop.h" #include "gdesktop-icon.h" +#include "gdesktop-init.h" #include "gicon.h" #include "gmain.h" #include "gmetadata.h" @@ -1364,6 +1365,7 @@ create_panel_from_desktop (void) panel->total = total; panel->selected = selected_index; panel->is_a_desktop_panel = TRUE; + panel->id = -1; return panel; } @@ -2399,19 +2401,22 @@ set_background_image (GtkWidget *widget, gpointer data) { gchar *bg_capplet; gchar *argv[1]; + GtkWidget *msg_box; + bg_capplet = gnome_is_program_in_path ("background-properties-capplet"); + if (bg_capplet) { argv[0] = bg_capplet; gnome_execute_async (bg_capplet, 1, argv); g_free (bg_capplet); } else { - GtkWidget *msg_box; - msg_box = gnome_message_box_new (_("Unable to locate the file:\nbackground-properties-capplet\n" - "in your path.\n\nWe are unable to set the background."), - GNOME_MESSAGE_BOX_WARNING, - GNOME_STOCK_BUTTON_OK, - NULL); - gnome_dialog_run (msg_box); + msg_box = gnome_message_box_new ( + _("Unable to locate the file:\nbackground-properties-capplet\n" + "in your path.\n\nWe are unable to set the background."), + GNOME_MESSAGE_BOX_WARNING, + GNOME_STOCK_BUTTON_OK, + NULL); + gnome_dialog_run (GNOME_DIALOG (msg_box)); } } static GnomeUIInfo gnome_panel_new_menu [] = { diff --git a/gnome/gdesktop.h b/gnome/gdesktop.h index f224ad026..460a37e2a 100644 --- a/gnome/gdesktop.h +++ b/gnome/gdesktop.h @@ -1,6 +1,6 @@ /* Desktop management for the Midnight Commander * - * Copyright (C) 1998 The Free Software Foundation + * Copyright (C) 1998-1999 The Free Software Foundation * * Authors: Federico Mena * Miguel de Icaza @@ -66,6 +66,8 @@ gboolean do_eject (char *filename); void desktop_arrange_icons (void); void desktop_rescan_devices (void); void desktop_reload_icons (int user_pos, int xpos, int ypos); +void desktop_create_url (const char *filename, const char *title, const char *url, const char *icon); extern int desktop_wm_is_gnome_compliant; + #endif diff --git a/gnome/gdnd.c b/gnome/gdnd.c index a32c0e42f..a056a10d8 100644 --- a/gnome/gdnd.c +++ b/gnome/gdnd.c @@ -18,6 +18,7 @@ #include "gscreen.h" #include "../vfs/vfs.h" #include +#include "gdesktop.h" #include "gdnd.h" diff --git a/gnome/glayout.c b/gnome/glayout.c index 1af1d6e41..09f30bef3 100644 --- a/gnome/glayout.c +++ b/gnome/glayout.c @@ -26,6 +26,7 @@ #include "setup.h" #include "../vfs/vfs.h" #include "gprefs.h" +#include "gsession.h" #include "listing-iconic.xpm" #include "listing-brief-list.xpm" #include "listing-list.xpm" @@ -333,11 +334,11 @@ gnome_exit (void) GNOME_STOCK_BUTTON_CANCEL, NULL); v = gnome_dialog_run (GNOME_DIALOG (w)); - if (v == 0){ + if (v == 0) { /* * We do not want to be restarted by the session manager now */ - gnome_client_set_restart_style (session_client, GNOME_RESTART_NEVER); + session_set_restart (FALSE); gmc_do_quit (); } } @@ -705,17 +706,19 @@ copy_uiinfo_widgets (GnomeUIInfo *uiinfo, gpointer **dest) WPanel * create_container (Dlg_head *h, char *name, char *geometry) { - PanelContainer *container = g_new (PanelContainer, 1); - WPanel *panel; - GtkWidget *app, *vbox; - int xpos, ypos, width, height; + PanelContainer *container; + WPanel *panel; + GtkWidget *app, *vbox; + int xpos, ypos, width, height; GnomeUIInfo *uiinfo; + char buf[50]; + + container = g_new (PanelContainer, 1); gnome_parse_geometry (geometry, &xpos, &ypos, &width, &height); - + container->splitted = 0; app = gnome_app_new ("gmc", name); - gtk_window_set_wmclass (GTK_WINDOW (app), "gmc", "gmc"); /* Geometry configuration */ if (width != -1 && height != -1) @@ -727,7 +730,13 @@ create_container (Dlg_head *h, char *name, char *geometry) panel = panel_new (name); - + /* Set the unique name for session management */ + + sprintf (buf, "%d", panel->id); + gtk_window_set_wmclass (GTK_WINDOW (app), "gmc", buf); + + /* Create the holder for the contents */ + vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 0); gnome_app_set_contents (GNOME_APP (app), vbox); @@ -739,7 +748,7 @@ create_container (Dlg_head *h, char *name, char *geometry) my_app_create_menus (GNOME_APP (app), uiinfo, panel); copy_uiinfo_widgets (panel_view_menu_uiinfo, &panel->view_menu_items); - + create_new_menu (GNOME_APP (app), panel); panel->ministatus = GNOME_APPBAR(gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_NEVER)); @@ -749,7 +758,7 @@ create_container (Dlg_head *h, char *name, char *geometry) gnome_app_install_menu_hints (GNOME_APP (app), gnome_panel_menu_without_desktop); else gnome_app_install_menu_hints (GNOME_APP (app), gnome_panel_menu_with_desktop); - + gtk_signal_connect (GTK_OBJECT (app), "enter_notify_event", GTK_SIGNAL_FUNC (panel_enter_event), @@ -766,7 +775,7 @@ create_container (Dlg_head *h, char *name, char *geometry) */ panel->widget.wdata = (widget_data) vbox; container->panel = panel; - + containers = g_list_append (containers, container); if (!current_panel_ptr){ @@ -787,7 +796,9 @@ new_panel_with_geometry_at (char *dir, char *geometry) panel = create_container (desktop_dlg, dir, geometry); add_widget (desktop_dlg, panel); set_current_panel (panel); +#if 0 x_flush_events (); +#endif return panel; } diff --git a/gnome/gmain.c b/gnome/gmain.c index 05754d638..542c7c0f5 100644 --- a/gnome/gmain.c +++ b/gnome/gmain.c @@ -21,9 +21,11 @@ #include "panel.h" #include "gscreen.h" #include "gcmd.h" +#include "gcorba.h" +#include "gdesktop.h" +#include "gsession.h" #include "command.h" #include "cmd.h" -#include "gdesktop.h" GdkColorContext *mc_cc; @@ -52,14 +54,15 @@ int dialog_panel_callback (struct Dlg_head *h, int id, int msg); /* The Dlg_head for the whole desktop */ Dlg_head *desktop_dlg; -int run_desktop = 1; - /* Session client */ GnomeClient *session_client; /* Used during argument processing */ extern int finish_program; +/* Whether the gmc server was present or not */ +int corba_have_server = FALSE; + /* This is only used by the editor, so we provide a dummy implementation */ void try_alloc_color_pair (char *str, char *str2) @@ -453,52 +456,48 @@ dialog_panel_callback (struct Dlg_head *h, int id, int msg) return 0; } -extern char *cmdline_geometry; - -typedef struct { - char *dir; char *geometry; -} dir_and_geometry; - -static int -idle_create_panel (void *data) +/* Ugly function to support the hack described in non_corba_create_panels() */ +static gint +idle_destroy_panel (gpointer data) { - dir_and_geometry *dg = data; - - new_panel_with_geometry_at (dg->dir, dg->geometry); - g_free (data); - - return 0; -} - -static int -idle_destroy_window (void *data) -{ - WPanel *panel = data; + WPanel *panel; + panel = data; gnome_close_panel (GTK_WIDGET (panel->widget.wdata), panel); - return 0; + return FALSE; } -/* - * wrapper for new_panel_with_geometry_at. - * first invocation is called directly, further calls use - * the idle handler +/* Initializes the desktop and creates the initial panels. This is to be used + * when we do not have a CORBA server. */ -static WPanel * -create_one_panel (char *dir, char *geometry) +static void +non_corba_create_panels (void) { - static int first = 1; - - if (first){ - first = 0; - return new_panel_with_geometry_at (dir, geometry); - } else { - dir_and_geometry *dg = g_new (dir_and_geometry, 1); - dg->dir = dir; - dg->geometry = geometry; - gtk_idle_add (idle_create_panel, dg); - return NULL; - } + WPanel *panel; + + desktop_init (); + gnome_init_panels (); + + cmdline = command_new (0, 0, 0); + the_hint = label_new (0, 0, 0, NULL); + desktop_dlg = create_dlg (0, 0, 24, 80, 0, + dialog_panel_callback, "[panel]", "midnight", DLG_NO_TED); + + session_load (); + + /* The following is a hack. We have to have at least one panel for + * run_dlg() to be happy. So we destroy it in the idle loop if we + * didn't need it in the first place. This idle function is to be run + * at a higher priority than the one used in session_load(). + */ + + panel = new_panel_at ("."); + gtk_idle_add_priority (GTK_PRIORITY_DEFAULT, idle_destroy_panel, panel); + panel->widget.options |= W_PANEL_HIDDEN; + + run_dlg (desktop_dlg); + + desktop_destroy (); } /* @@ -511,46 +510,14 @@ create_one_panel (char *dir, char *geometry) void create_panels (void) { - WPanel *panel; + if (!corba_have_server) + non_corba_create_panels (); + else { + if (!nowindows) + corba_create_window (); - if (run_desktop) - desktop_init (); - - cmdline = command_new (0, 0, 0); - the_hint = label_new (0, 0, 0, NULL); - - gnome_init_panels (); - - desktop_dlg = create_dlg (0, 0, 24, 80, 0, dialog_panel_callback, "[panel]", "midnight", DLG_NO_TED); - -#if 0 - if (directory_list){ - - for (p = directory_list; p; p = p->next){ - create_one_panel (p->data, cmdline_geometry); - } - panel = NULL; - } else -#endif - { - panel = create_one_panel (".", cmdline_geometry); - - if (nowindows){ - gtk_idle_add (idle_destroy_window, panel); - panel->widget.options |= W_PANEL_HIDDEN; - } + session_set_restart (FALSE); } -#if 0 - g_list_free (directory_list); -#endif - - main_corba_register_server (); - - run_dlg (desktop_dlg); - - /* shutdown gnome specific bits of midnight commander */ - - desktop_destroy (); } void @@ -561,7 +528,7 @@ gmc_do_quit (void) quit = 1; dlg_stop (desktop_dlg); } - +#if 0 static void session_die (void) { @@ -632,7 +599,7 @@ session_management_setup (char *name) GTK_SIGNAL_FUNC (session_die), NULL); } } - +#endif /* * Configures the GtkWindow/GnomeDialog from a WPanel. * @@ -645,3 +612,28 @@ gmc_window_setup_from_panel (GnomeDialog *dialog, WPanel *panel) gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); gnome_dialog_set_parent (dialog, GTK_WINDOW (panel->xwindow)); } + +/** + * gnome_check_super_user: + * @void: + * + * Puts out a warning if the user is running gmc as root. If the user selects + * Cancel, then gmc will terminate. + **/ +void +gnome_check_super_user (void) +{ + GtkWidget *warning_dlg; + GnomeClient *client; + + if (geteuid () != 0) + return; + + warning_dlg = gnome_message_box_new ( + _("You are running the GNOME Midnight Commander as root. \n\n" + "You will not be protected from severly damaging your system."), + GNOME_MESSAGE_BOX_WARNING, + GNOME_STOCK_BUTTON_OK, NULL); + + gnome_dialog_run (GNOME_DIALOG (warning_dlg)); +} diff --git a/gnome/gmain.h b/gnome/gmain.h index 575d3c314..0f0133a05 100644 --- a/gnome/gmain.h +++ b/gnome/gmain.h @@ -10,6 +10,7 @@ void xtoolkit_end (void); extern Dlg_head *desktop_dlg; extern int nowindows; +extern int corba_have_server; /* Required by the standard code */ widget_data xtoolkit_create_dialog (Dlg_head *h, int with_grid); @@ -44,6 +45,8 @@ int gmc_can_view_file (char *filename); int gmc_view (char *filename, int start_line); void x_show_info (WInfo *info, struct my_statfs *s, struct stat *b); void x_create_info (Dlg_head *h, widget_data parent, WInfo *info); +void gnome_check_super_user (void); +gint create_new_menu_from (char *file, GtkWidget *shell, gint pos); /* * stuff from gaction.c @@ -60,7 +63,9 @@ struct gmc_color_pairs_s { }; void gmc_do_quit (void); +#if 0 extern GnomeClient *session_client; +#endif extern struct gmc_color_pairs_s gmc_color_pairs []; #endif diff --git a/gnome/gnome-file-property-dialog.c b/gnome/gnome-file-property-dialog.c index 601d59916..1f594c786 100644 --- a/gnome/gnome-file-property-dialog.c +++ b/gnome/gnome-file-property-dialog.c @@ -434,7 +434,7 @@ static GtkWidget * generate_icon_sel (GnomeFilePropertyDialog *fp_dlg) { GtkWidget *retval; - const gchar *icon; + gchar *icon; retval = gnome_icon_entry_new ("gmc_file_icon", "Select an Icon"); icon = g_strdup (gicon_get_filename_for_icon (fp_dlg->im)); diff --git a/gnome/gnome-open-dialog.c b/gnome/gnome-open-dialog.c index 0ebcce140..d462e5dbc 100644 --- a/gnome/gnome-open-dialog.c +++ b/gnome/gnome-open-dialog.c @@ -17,12 +17,15 @@ * Boston, MA 02111-1307, USA. */ +#include "util.h" #include #include "gnome-open-dialog.h" #include #include #include +#include #include + static void gnome_open_dialog_init (GnomeOpenDialog *open_dialog); static void gnome_open_dialog_class_init (GnomeOpenDialogClass *klass); static void gnome_open_dialog_destroy (GtkObject *object); diff --git a/gnome/gscreen.c b/gnome/gscreen.c index ade910a40..3c81f662d 100644 --- a/gnome/gscreen.c +++ b/gnome/gscreen.c @@ -2022,10 +2022,11 @@ static void panel_tree_check_auto_expand (WPanel *panel, GtkCTreeNode *current) { GtkDTree *dtree = GTK_DTREE (panel->tree); - GtkCList *clist = GTK_CLIST (dtree); GList *tmp_list = dtree->auto_expanded_nodes; - GList *free_list; +#if 0 + GtkCList *clist = GTK_CLIST (dtree); gint row, old_y, new_y; +#endif if (current) { while (tmp_list) { diff --git a/gnome/gtkdtree.c b/gnome/gtkdtree.c index daf90e100..fca47b324 100644 --- a/gnome/gtkdtree.c +++ b/gnome/gtkdtree.c @@ -18,6 +18,7 @@ #include "main.h" #include "treestore.h" #include "gtkdtree.h" +#include "../vfs/vfs.h" #ifdef HACK # define mc_opendir opendir diff --git a/gnome/gtools.c b/gnome/gtools.c index 86bca0217..82d5ad002 100644 --- a/gnome/gtools.c +++ b/gnome/gtools.c @@ -20,26 +20,20 @@ #include "color.h" #include "gmain.h" #include "gwidget.h" + Dlg_head *last_query_dlg; static int sel_pos; -void query_set_sel (int new_sel) +void +query_set_sel (int new_sel) { sel_pos = new_sel; } -static void -pack_button (WButton *button, GtkBox *box) -{ - if (!button) - return; - gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (button->widget.wdata), 0, 0, 0); -} - -int query_dialog (char *header, char *text, int flags, int count, ...) +int +query_dialog (char *header, char *text, int flags, int count, ...) { va_list ap; - WLabel *label; GtkWidget *dialog; int i, result = -1; const gchar **buttons; @@ -94,7 +88,8 @@ int query_dialog (char *header, char *text, int flags, int count, ...) } /* To show nice messages to the users */ -Dlg_head *message (int error, char *header, char *text, ...) +Dlg_head * +message (int error, char *header, char *text, ...) { va_list args; char buffer [4096]; diff --git a/gnome/gwidget.c b/gnome/gwidget.c index ec796c7a1..9c0e42b1b 100644 --- a/gnome/gwidget.c +++ b/gnome/gwidget.c @@ -326,7 +326,9 @@ x_create_input (Dlg_head *h, widget_data parent, WInput *in) void x_update_input (WInput *in) { +#ifdef USE_GNOME_ENTRY GnomeEntry *gnome_entry; +#endif GtkEntry *entry; char *text; int draw = 0; @@ -545,6 +547,7 @@ x_label_set_text (WLabel *label, char *text) gtk_label_set (GTK_LABEL (label->widget.wdata), text); } +#if 0 /* Buttonbar */ static void buttonbar_clicked (GtkWidget *widget, WButtonBar *bb) @@ -563,12 +566,15 @@ buttonbar_clicked (GtkWidget *widget, WButtonBar *bb) } printf ("Mhm, should not happen or The Cow is out\n"); } +#endif int x_create_buttonbar (Dlg_head *h, widget_data parent, WButtonBar *bb) { GtkWidget *hbox; +#if 0 int i; +#endif hbox = gtk_hbox_new (0, 0); #if 0 diff --git a/src/ChangeLog b/src/ChangeLog index 00d781a86..af0fe6d31 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,33 @@ +1999-03-30 Federico Mena Quintero + + * dlg.c (dlg_run_done): Do not call the callback of a NULL current + widget. + + * setup.h: Added missing prototype for setup_init(). + + * filegui.c (check_progress_buttons): Added a missing return + value. + + * dlg.c (remove_widget): Added a missing return value. + + * main.c: Removed the global directory_list variable. + Removed the main_corba_register_server() function. + + * main.h: Removed the global run_desktop variable. + + * panel.h: Now the panel structure has a unique numerical ID used + for session management. + + * screen.c (panel_new): Maintain a unique ID for each panel. + + * main.c (maybe_display_linksdir): Handle display of the desktop + init dir here. + (main): Call gnome_check_super_user(). + (init_corba_with_args): Call corba_init_server(). + + * main.c (init_corba_with_args): Do CORBA initialization here. Also + removed the global force_activation option. + 1999-03-29 Jonathan Blandford * main.c (main): updated message. diff --git a/src/dlg.c b/src/dlg.c index 26552712a..2dc71c445 100644 --- a/src/dlg.c +++ b/src/dlg.c @@ -341,7 +341,7 @@ int remove_widget (Dlg_head *h, void *what) Widget_Item *first, *p; if (!h->current) - return; + return 0; first = p = h->current; @@ -866,7 +866,9 @@ void init_dlg (Dlg_head *h) /* Shutdown the run_dlg */ void dlg_run_done (Dlg_head *h) { - (*h->callback) (h, h->current->dlg_id, DLG_END); + if (h->current) + (*h->callback) (h, h->current->dlg_id, DLG_END); + current_dlg = (Dlg_head *) h->previous_dialog; if (current_dlg){ diff --git a/src/filegui.c b/src/filegui.c index 5cc900614..267088ecf 100644 --- a/src/filegui.c +++ b/src/filegui.c @@ -179,7 +179,7 @@ check_progress_buttons (FileOpContext *ctx) FileOpContextUI *ui; if (ctx->ui == NULL) - return; + return FILE_CONT; ui = ctx->ui; diff --git a/src/main.c b/src/main.c index 9323e702e..51e819642 100644 --- a/src/main.c +++ b/src/main.c @@ -81,7 +81,6 @@ #ifdef HAVE_CORBA # include -# include "gcorba.h" #endif #include @@ -139,6 +138,12 @@ #include "popt.h" +#ifdef HAVE_GNOME +#include "gcorba.h" +#include "gmain.h" +#include "gsession.h" +#endif + /* "$Id$" */ /* When the modes are active, left_panel, right_panel and tree_panel */ @@ -2637,8 +2642,6 @@ static void parse_an_arg (poptContext state, #endif char *cmdline_geometry = NULL; -char **directory_list = NULL; -int force_activation = 0; static struct poptOption argument_table [] = { #ifdef HAVE_GNOME @@ -2715,22 +2718,59 @@ static struct poptOption argument_table [] = { #ifdef HAVE_GNOME { "geometry", '\0', POPT_ARG_STRING, &cmdline_geometry, 0, N_("Geometry for the window"), N_("GEOMETRY")}, {"nowindows", '\0', POPT_ARG_NONE, &nowindows, 0, N_("No windows opened at startup"), NULL}, - {"force-activation",0,POPT_ARG_NONE, &force_activation, 0, N_("Force activation even if a server is already running"), NULL}, {"desktop-linksdir", '\0', POPT_ARG_NONE, &display_linksdir, 0, - N_("Displays the directory that holds the .links startup files")}, + N_("Display the directory that holds the .links startup files and exit")}, #endif { NULL, 0, 0, NULL, 0 } }; -void -main_corba_register_server (void) +/* Convenience function to display the desktop initialization directory and exit */ +static void +maybe_display_linksdir (void) { -#ifdef HAVE_CORBA - corba_register_server (); -#endif + if (display_linksdir) { + puts (DESKTOP_INIT_DIR); + exit (1); + } } +#ifdef HAVE_CORBA +/* Initializes the ORB and does the initial argument processing */ +static void +init_corba_with_args (int *argc, char **argv, poptContext *ctx) +{ + CORBA_Environment ev; + + CORBA_exception_init (&ev); + orb = gnome_CORBA_init_with_popt_table ("gmc", VERSION, argc, argv, argument_table, 0, ctx, + GNORBA_INIT_SERVER_FUNC, &ev); + + maybe_display_linksdir (); + + if (ev._major != CORBA_NO_EXCEPTION) { + CORBA_exception_free (&ev); + g_warning ("Could not initialize CORBA"); + exit (1); + } + + CORBA_exception_free (&ev); + + if (!corba_init_server ()) { + g_warning ("Could not initialize the CORBA server"); + exit (1); + } +} +#endif + +#ifndef HAVE_CORBA +void +corba_create_window (void) +{ + /* nothing */ +} +#endif + static void handle_args (int argc, char *argv []) { @@ -2740,28 +2780,12 @@ handle_args (int argc, char *argv []) #ifdef HAVE_GNOME #ifdef HAVE_CORBA - CORBA_Environment ev; - - CORBA_exception_init (&ev); - orb = gnome_CORBA_init_with_popt_table ( - "gmc", VERSION, &argc, argv, argument_table, 0, &ctx, GNORBA_INIT_SERVER_FUNC, &ev); - - if (display_linksdir){ - puts (DESKTOP_INIT_DIR); - exit (1); - } - - corba_init (); - if (!force_activation) - if (try_to_activate_running_copy ()) - exit (1); + init_corba_with_args (&argc, argv, &ctx); #else gnome_init_with_popt_table ("gmc", VERSION, argc, argv, argument_table, 0, &ctx); #endif - if (display_linksdir){ - puts (DESKTOP_INIT_DIR); - exit (1); - } + maybe_display_linksdir (); + gtk_widget_push_visual (gdk_imlib_get_visual ()); gtk_widget_push_colormap (gdk_imlib_get_colormap ()); @@ -2913,15 +2937,17 @@ int main (int argc, char *argv []) setlocale (LC_ALL, ""); bindtextdomain ("mc", LOCALEDIR); textdomain ("mc"); - - /* This is here to debug the CORBA async invocations */ +#if 0 + /* This is here to debug startup stuff */ { - volatile int i = 1; + volatile int i = 0; + printf ("GMC IS WAITING %d\n", getpid ()); while (!i) ; } +#endif /* Initialize list of all user group for timur_clr_mode */ init_groups (); @@ -2956,7 +2982,7 @@ int main (int argc, char *argv []) mc_tree_store_load (); - session_management_setup (argv [0]); + session_init (); probably_finish_program (); #endif @@ -3065,17 +3091,11 @@ int main (int argc, char *argv []) if (alternate_plus_minus) application_keypad_mode (); # endif -/* INSERT ROOT DIALOG HERE */ + #ifdef HAVE_GNOME - if (geteuid () == 0) { - GtkWidget *warning_dlg; - warning_dlg = gnome_message_box_new (_("You are running the GNOME Midnight Commander as root. \n\n" - "You will not be protected from severly damaging your system.") - GNOME_MESSAGE_BOX_WARNING, - GNOME_STOCK_BUTTON_OK, NULL); - gnome_dialog_run (GNOME_DIALOG (warning_dlg)); - } + gnome_check_super_user (); #endif + if (show_change_notice){ message (1, _(" Notice "), _(" The Midnight Commander configuration files \n" diff --git a/src/main.h b/src/main.h index 0835f0f03..f84bd5871 100644 --- a/src/main.h +++ b/src/main.h @@ -99,7 +99,7 @@ extern int output_starts_shell; extern int midnight_shutdown; extern char search_buffer [256]; extern char cmd_buf [512]; -extern int run_desktop; +extern char *cmdline_geometry; #if HAVE_GNOME #define MENU_PANEL get_current_panel () @@ -188,8 +188,6 @@ void done_menu (void); void init_menu (void); void exec_shell (void); -void main_corba_register_server (void); - #ifdef OS2_NT # define MC_BASE "" #else diff --git a/src/panel.h b/src/panel.h index 9c48a8831..09e811ead 100644 --- a/src/panel.h +++ b/src/panel.h @@ -158,6 +158,9 @@ typedef struct { int dragging; + /* Unique numerical ID for session management */ + int id; + /* Used for scrolling nicely during drags */ int timer_id; int drag_motion_x; diff --git a/src/screen.c b/src/screen.c index 657ec0a4d..614706d93 100644 --- a/src/screen.c +++ b/src/screen.c @@ -955,12 +955,15 @@ void directory_history_add (WPanel * panel, char *s); WPanel * panel_new (char *panel_name) { +#ifdef HAVE_GNOME + static int panel_id = 0; +#endif WPanel *panel; char *section; int i, err; panel = g_new0 (WPanel, 1); - + /* No know sizes of the panel at startup */ init_widget (&panel->widget, 0, 0, 0, 0, (callback_fn) panel_callback, (destroy_fn) panel_destroy, @@ -968,7 +971,7 @@ panel_new (char *panel_name) /* We do not want the cursor */ widget_want_cursor (panel->widget, 0); - + mc_get_current_wd (panel->cwd, sizeof (panel->cwd)-2); strcpy (panel->lwd, "."); @@ -995,14 +998,15 @@ panel_new (char *panel_name) panel->format_modified = 1; #ifdef HAVE_GNOME panel->is_a_desktop_panel = FALSE; + panel->id = panel_id++; #endif - + panel->panel_name = g_strdup (panel_name); panel->user_format = g_strdup (DEFAULT_USER_FORMAT); - + for(i = 0; i < LIST_TYPES; i++) panel->user_status_format [i] = g_strdup (DEFAULT_USER_FORMAT); - + panel->search_buffer [0] = 0; panel->frame_size = frame_half; section = g_strconcat ("Temporal:", panel->panel_name, NULL); @@ -1026,7 +1030,7 @@ panel_new (char *panel_name) } set_panel_formats (panel); } - + /* Load the default format */ panel->count = do_load_dir (&panel->dir, panel->sort_type, panel->reverse, panel->case_sensitive, panel->filter); diff --git a/src/setup.h b/src/setup.h index f9e6a03aa..0e24c129f 100644 --- a/src/setup.h +++ b/src/setup.h @@ -1,6 +1,7 @@ #ifndef __SETUP_H #define __SETUP_H +char *setup_init (void); void save_layout (void); void save_configure (void); void load_setup (void); diff --git a/vfs/ChangeLog b/vfs/ChangeLog index 4fda2c07d..dfeab2285 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,19 @@ +1999-03-30 Federico Mena Quintero + + * vfs.c (vfs_add_current_stamps): Only do stamping of the panels + if they exist. + + * mcserv.c: #include + (get_client): Put `#ifdef __EMX__' around an otherwise-unused + variable. + + * utilvfs.c (vfs_split_url): Fix NULL <-> 0 confusion when + comparing characters. + + * ftpfs.c (retrieve_dir): Removed unused variable dot_dot_found. + + * extfs.c (extfs_init): Assign `key' to c, not `&key'. + Sun Mar 28 23:50:47 1999 Norbert Warmuth * vfs.h (vfs_translate_url): Fixed the macro which is used when diff --git a/vfs/extfs.c b/vfs/extfs.c index baffd0418..46ad4395a 100644 --- a/vfs/extfs.c +++ b/vfs/extfs.c @@ -918,12 +918,12 @@ static int extfs_init (vfs *me) if ((c = strchr (key, '\n'))){ *c = 0; - c = &key [strlen (key)-1]; + c = &key [strlen (key) - 1]; } else { - c = &key; + c = key; } - extfs_need_archive [extfs_no] = !(*c==':'); - if (*c==':') + extfs_need_archive [extfs_no] = !(*c == ':'); + if (*c == ':') *c = 0; if (!(*key)) continue; diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index 9aedb3976..16a20be7f 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -1292,7 +1292,6 @@ retrieve_dir(struct connection *bucket, char *remote_path, int resolve_symlinks) struct dir *dcache; int got_intr = 0; int dot_found = 0; - int dot_dot_found = 0; int has_spaces = (strchr (remote_path, ' ') != NULL); canonicalize_pathname (remote_path); diff --git a/vfs/mcserv.c b/vfs/mcserv.c index 379e04a17..a5e9e95c6 100644 --- a/vfs/mcserv.c +++ b/vfs/mcserv.c @@ -63,6 +63,7 @@ #endif #include #include +#include #include #include #ifdef SCO_FLAVOR @@ -1109,7 +1110,9 @@ char *get_client (int portnum) struct hostent *hp; char hostname [255]; int yes = 1; +#ifdef __EMX__ char *me; +#endif if ((sock = socket (AF_INET, SOCK_STREAM, 0)) < 0) return "Can't create socket"; diff --git a/vfs/utilvfs.c b/vfs/utilvfs.c index 9555e7ba5..41a5fa179 100644 --- a/vfs/utilvfs.c +++ b/vfs/utilvfs.c @@ -102,7 +102,7 @@ char *vfs_split_url (char *path, char **host, char **user, int *port, char **pas else *pass = g_strdup (inner_colon); } - if (*pcopy != NULL) + if (*pcopy != 0) *user = g_strdup (pcopy); else default_is_anon = 0; diff --git a/vfs/vfs.c b/vfs/vfs.c index d9bd1850c..28953bdcb 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -865,10 +865,16 @@ void vfs_add_current_stamps (void) { vfs_stamp_path (current_dir); - if (get_current_type () == view_listing) - vfs_stamp_path (cpanel->cwd); - if (get_other_type () == view_listing) - vfs_stamp_path (opanel->cwd); + + if (cpanel) { + if (get_current_type () == view_listing) + vfs_stamp_path (cpanel->cwd); + } + + if (opanel) { + if (get_other_type () == view_listing) + vfs_stamp_path (opanel->cwd); + } } #endif