Commit 16062e0e authored by Maciej Stachowiak's avatar Maciej Stachowiak

Fixed bugzilla.eazel.com bugs 4051 (applications which require

	terminals don't get them) and 4072 (mime types: command= string
	can't take args?).

	* libnautilus-extensions/nautilus-gnome-extensions.c
	(nautilus_gnome_terminal_shell_execute): Don't take the shell as
	an argument, just use "/bin/sh", there's no reason to use any
	other shell for the purpose of launching a terminal like this.

	(nautilus_gnome_open_terminal): Don't pass user shell to
	`nautilus_gnome_terminal_shell_execute'; handle `gnome-terminal'
	properly by passing it "-x" instead of incorrectly trying to quote
	the command.

	* libnautilus-extensions/nautilus-gnome-extensions.h: Fix minor
	typo.

	* libnautilus-extensions/nautilus-program-choosing.h,
	libnautilus-extensions/nautilus-program-choosing.c:
	(nautilus_launch_application_from_command): Add a use_termial
	argument and if passed, launch the program in a terminal; minor
	fixes to the way non-terminal-requiring programs are launched as
	well, including not quoting the command, so that it can include
	command line arguments (if the command name includes a space, it
	had better be quoted already).

	(nautilus_launch_application): Use the new `use_terminal' argument
	when calling `nautilus_launch_application_from_command'.

	* libnautilus-extensions/nautilus-program-chooser.c:
	(launch_mime_capplet): Use the new `use_terminal' argument
	when calling `nautilus_launch_application_from_command'.

	* src/file-manager/fm-desktop-icon-view.c
	(change_desktop_background_menu_item_callback): Use the new
	`use_terminal' argument when calling
	`nautilus_launch_application_from_command'.

	* src/file-manager/fm-directory-view.c (activate_callback): Use
	the new `use_terminal' argument when calling
	`nautilus_launch_application_from_command'. Also, shell-quote the
	command, since nautilus_application_launch_from_command won't do
	that for you any more.
parent e821cf8d
2000-11-11 Maciej Stachowiak <mjs@eazel.com>
Fixed bugzilla.eazel.com bugs 4051 (applications which require
terminals don't get them) and 4072 (mime types: command= string
can't take args?).
* libnautilus-extensions/nautilus-gnome-extensions.c
(nautilus_gnome_terminal_shell_execute): Don't take the shell as
an argument, just use "/bin/sh", there's no reason to use any
other shell for the purpose of launching a terminal like this.
(nautilus_gnome_open_terminal): Don't pass user shell to
`nautilus_gnome_terminal_shell_execute'; handle `gnome-terminal'
properly by passing it "-x" instead of incorrectly trying to quote
the command.
* libnautilus-extensions/nautilus-gnome-extensions.h: Fix minor
typo.
* libnautilus-extensions/nautilus-program-choosing.h,
libnautilus-extensions/nautilus-program-choosing.c:
(nautilus_launch_application_from_command): Add a use_termial
argument and if passed, launch the program in a terminal; minor
fixes to the way non-terminal-requiring programs are launched as
well, including not quoting the command, so that it can include
command line arguments (if the command name includes a space, it
had better be quoted already).
(nautilus_launch_application): Use the new `use_terminal' argument
when calling `nautilus_launch_application_from_command'.
* libnautilus-extensions/nautilus-program-chooser.c:
(launch_mime_capplet): Use the new `use_terminal' argument
when calling `nautilus_launch_application_from_command'.
* src/file-manager/fm-desktop-icon-view.c
(change_desktop_background_menu_item_callback): Use the new
`use_terminal' argument when calling
`nautilus_launch_application_from_command'.
* src/file-manager/fm-directory-view.c (activate_callback): Use
the new `use_terminal' argument when calling
`nautilus_launch_application_from_command'. Also, shell-quote the
command, since nautilus_application_launch_from_command won't do
that for you any more.
2000-11-10 Maciej Stachowiak <mjs@eazel.com>
* icons/gnome/Makefile.am, icons/i-executable.png: Restored
......
......@@ -478,7 +478,7 @@ max_open_files (void)
}
static int
nautilus_gnome_terminal_shell_execute (const char *shell, const char *command)
nautilus_gnome_terminal_shell_execute (const char *command)
{
struct sigaction ignore, save_intr, save_quit, save_stop;
int status, i;
......@@ -530,7 +530,7 @@ nautilus_gnome_terminal_shell_execute (const char *shell, const char *command)
pid = fork ();
if (pid == 0){
execl (shell, shell, "-c", command, (char *) 0);
execl ("/bin/sh", "/bin/sh", "-c", command, (char *) 0);
/* See note below for why we use _exit () */
_exit (127); /* Exec error */
}
......@@ -553,24 +553,19 @@ nautilus_gnome_open_terminal (const char *command)
{
char *terminal_path;
char *terminal_path_with_flags;
char *shell;
char *terminal_flags;
gboolean quote_all;
gboolean using_gnome_terminal;
char *command_line;
quote_all = FALSE;
/* figure out whichever shell we are using */
shell = gnome_util_user_shell ();
using_gnome_terminal = FALSE;
/* Look up a well-known terminal app */
terminal_path = gnome_is_program_in_path ("gnome-terminal");
if (terminal_path != NULL) {
/* apparently gnome-terminal needs it's input nicely quoted and the other
* terminals don't
/* gnome-terminal has different command-line options than the others
*/
quote_all = TRUE;
using_gnome_terminal = TRUE;
}
if (terminal_path == NULL) {
......@@ -596,29 +591,29 @@ nautilus_gnome_open_terminal (const char *command)
if (terminal_path == NULL){
g_message (" Could not start a terminal ");
} else if (command){
if (quote_all) {
command_line = g_strconcat (terminal_path, " -e '", command, "'", NULL);
} else if (command) {
if (using_gnome_terminal) {
command_line = g_strconcat (terminal_path, " -x ", command, NULL);
} else {
command_line = g_strconcat (terminal_path, " -e ", command, NULL);
}
nautilus_gnome_terminal_shell_execute (shell, command_line);
nautilus_gnome_terminal_shell_execute (command_line);
g_free (command_line);
} else {
if (quote_all) {
if (using_gnome_terminal) {
terminal_flags = " --login";
terminal_path_with_flags = g_strconcat (terminal_path, terminal_flags, NULL);
nautilus_gnome_terminal_shell_execute (shell, terminal_path_with_flags);
nautilus_gnome_terminal_shell_execute (terminal_path_with_flags);
g_free (terminal_path_with_flags);
} else {
terminal_flags = " -ls";
terminal_path_with_flags = g_strconcat (terminal_path, terminal_flags, NULL);
nautilus_gnome_terminal_shell_execute (shell, terminal_path_with_flags);
nautilus_gnome_terminal_shell_execute (terminal_path_with_flags);
}
}
g_free (shell);
g_free (terminal_path);
}
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-gmp,e-extensions.h - interface for new functions that operate on
/* nautilus-gnome-extensions.h - interface for new functions that operate on
gnome classes. Perhaps some of these should be
rolled into gnome someday.
......
......@@ -893,7 +893,7 @@ launch_mime_capplet (GtkWidget *button, gpointer ignored)
{
g_assert (GTK_IS_WIDGET (button));
nautilus_launch_application_from_command ("nautilus-mime-type-capplet", NULL);
nautilus_launch_application_from_command ("nautilus-mime-type-capplet", NULL, FALSE);
}
static void
......
......@@ -27,6 +27,7 @@
#include "nautilus-program-choosing.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-gnome-extensions.h"
#include "nautilus-mime-actions.h"
#include "nautilus-program-chooser.h"
#include "nautilus-stock-dialogs.h"
......@@ -390,7 +391,6 @@ nautilus_launch_application (GnomeVFSMimeApplication *application,
GtkWindow *parent_window)
{
GnomeDialog *dialog;
char *command_string;
char *parameter;
char *prompt;
......@@ -420,16 +420,11 @@ nautilus_launch_application (GnomeVFSMimeApplication *application,
}
}
if (application->requires_terminal) {
command_string = g_strconcat ("gnome-terminal -x ", application->command, NULL);
} else {
command_string = g_strdup (application->command);
}
nautilus_launch_application_from_command (command_string, parameter);
nautilus_launch_application_from_command (application->command,
parameter,
application->requires_terminal);
g_free (parameter);
g_free (command_string);
}
/**
......@@ -443,23 +438,35 @@ nautilus_launch_application (GnomeVFSMimeApplication *application,
* @parameter: Passed as a parameter to the application as is.
*/
void
nautilus_launch_application_from_command (const char *command_string, const char *parameter)
nautilus_launch_application_from_command (const char *command_string,
const char *parameter,
gboolean use_terminal)
{
char *full_command, *quoted_parameter, *quoted_command;
char *full_command;
char *quoted_parameter;
char *quoted_full_command;
char *final_command;
if (parameter != NULL) {
quoted_parameter = nautilus_shell_quote (parameter);
quoted_command = nautilus_shell_quote (command_string);
full_command = g_strconcat (quoted_command, " ", quoted_parameter, " &", NULL);
g_free (quoted_command);
full_command = g_strconcat (command_string, " ", quoted_parameter, NULL);
g_free (quoted_parameter);
} else {
quoted_command = nautilus_shell_quote (command_string);
full_command = g_strconcat (quoted_command, " &", NULL);
g_free (quoted_command);
full_command = g_strdup (command_string);
}
system (full_command);
if (use_terminal) {
quoted_full_command = nautilus_shell_quote (full_command);
final_command = g_strconcat ("/bin/sh -c ", quoted_full_command, NULL);
nautilus_gnome_open_terminal (final_command);
g_free (quoted_full_command);
} else {
final_command = g_strconcat (full_command, " &", NULL);
printf ("XXX - final_command: %s\n", final_command);
system (final_command);
}
g_free (final_command);
g_free (full_command);
}
......@@ -54,6 +54,7 @@ void nautilus_launch_application (GnomeVFSMimeApplication
const char *uri,
GtkWindow *parent_window);
void nautilus_launch_application_from_command (const char *command_string,
const char *parameter);
const char *parameter,
gboolean use_terminal);
#endif /* NAUTILUS_PROGRAM_CHOOSING_H */
......@@ -478,7 +478,7 @@ max_open_files (void)
}
static int
nautilus_gnome_terminal_shell_execute (const char *shell, const char *command)
nautilus_gnome_terminal_shell_execute (const char *command)
{
struct sigaction ignore, save_intr, save_quit, save_stop;
int status, i;
......@@ -530,7 +530,7 @@ nautilus_gnome_terminal_shell_execute (const char *shell, const char *command)
pid = fork ();
if (pid == 0){
execl (shell, shell, "-c", command, (char *) 0);
execl ("/bin/sh", "/bin/sh", "-c", command, (char *) 0);
/* See note below for why we use _exit () */
_exit (127); /* Exec error */
}
......@@ -553,24 +553,19 @@ nautilus_gnome_open_terminal (const char *command)
{
char *terminal_path;
char *terminal_path_with_flags;
char *shell;
char *terminal_flags;
gboolean quote_all;
gboolean using_gnome_terminal;
char *command_line;
quote_all = FALSE;
/* figure out whichever shell we are using */
shell = gnome_util_user_shell ();
using_gnome_terminal = FALSE;
/* Look up a well-known terminal app */
terminal_path = gnome_is_program_in_path ("gnome-terminal");
if (terminal_path != NULL) {
/* apparently gnome-terminal needs it's input nicely quoted and the other
* terminals don't
/* gnome-terminal has different command-line options than the others
*/
quote_all = TRUE;
using_gnome_terminal = TRUE;
}
if (terminal_path == NULL) {
......@@ -596,29 +591,29 @@ nautilus_gnome_open_terminal (const char *command)
if (terminal_path == NULL){
g_message (" Could not start a terminal ");
} else if (command){
if (quote_all) {
command_line = g_strconcat (terminal_path, " -e '", command, "'", NULL);
} else if (command) {
if (using_gnome_terminal) {
command_line = g_strconcat (terminal_path, " -x ", command, NULL);
} else {
command_line = g_strconcat (terminal_path, " -e ", command, NULL);
}
nautilus_gnome_terminal_shell_execute (shell, command_line);
nautilus_gnome_terminal_shell_execute (command_line);
g_free (command_line);
} else {
if (quote_all) {
if (using_gnome_terminal) {
terminal_flags = " --login";
terminal_path_with_flags = g_strconcat (terminal_path, terminal_flags, NULL);
nautilus_gnome_terminal_shell_execute (shell, terminal_path_with_flags);
nautilus_gnome_terminal_shell_execute (terminal_path_with_flags);
g_free (terminal_path_with_flags);
} else {
terminal_flags = " -ls";
terminal_path_with_flags = g_strconcat (terminal_path, terminal_flags, NULL);
nautilus_gnome_terminal_shell_execute (shell, terminal_path_with_flags);
nautilus_gnome_terminal_shell_execute (terminal_path_with_flags);
}
}
g_free (shell);
g_free (terminal_path);
}
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-gmp,e-extensions.h - interface for new functions that operate on
/* nautilus-gnome-extensions.h - interface for new functions that operate on
gnome classes. Perhaps some of these should be
rolled into gnome someday.
......
......@@ -893,7 +893,7 @@ launch_mime_capplet (GtkWidget *button, gpointer ignored)
{
g_assert (GTK_IS_WIDGET (button));
nautilus_launch_application_from_command ("nautilus-mime-type-capplet", NULL);
nautilus_launch_application_from_command ("nautilus-mime-type-capplet", NULL, FALSE);
}
static void
......
......@@ -27,6 +27,7 @@
#include "nautilus-program-choosing.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-gnome-extensions.h"
#include "nautilus-mime-actions.h"
#include "nautilus-program-chooser.h"
#include "nautilus-stock-dialogs.h"
......@@ -390,7 +391,6 @@ nautilus_launch_application (GnomeVFSMimeApplication *application,
GtkWindow *parent_window)
{
GnomeDialog *dialog;
char *command_string;
char *parameter;
char *prompt;
......@@ -420,16 +420,11 @@ nautilus_launch_application (GnomeVFSMimeApplication *application,
}
}
if (application->requires_terminal) {
command_string = g_strconcat ("gnome-terminal -x ", application->command, NULL);
} else {
command_string = g_strdup (application->command);
}
nautilus_launch_application_from_command (command_string, parameter);
nautilus_launch_application_from_command (application->command,
parameter,
application->requires_terminal);
g_free (parameter);
g_free (command_string);
}
/**
......@@ -443,23 +438,35 @@ nautilus_launch_application (GnomeVFSMimeApplication *application,
* @parameter: Passed as a parameter to the application as is.
*/
void
nautilus_launch_application_from_command (const char *command_string, const char *parameter)
nautilus_launch_application_from_command (const char *command_string,
const char *parameter,
gboolean use_terminal)
{
char *full_command, *quoted_parameter, *quoted_command;
char *full_command;
char *quoted_parameter;
char *quoted_full_command;
char *final_command;
if (parameter != NULL) {
quoted_parameter = nautilus_shell_quote (parameter);
quoted_command = nautilus_shell_quote (command_string);
full_command = g_strconcat (quoted_command, " ", quoted_parameter, " &", NULL);
g_free (quoted_command);
full_command = g_strconcat (command_string, " ", quoted_parameter, NULL);
g_free (quoted_parameter);
} else {
quoted_command = nautilus_shell_quote (command_string);
full_command = g_strconcat (quoted_command, " &", NULL);
g_free (quoted_command);
full_command = g_strdup (command_string);
}
system (full_command);
if (use_terminal) {
quoted_full_command = nautilus_shell_quote (full_command);
final_command = g_strconcat ("/bin/sh -c ", quoted_full_command, NULL);
nautilus_gnome_open_terminal (final_command);
g_free (quoted_full_command);
} else {
final_command = g_strconcat (full_command, " &", NULL);
printf ("XXX - final_command: %s\n", final_command);
system (final_command);
}
g_free (final_command);
g_free (full_command);
}
......@@ -54,6 +54,7 @@ void nautilus_launch_application (GnomeVFSMimeApplication
const char *uri,
GtkWindow *parent_window);
void nautilus_launch_application_from_command (const char *command_string,
const char *parameter);
const char *parameter,
gboolean use_terminal);
#endif /* NAUTILUS_PROGRAM_CHOOSING_H */
......@@ -361,7 +361,7 @@ reset_desktop_background_menu_item_callback (GtkMenuItem *item, FMDirectoryView
static void
change_desktop_background_menu_item_callback (GtkMenuItem *item, FMDirectoryView *view)
{
nautilus_launch_application_from_command ("background-properties-capplet", NULL);
nautilus_launch_application_from_command ("background-properties-capplet", NULL, FALSE);
}
static void
......
......@@ -3790,7 +3790,7 @@ activate_callback (NautilusFile *file, gpointer callback_data)
{
ActivateParameters *parameters;
FMDirectoryView *view;
char *uri, *command, *executable_path;
char *uri, *command, *executable_path, *quoted_path;
GnomeVFSMimeActionType action_type;
GnomeVFSMimeApplication *application;
gboolean performed_special_handling;
......@@ -3844,8 +3844,10 @@ activate_callback (NautilusFile *file, gpointer callback_data)
* and act like non-executables.
*/
if (executable_path != NULL) {
nautilus_launch_application_from_command (executable_path, NULL);
quoted_path = nautilus_shell_quote (executable_path);
nautilus_launch_application_from_command (quoted_path, NULL, FALSE);
g_free (executable_path);
g_free (quoted_path);
performed_special_handling = TRUE;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment