1391
1393
int errsv = errno;
1394
char *display_name = g_filename_display_name (path);
1393
1395
g_object_unref (info);
1394
1396
g_set_error (error, G_IO_ERROR,
1395
1397
g_io_error_from_errno (errsv),
1396
1398
_("Error stating file '%s': %s"),
1397
path, g_strerror (errsv));
1399
display_name, g_strerror (errsv));
1400
g_free (display_name);
1487
1490
if (g_file_attribute_matcher_matches (attribute_matcher,
1488
1491
G_FILE_ATTRIBUTE_STANDARD_ICON))
1490
char *mimetype_icon, *generic_mimetype_icon, *type_icon, *p;
1491
char *icon_names[3];
1495
mimetype_icon = g_strdup (content_type);
1497
while ((p = strchr (mimetype_icon, '/')) != NULL)
1500
p = strchr (content_type, '/');
1502
p = content_type + strlen (content_type);
1504
generic_mimetype_icon = g_malloc (p - content_type + strlen ("-x-generic") + 1);
1505
memcpy (generic_mimetype_icon, content_type, p - content_type);
1506
memcpy (generic_mimetype_icon + (p - content_type), "-x-generic", strlen ("-x-generic"));
1507
generic_mimetype_icon[(p - content_type) + strlen ("-x-generic")] = 0;
1509
/* TODO: Special case desktop dir? That could be expensive with xdg dirs... */
1510
if (strcmp (path, g_get_home_dir ()) == 0)
1511
type_icon = "user-home";
1512
else if (S_ISDIR (statbuf.st_mode))
1513
type_icon = "folder";
1514
else if (statbuf.st_mode & S_IXUSR)
1515
type_icon = "application-x-executable";
1517
type_icon = "text-x-generic";
1520
icon_names[i++] = mimetype_icon;
1521
icon_names[i++] = generic_mimetype_icon;
1522
if (strcmp (generic_mimetype_icon, type_icon) != 0 &&
1523
strcmp (mimetype_icon, type_icon) != 0)
1524
icon_names[i++] = type_icon;
1526
icon = g_themed_icon_new_from_names (icon_names, i);
1527
g_file_info_set_icon (info, icon);
1529
g_object_unref (icon);
1530
g_free (mimetype_icon);
1531
g_free (generic_mimetype_icon);
1495
icon = g_content_type_get_icon (content_type);
1498
if (G_IS_THEMED_ICON (icon))
1500
const char *type_icon;
1502
/* TODO: Special case desktop dir? That could be expensive with xdg dirs... */
1503
if (strcmp (path, g_get_home_dir ()) == 0)
1504
type_icon = "user-home";
1505
else if (S_ISDIR (statbuf.st_mode))
1506
type_icon = "folder";
1507
else if (statbuf.st_mode & S_IXUSR)
1508
type_icon = "application-x-executable";
1510
type_icon = "text-x-generic";
1512
g_themed_icon_append_name (G_THEMED_ICON (icon), type_icon);
1515
g_file_info_set_icon (info, icon);
1516
g_object_unref (icon);
1534
1520
g_free (content_type);