~ubuntu-branches/ubuntu/trusty/glib2.0/trusty-proposed

« back to all changes in this revision

Viewing changes to gio/glocalfileinfo.c

Tags: upstream-2.15.6
ImportĀ upstreamĀ versionĀ 2.15.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 
2
 
1
3
/* GIO - GLib Input, Output and Streaming Library
2
4
 * 
3
5
 * Copyright (C) 2006-2007 Red Hat, Inc.
1389
1391
  if (res == -1)
1390
1392
    {
1391
1393
      int errsv = errno;
1392
 
 
 
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);
1398
1401
      return NULL;
1399
1402
    }
1400
1403
  
1487
1490
          if (g_file_attribute_matcher_matches (attribute_matcher,
1488
1491
                                                G_FILE_ATTRIBUTE_STANDARD_ICON))
1489
1492
            {
1490
 
              char *mimetype_icon, *generic_mimetype_icon, *type_icon, *p;
1491
 
              char *icon_names[3];
1492
1493
              GIcon *icon;
1493
 
              int i;
1494
 
 
1495
 
              mimetype_icon = g_strdup (content_type);
1496
 
              
1497
 
              while ((p = strchr (mimetype_icon, '/')) != NULL)
1498
 
                *p = '-';
1499
 
 
1500
 
              p = strchr (content_type, '/');
1501
 
              if (p == NULL)
1502
 
                p = content_type + strlen (content_type);
1503
 
 
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;
1508
 
 
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";
1516
 
              else
1517
 
                type_icon = "text-x-generic";
1518
 
 
1519
 
              i = 0;
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;
1525
 
              
1526
 
              icon = g_themed_icon_new_from_names (icon_names, i);
1527
 
              g_file_info_set_icon (info, icon);
1528
 
              
1529
 
              g_object_unref (icon);
1530
 
              g_free (mimetype_icon);
1531
 
              g_free (generic_mimetype_icon);
 
1494
 
 
1495
              icon = g_content_type_get_icon (content_type);
 
1496
              if (icon != NULL)
 
1497
                {
 
1498
                  if (G_IS_THEMED_ICON (icon))
 
1499
                    {
 
1500
                      const char *type_icon;
 
1501
 
 
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";
 
1509
                      else
 
1510
                        type_icon = "text-x-generic";
 
1511
 
 
1512
                      g_themed_icon_append_name (G_THEMED_ICON (icon), type_icon);
 
1513
                    }
 
1514
 
 
1515
                  g_file_info_set_icon (info, icon);
 
1516
                  g_object_unref (icon);
 
1517
                }
1532
1518
            }
1533
1519
          
1534
1520
          g_free (content_type);