Try to get real mime type for bak files

master
Yevgen Muntyan 2007-03-31 00:53:42 -05:00
parent c66f97a3ba
commit 6e325a8e25
2 changed files with 17 additions and 1 deletions

View File

@ -34,7 +34,7 @@
</configure>
</optimized>
</configurations>
<file_selector_dir>/home/muntyan/projects/moo/</file_selector_dir>
<file_selector_dir>/home/muntyan/projects/moo/moo/mooedit/</file_selector_dir>
<run>
<args>--g-fatal-warnings --new-app --mode=project</args>
<exe>medit/medit</exe>

View File

@ -303,6 +303,22 @@ moo_file_selector_activate (MooFileView *fileview,
#ifdef MOO_USE_XDGMIME
{
const char *mime_type = xdg_mime_get_mime_type_for_file (path, &statbuf);
if (!strcmp (mime_type, "application/x-trash"))
{
guint i;
const char *bak_suffixes[] = {"~", "%", ".bak", ".old", ".sik"};
for (i = 0; i < G_N_ELEMENTS (bak_suffixes); ++i)
if (g_str_has_suffix (path, bak_suffixes[i]))
{
char *tmp = g_strndup (path, strlen (path) - strlen (bak_suffixes[i]));
mime_type = xdg_mime_get_mime_type_from_file_name (tmp);
g_free (tmp);
break;
}
}
is_text = !strcmp (mime_type, "application/octet-stream") ||
xdg_mime_mime_type_subclass (mime_type, "text/plain");
is_exe = !strcmp (mime_type, "application/x-executable");