? a
Index: terminal-screen.c
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal-screen.c,v
retrieving revision 1.74
diff -U5 -r1.74 terminal-screen.c
--- terminal-screen.c	24 Apr 2003 14:43:28 -0000	1.74
+++ terminal-screen.c	23 Jun 2003 00:41:39 -0000
@@ -156,15 +156,13 @@
 }
 
 static void
 terminal_screen_init (TerminalScreen *screen)
 {
-  char buf[PATH_MAX+1];
-  
   screen->priv = g_new0 (TerminalScreenPrivate, 1);
 
-  screen->priv->working_dir = g_strdup (getcwd (buf, sizeof (buf)));
+  screen->priv->working_dir = g_get_current_dir ();
   if (screen->priv->working_dir == NULL) /* shouldn't ever happen */
     screen->priv->working_dir = g_strdup (g_get_home_dir ());
   screen->priv->child_pid = -1;
 
   screen->priv->recheck_working_dir_idle = 0;
Index: terminal.c
===================================================================
RCS file: /cvs/gnome/gnome-terminal/src/terminal.c,v
retrieving revision 1.57
diff -U5 -r1.57 terminal.c
--- terminal.c	2 Apr 2003 19:17:58 -0000	1.57
+++ terminal.c	23 Jun 2003 00:41:45 -0000
@@ -1281,11 +1281,11 @@
         }
     }
 }
 
 static int
-new_terminal_with_options (OptionParsingResults *results)
+new_terminal_with_options (OptionParsingResults *results, const char *default_working_dir)
 {
   GList *tmp;
   
   tmp = results->initial_windows;
   while (tmp != NULL)
@@ -1337,11 +1337,11 @@
                                          iw->force_menubar_state,
                                          iw->menubar_state,
                                          it->exec_argv,
                                          iw->geometry,
                                          it->title,
-                                         it->working_dir,
+                                         it->working_dir ? it->working_dir : default_working_dir,
                                          iw->role,
                                          it->zoom_set ?
                                          it->zoom : 1.0,
                                          results->startup_id,
                                          results->display_name,
@@ -1356,11 +1356,11 @@
                                          current_window,
                                          FALSE, FALSE,
                                          it->exec_argv,
                                          NULL,
                                          it->title,
-                                         it->working_dir,
+                                         it->working_dir ? it->working_dir : default_working_dir,
                                          NULL,
                                          it->zoom_set ?
                                          it->zoom : 1.0,
                                          NULL, NULL, -1);
             }
@@ -1571,11 +1571,11 @@
 
   g_signal_connect (G_OBJECT (sm_client), "die",
                     G_CALLBACK (client_die_cb),
                     NULL);
 
-  if (new_terminal_with_options (results))
+  if (new_terminal_with_options (results, NULL))
     return 1;
 
   option_parsing_results_free (results);
   results = NULL;
 
@@ -3226,11 +3226,11 @@
   while (tmp != NULL)
     {
       GList *tabs;
       GList *tmp2;
       TerminalWindow *window = tmp->data;
-      TerminalWindow *active_screen;
+      TerminalScreen *active_screen;
 
       active_screen = terminal_window_get_active (window);
       
       tabs = terminal_window_list_screens (window);
 
@@ -3511,15 +3511,17 @@
 
 typedef struct
 {
   int argc;
   char **argv;
+  char *working_dir;
 } NewTerminalEvent;
 
 static void
 handle_new_terminal_event (int          argc,
-                           char       **argv)
+                           char       **argv,
+                           char        *working_dir)
 {
   int nextopt;
   poptContext ctx;
   const void *store;
   OptionParsingResults *results;
@@ -3554,11 +3556,11 @@
 	       poptStrerror (nextopt));
 
   poptFreeContext (ctx);
   options[0].descrip = store;
 
-  new_terminal_with_options (results);
+  new_terminal_with_options (results, working_dir);
 
   option_parsing_results_free (results);
 }
 
 static void
@@ -3567,13 +3569,14 @@
   while (pending_new_terminal_events != NULL)
     {
       GSList *next = pending_new_terminal_events->next;
       NewTerminalEvent *event = pending_new_terminal_events->data;
 
-      handle_new_terminal_event (event->argc, event->argv);
+      handle_new_terminal_event (event->argc, event->argv, event->working_dir);
 
       g_strfreev (event->argv);
+      g_free (event->working_dir);
       g_free (event);
       g_slist_free_1 (pending_new_terminal_events);
       pending_new_terminal_events = next;
     }
 }
@@ -3603,22 +3606,23 @@
     }
 
   args = any->_value;
   
   tmp_argv = g_new0 (char*, args->_length + 1);
-  i = 0;
+  i = 1;
   while (i < args->_length)
     {
-      tmp_argv[i] = g_strdup (((const char**)args->_buffer)[i]);
+      tmp_argv[i-1] = g_strdup (((const char**)args->_buffer)[i]);
       ++i;
     }
   tmp_argv[i] = NULL;
-  tmp_argc = i;
+  tmp_argc = i-1;
 
   event = g_new0 (NewTerminalEvent, 1);
   event->argc = tmp_argc;
   event->argv = tmp_argv;
+  event->working_dir = g_strdup (((const char**)args->_buffer)[0]);
 
   pending_new_terminal_events = g_slist_append (pending_new_terminal_events,
                                                 event);
 
   if (initialization_complete)
@@ -3675,27 +3679,32 @@
     ACT_IID, Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, NULL, NULL);
 
   if (listener != CORBA_OBJECT_NIL)
     {
       int i;
+      char *dir;
       CORBA_any any;
       CORBA_sequence_CORBA_string args;
       CORBA_Environment ev;
 
       CORBA_exception_init (&ev);
 
       any._type = TC_CORBA_sequence_CORBA_string;
       any._value = &args;
 
-      args._length = argc;
-      args._buffer = g_newa (CORBA_char *, args._length);
+      args._length = argc + 1;
+      args._buffer = g_newa (CORBA_char *, args._length + 1);
+
+      dir = g_get_current_dir ();
 
+      args._buffer[0] = dir;
       for (i = 0; i < args._length; i++)
-        args._buffer [i] = argv [i];
+        args._buffer [i+1] = argv [i];
       
       Bonobo_Listener_event (listener, "new_terminal", &any, &ev);
       CORBA_Object_release (listener, &ev);
+      g_free (dir);
       if (!BONOBO_EX (&ev))
         return TRUE;
 
       CORBA_exception_free (&ev);
     }
