anjuta r3869 - in trunk: . libanjuta libanjuta/interfaces plugins/build-basic-autotools plugins/gdb plugins/terminal
- From: sgranjoux svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r3869 - in trunk: . libanjuta libanjuta/interfaces plugins/build-basic-autotools plugins/gdb plugins/terminal
- Date: Fri, 18 Apr 2008 19:53:41 +0100 (BST)
Author: sgranjoux
Date: Fri Apr 18 18:53:40 2008
New Revision: 3869
URL: http://svn.gnome.org/viewvc/anjuta?rev=3869&view=rev
Log:
2008-04-18 SÃbastien Granjoux <seb sfo free fr>
* libanjuta/interfaces/libanjuta.idl,
plugins/terminal/terminal.c,
plugins/build-basic-autotools/executer.c,
plugins/gdb/plugin.c:
Add an env parameter in the IAnjutaTerminal interface allowing
to specify additional environment variables
* libanjuta/anjuta-launcher.c:
Add one initialization
Modified:
trunk/ChangeLog
trunk/libanjuta/anjuta-launcher.c
trunk/libanjuta/interfaces/libanjuta.idl
trunk/plugins/build-basic-autotools/executer.c
trunk/plugins/gdb/plugin.c
trunk/plugins/terminal/terminal.c
Modified: trunk/libanjuta/anjuta-launcher.c
==============================================================================
--- trunk/libanjuta/anjuta-launcher.c (original)
+++ trunk/libanjuta/anjuta-launcher.c Fri Apr 18 18:53:40 2008
@@ -194,6 +194,7 @@
obj->priv->child_pid = 0;
obj->priv->child_status = -1;
obj->priv->child_has_terminated = TRUE;
+ obj->priv->source = 0;
/* Synchronization in progress */
obj->priv->in_cleanup = FALSE;
@@ -253,15 +254,15 @@
AnjutaLauncher *launcher = ANJUTA_LAUNCHER (obj);
if (anjuta_launcher_is_busy (launcher))
{
- pid_t child_pid_save = launcher->priv->child_pid;
- guint child_source = launcher->priv->source;
- g_source_remove (child_source);
+ g_source_remove (launcher->priv->source);
+ launcher->priv->source = 0;
+
anjuta_launcher_execution_done_cleanup (launcher, FALSE);
/* We can not call anjuta_launcher_reset (launcher) to kill the
* running child because launcher has been initialized in cleanup
*/
- kill (child_pid_save, SIGTERM);
+ kill (launcher->priv->child_pid, SIGTERM);
launcher->priv->busy = FALSE;
}
Modified: trunk/libanjuta/interfaces/libanjuta.idl
==============================================================================
--- trunk/libanjuta/interfaces/libanjuta.idl (original)
+++ trunk/libanjuta/interfaces/libanjuta.idl Fri Apr 18 18:53:40 2008
@@ -2596,15 +2596,17 @@
/**
* ianjuta_terminal_execute_command:
* @obj: Self
- * @directory: fixme
- * @command: fixme
+ * @directory: Working directory
+ * @command: Command executed followed by arguments
+ * @environment: List of additional environment variables
* @err: Error propagation and reporting.
*
- * fixme
+ * Run the command in a terminal, setting the working directory
+ * and environment variables.
*
- * Returns: fixme
+ * Returns: Process ID
*/
- pid_t execute_command (const gchar* directory, const gchar *command);
+ pid_t execute_command (const gchar* directory, const gchar *command, gchar **environment);
}
/**
Modified: trunk/plugins/build-basic-autotools/executer.c
==============================================================================
--- trunk/plugins/build-basic-autotools/executer.c (original)
+++ trunk/plugins/build-basic-autotools/executer.c Fri Apr 18 18:53:40 2008
@@ -422,7 +422,7 @@
}
- ianjuta_terminal_execute_command (term, dir, cmd, NULL);
+ ianjuta_terminal_execute_command (term, dir, cmd, NULL, NULL);
}
else
{
Modified: trunk/plugins/gdb/plugin.c
==============================================================================
--- trunk/plugins/gdb/plugin.c (original)
+++ trunk/plugins/gdb/plugin.c Fri Apr 18 18:53:40 2008
@@ -122,7 +122,7 @@
/* Launch terminal */
cmd = g_strconcat ("anjuta_launcher --__debug_terminal ", file, NULL);
- plugin->term_pid = ianjuta_terminal_execute_command (term, NULL, cmd, NULL);
+ plugin->term_pid = ianjuta_terminal_execute_command (term, NULL, cmd, NULL, NULL);
g_free (cmd);
if (plugin->term_pid > 0)
Modified: trunk/plugins/terminal/terminal.c
==============================================================================
--- trunk/plugins/terminal/terminal.c (original)
+++ trunk/plugins/terminal/terminal.c Fri Apr 18 18:53:40 2008
@@ -63,8 +63,6 @@
#include <gtk/gtk.h>
#include <libanjuta/anjuta-plugin.h>
-extern char **environ;
-
extern GType terminal_plugin_get_type (GTypeModule *module);
#define ANJUTA_PLUGIN_TERMINAL_TYPE (terminal_plugin_get_type (NULL))
#define ANJUTA_PLUGIN_TERMINAL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ANJUTA_PLUGIN_TERMINAL_TYPE, TerminalPlugin))
@@ -315,45 +313,104 @@
gtk_widget_set_sensitive (term->pref_profile_combo, TRUE);
}
-static char **
-get_child_environment (void)
+static const gchar *
+strncmpv (gchar **str_array, const gchar *str, gsize n)
{
- /* code from gnome-terminal, sort of. */
- char **p;
- int i;
- char **retval;
-#define EXTRA_ENV_VARS 6
+ if (str_array != NULL)
+ {
+ gchar **p;
+
+ for (p = str_array; *p; p++)
+ {
+ if (strncmp (*p, str, n) == 0) return *p;
+ }
+ }
+
+ return NULL;
+}
- /* count env vars that are set */
- for (p = environ; *p; p++);
+static gchar **
+get_child_environment (gchar **environment)
+{
+ gchar **p;
+ gchar **new_env;
+ gchar **old_env;
+ gint i;
+ gsize len;
+
+#define EXTRA_ENV_VARS 6
- i = p - environ;
- retval = g_new (char *, i + 1 + EXTRA_ENV_VARS);
+ /* Allocate space for new environment variables */
+ old_env = g_listenv ();
- for (i = 0, p = environ; *p; p++) {
- /* Strip all these out, we'll replace some of them */
+ len = old_env ? g_strv_length (old_env) : 0;
+ len += environment ? g_strv_length (environment) : 0;
+ len += EXTRA_ENV_VARS + 1;
+ new_env = g_new (char *, len);
+
+ /* Remove some environment variables, Move other in new_env */
+ i = 0;
+ for (p = old_env; *p; p++)
+ {
if ((strncmp (*p, "COLUMNS=", 8) == 0) ||
(strncmp (*p, "LINES=", 6) == 0) ||
(strncmp (*p, "TERM=", 5) == 0) ||
- (strncmp (*p, "GNOME_DESKTOP_ICON=", 19) == 0)) {
- /* nothing: do not copy */
- } else {
- retval[i] = g_strdup (*p);
- ++i;
+ (strncmp (*p, "GNOME_DESKTOP_ICON=", 19) == 0))
+ {
+ /* Remove some environment variables */
+ g_free (*p);
}
- }
+ else
+ {
+ const gchar *eq;
- retval[i] = g_strdup ("TERM=xterm"); /* FIXME configurable later? */
- ++i;
+ eq = strchr (*p, '=');
+ if (eq != NULL)
+ {
+ if (strncmpv (environment, *p, eq - *p + 1))
+ {
+ /* Remove variable in the list */
+ g_free (*p);
+ }
+ else
+ {
+ /* Valid environment variable */
+ new_env[i++] = *p;
+ }
+ }
+ else
+ {
+ /* Invalid environment variable */
+ g_free (*p);
+ }
+ }
+ }
+ g_free (old_env); /* No need to use g_strfreev */
- retval[i] = NULL;
+ /* Add TERM variable */
+ if (!strncmpv (environment, "TERM=", 5))
+ {
+ /* Add default terminal */
+ new_env[i++] = g_strdup ("TERM=xterm");
+ }
+
+ /* Add all other environment variable from list */
+ if (environment)
+ {
+ for (p = environment; *p; p++)
+ {
+ new_env[i++] = g_strdup(*p);
+ }
+ }
+
+ new_env[i] = NULL;
- return retval;
+ return new_env;
}
static pid_t
terminal_execute (TerminalPlugin *term_plugin, const gchar *directory,
- const gchar *command)
+ const gchar *command, gchar **environment)
{
char **env, **args, **args_ptr;
GList *args_list, *args_list_ptr;
@@ -384,7 +441,7 @@
vte_terminal_reset (term, TRUE, TRUE);
- env = get_child_environment ();
+ env = get_child_environment (environment);
term_plugin->child_pid = vte_terminal_fork_command (term, args[0], args,
env, dir, 0, 0, 0);
@@ -418,7 +475,7 @@
shell = "/bin/sh";
dir = "/";
}
- terminal_execute (term_plugin, dir, shell);
+ terminal_execute (term_plugin, dir, shell, NULL);
}
static gboolean
@@ -685,7 +742,8 @@
static pid_t
iterminal_execute_command (IAnjutaTerminal *terminal,
const gchar *directory,
- const gchar *command, GError **err)
+ const gchar *command,
+ gchar **environment, GError **err)
{
TerminalPlugin *plugin;
const gchar *dir;
@@ -697,7 +755,7 @@
else
dir = directory;
- return terminal_execute (plugin, directory, command);
+ return terminal_execute (plugin, directory, command, environment);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]