4 * ROX-Filer, filer for the ROX desktop project
5 * By Thomas Leonard, <tal197@ecs.soton.ac.uk>.
8 /* type.c - code for dealing with filetypes */
18 #include "gui_support.h"
23 /* Static prototypes */
25 /* XXX: Just for testing... */
26 static MIME_type text_plain
= {"text/plain"};
27 static MIME_type image_xpm
= {"image/x-xpixmap"};
33 char *basetype_name(FileItem
*item
)
35 if (item
->flags
& ITEM_FLAG_SYMLINK
)
37 else if (item
->flags
& ITEM_FLAG_MOUNT_POINT
)
39 else if (item
->flags
& ITEM_FLAG_APPDIR
)
42 switch (item
->base_type
)
48 case TYPE_CHAR_DEVICE
:
50 case TYPE_BLOCK_DEVICE
:
61 /* MIME-type guessing */
63 /* Returns a pointer to the MIME-type string, or NULL if we have
66 MIME_type
*type_from_path(char *path
)
68 if (strstr(path
, ".xpm"))
73 /* Actions for types */
75 gboolean
type_open(char *path
, MIME_type
*type
)
77 char *argv
[] = {NULL
, path
, NULL
};
80 gboolean needs_free
= FALSE
;
82 open
= choices_find_path_load_shared(type
->name
, "MIME-open");
86 if (stat(open
, &info
))
88 report_error("ROX-Filer", g_strerror(errno
));
92 if (S_ISDIR(info
.st_mode
))
94 argv
[0] = g_strconcat(open
, "/AppRun");
101 report_error("ROX-Filer",
102 "Failed to fork() child process");
110 MaskedPixmap
*type_to_icon(GtkWidget
*window
, MIME_type
*type
)
119 path
= g_strconcat(type
->name
, ".xpm", NULL
);
120 open
= choices_find_path_load_shared(path
, "MIME-icons");
122 type
->image
= load_pixmap_from(window
, open
);
124 type
->image
= default_pixmap
+ TYPE_UNKNOWN
;