[Usability] custom workdir for gnome-terminal



Hi list,

in my daily use I miss the chance to assign a custom start working
directory for the gnome-terminal (-tab).
Neither the working-directory switch nor the custom command line help to
open a profiled session with my custom working directory.

I want something like:

gnome-terminal --tab-with-profile="src" --tab-with-profile="testsuite"
--tab-with-profile="work"

with src in /home/user/src, testsuite in /home/user/testsuite ...

I attach a patch that satisfies my needs.  And now my question:
Is there anybody out there with the same needs? Is my wish too special
or can I hope that this patch will be applied?

The patch is not perfect (the right words for the labels must be found,
translation, ...) but I can put some work in it if there is a chance for
general acceptance.

Mario.


diff -Nur gnome-terminal-2.16.1/po/de.po my_gnome-terminal-2.16.1/po/de.po
--- gnome-terminal-2.16.1/po/de.po	2006-06-15 17:08:32.000000000 +0200
+++ my_gnome-terminal-2.16.1/po/de.po	2007-09-11 15:06:31.872835000 +0200
@@ -361,6 +361,9 @@
 msgid "Custom co_mmand:"
 msgstr "_Benutzerdefinierter Befehl:"
 
+msgid "Custom base_dir:"
+msgstr "_Benutzerdefinierter Pfad:"
+
 #: ../src/gnome-terminal.glade2.h:35
 msgid "Disable all me_nu access keys (such as Alt+f to open File menu)"
 msgstr ""
diff -Nur gnome-terminal-2.16.1/po/en_GB.po my_gnome-terminal-2.16.1/po/en_GB.po
--- gnome-terminal-2.16.1/po/en_GB.po	2006-09-10 11:52:56.000000000 +0200
+++ my_gnome-terminal-2.16.1/po/en_GB.po	2007-09-11 15:04:43.466458000 +0200
@@ -381,6 +381,9 @@
 msgid "Custom co_mmand:"
 msgstr "Custom co_mmand:"
 
+msgid "Custom base_dir:"
+msgstr "Custom base_dir:"
+
 #: ../src/gnome-terminal.glade2.h:35
 msgid "Disable all me_nu access keys (such as Alt+f to open File menu)"
 msgstr "Disable all me_nu access keys (such as Alt+f to open File menu)"
diff -Nur gnome-terminal-2.16.1/src/gnome-terminal.glade2 my_gnome-terminal-2.16.1/src/gnome-terminal.glade2
--- gnome-terminal-2.16.1/src/gnome-terminal.glade2	2006-02-01 19:58:00.000000000 +0100
+++ my_gnome-terminal-2.16.1/src/gnome-terminal.glade2	2007-09-11 14:40:50.438587000 +0200
@@ -1474,7 +1483,7 @@
 	    <widget class="GtkTable" id="table20">
 	      <property name="border_width">12</property>
 	      <property name="visible">True</property>
-	      <property name="n_rows">2</property>
+	      <property name="n_rows">3</property>
 	      <property name="n_columns">1</property>
 	      <property name="homogeneous">False</property>
 	      <property name="row_spacing">18</property>
@@ -2058,6 +2069,236 @@
 		  <property name="y_options">fill</property>
 		</packing>
 	      </child>
+
+	      <child>
+		<widget class="GtkVBox" id="vbox88">
+		  <property name="visible">True</property>
+		  <property name="homogeneous">False</property>
+		  <property name="spacing">6</property>
+
+		  <child>
+		    <widget class="GtkLabel" id="label479">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">&lt;b&gt;Basedir&lt;/b&gt;</property>
+		      <property name="use_underline">False</property>
+		      <property name="use_markup">True</property>
+		      <property name="justify">GTK_JUSTIFY_LEFT</property>
+		      <property name="wrap">False</property>
+		      <property name="selectable">False</property>
+		      <property name="xalign">0</property>
+		      <property name="yalign">0.5</property>
+		      <property name="xpad">0</property>
+		      <property name="ypad">0</property>
+		      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		      <property name="width_chars">-1</property>
+		      <property name="single_line_mode">False</property>
+		      <property name="angle">0</property>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">False</property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkHBox" id="hbox28">
+		      <property name="visible">True</property>
+		      <property name="homogeneous">False</property>
+		      <property name="spacing">0</property>
+
+		      <child>
+			<widget class="GtkLabel" id="label480">
+			  <property name="visible">True</property>
+			  <property name="label" translatable="yes">    </property>
+			  <property name="use_underline">False</property>
+			  <property name="use_markup">False</property>
+			  <property name="justify">GTK_JUSTIFY_LEFT</property>
+			  <property name="wrap">False</property>
+			  <property name="selectable">False</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xpad">0</property>
+			  <property name="ypad">0</property>
+			  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+			  <property name="width_chars">-1</property>
+			  <property name="single_line_mode">False</property>
+			  <property name="angle">0</property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkVBox" id="vbox89">
+			  <property name="visible">True</property>
+			  <property name="homogeneous">False</property>
+			  <property name="spacing">0</property>
+
+			  <child>
+			    <widget class="GtkTable" id="table35">
+			      <property name="visible">True</property>
+			      <property name="n_rows">4</property>
+			      <property name="n_columns">2</property>
+			      <property name="homogeneous">False</property>
+			      <property name="row_spacing">6</property>
+			      <property name="column_spacing">12</property>
+
+			      <child>
+				<widget class="GtkAlignment" id="alignment10104">
+				  <property name="visible">True</property>
+				  <property name="xalign">1.49012002737e-08</property>
+				  <property name="yalign">0.5</property>
+				  <property name="xscale">0</property>
+				  <property name="yscale">1</property>
+				  <property name="top_padding">0</property>
+				  <property name="bottom_padding">0</property>
+				  <property name="left_padding">0</property>
+				  <property name="right_padding">0</property>
+
+				  <child>
+				    <widget class="GtkCheckButton" id="use-custom-basedir-checkbutton">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="label" translatable="yes">_Start from Dir insted of $HOME</property>
+				      <property name="use_underline">True</property>
+				      <property name="relief">GTK_RELIEF_NORMAL</property>
+				      <property name="focus_on_click">True</property>
+				      <property name="active">False</property>
+				      <property name="inconsistent">False</property>
+				      <property name="draw_indicator">True</property>
+				    </widget>
+				  </child>
+				</widget>
+				<packing>
+				  <property name="left_attach">0</property>
+				  <property name="right_attach">2</property>
+				  <property name="top_attach">2</property>
+				  <property name="bottom_attach">3</property>
+				  <property name="y_options"></property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkEntry" id="custom-basedir-entry">
+				  <property name="visible">True</property>
+				  <property name="can_focus">True</property>
+				  <property name="editable">True</property>
+				  <property name="visibility">True</property>
+				  <property name="max_length">0</property>
+				  <property name="text" translatable="yes"></property>
+				  <property name="has_frame">True</property>
+				  <property name="invisible_char">â??</property>
+				  <property name="activates_default">False</property>
+				</widget>
+				<packing>
+				  <property name="left_attach">1</property>
+				  <property name="right_attach">2</property>
+				  <property name="top_attach">3</property>
+				  <property name="bottom_attach">4</property>
+				  <property name="y_options"></property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkHBox" id="hbox29">
+				  <property name="visible">True</property>
+				  <property name="homogeneous">False</property>
+				  <property name="spacing">0</property>
+
+				  <child>
+				    <widget class="GtkLabel" id="label482">
+				      <property name="visible">True</property>
+				      <property name="label" translatable="yes">    </property>
+				      <property name="use_underline">False</property>
+				      <property name="use_markup">False</property>
+				      <property name="justify">GTK_JUSTIFY_LEFT</property>
+				      <property name="wrap">False</property>
+				      <property name="selectable">False</property>
+				      <property name="xalign">0.5</property>
+				      <property name="yalign">0.5</property>
+				      <property name="xpad">0</property>
+				      <property name="ypad">0</property>
+				      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+				      <property name="width_chars">-1</property>
+				      <property name="single_line_mode">False</property>
+				      <property name="angle">0</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkLabel" id="custom-basedir-entry-label">
+				      <property name="visible">True</property>
+				      <property name="label" translatable="yes">Custom base_dir:</property>
+				      <property name="use_underline">True</property>
+				      <property name="use_markup">False</property>
+				      <property name="justify">GTK_JUSTIFY_CENTER</property>
+				      <property name="wrap">False</property>
+				      <property name="selectable">False</property>
+				      <property name="xalign">0</property>
+				      <property name="yalign">0.5</property>
+				      <property name="xpad">0</property>
+				      <property name="ypad">0</property>
+				      <property name="mnemonic_widget">custom-command-entry</property>
+				      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+				      <property name="width_chars">-1</property>
+				      <property name="single_line_mode">False</property>
+				      <property name="angle">0</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+				</widget>
+				<packing>
+				  <property name="left_attach">0</property>
+				  <property name="right_attach">1</property>
+				  <property name="top_attach">3</property>
+				  <property name="bottom_attach">4</property>
+				  <property name="x_options">fill</property>
+				  <property name="y_options">fill</property>
+				</packing>
+			      </child>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">True</property>
+			      <property name="fill">True</property>
+			    </packing>
+			  </child>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">True</property>
+			  <property name="fill">True</property>
+			</packing>
+		      </child>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">True</property>
+		      <property name="fill">True</property>
+		    </packing>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">2</property>
+		  <property name="bottom_attach">3</property>
+		  <property name="x_options">fill</property>
+		</packing>
+	      </child>
 	    </widget>
 	    <packing>
 	      <property name="tab_expand">False</property>
diff -Nur gnome-terminal-2.16.1/src/profile-editor.c my_gnome-terminal-2.16.1/src/profile-editor.c
--- gnome-terminal-2.16.1/src/profile-editor.c	2006-09-22 22:50:02.000000000 +0200
+++ my_gnome-terminal-2.16.1/src/profile-editor.c	2007-09-11 14:12:35.799183000 +0200
@@ -116,6 +116,10 @@
                                                               TerminalProfile *profile);
 static void       profile_editor_update_custom_command       (GtkWidget       *widget,
                                                               TerminalProfile *profile);
+static void       profile_editor_update_use_custom_basedir   (GtkWidget       *widget,
+                                                              TerminalProfile *profile);
+static void       profile_editor_update_custom_basedir       (GtkWidget       *widget,
+                                                              TerminalProfile *profile);
 static void       profile_editor_update_palette              (GtkWidget       *widget,
                                                               TerminalProfile *profile);
 static void       profile_editor_update_x_font               (GtkWidget       *widget,
@@ -309,6 +313,12 @@
   if (mask->custom_command)
     profile_editor_update_custom_command (editor, profile);
 
+  if (mask->use_custom_basedir)
+    profile_editor_update_use_custom_basedir (editor, profile);
+
+  if (mask->custom_basedir)
+    profile_editor_update_custom_basedir (editor, profile);
+
   if (mask->palette)
     profile_editor_update_palette (editor, profile);
 
@@ -597,6 +607,27 @@
 }
 
 static void
+use_custom_basedir_toggled (GtkWidget       *checkbutton,
+                            TerminalProfile *profile)
+{
+  terminal_profile_set_use_custom_basedir (profile,
+                                           gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)));
+}
+
+static void
+custom_basedir_changed (GtkWidget       *entry,
+                        TerminalProfile *profile)
+{
+  char *text;
+
+  text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
+
+  terminal_profile_set_custom_basedir (profile, text);
+
+  g_free (text);
+}
+
+static void
 palette_scheme_changed (GtkWidget       *combo_box,
                       TerminalProfile *profile)
 {
@@ -1126,6 +1157,18 @@
                         G_CALLBACK (custom_command_changed),
                         profile);
 
+      w = glade_xml_get_widget (xml, "use-custom-basedir-checkbutton");
+      profile_editor_update_use_custom_basedir (editor, profile);
+      g_signal_connect (G_OBJECT (w), "toggled",
+                        G_CALLBACK (use_custom_basedir_toggled),
+                        profile);
+
+      w = glade_xml_get_widget (xml, "custom-basedir-entry");
+      profile_editor_update_custom_basedir (editor, profile);
+      g_signal_connect (G_OBJECT (w), "changed",
+                        G_CALLBACK (custom_basedir_changed),
+                        profile);
+
       w = glade_xml_get_widget (xml, "palette-combobox");
       g_assert (w);
       init_palette_scheme_menu (w);
@@ -1357,6 +1400,17 @@
   gtk_widget_set_sensitive (w,
                             !((mask->custom_command) ||
                               !terminal_profile_get_use_custom_command (profile))); 
+
+  w = profile_editor_get_widget (editor, "custom-basedir-entry");
+  gtk_widget_set_sensitive (w,
+                            !((mask->custom_basedir) ||
+                              !terminal_profile_get_use_custom_basedir (profile))); 
+
+  w = profile_editor_get_widget (editor, "custom-basedir-entry-label");
+  gtk_widget_set_sensitive (w,
+                            !((mask->custom_basedir) ||
+                              !terminal_profile_get_use_custom_basedir (profile))); 
+
   if (terminal_profile_get_background_type (profile) == TERMINAL_BACKGROUND_IMAGE)
     {
       w = profile_editor_get_widget (editor, "background-image-filechooser");
@@ -1500,6 +1554,9 @@
   set_insensitive (editor, "use-custom-command-checkbutton",
                    mask->use_custom_command);
 
+  set_insensitive (editor, "use-custom-basedir-checkbutton",
+                   mask->use_custom_basedir);
+
   set_insensitive (editor, "palette-combobox",
                    mask->palette);
 
@@ -1850,6 +1907,55 @@
     }            
 }
 
+
+static void
+profile_editor_update_use_custom_basedir (GtkWidget       *editor,
+                                          TerminalProfile *profile)
+{
+  GtkWidget *w;
+
+  w = profile_editor_get_widget (editor, "use-custom-basedir-checkbutton");
+  
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
+                               terminal_profile_get_use_custom_basedir (profile));
+
+}
+
+static void
+profile_editor_update_custom_basedir (GtkWidget       *editor,
+                                      TerminalProfile *profile)
+{
+  GtkWidget *w;
+  const char *basedir;
+
+  w = profile_editor_get_widget (editor, "custom-basedir-entry");
+
+  basedir = terminal_profile_get_custom_basedir (profile);
+  
+  entry_set_text_if_changed (GTK_ENTRY (w), basedir);
+
+  /* FIXME get error from this and display it in a tooltip
+   * or label
+   */
+  if (g_shell_parse_argv (basedir, NULL, NULL, NULL))
+    {
+      GtkRcStyle *mod;
+
+      mod = gtk_widget_get_modifier_style (w);
+      if (mod)
+        mod->color_flags[GTK_STATE_NORMAL] &= ~GTK_RC_TEXT;
+
+      gtk_widget_modify_style (w, mod);
+      /* caution, mod destroyed at this point */
+    }
+  else
+    {
+      GdkColor color;
+      gdk_color_parse ("red", &color);
+      gtk_widget_modify_text (w, GTK_STATE_NORMAL, &color);
+    }            
+}
+
 static void
 profile_editor_update_palette (GtkWidget       *editor,
                                TerminalProfile *profile)
diff -Nur gnome-terminal-2.16.1/src/terminal-profile.c my_gnome-terminal-2.16.1/src/terminal-profile.c
--- gnome-terminal-2.16.1/src/terminal-profile.c	2006-09-22 22:50:04.000000000 +0200
+++ my_gnome-terminal-2.16.1/src/terminal-profile.c	2007-09-11 13:04:41.484684000 +0200
@@ -57,6 +57,8 @@
 #define KEY_UPDATE_RECORDS "update_records"
 #define KEY_USE_CUSTOM_COMMAND "use_custom_command"
 #define KEY_CUSTOM_COMMAND "custom_command"
+#define KEY_USE_CUSTOM_BASEDIR "use_custom_basedir"
+#define KEY_CUSTOM_BASEDIR "custom_basedir"
 #define KEY_ICON "icon"
 #define KEY_PALETTE "palette"
 #define KEY_X_FONT "x_font"
@@ -97,6 +99,7 @@
   int scrollback_lines;
   TerminalExitAction exit_action;
   char *custom_command;
+  char *custom_basedir;
 
   char *icon_file;
   GdkPixbuf *icon;
@@ -126,6 +129,7 @@
   guint login_shell : 1;
   guint update_records : 1;
   guint use_custom_command : 1;
+  guint use_custom_basedir : 1;
   guint scroll_background : 1;
   guint use_theme_colors : 1;
   guint use_system_font : 1;
@@ -281,6 +285,7 @@
   profile->priv->allow_bold = TRUE;
   profile->priv->word_chars = g_strdup ("");
   profile->priv->custom_command = g_strdup ("");
+  profile->priv->custom_basedir = g_strdup ("");
   profile->priv->icon_file = g_strdup ("gnome-terminal.png");
   memcpy (profile->priv->palette,
           terminal_palette_linux,
@@ -974,6 +979,61 @@
   g_free (key);
 }
 
+
+gboolean
+terminal_profile_get_use_custom_basedir (TerminalProfile *profile)
+{
+  g_return_val_if_fail (TERMINAL_IS_PROFILE (profile), FALSE);
+
+  return profile->priv->use_custom_basedir;
+}
+
+void
+terminal_profile_set_use_custom_basedir (TerminalProfile *profile,
+                                         gboolean         setting)
+{
+  char *key;
+
+  RETURN_IF_NOTIFYING (profile);
+  
+  key = gconf_concat_dir_and_key (profile->priv->profile_dir,
+                                  KEY_USE_CUSTOM_BASEDIR);
+  
+  gconf_client_set_bool (profile->priv->conf,
+                         key,
+                         setting,
+                         NULL);
+
+  g_free (key);
+}
+
+const char*
+terminal_profile_get_custom_basedir (TerminalProfile *profile)
+{
+  g_return_val_if_fail (TERMINAL_IS_PROFILE (profile), NULL);
+
+  return profile->priv->custom_basedir;
+}
+
+void
+terminal_profile_set_custom_basedir (TerminalProfile *profile,
+                                     const char      *basedir)
+{
+  char *key;
+
+  RETURN_IF_NOTIFYING (profile);
+  
+  key = gconf_concat_dir_and_key (profile->priv->profile_dir,
+                                  KEY_CUSTOM_BASEDIR);
+  
+  gconf_client_set_string (profile->priv->conf,
+                           key,
+                           basedir,
+                           NULL);
+
+  g_free (key);
+}
+
 const char*
 terminal_profile_get_icon_file (TerminalProfile *profile)
 {
@@ -1707,6 +1767,25 @@
 }
 
 static gboolean
+set_custom_basedir (TerminalProfile *profile,
+                    const char      *candidate_basedir)
+{
+  if (candidate_basedir &&
+      strcmp (profile->priv->custom_basedir, candidate_basedir) == 0)
+    return FALSE;
+
+  if (candidate_basedir != NULL)
+    {
+      g_free (profile->priv->custom_basedir);
+      profile->priv->custom_basedir = g_strdup (candidate_basedir);
+      return TRUE;
+    }
+  /* otherwise just leave the old basedir */
+
+  return FALSE;
+}
+
+static gboolean
 set_icon_file (TerminalProfile *profile,
                const char      *candidate_file)
 {
@@ -1991,6 +2070,8 @@
   UPDATE_BOOLEAN (KEY_UPDATE_RECORDS,       update_records);
   UPDATE_BOOLEAN (KEY_USE_CUSTOM_COMMAND,   use_custom_command);
   UPDATE_STRING  (KEY_CUSTOM_COMMAND,       custom_command);
+  UPDATE_BOOLEAN (KEY_USE_CUSTOM_BASEDIR,   use_custom_basedir);
+  UPDATE_STRING  (KEY_CUSTOM_BASEDIR,       custom_basedir);
   UPDATE_STRING  (KEY_ICON,                 icon_file);
   UPDATE_STRING  (KEY_PALETTE,              palette);
   UPDATE_STRING  (KEY_X_FONT,               x_font);
@@ -2138,6 +2219,8 @@
      UPDATE_BOOLEAN (KEY_UPDATE_RECORDS,         update_records,         FALSE);
      UPDATE_BOOLEAN (KEY_USE_CUSTOM_COMMAND,     use_custom_command,     FALSE);
      UPDATE_STRING  (KEY_CUSTOM_COMMAND,         custom_command,         NULL);
+     UPDATE_BOOLEAN (KEY_USE_CUSTOM_BASEDIR,     use_custom_basedir,     FALSE);
+     UPDATE_STRING  (KEY_CUSTOM_BASEDIR,         custom_basedir,         NULL);
      UPDATE_STRING  (KEY_ICON,                   icon_file,              NULL);
      UPDATE_STRING  (KEY_PALETTE,                palette,                NULL);
      UPDATE_STRING  (KEY_X_FONT,                 x_font,                 NULL);
@@ -2792,6 +2875,26 @@
 
   g_free (key);
   key = gconf_concat_dir_and_key (profile_dir,
+                                  KEY_USE_CUSTOM_BASEDIR);
+
+  gconf_client_set_bool (base_profile->priv->conf,
+                         key,
+                         base_profile->priv->use_custom_basedir,
+                         &err);
+
+  BAIL_OUT_CHECK ();
+
+
+  g_free (key);
+  key = gconf_concat_dir_and_key (profile_dir,
+                                  KEY_CUSTOM_BASEDIR);
+  gconf_client_set_string (base_profile->priv->conf,
+                           key, base_profile->priv->custom_basedir,
+                           &err);
+  BAIL_OUT_CHECK ();
+
+  g_free (key);
+  key = gconf_concat_dir_and_key (profile_dir,
                                   KEY_ICON);
   gconf_client_set_string (base_profile->priv->conf,
                            key, base_profile->priv->icon_file,
diff -Nur gnome-terminal-2.16.1/src/terminal-profile.h my_gnome-terminal-2.16.1/src/terminal-profile.h
--- gnome-terminal-2.16.1/src/terminal-profile.h	2006-09-22 22:50:04.000000000 +0200
+++ my_gnome-terminal-2.16.1/src/terminal-profile.h	2007-09-11 13:13:41.064357000 +0200
@@ -53,6 +53,8 @@
   unsigned int update_records : 1;
   unsigned int use_custom_command : 1;
   unsigned int custom_command : 1;
+  unsigned int use_custom_basedir : 1;
+  unsigned int custom_basedir : 1;
   unsigned int icon_file : 1;
   unsigned int is_default : 1;
   unsigned int palette : 1;
@@ -167,6 +169,8 @@
 gboolean                  terminal_profile_get_update_records       (TerminalProfile *profile);
 gboolean                  terminal_profile_get_use_custom_command   (TerminalProfile *profile);
 const char*               terminal_profile_get_custom_command       (TerminalProfile *profile);
+gboolean                  terminal_profile_get_use_custom_basedir   (TerminalProfile *profile);
+const char*               terminal_profile_get_custom_basedir       (TerminalProfile *profile);
 
 const char*               terminal_profile_get_icon_file            (TerminalProfile *profile);
 GdkPixbuf*                terminal_profile_get_icon                 (TerminalProfile *profile);
@@ -227,6 +231,10 @@
                                                 gboolean                   setting);
 void terminal_profile_set_custom_command       (TerminalProfile          *profile,
                                                 const char               *command);
+void terminal_profile_set_use_custom_basedir   (TerminalProfile           *profile,
+                                                gboolean                   setting);
+void terminal_profile_set_custom_basedir       (TerminalProfile          *profile,
+                                                const char               *basedir);
 
 void terminal_profile_set_icon_file            (TerminalProfile          *profile,
                                                 const char               *filename);
diff -Nur gnome-terminal-2.16.1/src/terminal-screen.c my_gnome-terminal-2.16.1/src/terminal-screen.c
--- gnome-terminal-2.16.1/src/terminal-screen.c	2006-10-02 21:08:52.000000000 +0200
+++ my_gnome-terminal-2.16.1/src/terminal-screen.c	2007-09-11 14:58:58.682139000 +0200
@@ -1035,21 +1035,26 @@
 static gboolean
 get_child_command (TerminalScreen *screen,
                    char          **file_p,
+                   char          **dir_p,
                    char         ***argv_p,
                    GError        **err)
 {
   /* code from gnome-terminal */
   TerminalProfile *profile;
   char  *file;
+  char  *dir;
   char **argv;
 
   profile = screen->priv->profile;
 
   file = NULL;
+  dir  = NULL;
   argv = NULL;
   
   if (file_p)
     *file_p = NULL;
+  if (dir_p)
+    *dir_p = NULL;
   if (argv_p)
     *argv_p = NULL;
 
@@ -1067,6 +1072,15 @@
 
       file = g_strdup (argv[0]);
     }
+  else if (terminal_profile_get_use_custom_basedir (profile))
+    {
+      if (!g_shell_parse_argv (terminal_profile_get_custom_basedir (profile),
+                               NULL, &argv,
+                               err))
+        return FALSE;
+
+      dir = g_strdup (argv[0]);
+    }
   else
     {
       const char *only_name;
@@ -1099,6 +1113,11 @@
   else
     g_free (file);
 
+  if (dir_p)
+    *dir_p = dir;
+  else
+    g_free (dir);
+
   if (argv_p)
     *argv_p = argv;
   else
@@ -1266,13 +1285,14 @@
   TerminalProfile *profile;
   char **env;
   char  *path;
+  char  *dir;
   char **argv;
   GError *err;
   
   profile = screen->priv->profile;
 
   err = NULL;
-  if (!get_child_command (screen, &path, &argv, &err))
+  if (!get_child_command (screen, &path, &dir, &argv, &err))
     {
       show_command_error_dialog (screen, err);
       g_error_free (err);
@@ -1288,7 +1308,7 @@
                                      path,
                                      argv,
                                      env,
-                                     terminal_screen_get_working_dir (screen),
+                                     dir!=NULL?dir:terminal_screen_get_working_dir (screen),
                                      &screen->priv->child_pid,
                                      &err))
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]