Commiting the MIME-based Midnight Commander code into the MC_MIME_TYPE branch

This commit is contained in:
Miguel de Icaza 1998-12-16 06:25:41 +00:00
parent 549fecfff7
commit cb83d83796
9 changed files with 130 additions and 100 deletions

View File

@ -8,7 +8,7 @@ GNOMEDEFS = -DHAVE_X -DHAVE_GNOME @GNOME_INCLUDEDIR@
CFLAGS = -g $(XCFLAGS) @X_CFLAGS@
CPPFLAGS = $(XCPPFLAGS) -I$(vfsdir) -I$(slangdir) $(GNOMEDEFS)
LDFLAGS = $(XLDFLAGS) @GNOME_LIBDIR@ @GNOMEUI_LIBS@
CORBA_LDFLAGS = $(XLDFLAGS) @GNOME_LIBDIR@ @GNOMEGNORBA_LIBS@
pCORBA_LDFLAGS = $(XLDFLAGS) @GNOME_LIBDIR@ @GNOMEGNORBA_LIBS@
DEFS = $(XDEFS)
LIBS = $(XLIBS) @TERMNET@
EXTRALIBS = @LVFS@ -lgtkedit @LINTL@
@ -117,6 +117,7 @@ CORBAOBJS = \
OBJS = \
$(LOBJS) \
$(OOBJS) \
gaction.o \
gblist.o \
gcache.o \
gcliplabel.o \

View File

@ -247,6 +247,8 @@ gicon_get_icon_for_file (file_entry *fe)
*/
if (gnome_metadata_get (fe->fname, "icon-filename", &size, &buf) == 0){
image = gicon_get_by_filename (buf);
free (buf);
if (image)
return image;

View File

@ -332,28 +332,35 @@ get_label_text (GtkMenuItem *item)
}
static void
regex_command_from_panel (GtkMenuItem *item, WPanel *panel)
mime_command_from_panel (GtkMenuItem *item, WPanel *panel)
{
char *filename;
char *action;
int movedir;
/* This is broken */
filename = panel->dir.list[panel->selected].fname;
action = get_label_text (item);
regex_command (filename, action, NULL, &movedir);
/*
* This is broken, but we dont mind. Federico
* needs to explain me what was he intending here.
* panel->selected does not mean, it was the icon
* that got clicked.
*/
}
static void
regex_command_from_desktop_icon (GtkMenuItem *item, char *filename)
mime_command_from_desktop_icon (GtkMenuItem *item, char *filename)
{
char *action;
int movedir;
char *key, *mime_type, *val;
action = get_label_text (item);
regex_command (filename, action, NULL, &movedir);
key = gtk_object_get_user_data (GTK_OBJECT (item));
mime_type = gnome_mime_type_or_default (filename, NULL);
if (!mime_type)
return;
val = gnome_mime_get_value (mime_type, key);
exec_extension (filename, val, NULL, NULL, 0);
}
/* Create the menu items common to files from panel window and desktop icons, and also the items for
@ -366,8 +373,8 @@ create_regexp_actions (GtkWidget *menu, WPanel *panel, int panel_row, char *file
GnomeUIInfo *a_uiinfo;
int i;
GtkSignalFunc regex_callback;
char *p, *q;
int c;
char *mime_type;
GList *keys, *l;
GnomeUIInfo uiinfo[] = {
{ 0 },
GNOMEUIINFO_END
@ -376,12 +383,12 @@ create_regexp_actions (GtkWidget *menu, WPanel *panel, int panel_row, char *file
if (panel) {
a_uiinfo = panel_actions;
closure = panel;
regex_callback = regex_command_from_desktop_icon;
regex_callback = mime_command_from_desktop_icon;
regex_closure = filename;
} else {
a_uiinfo = desktop_icon_actions;
closure = filename;
regex_callback = regex_command_from_desktop_icon;
regex_callback = mime_command_from_desktop_icon;
regex_closure = filename;
}
@ -395,30 +402,34 @@ create_regexp_actions (GtkWidget *menu, WPanel *panel, int panel_row, char *file
/* Fill in the regex command part */
p = regex_command (filename, NULL, NULL, NULL);
if (!p)
mime_type = gnome_mime_type_or_default (filename, NULL);
if (!mime_type)
return;
keys = gnome_mime_get_keys (mime_type);
for (;;) {
/* Strip off an entry */
for (l = keys; l; l = l->next) {
char *key = l->data;
char *str;
str = key;
if (strncmp (key, "open.", 5) != 0)
continue;
while (*p == ' ' || *p == '\t')
p++;
str += 5;
while (*str && *str != '.')
str++;
if (!*p)
break;
q = p;
while (*q && *q != '=' && *q != '\t')
q++;
c = *q;
*q = 0;
if (*str)
str++;
if (!*str)
continue;
/* Create the item for that entry */
uiinfo[0].type = GNOME_APP_UI_ITEM;
uiinfo[0].label = p;
uiinfo[0].label = str;
uiinfo[0].hint = NULL;
uiinfo[0].moreinfo = regex_callback;
uiinfo[0].user_data = regex_closure;
@ -430,14 +441,9 @@ create_regexp_actions (GtkWidget *menu, WPanel *panel, int panel_row, char *file
uiinfo[0].widget = NULL;
fill_menu (GTK_MENU_SHELL (menu), uiinfo, insert_pos++);
/* Next! */
if (!c)
break;
p = q + 1;
gtk_object_set_user_data (GTK_OBJECT (uiinfo [0].widget), key);
}
g_list_free (keys);
}
/* Convenience callback to exit the main loop of a modal popup menu when it is deactivated*/

View File

@ -1108,6 +1108,8 @@ panel_icon_list_select_icon (GtkWidget *widget, int index, GdkEvent *event, WPan
display_mini_info (panel);
execute_hooks (select_file_hook);
if (event)
printf ("Icon list select icon, event->type= %d %d %d\n", event->type, GDK_BUTTON_PRESS, GDK_2BUTTON_PRESS);
if (!event)
return;
@ -2095,8 +2097,9 @@ x_create_panel (Dlg_head *h, widget_data parent, WPanel *panel)
button_switch_to_listing (panel),
"Switch view to detailed view.", NULL);
dock = gnome_dock_item_new ("gmc-toolbar", GNOME_DOCK_ITEM_BEH_EXCLUSIVE | GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL);
gtk_container_add(GTK_CONTAINER(dock),status_line);
gnome_dock_add_item (GNOME_DOCK(GNOME_APP (panel->xwindow)->dock), dock, GNOME_DOCK_TOP, 1, 0, 0, FALSE);
gtk_container_add (GTK_CONTAINER(dock),status_line);
gnome_dock_add_item (GNOME_DOCK(GNOME_APP (panel->xwindow)->dock),
GNOME_DOCK_ITEM (dock), GNOME_DOCK_TOP, 1, 0, 0, FALSE);
gtk_widget_show_all (dock);

116
po/mc.pot
View File

@ -1,6 +1,6 @@
msgid ""
msgstr ""
"Date: 1998-12-11 03:58:53-0600\n"
"Date: 1998-12-15 04:49:13-0600\n"
"From: Miguel de Icaza,computo,622-4680 <miguel@metropolis.nuclecu.unam.mx>\n"
"Content-Type: text/plain; charset=\n"
"Xgettext-Options: --default-domain=mc --directory=.. --add-comments --keyword=_ --keyword=N_ --files-from=./POTFILES.in\n"
@ -39,7 +39,7 @@ msgstr ""
msgid "The GNOME edition of the Midnight Commander file manager."
msgstr ""
#: gnome/gcmd.c:93 src/main.c:813 src/screen.c:2047
#: gnome/gcmd.c:93 src/main.c:813 src/screen.c:2050
msgid " The Midnight Commander "
msgstr ""
@ -47,11 +47,11 @@ msgstr ""
msgid " Do you really want to quit the Midnight Commander? "
msgstr ""
#: gnome/gcmd.c:95 gtkedit/editcmd.c:2235 src/cmd.c:249 src/file.c:1715 src/file.c:2078 src/hotlist.c:1029 src/main.c:815 src/screen.c:2049 src/subshell.c:701 src/subshell.c:727 src/tree.c:1205 src/view.c:408
#: gnome/gcmd.c:95 gtkedit/editcmd.c:2235 src/cmd.c:249 src/file.c:1715 src/file.c:2078 src/hotlist.c:1029 src/main.c:815 src/screen.c:2052 src/subshell.c:701 src/subshell.c:727 src/tree.c:1205 src/view.c:408
msgid "&Yes"
msgstr ""
#: gnome/gcmd.c:95 gtkedit/editcmd.c:2235 src/cmd.c:249 src/file.c:1715 src/file.c:2078 src/hotlist.c:1029 src/main.c:815 src/screen.c:2049 src/subshell.c:701 src/subshell.c:727 src/tree.c:1205 src/view.c:408
#: gnome/gcmd.c:95 gtkedit/editcmd.c:2235 src/cmd.c:249 src/file.c:1715 src/file.c:2078 src/hotlist.c:1029 src/main.c:815 src/screen.c:2052 src/subshell.c:701 src/subshell.c:727 src/tree.c:1205 src/view.c:408
msgid "&No"
msgstr ""
@ -487,96 +487,95 @@ msgstr ""
msgid "Select icon"
msgstr ""
#: gnome/gscreen.c:1199
#: gnome/gscreen.c:1323
msgid "All files"
msgstr ""
#: gnome/gscreen.c:1201
#: gnome/gscreen.c:1325
msgid "Archives and compressed files"
msgstr ""
#: gnome/gscreen.c:1203
#: gnome/gscreen.c:1327
msgid "RPM/DEB files"
msgstr ""
#: gnome/gscreen.c:1205
#: gnome/gscreen.c:1329
msgid "Text/Document files"
msgstr ""
#: gnome/gscreen.c:1207
#: gnome/gscreen.c:1331
msgid "HTML and SGML files"
msgstr ""
#: gnome/gscreen.c:1209
#: gnome/gscreen.c:1333
msgid "Postscript and PDF files"
msgstr ""
#: gnome/gscreen.c:1211
#: gnome/gscreen.c:1335
msgid "Spreadsheet files"
msgstr ""
#: gnome/gscreen.c:1213
#: gnome/gscreen.c:1337
msgid "Image files"
msgstr ""
#: gnome/gscreen.c:1216
#: gnome/gscreen.c:1340
msgid "Video/animation files"
msgstr ""
#: gnome/gscreen.c:1218
#: gnome/gscreen.c:1342
msgid "Audio files"
msgstr ""
#: gnome/gscreen.c:1220
#: gnome/gscreen.c:1344
msgid "C program files"
msgstr ""
#: gnome/gscreen.c:1222
#: gnome/gscreen.c:1346
msgid "C++ program files"
msgstr ""
#: gnome/gscreen.c:1224
#: gnome/gscreen.c:1348
msgid "Objective-C program files"
msgstr ""
#: gnome/gscreen.c:1226
#: gnome/gscreen.c:1350
msgid "Scheme program files"
msgstr ""
#: gnome/gscreen.c:1228
#: gnome/gscreen.c:1352
msgid "Assembler program files"
msgstr ""
#: gnome/gscreen.c:1230
#: gnome/gscreen.c:1354
msgid "Misc. program files"
msgstr ""
#: gnome/gscreen.c:1232
#: gnome/gscreen.c:1356
msgid "Font files"
msgstr ""
#: gnome/gscreen.c:1359
#: gnome/gscreen.c:1483
msgid "Search: %s"
msgstr ""
#: gnome/gscreen.c:1368
#: gnome/gscreen.c:1492
msgid "%s bytes in %d file"
msgstr ""
#: gnome/gscreen.c:1368
#: gnome/gscreen.c:1492
msgid "%s bytes in %d files"
msgstr ""
#. free (str);
#: gnome/gscreen.c:1393 src/screen.c:673
#: gnome/gscreen.c:1515 src/screen.c:673
msgid "<readlink failed>"
msgstr ""
#: gnome/gscreen.c:1444
#: gnome/gscreen.c:1566
msgid "Filter"
msgstr ""
#: gnome/gscreen.c:1895
#: gnome/gscreen.c:2075
msgid "Location:"
msgstr ""
@ -702,7 +701,7 @@ msgid "abort"
msgstr ""
#. The file-name is printed after the ':'
#: gtkedit/edit.c:127 gtkedit/edit.c:222 gtkedit/edit.c:229 gtkedit/edit.c:236 gtkedit/edit.c:243 gtkedit/edit.c:249 gtkedit/edit.c:306 gtkedit/edit.c:342 gtkedit/editcmd.c:1932 gtkedit/editwidget.c:1016 src/dir.c:378 src/screen.c:2298 src/tree.c:1145 src/tree.c:1151 src/wtools.c:225 vfs/fish.c:226
#: gtkedit/edit.c:127 gtkedit/edit.c:222 gtkedit/edit.c:229 gtkedit/edit.c:236 gtkedit/edit.c:243 gtkedit/edit.c:249 gtkedit/edit.c:306 gtkedit/edit.c:342 gtkedit/editcmd.c:1932 gtkedit/editwidget.c:1016 src/dir.c:377 src/screen.c:2304 src/tree.c:1145 src/tree.c:1151 src/wtools.c:225 vfs/fish.c:226
msgid " Error "
msgstr ""
@ -737,7 +736,7 @@ msgid " Save As "
msgstr ""
#. the file exists
#: gtkedit/editcmd.c:482 gtkedit/editcmd.c:801 gtkedit/editcmd.c:831 gtkedit/editcmd.c:978 gtkedit/editcmd.c:1075 src/ext.c:295 src/file.c:674 src/help.c:321 src/main.c:660 src/screen.c:2063 src/subshell.c:700 src/subshell.c:726 src/utilunix.c:384 src/utilunix.c:388 src/utilunix.c:454 vfs/mcfs.c:171
#: gtkedit/editcmd.c:482 gtkedit/editcmd.c:801 gtkedit/editcmd.c:831 gtkedit/editcmd.c:978 gtkedit/editcmd.c:1075 src/ext.c:295 src/file.c:674 src/help.c:321 src/main.c:660 src/screen.c:2066 src/subshell.c:700 src/subshell.c:726 src/utilunix.c:384 src/utilunix.c:388 src/utilunix.c:454 vfs/mcfs.c:171
msgid " Warning "
msgstr ""
@ -1432,7 +1431,7 @@ msgstr ""
msgid "Error initialising editor.\n"
msgstr ""
#: gtkedit/editwidget.c:1129 gtkedit/gtkedit.c:1210 src/help.c:809 src/main.c:1678 src/screen.c:2276 src/screen.c:2306 src/tree.c:1478 src/view.c:1963
#: gtkedit/editwidget.c:1129 gtkedit/gtkedit.c:1210 src/help.c:809 src/main.c:1678 src/screen.c:2282 src/screen.c:2312 src/tree.c:1478 src/view.c:1963
msgid "Help"
msgstr ""
@ -1444,7 +1443,7 @@ msgstr ""
msgid "Replac"
msgstr ""
#: gtkedit/editwidget.c:1133 gtkedit/gtkedit.c:1160 src/screen.c:2280 src/screen.c:2310 src/tree.c:1484
#: gtkedit/editwidget.c:1133 gtkedit/gtkedit.c:1160 src/screen.c:2286 src/screen.c:2316 src/tree.c:1484
msgid "Copy"
msgstr ""
@ -1452,7 +1451,7 @@ msgstr ""
msgid "Move"
msgstr ""
#: gtkedit/editwidget.c:1136 src/screen.c:2283 src/screen.c:2313
#: gtkedit/editwidget.c:1136 src/screen.c:2289 src/screen.c:2319
msgid "Delete"
msgstr ""
@ -1584,7 +1583,7 @@ msgstr ""
msgid "Info about GNOME hello"
msgstr ""
#: gtkedit/gtkedit.c:1208 src/screen.c:2279 src/screen.c:2309 src/view.c:1972
#: gtkedit/gtkedit.c:1208 src/screen.c:2285 src/screen.c:2315 src/view.c:1972
msgid "Edit"
msgstr ""
@ -2286,67 +2285,68 @@ msgid ""
"\n"
msgstr ""
#: src/dir.c:57
#: src/dir.c:56
msgid "&Unsorted"
msgstr ""
#: src/dir.c:58
#: src/dir.c:57
msgid "&Name"
msgstr ""
#: src/dir.c:59
#: src/dir.c:58
msgid "&Extension"
msgstr ""
#: src/dir.c:60
#: src/dir.c:59
msgid "&Modify time"
msgstr ""
#: src/dir.c:61
#: src/dir.c:60
msgid "&Access time"
msgstr ""
#: src/dir.c:62
#: src/dir.c:61
msgid "&Change time"
msgstr ""
#: src/dir.c:63
#: src/dir.c:62
msgid "&Size"
msgstr ""
#: src/dir.c:64
#: src/dir.c:63
msgid "&Inode"
msgstr ""
#: src/dir.c:67
#. New sort orders
#: src/dir.c:66
msgid "&Type"
msgstr ""
#: src/dir.c:68
#: src/dir.c:67
msgid "&Links"
msgstr ""
#: src/dir.c:69
#: src/dir.c:68
msgid "N&GID"
msgstr ""
#: src/dir.c:70
#: src/dir.c:69
msgid "N&UID"
msgstr ""
#: src/dir.c:71
#: src/dir.c:70
msgid "&Owner"
msgstr ""
#: src/dir.c:72
#: src/dir.c:71
msgid "&Group"
msgstr ""
#: src/dir.c:378
#: src/dir.c:377
msgid "File exists but can not be stat-ed: %s %s"
msgstr ""
#: src/dir.c:635
#: src/dir.c:632
msgid "Unknown"
msgstr ""
@ -3551,7 +3551,7 @@ msgid ""
" the details. "
msgstr ""
#: src/main.c:1679 src/screen.c:2277 src/screen.c:2307
#: src/main.c:1679 src/screen.c:2283 src/screen.c:2313
msgid "Menu"
msgstr ""
@ -3814,31 +3814,31 @@ msgstr ""
msgid " %s bytes in %d file%s"
msgstr ""
#: src/screen.c:1311
#: src/screen.c:1314
msgid "Unknow tag on display format: "
msgstr ""
#: src/screen.c:2048
#: src/screen.c:2051
msgid " Do you really want to execute? "
msgstr ""
#: src/screen.c:2063
#: src/screen.c:2066
msgid " No action taken "
msgstr ""
#: src/screen.c:2278 src/screen.c:2308
#: src/screen.c:2284 src/screen.c:2314
msgid "View"
msgstr ""
#: src/screen.c:2281 src/screen.c:2311 src/tree.c:1486
#: src/screen.c:2287 src/screen.c:2317 src/tree.c:1486
msgid "RenMov"
msgstr ""
#: src/screen.c:2282 src/screen.c:2312 src/tree.c:1490
#: src/screen.c:2288 src/screen.c:2318 src/tree.c:1490
msgid "Mkdir"
msgstr ""
#: src/screen.c:2298
#: src/screen.c:2304
msgid ""
" Can't chdir to %s \n"
" %s "

View File

@ -174,6 +174,11 @@ int view_file_at_line (char *filename, int plain_view, int internal, int start_l
if (internal){
char view_entry [32];
#ifdef HAVE_GNOME
if (!gmc_view (filename, start_line)){
view (0, filename, &move_dir, start_line);
}
#else
if (start_line != 0)
sprintf (view_entry, "View:%d", start_line);
else
@ -183,6 +188,7 @@ int view_file_at_line (char *filename, int plain_view, int internal, int start_l
view (0, filename, &move_dir, start_line);
repaint_screen ();
}
#endif
} else {
char *localcopy;

View File

@ -53,6 +53,7 @@
#include <sys/wait.h>
#endif /* SCO_FLAVOR */
#include <glib.h>
/* "$Id$" */
/* If set, we execute the file command to check the file type */
@ -102,7 +103,7 @@ quote_block (quote_func_t quote_func, char **quoting_block)
return result;
}
static void
void
exec_extension (char *filename, char *data, char **drops, int *move_dir, int start_line)
{
char *file_name;
@ -124,6 +125,9 @@ exec_extension (char *filename, char *data, char **drops, int *move_dir, int sta
struct stat mystat;
quote_func_t quote_func = name_quote;
g_return_if_fail (filename != NULL);
g_return_if_fail (data != NULL);
/* Avoid making a local copy if we are doing a cd */
if (!vfs_file_is_local(filename))
do_local_copy = 1;

View File

@ -2,6 +2,7 @@
#define __EXT_H
char *regex_command (char *filename, char *action, char **drops, int *move_dir);
void exec_extension (char *filename, char *data, char **drops, int *move_dir, int start_line);
/* Call it after the user has edited the mc.ext file,
* to flush the cached mc.ext file

View File

@ -2056,8 +2056,15 @@ do_enter_on_file_entry (file_entry *fe)
return 1;
} else {
char *p;
#ifdef HAVE_GNOME
if (gmc_open (fe))
return 1;
else
return 0;
#else
p = regex_command (fe->fname, "Open", NULL, 0);
#endif
if (p && (strcmp (p, "Success") == 0))
return 1;
else