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
};
81 gboolean needs_free
= FALSE
;
83 type_path
= g_string_new(type
->name
);
84 g_string_append(type_path
, "/open");
85 open
= choices_find_path_load_shared(type_path
->str
, "MIME-types");
86 g_string_free(type_path
, TRUE
);
91 if (stat(open
, &info
))
93 report_error("ROX-Filer", g_strerror(errno
));
97 if (S_ISDIR(info
.st_mode
))
99 argv
[0] = g_strconcat(open
, "/AppRun");
106 report_error("ROX-Filer",
107 "Failed to fork() child process");
115 MaskedPixmap
*type_to_icon(GtkWidget
*window
, MIME_type
*type
)
124 path
= g_strconcat(type
->name
, "/icon.xpm", NULL
);
125 open
= choices_find_path_load_shared(path
, "MIME-types");
126 type
->image
= load_pixmap_from(window
, open
);
128 type
->image
= default_pixmap
+ TYPE_UNKNOWN
;