File configure changed (mode: 100755) (index f8102bcf8..609466e34) |
... |
... |
fi |
13107 |
13107 |
|
|
13108 |
13108 |
LIBS=$LIBS $GUI_LINK_OPTS_TERM |
LIBS=$LIBS $GUI_LINK_OPTS_TERM |
13109 |
13109 |
|
|
|
13110 |
|
|
|
13111 |
|
if pkg-config --exists glib-2.0 gtk+-2.0; then |
|
13112 |
|
CFLAGS="$CFLAGS $(pkg-config --cflags glib-2.0 gtk+-2.0)" |
|
13113 |
|
LIBS="$LIBS $(pkg-config --libs glib-2.0 gtk+-2.0)" |
|
13114 |
|
|
|
13115 |
|
$as_echo "#define HAVE_LIBGTK 1" >>confdefs.h |
|
13116 |
|
|
|
13117 |
|
fi |
|
13118 |
|
|
|
13119 |
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for magic_open in -lmagic" >&5 |
|
13120 |
|
$as_echo_n "checking for magic_open in -lmagic... " >&6; } |
|
13121 |
|
if ${ac_cv_lib_magic_magic_open+:} false; then : |
|
13122 |
|
$as_echo_n "(cached) " >&6 |
|
13123 |
|
else |
|
13124 |
|
ac_check_lib_save_LIBS=$LIBS |
|
13125 |
|
LIBS="-lmagic $LIBS" |
|
13126 |
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
|
13127 |
|
/* end confdefs.h. */ |
|
13128 |
|
|
|
13129 |
|
/* Override any GCC internal prototype to avoid an error. |
|
13130 |
|
Use char because int might match the return type of a GCC |
|
13131 |
|
builtin and then its argument prototype would still apply. */ |
|
13132 |
|
#ifdef __cplusplus |
|
13133 |
|
extern "C" |
|
13134 |
|
#endif |
|
13135 |
|
char magic_open (); |
|
13136 |
|
int |
|
13137 |
|
main () |
|
13138 |
|
{ |
|
13139 |
|
return magic_open (); |
|
13140 |
|
; |
|
13141 |
|
return 0; |
|
13142 |
|
} |
|
13143 |
|
_ACEOF |
|
13144 |
|
if ac_fn_c_try_link "$LINENO"; then : |
|
13145 |
|
ac_cv_lib_magic_magic_open=yes |
|
13146 |
|
else |
|
13147 |
|
ac_cv_lib_magic_magic_open=no |
|
13148 |
|
fi |
|
13149 |
|
rm -f core conftest.err conftest.$ac_objext \ |
|
13150 |
|
conftest$ac_exeext conftest.$ac_ext |
|
13151 |
|
LIBS=$ac_check_lib_save_LIBS |
|
13152 |
|
fi |
|
13153 |
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_magic_magic_open" >&5 |
|
13154 |
|
$as_echo "$ac_cv_lib_magic_magic_open" >&6; } |
|
13155 |
|
if test "x$ac_cv_lib_magic_magic_open" = xyes; then : |
|
13156 |
|
cat >>confdefs.h <<_ACEOF |
|
13157 |
|
#define HAVE_LIBMAGIC 1 |
|
13158 |
|
_ACEOF |
|
13159 |
|
|
|
13160 |
|
LIBS="-lmagic $LIBS" |
|
13161 |
|
|
|
13162 |
|
fi |
|
13163 |
|
|
|
13164 |
|
|
|
13165 |
|
|
13110 |
13166 |
# Check whether --enable-extended_keys was given. |
# Check whether --enable-extended_keys was given. |
13111 |
13167 |
if test "${enable_extended_keys+set}" = set; then : |
if test "${enable_extended_keys+set}" = set; then : |
13112 |
13168 |
enableval=$enable_extended_keys; extended_keys=$enableval |
enableval=$enable_extended_keys; extended_keys=$enableval |
File src/Makefile.in changed (mode: 100644) (index 5cc8e7f19..9bb79254b) |
... |
... |
PROGRAMS = $(bin_PROGRAMS) |
53 |
53 |
am_vifm_OBJECTS = background.$(OBJEXT) bookmarks.$(OBJEXT) \ |
am_vifm_OBJECTS = background.$(OBJEXT) bookmarks.$(OBJEXT) \ |
54 |
54 |
cmdline.$(OBJEXT) color_scheme.$(OBJEXT) commands.$(OBJEXT) \ |
cmdline.$(OBJEXT) color_scheme.$(OBJEXT) commands.$(OBJEXT) \ |
55 |
55 |
config.$(OBJEXT) dir_stack.$(OBJEXT) file_info.$(OBJEXT) \ |
config.$(OBJEXT) dir_stack.$(OBJEXT) file_info.$(OBJEXT) \ |
56 |
|
filelist.$(OBJEXT) fileops.$(OBJEXT) filetype.$(OBJEXT) \ |
|
57 |
|
keys.$(OBJEXT) main_loop.$(OBJEXT) menu.$(OBJEXT) \ |
|
58 |
|
menus.$(OBJEXT) modes.$(OBJEXT) normal.$(OBJEXT) \ |
|
59 |
|
permissions_dialog.$(OBJEXT) registers.$(OBJEXT) \ |
|
60 |
|
search.$(OBJEXT) signals.$(OBJEXT) sort.$(OBJEXT) \ |
|
61 |
|
sort_dialog.$(OBJEXT) status.$(OBJEXT) ui.$(OBJEXT) \ |
|
62 |
|
utils.$(OBJEXT) vifm.$(OBJEXT) visual.$(OBJEXT) |
|
|
56 |
|
file_magic.$(OBJEXT) filelist.$(OBJEXT) fileops.$(OBJEXT) \ |
|
57 |
|
filetype.$(OBJEXT) keys.$(OBJEXT) main_loop.$(OBJEXT) \ |
|
58 |
|
menu.$(OBJEXT) menus.$(OBJEXT) modes.$(OBJEXT) \ |
|
59 |
|
normal.$(OBJEXT) permissions_dialog.$(OBJEXT) \ |
|
60 |
|
registers.$(OBJEXT) search.$(OBJEXT) signals.$(OBJEXT) \ |
|
61 |
|
sort.$(OBJEXT) sort_dialog.$(OBJEXT) status.$(OBJEXT) \ |
|
62 |
|
ui.$(OBJEXT) utils.$(OBJEXT) vifm.$(OBJEXT) visual.$(OBJEXT) |
63 |
63 |
vifm_OBJECTS = $(am_vifm_OBJECTS) |
vifm_OBJECTS = $(am_vifm_OBJECTS) |
64 |
64 |
vifm_LDADD = $(LDADD) |
vifm_LDADD = $(LDADD) |
65 |
65 |
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; |
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; |
|
... |
... |
vifm_SOURCES = \ |
236 |
236 |
config.c config.h \ |
config.c config.h \ |
237 |
237 |
dir_stack.c dir_stack.h \ |
dir_stack.c dir_stack.h \ |
238 |
238 |
file_info.c file_info.h \ |
file_info.c file_info.h \ |
|
239 |
|
file_magic.c file_magic.h \ |
239 |
240 |
filelist.c filelist.h \ |
filelist.c filelist.h \ |
240 |
241 |
fileops.c fileops.h \ |
fileops.c fileops.h \ |
241 |
242 |
filetype.c filetype.h \ |
filetype.c filetype.h \ |
|
... |
... |
distclean-compile: |
386 |
387 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/config.Po@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/config.Po@am__quote@ |
387 |
388 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dir_stack.Po@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dir_stack.Po@am__quote@ |
388 |
389 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_info.Po@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_info.Po@am__quote@ |
|
390 |
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_magic.Po@am__quote@ |
389 |
391 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filelist.Po@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filelist.Po@am__quote@ |
390 |
392 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileops.Po@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileops.Po@am__quote@ |
391 |
393 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filetype.Po@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filetype.Po@am__quote@ |
File src/file_info.c changed (mode: 100644) (index 9c275e741..1d5cb329d) |
37 |
37 |
void |
void |
38 |
38 |
get_perm_string (char * buf, int len, mode_t mode) |
get_perm_string (char * buf, int len, mode_t mode) |
39 |
39 |
{ |
{ |
40 |
|
char *perm_sets[] = |
|
|
40 |
|
char *perm_sets[] = |
41 |
41 |
{ "---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx" }; |
{ "---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx" }; |
42 |
|
int u, g, o; |
|
43 |
|
|
|
44 |
|
u = (mode & S_IRWXU) >> 6; |
|
45 |
|
g = (mode & S_IRWXG) >> 3; |
|
46 |
|
o = (mode & S_IRWXO); |
|
47 |
|
|
|
48 |
|
snprintf (buf, len, "-%s%s%s", perm_sets[u], perm_sets[g], perm_sets[o]); |
|
49 |
|
|
|
50 |
|
if (S_ISLNK (mode)) |
|
51 |
|
buf[0] = 'l'; |
|
52 |
|
else if (S_ISDIR (mode)) |
|
53 |
|
buf[0] = 'd'; |
|
54 |
|
else if (S_ISBLK (mode)) |
|
55 |
|
buf[0] = 'b'; |
|
56 |
|
else if (S_ISCHR (mode)) |
|
57 |
|
buf[0] = 'c'; |
|
58 |
|
else if (S_ISFIFO (mode)) |
|
59 |
|
buf[0] = 'f'; |
|
60 |
|
else if (S_ISSOCK (mode)) |
|
61 |
|
buf[0] = 's'; |
|
62 |
|
|
|
63 |
|
if (mode & S_ISVTX) |
|
64 |
|
buf[9] = (buf[9] == '-') ? 'T' : 't'; |
|
65 |
|
if (mode & S_ISGID) |
|
66 |
|
buf[6] = (buf[6] == '-') ? 'S' : 's'; |
|
67 |
|
if (mode & S_ISUID) |
|
68 |
|
buf[3] = (buf[3] == '-') ? 'S' : 's'; |
|
|
42 |
|
int u, g, o; |
|
43 |
|
|
|
44 |
|
u = (mode & S_IRWXU) >> 6; |
|
45 |
|
g = (mode & S_IRWXG) >> 3; |
|
46 |
|
o = (mode & S_IRWXO); |
|
47 |
|
|
|
48 |
|
snprintf (buf, len, "-%s%s%s", perm_sets[u], perm_sets[g], perm_sets[o]); |
|
49 |
|
|
|
50 |
|
if (S_ISLNK (mode)) |
|
51 |
|
buf[0] = 'l'; |
|
52 |
|
else if (S_ISDIR (mode)) |
|
53 |
|
buf[0] = 'd'; |
|
54 |
|
else if (S_ISBLK (mode)) |
|
55 |
|
buf[0] = 'b'; |
|
56 |
|
else if (S_ISCHR (mode)) |
|
57 |
|
buf[0] = 'c'; |
|
58 |
|
else if (S_ISFIFO (mode)) |
|
59 |
|
buf[0] = 'f'; |
|
60 |
|
else if (S_ISSOCK (mode)) |
|
61 |
|
buf[0] = 's'; |
|
62 |
|
|
|
63 |
|
if (mode & S_ISVTX) |
|
64 |
|
buf[9] = (buf[9] == '-') ? 'T' : 't'; |
|
65 |
|
if (mode & S_ISGID) |
|
66 |
|
buf[6] = (buf[6] == '-') ? 'S' : 's'; |
|
67 |
|
if (mode & S_ISUID) |
|
68 |
|
buf[3] = (buf[3] == '-') ? 'S' : 's'; |
69 |
69 |
} |
} |
70 |
70 |
|
|
71 |
71 |
void |
void |
File src/file_magic.c added (mode: 100644) (index 000000000..eb49fdfff) |
|
1 |
|
#include "../config.h" |
|
2 |
|
|
|
3 |
|
#if defined(HAVE_LIBGTK) || defined(HAVE_LIBMAGIC) |
|
4 |
|
|
|
5 |
|
#ifdef HAVE_LIBGTK |
|
6 |
|
#include <gtk/gtk.h> |
|
7 |
|
#include <glib-2.0/gio/gio.h> |
|
8 |
|
#endif |
|
9 |
|
|
|
10 |
|
#ifdef HAVE_LIBMAGIC |
|
11 |
|
#include <magic.h> |
|
12 |
|
#endif |
|
13 |
|
|
|
14 |
|
#include <sys/dir.h> |
|
15 |
|
|
|
16 |
|
#include <stdio.h> |
|
17 |
|
#include <stdlib.h> |
|
18 |
|
#include <string.h> |
|
19 |
|
|
|
20 |
|
#include "status.h" |
|
21 |
|
|
|
22 |
|
#include "file_magic.h" |
|
23 |
|
|
|
24 |
|
static char* handlers; |
|
25 |
|
static size_t handlers_len; |
|
26 |
|
|
|
27 |
|
static int get_gtk_mimetype(const char* filename, char* buf); |
|
28 |
|
static int get_magic_mimetype(const char* filename, char* buf); |
|
29 |
|
static char * get_handlers(const char* mime_type); |
|
30 |
|
static void enum_files(const char* path, const char* mime_type); |
|
31 |
|
static void process_file(const char* path, const char* mime_type); |
|
32 |
|
static int ends_with(const char* str, const char* suffix); |
|
33 |
|
static void expand_desktop(const char* str, char* buf); |
|
34 |
|
|
|
35 |
|
char* |
|
36 |
|
get_magic_handlers(const char* file) |
|
37 |
|
{ |
|
38 |
|
char mimetype[128]; |
|
39 |
|
|
|
40 |
|
if(get_gtk_mimetype(file, mimetype) == -1) |
|
41 |
|
{ |
|
42 |
|
if(get_magic_mimetype(file, mimetype) == -1) |
|
43 |
|
return NULL; |
|
44 |
|
} |
|
45 |
|
|
|
46 |
|
return get_handlers(mimetype); |
|
47 |
|
} |
|
48 |
|
|
|
49 |
|
static int |
|
50 |
|
get_gtk_mimetype(const char* filename, char* buf) |
|
51 |
|
{ |
|
52 |
|
#ifdef HAVE_LIBGTK |
|
53 |
|
GFile* file; |
|
54 |
|
GFileInfo* info; |
|
55 |
|
|
|
56 |
|
if(!curr_stats.gtk_available) |
|
57 |
|
return -1; |
|
58 |
|
|
|
59 |
|
file = g_file_new_for_path(filename); |
|
60 |
|
info = g_file_query_info(file, "standard::", G_FILE_QUERY_INFO_NONE, NULL, |
|
61 |
|
NULL); |
|
62 |
|
if(info == NULL) |
|
63 |
|
{ |
|
64 |
|
g_object_unref(file); |
|
65 |
|
return -1; |
|
66 |
|
} |
|
67 |
|
|
|
68 |
|
strcpy(buf, g_file_info_get_content_type(info)); |
|
69 |
|
g_object_unref(info); |
|
70 |
|
g_object_unref(file); |
|
71 |
|
return 0; |
|
72 |
|
#else /* #ifdef HAVE_LIBGTK */ |
|
73 |
|
return -1; |
|
74 |
|
#endif /* #ifdef HAVE_LIBGTK */ |
|
75 |
|
} |
|
76 |
|
|
|
77 |
|
static int |
|
78 |
|
get_magic_mimetype(const char* filename, char* buf) |
|
79 |
|
{ |
|
80 |
|
#ifdef HAVE_LIBMAGIC |
|
81 |
|
magic_t magic; |
|
82 |
|
|
|
83 |
|
magic = magic_open(MAGIC_MIME_TYPE); |
|
84 |
|
if(magic == NULL) |
|
85 |
|
return -1; |
|
86 |
|
|
|
87 |
|
magic_load(magic, NULL); |
|
88 |
|
|
|
89 |
|
strcpy(buf, magic_file(magic, filename)); |
|
90 |
|
|
|
91 |
|
magic_close(magic); |
|
92 |
|
return 0; |
|
93 |
|
#else /* #ifdef HAVE_LIBMAGIC */ |
|
94 |
|
return -1; |
|
95 |
|
#endif /* #ifdef HAVE_LIBMAGIC */ |
|
96 |
|
} |
|
97 |
|
|
|
98 |
|
char * |
|
99 |
|
get_handlers(const char* mime_type) |
|
100 |
|
{ |
|
101 |
|
free(handlers); |
|
102 |
|
handlers = NULL; |
|
103 |
|
handlers_len = 0; |
|
104 |
|
|
|
105 |
|
enum_files("/usr/share/applications", mime_type); |
|
106 |
|
enum_files("/usr/local/share/applications", mime_type); |
|
107 |
|
|
|
108 |
|
return handlers; |
|
109 |
|
} |
|
110 |
|
|
|
111 |
|
static void |
|
112 |
|
enum_files(const char* path, const char* mime_type) |
|
113 |
|
{ |
|
114 |
|
DIR* dir; |
|
115 |
|
struct dirent* dentry; |
|
116 |
|
const char* slash = ""; |
|
117 |
|
|
|
118 |
|
dir = opendir(path); |
|
119 |
|
if(dir == NULL) |
|
120 |
|
{ |
|
121 |
|
perror("opendir"); |
|
122 |
|
return; |
|
123 |
|
} |
|
124 |
|
|
|
125 |
|
if(path[strlen(path) - 1] != '/') |
|
126 |
|
slash = "/"; |
|
127 |
|
|
|
128 |
|
while((dentry = readdir(dir)) != NULL) { |
|
129 |
|
char buf[PATH_MAX]; |
|
130 |
|
|
|
131 |
|
if(strcmp(dentry->d_name, ".") == 0) |
|
132 |
|
continue; |
|
133 |
|
else if (strcmp(dentry->d_name, "..") == 0) |
|
134 |
|
continue; |
|
135 |
|
|
|
136 |
|
snprintf(buf, sizeof (buf), "%s%s%s", path, slash, dentry->d_name); |
|
137 |
|
if(dentry->d_type == DT_DIR) |
|
138 |
|
enum_files(buf, mime_type); |
|
139 |
|
else |
|
140 |
|
process_file(buf, mime_type); |
|
141 |
|
} |
|
142 |
|
|
|
143 |
|
if(closedir(dir) != 0) |
|
144 |
|
perror("closedir"); |
|
145 |
|
} |
|
146 |
|
|
|
147 |
|
static void |
|
148 |
|
process_file(const char* path, const char* mime_type) |
|
149 |
|
{ |
|
150 |
|
FILE* f; |
|
151 |
|
char *p; |
|
152 |
|
char exec_buf[1024] = ""; |
|
153 |
|
char mime_type_buf[2048] = ""; |
|
154 |
|
char buf[2048]; |
|
155 |
|
|
|
156 |
|
if(!ends_with(path, ".desktop")) |
|
157 |
|
return; |
|
158 |
|
|
|
159 |
|
f = fopen(path, "r"); |
|
160 |
|
if(f == NULL) |
|
161 |
|
{ |
|
162 |
|
perror("fopen"); |
|
163 |
|
return; |
|
164 |
|
} |
|
165 |
|
|
|
166 |
|
while(fgets(buf, sizeof (buf), f) != NULL) |
|
167 |
|
{ |
|
168 |
|
size_t len = strlen(buf); |
|
169 |
|
|
|
170 |
|
if(buf[len - 1] == '\n') |
|
171 |
|
buf[len - 1] = '\0'; |
|
172 |
|
|
|
173 |
|
if(strncmp(buf, "Exec=", 5) == 0) |
|
174 |
|
strcpy(exec_buf, buf); |
|
175 |
|
else if (strncmp(buf, "MimeType=", 9) == 0) |
|
176 |
|
strcpy(mime_type_buf, buf); |
|
177 |
|
} |
|
178 |
|
|
|
179 |
|
fclose(f); |
|
180 |
|
|
|
181 |
|
if(strstr(mime_type_buf, mime_type) == NULL) |
|
182 |
|
return; |
|
183 |
|
if(exec_buf[0] == '\0') |
|
184 |
|
return; |
|
185 |
|
|
|
186 |
|
expand_desktop(exec_buf + 5, buf); |
|
187 |
|
p = realloc(handlers, handlers_len + 1 + strlen(buf) + 1); |
|
188 |
|
if(p == NULL) |
|
189 |
|
return; |
|
190 |
|
|
|
191 |
|
handlers = p; |
|
192 |
|
if(handlers_len == 0) |
|
193 |
|
*handlers = '\0'; |
|
194 |
|
else |
|
195 |
|
strcat(handlers, ","); |
|
196 |
|
handlers_len += 1 + strlen(buf); |
|
197 |
|
strcat(handlers, buf); |
|
198 |
|
} |
|
199 |
|
|
|
200 |
|
static int |
|
201 |
|
ends_with(const char* str, const char* suffix) |
|
202 |
|
{ |
|
203 |
|
size_t str_len = strlen(str); |
|
204 |
|
size_t suf_len = strlen(suffix); |
|
205 |
|
|
|
206 |
|
if(str_len < suf_len) |
|
207 |
|
return 0; |
|
208 |
|
else |
|
209 |
|
return (strcmp(suffix, str + str_len - suf_len) == 0); |
|
210 |
|
} |
|
211 |
|
|
|
212 |
|
static void |
|
213 |
|
expand_desktop(const char* str, char* buf) |
|
214 |
|
{ |
|
215 |
|
int substituted = 0; |
|
216 |
|
while(*str != '\0') |
|
217 |
|
{ |
|
218 |
|
if(*str != '%') |
|
219 |
|
{ |
|
220 |
|
*buf++ = *str++; |
|
221 |
|
continue; |
|
222 |
|
} |
|
223 |
|
str++; |
|
224 |
|
if(*str == 'c') |
|
225 |
|
{ |
|
226 |
|
substituted = 1; |
|
227 |
|
strcpy(buf, "caption"); |
|
228 |
|
buf += strlen(buf); |
|
229 |
|
} |
|
230 |
|
else if(strchr("Uuf", *str) != NULL) |
|
231 |
|
{ |
|
232 |
|
substituted = 1; |
|
233 |
|
strcpy(buf, "%f"); |
|
234 |
|
buf += strlen(buf); |
|
235 |
|
} |
|
236 |
|
str++; |
|
237 |
|
} |
|
238 |
|
if(substituted) |
|
239 |
|
*buf = '\0'; |
|
240 |
|
else |
|
241 |
|
{ |
|
242 |
|
*buf = ' '; |
|
243 |
|
strcpy(buf + 1, "%f"); |
|
244 |
|
} |
|
245 |
|
} |
|
246 |
|
|
|
247 |
|
#endif /* #if defined(HAVE_LIBGTK) || defined(HAVE_LIBMAGIC) */ |
|
248 |
|
|
|
249 |
|
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab : */ |
File src/menus.c changed (mode: 100644) (index d71b3f48c..dbfefa69d) |
25 |
25 |
#include <sys/ioctl.h> |
#include <sys/ioctl.h> |
26 |
26 |
#include <signal.h> |
#include <signal.h> |
27 |
27 |
|
|
|
28 |
|
#include "../config.h" |
|
29 |
|
|
28 |
30 |
#include "background.h" |
#include "background.h" |
29 |
31 |
#include "bookmarks.h" |
#include "bookmarks.h" |
30 |
32 |
#include "cmdline.h" |
#include "cmdline.h" |
31 |
33 |
#include "color_scheme.h" |
#include "color_scheme.h" |
32 |
34 |
#include "commands.h" |
#include "commands.h" |
33 |
35 |
#include "config.h" |
#include "config.h" |
|
36 |
|
#include "file_magic.h" |
34 |
37 |
#include "filelist.h" |
#include "filelist.h" |
35 |
38 |
#include "fileops.h" |
#include "fileops.h" |
36 |
39 |
#include "filetype.h" |
#include "filetype.h" |
|
... |
... |
reset_popup_menu(menu_info *m) |
149 |
152 |
free(m->title); |
free(m->title); |
150 |
153 |
|
|
151 |
154 |
werase(menu_win); |
werase(menu_win); |
152 |
|
redraw_window(); |
|
153 |
155 |
} |
} |
154 |
156 |
|
|
155 |
157 |
void |
void |
|
... |
... |
execute_apropos_cb(FileView *view, menu_info *m) |
458 |
460 |
} |
} |
459 |
461 |
else |
else |
460 |
462 |
free(free_this); |
free(free_this); |
461 |
|
|
|
462 |
463 |
} |
} |
463 |
464 |
|
|
464 |
465 |
static void |
static void |
|
... |
... |
execute_locate_cb(FileView *view, menu_info *m) |
512 |
513 |
free(free_this); |
free(free_this); |
513 |
514 |
} |
} |
514 |
515 |
|
|
|
516 |
|
static void |
|
517 |
|
execute_filetype(char *cmd, int background) |
|
518 |
|
{ |
|
519 |
|
if(!background) |
|
520 |
|
shellout(cmd, 0); |
|
521 |
|
else |
|
522 |
|
start_background_job(cmd); |
|
523 |
|
} |
|
524 |
|
|
515 |
525 |
static void |
static void |
516 |
526 |
execute_filetype_cb(FileView *view, menu_info *m) |
execute_filetype_cb(FileView *view, menu_info *m) |
517 |
527 |
{ |
{ |
|
... |
... |
execute_filetype_cb(FileView *view, menu_info *m) |
519 |
529 |
char *prog_str = get_all_programs_for_file(filename); |
char *prog_str = get_all_programs_for_file(filename); |
520 |
530 |
char command[NAME_MAX]; |
char command[NAME_MAX]; |
521 |
531 |
char *ptr = NULL; |
char *ptr = NULL; |
|
532 |
|
int background = m->extra_data; |
522 |
533 |
|
|
|
534 |
|
#if defined(HAVE_LIBGTK) || defined(HAVE_LIBMAGIC) |
|
535 |
|
if(prog_str == NULL) |
|
536 |
|
prog_str = get_magic_handlers(filename); |
|
537 |
|
#endif |
523 |
538 |
|
|
524 |
539 |
if((ptr = strchr(prog_str, ',')) == NULL) |
if((ptr = strchr(prog_str, ',')) == NULL) |
525 |
540 |
{ |
{ |
|
... |
... |
execute_filetype_cb(FileView *view, menu_info *m) |
527 |
542 |
{ |
{ |
528 |
543 |
int m = 0; |
int m = 0; |
529 |
544 |
char *expanded_command = expand_macros(view, prog_str, NULL, &m, 0); |
char *expanded_command = expand_macros(view, prog_str, NULL, &m, 0); |
530 |
|
shellout(expanded_command, 0); |
|
|
545 |
|
execute_filetype(expanded_command, background); |
531 |
546 |
free(expanded_command); |
free(expanded_command); |
532 |
547 |
return; |
return; |
533 |
548 |
} |
} |
534 |
549 |
else |
else |
535 |
550 |
{ |
{ |
536 |
551 |
snprintf(command, sizeof(command), "%s %s", prog_str, filename); |
snprintf(command, sizeof(command), "%s %s", prog_str, filename); |
537 |
|
shellout(command, 0); |
|
|
552 |
|
execute_filetype(command, background); |
538 |
553 |
return; |
return; |
539 |
554 |
} |
} |
540 |
555 |
} |
} |
|
... |
... |
execute_filetype_cb(FileView *view, menu_info *m) |
556 |
571 |
{ |
{ |
557 |
572 |
int m = 0; |
int m = 0; |
558 |
573 |
char *expanded_command = expand_macros(view, prog_copy, NULL, &m, 0); |
char *expanded_command = expand_macros(view, prog_copy, NULL, &m, 0); |
559 |
|
shellout(expanded_command, 0); |
|
|
574 |
|
execute_filetype(expanded_command, background); |
560 |
575 |
free(expanded_command); |
free(expanded_command); |
561 |
576 |
free(free_this); |
free(free_this); |
562 |
577 |
return; |
return; |
563 |
578 |
} |
} |
564 |
579 |
else |
else |
565 |
580 |
{ |
{ |
566 |
|
snprintf(command, sizeof(command), "%s %s", |
|
567 |
|
prog_copy, filename); |
|
568 |
|
shellout(command, 0); |
|
|
581 |
|
snprintf(command, sizeof(command), "%s %s", prog_copy, filename); |
|
582 |
|
execute_filetype(command, background); |
569 |
583 |
free(free_this); |
free(free_this); |
570 |
584 |
return; |
return; |
571 |
585 |
} |
} |
|
... |
... |
execute_filetype_cb(FileView *view, menu_info *m) |
577 |
591 |
{ |
{ |
578 |
592 |
int m = 0; |
int m = 0; |
579 |
593 |
char *expanded_command = expand_macros(view, prog_copy, NULL, &m, 0); |
char *expanded_command = expand_macros(view, prog_copy, NULL, &m, 0); |
580 |
|
shellout(expanded_command, 0); |
|
|
594 |
|
execute_filetype(expanded_command, background); |
581 |
595 |
free(expanded_command); |
free(expanded_command); |
582 |
596 |
free(free_this); |
free(free_this); |
583 |
597 |
return; |
return; |
|
... |
... |
execute_filetype_cb(FileView *view, menu_info *m) |
585 |
599 |
else |
else |
586 |
600 |
{ |
{ |
587 |
601 |
snprintf(command, sizeof(command), "%s %s", prog_copy, filename); |
snprintf(command, sizeof(command), "%s %s", prog_copy, filename); |
588 |
|
shellout(command, 0); |
|
|
602 |
|
execute_filetype(command, background); |
589 |
603 |
free(free_this); |
free(free_this); |
590 |
604 |
return; |
return; |
591 |
605 |
} |
} |
|
... |
... |
execute_menu_cb(FileView *view, menu_info *m) |
616 |
630 |
execute_jobs_cb(view, m); |
execute_jobs_cb(view, m); |
617 |
631 |
break; |
break; |
618 |
632 |
case LOCATE: |
case LOCATE: |
619 |
|
execute_locate_cb(view, m); |
|
620 |
|
break; |
|
|
633 |
|
execute_locate_cb(view, m); |
621 |
634 |
break; |
break; |
622 |
635 |
case VIFM: |
case VIFM: |
623 |
636 |
break; |
break; |
|
... |
... |
reload_bookmarks_menu_list(menu_info *m) |
634 |
647 |
|
|
635 |
648 |
getmaxyx(menu_win, z, len); |
getmaxyx(menu_win, z, len); |
636 |
649 |
|
|
637 |
|
|
|
638 |
650 |
for (z = 0; z < m->len; z++) |
for (z = 0; z < m->len; z++) |
639 |
651 |
{ |
{ |
640 |
652 |
free(m->data[z]); |
free(m->data[z]); |
|
... |
... |
show_commands_menu(FileView *view) |
914 |
926 |
} |
} |
915 |
927 |
|
|
916 |
928 |
void |
void |
917 |
|
show_filetypes_menu(FileView *view) |
|
|
929 |
|
show_filetypes_menu(FileView *view, int force_mime, int background) |
918 |
930 |
{ |
{ |
919 |
931 |
char *filename = get_current_file_name(view); |
char *filename = get_current_file_name(view); |
920 |
932 |
char *prog_str = get_all_programs_for_file(filename); |
char *prog_str = get_all_programs_for_file(filename); |
921 |
|
if (prog_str == NULL) |
|
922 |
|
{ |
|
923 |
|
show_error_msg(" Filetype is not set. ", |
|
|
933 |
|
|
|
934 |
|
#if defined(HAVE_LIBGTK) || defined(HAVE_LIBMAGIC) |
|
935 |
|
if(prog_str == NULL || force_mime) |
|
936 |
|
prog_str = get_magic_handlers(filename); |
|
937 |
|
#endif |
|
938 |
|
|
|
939 |
|
if(prog_str == NULL) { |
|
940 |
|
show_error_msg(" Filetype is not set. ", |
924 |
941 |
"No programs set for this filetype."); |
"No programs set for this filetype."); |
925 |
942 |
return; |
return; |
926 |
943 |
} |
} |
927 |
|
else |
|
|
944 |
|
|
928 |
945 |
{ |
{ |
929 |
946 |
int x = 0; |
int x = 0; |
930 |
947 |
int len = 0; |
int len = 0; |
|
... |
... |
show_filetypes_menu(FileView *view) |
943 |
960 |
m.title = NULL; |
m.title = NULL; |
944 |
961 |
m.args = NULL; |
m.args = NULL; |
945 |
962 |
m.data = NULL; |
m.data = NULL; |
|
963 |
|
m.extra_data = background; |
946 |
964 |
|
|
947 |
965 |
getmaxyx(menu_win, m.win_rows, len); |
getmaxyx(menu_win, m.win_rows, len); |
948 |
966 |
|
|
File src/menus.h changed (mode: 100644) (index 54e5a066b..0b766d9b7) |
... |
... |
typedef struct menu_info |
54 |
54 |
char *title; |
char *title; |
55 |
55 |
char *args; |
char *args; |
56 |
56 |
char **data; |
char **data; |
|
57 |
|
int extra_data; /* for filetype background flag */ |
57 |
58 |
/* For user menus only */ |
/* For user menus only */ |
58 |
59 |
char *get_info_script; /* program + args to fill in menu. */ |
char *get_info_script; /* program + args to fill in menu. */ |
59 |
60 |
}menu_info; |
}menu_info; |
|
... |
... |
void show_bookmarks_menu(FileView *view); |
62 |
63 |
void show_commands_menu(FileView *view); |
void show_commands_menu(FileView *view); |
63 |
64 |
void show_history_menu(FileView *view); |
void show_history_menu(FileView *view); |
64 |
65 |
void show_vifm_menu(FileView *view); |
void show_vifm_menu(FileView *view); |
65 |
|
void show_filetypes_menu(FileView *view); |
|
|
66 |
|
void show_filetypes_menu(FileView *view, int force_mime, int background); |
66 |
67 |
void show_jobs_menu(FileView *view); |
void show_jobs_menu(FileView *view); |
67 |
68 |
void show_locate_menu(FileView *view, char *args); |
void show_locate_menu(FileView *view, char *args); |
68 |
69 |
void show_apropos_menu(FileView *view, char *args); |
void show_apropos_menu(FileView *view, char *args); |
File src/ui.c changed (mode: 100644) (index 2fd593145..9dfc76b71) |
... |
... |
update_stat_window(FileView *view) |
139 |
139 |
mvwaddstr(stat_win, 0, cur_x, size_buf); |
mvwaddstr(stat_win, 0, cur_x, size_buf); |
140 |
140 |
cur_x += 12; |
cur_x += 12; |
141 |
141 |
mvwaddstr(stat_win, 0, cur_x, perm_buf); |
mvwaddstr(stat_win, 0, cur_x, perm_buf); |
142 |
|
cur_x += 9; |
|
|
142 |
|
cur_x += 10; |
143 |
143 |
mvwaddstr(stat_win, 0, cur_x, id_buf); |
mvwaddstr(stat_win, 0, cur_x, id_buf); |
144 |
144 |
snprintf(name_buf, sizeof(name_buf), "%d %s filtered", |
snprintf(name_buf, sizeof(name_buf), "%d %s filtered", |
145 |
145 |
view->filtered, view->filtered == 1 ? "file" : "files"); |
view->filtered, view->filtered == 1 ? "file" : "files"); |
File src/vifmrc changed (mode: 100644) (index afd628bc0..bb48d3d2f) |
... |
... |
SHOW_FULL=0 |
81 |
81 |
|
|
82 |
82 |
USE_VIM_HELP=0 |
USE_VIM_HELP=0 |
83 |
83 |
|
|
84 |
|
# If you would like to run an executable file when you |
|
|
84 |
|
# If you would like to run an executable file when you |
85 |
85 |
# press return on the file name set this to 1. |
# press return on the file name set this to 1. |
86 |
86 |
|
|
87 |
87 |
RUN_EXECUTABLE=0 |
RUN_EXECUTABLE=0 |
|
... |
... |
FILETYPE=Archive=tar.gz,tgz==tar -tzf %f | less,tar -zxvf %f |
129 |
129 |
|
|
130 |
130 |
# For automated FUSE mounts, you must register an extension with FILETYPE=.. |
# For automated FUSE mounts, you must register an extension with FILETYPE=.. |
131 |
131 |
# in the following format: |
# in the following format: |
132 |
|
# FILETYPE=description=extensions=FUSE_MOUNT|some_mount_command using %SOURCE_FILE and %DESTINATION_DIR variables |
|
|
132 |
|
# FILETYPE=description=extensions=consoleviewer=FUSE_MOUNT|some_mount_command using %SOURCE_FILE and %DESTINATION_DIR variables |
133 |
133 |
# %SOURCE_FILE and %DESTINATION_DIR are filled in by vifm at runtime. |
# %SOURCE_FILE and %DESTINATION_DIR are filled in by vifm at runtime. |
134 |
134 |
# A sample line might look like this: |
# A sample line might look like this: |
135 |
|
# FILETYPE=FuseZipMount=zip,jar,war,ear=FUSE_MOUNT|fuse-zip %SOURCE_FILE %DESTINATION_DIR |
|
|
135 |
|
# FILETYPE=FuseZipMount=zip,jar,war,ear==FUSE_MOUNT|fuse-zip %SOURCE_FILE %DESTINATION_DIR |
136 |
136 |
|
|
137 |
137 |
# The FUSE_HOME directory will be used as a root dir for all FUSE mounts. |
# The FUSE_HOME directory will be used as a root dir for all FUSE mounts. |
138 |
138 |
# Unless it exists with write/exec permissions set, vifm will attempt to create it. |
# Unless it exists with write/exec permissions set, vifm will attempt to create it. |