1998-12-16 05:51:44 +03:00
|
|
|
#include <config.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "x.h"
|
1999-01-27 04:14:57 +03:00
|
|
|
#include "global.h"
|
1998-12-16 05:51:44 +03:00
|
|
|
#include "dir.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "panel.h"
|
|
|
|
#define WANT_WIDGETS /* bleah */
|
|
|
|
#include "main.h"
|
|
|
|
#include "color.h"
|
|
|
|
#include "mouse.h"
|
|
|
|
#include "layout.h" /* get_panel_widget */
|
|
|
|
#include "ext.h" /* regex_command */
|
|
|
|
#include "cmd.h" /* copy_cmd, ren_cmd, delete_cmd, ... */
|
|
|
|
#include "gscreen.h"
|
1999-03-11 05:40:53 +03:00
|
|
|
#include "gmain.h"
|
1998-12-16 05:51:44 +03:00
|
|
|
#include "dir.h"
|
|
|
|
#include "dialog.h"
|
1999-04-10 04:54:10 +04:00
|
|
|
#include "view.h"
|
1999-03-11 05:40:53 +03:00
|
|
|
#include "gcmd.h"
|
1998-12-16 05:51:44 +03:00
|
|
|
#include "../vfs/vfs.h"
|
1999-03-11 05:40:53 +03:00
|
|
|
#include "gnome-open-dialog.h"
|
1998-12-16 05:51:44 +03:00
|
|
|
|
1999-04-09 05:18:06 +04:00
|
|
|
static void
|
|
|
|
gmc_unable_to_execute_dlg (gchar *fname, const gchar *command, gchar *action, const gchar *mime)
|
|
|
|
{
|
|
|
|
GtkWidget *msg_dialog = NULL;
|
1999-04-15 23:24:29 +04:00
|
|
|
GtkWidget *hack_widget;
|
1999-04-09 05:18:06 +04:00
|
|
|
gchar *msg;
|
|
|
|
gchar *fix = NULL;
|
|
|
|
if (!strcmp (action, "x-gnome-app-info")) {
|
1999-08-08 16:43:32 +04:00
|
|
|
msg = g_strdup_printf (
|
|
|
|
_("Unable to execute\n\"%s\".\n\n"
|
|
|
|
"Please check it to see if it points to a valid command."),
|
|
|
|
fname);
|
2000-01-03 19:39:00 +03:00
|
|
|
|
1999-04-09 05:18:06 +04:00
|
|
|
} else {
|
|
|
|
if (mime)
|
1999-08-08 16:43:32 +04:00
|
|
|
fix = g_strdup_printf (
|
|
|
|
_("\".\n\nTo fix this, bring up the mime-properties editor "
|
|
|
|
"in the GNOME Control Center, and edit the default %s"
|
|
|
|
"-action for \"%s\"."),
|
|
|
|
action, mime);
|
2000-01-03 19:39:00 +03:00
|
|
|
else
|
1999-08-08 16:43:32 +04:00
|
|
|
fix = g_strdup_printf (
|
|
|
|
_("\".\n\nTo fix this error, bring up this file's properties "
|
|
|
|
"and change the default %s-action."),
|
|
|
|
action);
|
|
|
|
|
|
|
|
msg = g_strdup_printf (
|
|
|
|
_("Unable to %s\n\"%s\"\nwith the command:\n\"%s\"%s"),
|
|
|
|
action, fname, command, fix);
|
2000-01-03 19:39:00 +03:00
|
|
|
|
1999-04-09 05:18:06 +04:00
|
|
|
g_free (fix);
|
|
|
|
}
|
|
|
|
msg_dialog = gnome_message_box_new (msg,
|
|
|
|
GNOME_MESSAGE_BOX_ERROR,
|
|
|
|
GNOME_STOCK_BUTTON_OK,
|
|
|
|
NULL);
|
|
|
|
/* Kids, don't try this at home */
|
1999-04-15 23:24:29 +04:00
|
|
|
/* this is pretty evil... <-: */
|
1999-04-09 05:18:06 +04:00
|
|
|
hack_widget = GNOME_DIALOG (msg_dialog)->vbox;
|
1999-04-15 23:24:29 +04:00
|
|
|
hack_widget = ((GtkBoxChild *) GTK_BOX (hack_widget)->children->data)->widget;
|
|
|
|
hack_widget = ((GtkBoxChild *) GTK_BOX (hack_widget)->children->next->data)->widget;
|
1999-04-09 05:18:06 +04:00
|
|
|
gtk_label_set_line_wrap (GTK_LABEL (hack_widget), TRUE);
|
1999-04-15 23:24:29 +04:00
|
|
|
|
1999-04-09 05:18:06 +04:00
|
|
|
gnome_dialog_run_and_close (GNOME_DIALOG (msg_dialog));
|
|
|
|
g_free (msg);
|
|
|
|
}
|
|
|
|
|
1998-12-16 05:51:44 +03:00
|
|
|
static void
|
1999-02-26 10:17:51 +03:00
|
|
|
gmc_execute (const char *fname, const char *buf, int needs_terminal)
|
1998-12-16 05:51:44 +03:00
|
|
|
{
|
1999-02-26 10:17:51 +03:00
|
|
|
exec_extension (fname, buf, NULL, NULL, 0, needs_terminal);
|
1998-12-16 05:51:44 +03:00
|
|
|
}
|
1999-08-08 16:43:32 +04:00
|
|
|
|
1999-04-09 05:18:06 +04:00
|
|
|
static gboolean
|
|
|
|
gmc_check_exec_string (const char *buf)
|
|
|
|
{
|
|
|
|
gint argc;
|
|
|
|
gint retval, i;
|
|
|
|
gchar *prog;
|
|
|
|
gchar **argv;
|
2000-01-03 19:39:00 +03:00
|
|
|
|
1999-04-09 05:18:06 +04:00
|
|
|
gnome_config_make_vector (buf, &argc, &argv);
|
|
|
|
if (argc < 1)
|
|
|
|
return FALSE;
|
1998-12-16 05:51:44 +03:00
|
|
|
|
1999-04-09 05:18:06 +04:00
|
|
|
prog = gnome_is_program_in_path (argv[0]);
|
2000-09-18 19:11:34 +04:00
|
|
|
if (prog) {
|
1999-04-09 05:18:06 +04:00
|
|
|
retval = TRUE;
|
2000-09-18 19:11:34 +04:00
|
|
|
g_free (prog);
|
|
|
|
} else
|
1999-04-09 05:18:06 +04:00
|
|
|
retval = FALSE;
|
|
|
|
/* check to see if it's a GMC directive. */
|
|
|
|
if ((strlen (argv[0]) > 1) && (argv[0][0] == '%') && (argv[0][1] != '%'))
|
|
|
|
retval = TRUE;
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
g_free (argv[i]);
|
|
|
|
g_free (argv);
|
|
|
|
return retval;
|
|
|
|
}
|
2000-09-18 19:11:34 +04:00
|
|
|
|
1998-12-16 05:51:44 +03:00
|
|
|
int
|
1998-12-30 06:24:46 +03:00
|
|
|
gmc_open_filename (char *fname, GList *args)
|
1998-12-16 05:51:44 +03:00
|
|
|
{
|
2000-01-03 Aaron Lehmann <aaronl@vitelus.com>
* gdesktop.c, gdnd.c, gaction.c, gicon.c,
gnome-file-property-dialog.c, gpopup.c, gpopup2.c, gprefs.cgmain.h,
setup.c: Add option of using GNOME "magic" routines to determine file
types. This makes MC intelligently look at the data in the file to see
what type of file it is, rather than looking at the filename extension.
This slows down MC quite a bit, so it has been made an optional
preference item. Type detection is expected to improve as mime-magic
matures.
2000-01-24 01:25:26 +03:00
|
|
|
/* fname is a full name */
|
|
|
|
|
1999-02-11 08:52:55 +03:00
|
|
|
const char *mime_type;
|
|
|
|
const char *cmd;
|
1999-04-09 05:18:06 +04:00
|
|
|
char *buf = NULL;
|
1998-12-16 05:51:44 +03:00
|
|
|
int size;
|
1999-02-26 10:17:51 +03:00
|
|
|
int needs_terminal = 0;
|
1998-12-16 05:51:44 +03:00
|
|
|
|
2000-01-03 Aaron Lehmann <aaronl@vitelus.com>
* gdesktop.c, gdnd.c, gaction.c, gicon.c,
gnome-file-property-dialog.c, gpopup.c, gpopup2.c, gprefs.cgmain.h,
setup.c: Add option of using GNOME "magic" routines to determine file
types. This makes MC intelligently look at the data in the file to see
what type of file it is, rather than looking at the filename extension.
This slows down MC quite a bit, so it has been made an optional
preference item. Type detection is expected to improve as mime-magic
matures.
2000-01-24 01:25:26 +03:00
|
|
|
if (use_magic)
|
|
|
|
mime_type = gnome_mime_type_or_default_of_file (fname, NULL);
|
|
|
|
else
|
|
|
|
mime_type = gnome_mime_type_or_default (fname, NULL);
|
2000-03-18 16:07:12 +03:00
|
|
|
|
1999-02-26 10:17:51 +03:00
|
|
|
/*
|
|
|
|
* We accept needs_terminal as -1, which means our caller
|
|
|
|
* did not want to do the work
|
|
|
|
*/
|
|
|
|
if (gnome_metadata_get (fname, "flags", &size, &buf) == 0){
|
|
|
|
needs_terminal = (strstr (buf, "needsterminal") != 0);
|
|
|
|
g_free (buf);
|
2000-03-18 16:07:12 +03:00
|
|
|
buf = NULL;
|
2000-01-03 19:39:00 +03:00
|
|
|
} else if (mime_type)
|
2000-03-18 16:07:12 +03:00
|
|
|
needs_terminal = gnome_mime_needsterminal (mime_type, "open.flags");
|
2000-01-03 19:39:00 +03:00
|
|
|
|
2000-03-18 16:07:12 +03:00
|
|
|
if (gnome_metadata_get (fname, "fm-open", &size, &buf) != 0)
|
1999-04-09 05:18:06 +04:00
|
|
|
gnome_metadata_get (fname, "open", &size, &buf);
|
2000-03-18 16:07:12 +03:00
|
|
|
|
1999-04-09 05:18:06 +04:00
|
|
|
if (buf) {
|
|
|
|
if (gmc_check_exec_string (buf))
|
|
|
|
gmc_execute (fname, buf, needs_terminal);
|
|
|
|
else
|
1999-08-08 16:43:32 +04:00
|
|
|
gmc_unable_to_execute_dlg (fname, buf, _("open"), NULL);
|
1999-01-06 07:03:15 +03:00
|
|
|
g_free (buf);
|
1998-12-16 05:51:44 +03:00
|
|
|
return 1;
|
|
|
|
}
|
2000-03-18 16:07:12 +03:00
|
|
|
|
1998-12-16 05:51:44 +03:00
|
|
|
if (!mime_type)
|
|
|
|
return 0;
|
2000-01-03 19:39:00 +03:00
|
|
|
|
1998-12-16 05:51:44 +03:00
|
|
|
cmd = gnome_mime_get_value (mime_type, "fm-open");
|
1999-04-09 05:18:06 +04:00
|
|
|
if (cmd == NULL) {
|
|
|
|
cmd = gnome_mime_get_value (mime_type, "open");
|
1998-12-16 05:51:44 +03:00
|
|
|
}
|
2000-01-03 19:39:00 +03:00
|
|
|
|
1998-12-16 05:51:44 +03:00
|
|
|
if (cmd){
|
1999-04-09 05:18:06 +04:00
|
|
|
if (gmc_check_exec_string (cmd))
|
|
|
|
gmc_execute (fname, cmd, needs_terminal);
|
2000-01-03 19:39:00 +03:00
|
|
|
else
|
1999-08-08 16:43:32 +04:00
|
|
|
gmc_unable_to_execute_dlg (fname, cmd, _("open"), mime_type);
|
1998-12-16 05:51:44 +03:00
|
|
|
return 1;
|
|
|
|
}
|
1999-02-11 08:52:55 +03:00
|
|
|
|
2000-03-18 16:07:12 +03:00
|
|
|
if ((strcmp (mime_type, "application/x-gnome-app-info") == 0) ||
|
|
|
|
(strcmp (mime_type, "application/x-kde-app-info") == 0)){
|
1999-02-11 08:52:55 +03:00
|
|
|
GnomeDesktopEntry *entry;
|
|
|
|
|
|
|
|
entry = gnome_desktop_entry_load (fname);
|
2000-03-18 16:07:12 +03:00
|
|
|
|
1999-02-11 08:52:55 +03:00
|
|
|
if (entry){
|
|
|
|
gnome_desktop_entry_launch (entry);
|
|
|
|
gnome_desktop_entry_free (entry);
|
1999-04-08 03:26:49 +04:00
|
|
|
return 1;
|
1999-04-09 05:18:06 +04:00
|
|
|
} else {
|
|
|
|
gmc_unable_to_execute_dlg (fname, NULL, "x-gnome-app-info", NULL);
|
|
|
|
return 1;
|
1999-02-11 08:52:55 +03:00
|
|
|
}
|
|
|
|
}
|
2000-03-18 16:07:12 +03:00
|
|
|
|
1999-04-09 05:18:06 +04:00
|
|
|
/* We just struck out. Prompt the user. */
|
1998-12-16 05:51:44 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-02-12 05:42:42 +03:00
|
|
|
int
|
1999-03-11 05:40:53 +03:00
|
|
|
gmc_edit (char *fname)
|
1999-02-12 05:42:42 +03:00
|
|
|
{
|
2000-01-03 Aaron Lehmann <aaronl@vitelus.com>
* gdesktop.c, gdnd.c, gaction.c, gicon.c,
gnome-file-property-dialog.c, gpopup.c, gpopup2.c, gprefs.cgmain.h,
setup.c: Add option of using GNOME "magic" routines to determine file
types. This makes MC intelligently look at the data in the file to see
what type of file it is, rather than looking at the filename extension.
This slows down MC quite a bit, so it has been made an optional
preference item. Type detection is expected to improve as mime-magic
matures.
2000-01-24 01:25:26 +03:00
|
|
|
/* fname is a full path */
|
|
|
|
|
1999-02-12 05:42:42 +03:00
|
|
|
const char *mime_type;
|
|
|
|
const char *cmd;
|
|
|
|
char *buf;
|
|
|
|
int size;
|
1999-02-16 00:19:03 +03:00
|
|
|
char *editor, *type;
|
|
|
|
int on_terminal;
|
1999-02-12 05:42:42 +03:00
|
|
|
|
|
|
|
if (gnome_metadata_get (fname, "edit", &size, &buf) == 0){
|
1999-04-09 16:58:10 +04:00
|
|
|
if (gmc_check_exec_string (buf))
|
|
|
|
gmc_execute (fname, buf, 0);
|
|
|
|
else
|
1999-08-08 16:43:32 +04:00
|
|
|
gmc_unable_to_execute_dlg (fname, buf, _("edit"), NULL);
|
1999-02-12 05:42:42 +03:00
|
|
|
g_free (buf);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2000-01-03 Aaron Lehmann <aaronl@vitelus.com>
* gdesktop.c, gdnd.c, gaction.c, gicon.c,
gnome-file-property-dialog.c, gpopup.c, gpopup2.c, gprefs.cgmain.h,
setup.c: Add option of using GNOME "magic" routines to determine file
types. This makes MC intelligently look at the data in the file to see
what type of file it is, rather than looking at the filename extension.
This slows down MC quite a bit, so it has been made an optional
preference item. Type detection is expected to improve as mime-magic
matures.
2000-01-24 01:25:26 +03:00
|
|
|
if (use_magic)
|
|
|
|
mime_type = gnome_mime_type_or_default_of_file (fname, NULL);
|
|
|
|
else
|
|
|
|
mime_type = gnome_mime_type_or_default (fname, NULL);
|
|
|
|
|
1999-02-16 00:19:03 +03:00
|
|
|
if (mime_type){
|
|
|
|
cmd = gnome_mime_get_value (mime_type, "edit");
|
2000-01-03 19:39:00 +03:00
|
|
|
|
1999-02-16 00:19:03 +03:00
|
|
|
if (cmd){
|
1999-04-09 16:58:10 +04:00
|
|
|
if (gmc_check_exec_string (cmd))
|
|
|
|
gmc_execute (fname, cmd, 0);
|
|
|
|
else
|
1999-08-08 16:43:32 +04:00
|
|
|
gmc_unable_to_execute_dlg (fname, cmd, _("edit"), mime_type);
|
1999-02-16 00:19:03 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
1999-03-11 05:40:53 +03:00
|
|
|
|
1999-02-16 00:19:03 +03:00
|
|
|
gnome_config_push_prefix( "/editor/Editor/");
|
|
|
|
type = gnome_config_get_string ("EDITOR_TYPE=executable");
|
2000-01-03 19:39:00 +03:00
|
|
|
|
1999-02-16 00:19:03 +03:00
|
|
|
if (strcmp (type, "mc-internal") == 0){
|
|
|
|
g_free (type);
|
|
|
|
do_edit (fname);
|
1999-02-12 05:42:42 +03:00
|
|
|
return 1;
|
|
|
|
}
|
1999-02-16 00:19:03 +03:00
|
|
|
g_free (type);
|
1999-03-11 05:40:53 +03:00
|
|
|
|
1999-02-16 00:19:03 +03:00
|
|
|
editor = gnome_config_get_string ("EDITOR=emacs");
|
|
|
|
on_terminal = gnome_config_get_bool ("NEEDS_TERM=false");
|
|
|
|
|
|
|
|
if (on_terminal){
|
|
|
|
char *quoted = name_quote (fname, 0);
|
|
|
|
char *editor_cmd = g_strconcat (editor, " ", quoted, NULL);
|
2000-01-03 19:39:00 +03:00
|
|
|
|
1999-02-16 00:19:03 +03:00
|
|
|
gnome_open_terminal_with_cmd (editor_cmd);
|
|
|
|
g_free (quoted);
|
|
|
|
g_free (editor_cmd);
|
|
|
|
} else {
|
|
|
|
char *cmd = g_strconcat (editor, " %s", NULL);
|
2000-01-03 19:39:00 +03:00
|
|
|
|
1999-02-26 10:17:51 +03:00
|
|
|
gmc_execute (fname, cmd, 0);
|
1999-02-16 00:19:03 +03:00
|
|
|
g_free (cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (editor);
|
1999-02-12 05:42:42 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-12-30 06:24:46 +03:00
|
|
|
int
|
|
|
|
gmc_open (file_entry *fe)
|
|
|
|
{
|
1999-04-09 05:18:06 +04:00
|
|
|
gint retval;
|
|
|
|
gchar *fullname;
|
|
|
|
fullname = g_concat_dir_and_file (cpanel->cwd, fe->fname);
|
|
|
|
retval = gmc_open_filename (fullname, NULL);
|
|
|
|
g_free (fullname);
|
|
|
|
return retval;
|
1998-12-30 06:24:46 +03:00
|
|
|
}
|
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
int
|
|
|
|
gmc_open_with (gchar *filename)
|
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
gchar *command = NULL;
|
|
|
|
gchar *real_command;
|
|
|
|
WPanel *panel = cpanel;
|
|
|
|
|
|
|
|
dialog = gnome_open_dialog_new (filename);
|
|
|
|
if (!is_a_desktop_panel (panel))
|
|
|
|
gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (panel->xwindow));
|
|
|
|
|
|
|
|
switch (gnome_dialog_run (GNOME_DIALOG (dialog))) {
|
|
|
|
case 0:
|
|
|
|
command = gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (
|
|
|
|
GNOME_FILE_ENTRY (GNOME_OPEN_DIALOG (dialog)->entry)->gentry))));
|
|
|
|
/* Assume COMMAND %f */
|
|
|
|
if (command) {
|
|
|
|
/* FIXME: these need the needs_terminal argument to be set correctly */
|
|
|
|
if (strchr (command, '%'))
|
|
|
|
exec_extension (filename, command, NULL, NULL, 0, FALSE);
|
|
|
|
else {
|
|
|
|
/* This prolly isn't perfect, but it will do. */
|
|
|
|
real_command = g_strconcat (command, " %f", NULL);
|
|
|
|
exec_extension (filename, real_command, NULL, NULL, 0, FALSE);
|
|
|
|
g_free (real_command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (command) {
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
return 0;
|
|
|
|
case 1:
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 19:11:34 +04:00
|
|
|
|
1998-12-16 05:51:44 +03:00
|
|
|
static void
|
1999-02-16 00:19:03 +03:00
|
|
|
gmc_run_view (const char *filename, const char *buf)
|
1998-12-16 05:51:44 +03:00
|
|
|
{
|
1999-02-26 10:17:51 +03:00
|
|
|
exec_extension (filename, buf, NULL, NULL, 0, 0);
|
1998-12-16 05:51:44 +03:00
|
|
|
}
|
2000-09-18 19:11:34 +04:00
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
static gchar *
|
|
|
|
gmc_view_command (gchar *filename)
|
1998-12-16 05:51:44 +03:00
|
|
|
{
|
1999-02-11 08:52:55 +03:00
|
|
|
const char *mime_type, *cmd;
|
1998-12-16 05:51:44 +03:00
|
|
|
char *buf;
|
|
|
|
int size;
|
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
if (gnome_metadata_get (filename, "fm-view", &size, &buf) == 0)
|
|
|
|
return buf;
|
1998-12-16 05:51:44 +03:00
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
if (gnome_metadata_get (filename, "view", &size, &buf) == 0)
|
|
|
|
return buf;
|
1998-12-16 05:51:44 +03:00
|
|
|
|
2000-01-03 Aaron Lehmann <aaronl@vitelus.com>
* gdesktop.c, gdnd.c, gaction.c, gicon.c,
gnome-file-property-dialog.c, gpopup.c, gpopup2.c, gprefs.cgmain.h,
setup.c: Add option of using GNOME "magic" routines to determine file
types. This makes MC intelligently look at the data in the file to see
what type of file it is, rather than looking at the filename extension.
This slows down MC quite a bit, so it has been made an optional
preference item. Type detection is expected to improve as mime-magic
matures.
2000-01-24 01:25:26 +03:00
|
|
|
if (use_magic)
|
|
|
|
mime_type = gnome_mime_type_or_default_of_file (filename, NULL);
|
|
|
|
else
|
|
|
|
mime_type = gnome_mime_type_or_default (filename, NULL);
|
|
|
|
|
1998-12-16 05:51:44 +03:00
|
|
|
if (!mime_type)
|
1999-03-11 05:40:53 +03:00
|
|
|
return NULL;
|
2000-01-03 19:39:00 +03:00
|
|
|
|
|
|
|
|
1998-12-16 05:51:44 +03:00
|
|
|
cmd = gnome_mime_get_value (mime_type, "fm-view");
|
2000-01-03 19:39:00 +03:00
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
if (cmd)
|
|
|
|
return g_strdup (cmd);
|
2000-01-03 19:39:00 +03:00
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
cmd = gnome_mime_get_value (mime_type, "view");
|
1998-12-16 05:51:44 +03:00
|
|
|
if (cmd){
|
1999-03-11 05:40:53 +03:00
|
|
|
return g_strdup (cmd);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-01-03 19:39:00 +03:00
|
|
|
|
1999-03-11 05:40:53 +03:00
|
|
|
int
|
|
|
|
gmc_view (char *filename, int start_line)
|
|
|
|
{
|
1999-04-09 16:58:10 +04:00
|
|
|
gchar *cmd;
|
|
|
|
const gchar *mime_type;
|
2000-01-03 Aaron Lehmann <aaronl@vitelus.com>
* gdesktop.c, gdnd.c, gaction.c, gicon.c,
gnome-file-property-dialog.c, gpopup.c, gpopup2.c, gprefs.cgmain.h,
setup.c: Add option of using GNOME "magic" routines to determine file
types. This makes MC intelligently look at the data in the file to see
what type of file it is, rather than looking at the filename extension.
This slows down MC quite a bit, so it has been made an optional
preference item. Type detection is expected to improve as mime-magic
matures.
2000-01-24 01:25:26 +03:00
|
|
|
if (use_magic)
|
|
|
|
mime_type = gnome_mime_type_or_default_of_file (filename, NULL);
|
|
|
|
else
|
|
|
|
mime_type = gnome_mime_type_or_default (filename, NULL);
|
1999-03-11 05:40:53 +03:00
|
|
|
cmd = gmc_view_command (filename);
|
|
|
|
if (cmd) {
|
1999-04-09 16:58:10 +04:00
|
|
|
if (gmc_check_exec_string (cmd))
|
|
|
|
gmc_run_view (filename, cmd);
|
|
|
|
else
|
1999-08-08 16:43:32 +04:00
|
|
|
gmc_unable_to_execute_dlg (filename, cmd, _("view"), mime_type);
|
1999-03-11 05:40:53 +03:00
|
|
|
g_free (cmd);
|
1998-12-16 05:51:44 +03:00
|
|
|
return 1;
|
1999-03-12 05:43:26 +03:00
|
|
|
} else
|
|
|
|
view (NULL, filename, 0, 0);
|
1998-12-16 05:51:44 +03:00
|
|
|
return 0;
|
|
|
|
}
|