gnome-terminal r3073 - trunk/src



Author: chpe
Date: Wed Sep 24 20:10:32 2008
New Revision: 3073
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=3073&view=rev

Log:
libgnome* exorcism II: copy the gnome_util_user_shell code into
gnome-terminal.

Added:
   trunk/src/eggusershell.c
   trunk/src/eggusershell.h
Modified:
   trunk/src/Makefile.am
   trunk/src/terminal-screen.c

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Wed Sep 24 20:10:32 2008
@@ -5,6 +5,8 @@
 bin_PROGRAMS = gnome-terminal
 
 gnome_terminal_SOURCES= \
+	eggusershell.c \
+	eggusershell.h \
 	encoding.c \
 	encoding.h \
 	profile-editor.c \

Added: trunk/src/eggusershell.c
==============================================================================
--- (empty file)
+++ trunk/src/eggusershell.c	Wed Sep 24 20:10:32 2008
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
+ * Copyright (C) 1999, 2000 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This file is part of the Gnome Library.
+ *
+ * The Gnome Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Gnome Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Gnome Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+/*
+  @NOTATION@
+ */
+
+/*
+ *
+ * Gnome utility routines.
+ * (C)  1997, 1998, 1999 the Free Software Foundation.
+ *
+ * Author: Miguel de Icaza,
+ */
+
+#include <config.h>
+
+#include "eggusershell.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#ifndef G_OS_WIN32
+#include <pwd.h>
+#endif
+
+#include <glib.h>
+
+/**
+ * egg_user_shell:
+ *
+ * Retrieves the user's preferred shell.
+ *
+ * Returns: A newly allocated string that is the path to the shell.
+ */
+char *
+egg_user_shell (void)
+{
+#ifndef G_OS_WIN32
+	struct passwd *pw;
+	int i;
+	const char *shell;
+	const char shells [][14] = {
+		/* Note that on some systems shells can also
+		 * be installed in /usr/bin */
+		"/bin/bash", "/usr/bin/bash",
+		"/bin/zsh", "/usr/bin/zsh",
+		"/bin/tcsh", "/usr/bin/tcsh",
+		"/bin/ksh", "/usr/bin/ksh",
+		"/bin/csh", "/bin/sh"
+	};
+
+	if (geteuid () == getuid () &&
+	    getegid () == getgid ()) {
+		/* only in non-setuid */
+		if ((shell = g_getenv ("SHELL"))){
+			if (access (shell, X_OK) == 0) {
+				return g_strdup (shell);
+			}
+		}
+	}
+	pw = getpwuid(getuid());
+	if (pw && pw->pw_shell) {
+		if (access (pw->pw_shell, X_OK) == 0) {
+			return g_strdup (pw->pw_shell);
+		}
+	}
+
+	for (i = 0; i != G_N_ELEMENTS (shells); i++) {
+		if (access (shells [i], X_OK) == 0) {
+			return g_strdup (shells[i]);
+		}
+	}
+
+	/* If /bin/sh doesn't exist, your system is truly broken.  */
+	abort ();
+
+	/* Placate compiler.  */
+	return NULL;
+#else
+	/* g_find_program_in_path() always looks also in the Windows
+	 * and System32 directories, so it should always find either cmd.exe
+	 * or command.com.
+	 */
+	char *retval = g_find_program_in_path ("cmd.exe");
+
+	if (retval == NULL)
+		retval = g_find_program_in_path ("command.com");
+
+	g_assert (retval != NULL);
+
+	return retval;
+#endif
+}

Added: trunk/src/eggusershell.h
==============================================================================
--- (empty file)
+++ trunk/src/eggusershell.h	Wed Sep 24 20:10:32 2008
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
+ * Copyright (C) 1999, 2000 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This file is part of the Gnome Library.
+ *
+ * The Gnome Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Gnome Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Gnome Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+/*
+  @NOTATION@
+ */
+
+#ifndef __EGG_USER_SHELL_H__
+#define __EGG_USER_SHELL_H__
+
+#include <stdlib.h>
+#include <glib.h>
+#include <libgnome/gnome-init.h>
+#include <libgnome/gnome-program.h>
+
+G_BEGIN_DECLS
+
+/* Find the name of the user's shell.  */
+char *egg_user_shell (void);
+
+G_END_DECLS
+
+#endif

Modified: trunk/src/terminal-screen.c
==============================================================================
--- trunk/src/terminal-screen.c	(original)
+++ trunk/src/terminal-screen.c	Wed Sep 24 20:10:32 2008
@@ -30,7 +30,6 @@
 #endif
 
 #include <gconf/gconf.h>
-#include <libgnome/gnome-util.h> /* gnome_util_user_shell */
 
 #include "terminal-accels.h"
 #include "terminal-app.h"
@@ -41,6 +40,8 @@
 #include "terminal-util.h"
 #include "terminal-window.h"
 
+#include "eggusershell.h"
+
 #define HTTP_PROXY_DIR "/system/http_proxy"
 
 #define URL_MATCH_CURSOR  (GDK_HAND2)
@@ -1139,7 +1140,7 @@
       const char *only_name;
       char *shell;
 
-      shell = gnome_util_user_shell ();
+      shell = egg_user_shell ();
 
       file = g_strdup (shell);
       



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