1998-12-16 05:51:44 +03:00
|
|
|
#include <config.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h> /* atoi */
|
|
|
|
#include "fs.h"
|
|
|
|
#include "mad.h"
|
|
|
|
#include "x.h"
|
|
|
|
#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"
|
|
|
|
#include "dir.h"
|
|
|
|
#include "dialog.h"
|
|
|
|
#include "../vfs/vfs.h"
|
|
|
|
|
|
|
|
static void
|
1998-12-30 21:29:32 +03:00
|
|
|
gmc_execute (char *fname, char *buf)
|
1998-12-16 05:51:44 +03:00
|
|
|
{
|
1998-12-30 21:29:32 +03:00
|
|
|
exec_extension (fname, buf, NULL, NULL, 0);
|
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
|
|
|
{
|
|
|
|
char *mime_type, *cmd;
|
|
|
|
char *buf;
|
|
|
|
int size;
|
|
|
|
|
1998-12-30 06:24:46 +03:00
|
|
|
if (gnome_metadata_get (fname, "fm-open", &size, &buf) == 0){
|
1998-12-30 21:29:32 +03:00
|
|
|
gmc_execute (fname, buf);
|
1999-01-06 07:03:15 +03:00
|
|
|
g_free (buf);
|
1998-12-16 05:51:44 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1998-12-30 06:24:46 +03:00
|
|
|
if (gnome_metadata_get (fname, "open", &size, &buf) == 0){
|
1998-12-30 21:29:32 +03:00
|
|
|
gmc_execute (fname, buf);
|
1999-01-06 07:03:15 +03:00
|
|
|
g_free (buf);
|
1998-12-16 05:51:44 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1998-12-30 06:24:46 +03:00
|
|
|
mime_type = gnome_mime_type_or_default (fname, NULL);
|
1998-12-16 05:51:44 +03:00
|
|
|
if (!mime_type)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
cmd = gnome_mime_get_value (mime_type, "fm-open");
|
|
|
|
|
|
|
|
if (cmd){
|
1998-12-30 21:29:32 +03:00
|
|
|
gmc_execute (fname, cmd);
|
1998-12-16 05:51:44 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd = gnome_mime_get_value (mime_type, "open");
|
|
|
|
if (cmd){
|
1998-12-30 21:29:32 +03:00
|
|
|
gmc_execute (fname, cmd);
|
1998-12-16 05:51:44 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-12-30 06:24:46 +03:00
|
|
|
int
|
|
|
|
gmc_open (file_entry *fe)
|
|
|
|
{
|
|
|
|
return gmc_open_filename (fe->fname, NULL);
|
|
|
|
}
|
|
|
|
|
1998-12-16 05:51:44 +03:00
|
|
|
static void
|
|
|
|
gmc_run_view (char *filename, char *buf)
|
|
|
|
{
|
|
|
|
exec_extension (filename, buf, NULL, NULL, 0);
|
|
|
|
}
|
|
|
|
|
1998-12-17 07:51:24 +03:00
|
|
|
int
|
1998-12-16 05:51:44 +03:00
|
|
|
gmc_view (char *filename, int start_line)
|
|
|
|
{
|
|
|
|
char *mime_type, *cmd;
|
|
|
|
char *buf;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
if (gnome_metadata_get (filename, "fm-view", &size, &buf) == 0){
|
|
|
|
gmc_run_view (filename, buf);
|
1999-01-06 07:03:15 +03:00
|
|
|
g_free (buf);
|
1998-12-16 05:51:44 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gnome_metadata_get (filename, "view", &size, &buf) == 0){
|
|
|
|
gmc_run_view (filename, buf);
|
1999-01-06 07:03:15 +03:00
|
|
|
g_free (buf);
|
1998-12-16 05:51:44 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mime_type = gnome_mime_type_or_default (filename, NULL);
|
|
|
|
if (!mime_type)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
cmd = gnome_mime_get_value (mime_type, "fm-view");
|
|
|
|
|
|
|
|
if (cmd){
|
|
|
|
gmc_run_view (filename, cmd);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd = gnome_mime_get_value (mime_type, "view");
|
|
|
|
if (cmd){
|
|
|
|
gmc_run_view (filename, cmd);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|