mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
be7cbf3768
Wed Jan 27 03:14:46 1999 Timur Bakeyev <mc@bat.ru> * Converted memory managment to Glib - where it wasn't done. Now we use g_new()/g_malloc()/g_strdup()/g_free() routings. copy_strings() re- placed by g_strconcat(), and sprintf() by g_snprintf(). Some other, minor changes.
115 lines
2.0 KiB
C
115 lines
2.0 KiB
C
#include <config.h>
|
|
#include <string.h>
|
|
#include "x.h"
|
|
#include "global.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
|
|
gmc_execute (char *fname, char *buf)
|
|
{
|
|
exec_extension (fname, buf, NULL, NULL, 0);
|
|
}
|
|
|
|
int
|
|
gmc_open_filename (char *fname, GList *args)
|
|
{
|
|
char *mime_type, *cmd;
|
|
char *buf;
|
|
int size;
|
|
|
|
if (gnome_metadata_get (fname, "fm-open", &size, &buf) == 0){
|
|
gmc_execute (fname, buf);
|
|
g_free (buf);
|
|
return 1;
|
|
}
|
|
|
|
if (gnome_metadata_get (fname, "open", &size, &buf) == 0){
|
|
gmc_execute (fname, buf);
|
|
g_free (buf);
|
|
return 1;
|
|
}
|
|
|
|
mime_type = gnome_mime_type_or_default (fname, NULL);
|
|
if (!mime_type)
|
|
return 0;
|
|
|
|
|
|
cmd = gnome_mime_get_value (mime_type, "fm-open");
|
|
|
|
if (cmd){
|
|
gmc_execute (fname, cmd);
|
|
return 1;
|
|
}
|
|
|
|
cmd = gnome_mime_get_value (mime_type, "open");
|
|
if (cmd){
|
|
gmc_execute (fname, cmd);
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
gmc_open (file_entry *fe)
|
|
{
|
|
return gmc_open_filename (fe->fname, NULL);
|
|
}
|
|
|
|
static void
|
|
gmc_run_view (char *filename, char *buf)
|
|
{
|
|
exec_extension (filename, buf, NULL, NULL, 0);
|
|
}
|
|
|
|
int
|
|
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);
|
|
g_free (buf);
|
|
return 1;
|
|
}
|
|
|
|
if (gnome_metadata_get (filename, "view", &size, &buf) == 0){
|
|
gmc_run_view (filename, buf);
|
|
g_free (buf);
|
|
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;
|
|
}
|