1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2012 David Zeuthen <zeuthen@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib/gi18n-lib.h>
#include "udisksobjectinfo.h"
#include "udisksclient.h"
#include "udisks-generated.h"
/**
* SECTION:udisksobjectinfo
* @title: UDisksObjectInfo
* @short_description: Detailed information about objects
*
* Detailed information about the D-Bus interfaces (such as
* #UDisksBlock and #UDisksDrive) on a #UDisksObject that is suitable
* to display in an user interface. Use
* udisks_client_get_object_info() to get #UDisksObjectInfo objects.
* Note that #UDisksObjectInfo is an immutable object; once it has
* been created it cannot be modified further.
*
* The <link
* linkend="gdbus-property-org-freedesktop-UDisks2-Block.HintName">HintName</link>
* and/or <link
* linkend="gdbus-property-org-freedesktop-UDisks2-Block.HintName">HintIconName</link>
* propreties on associated #UDisksBlock interfaces (if any) may
* influence what udisks_object_info_get_icon() and
* udisks_object_info_get_media_icon() returns.
*
* The value return by udisks_object_info_get_one_liner() is designed
* to contain enough information such that it is all that needs to be
* shown about the object. As a result for e.g. block devices or
* drives it contains the special device file
* e.g. <filename>/dev/sda</filename>.
*
* Since: 2.1
*/
/**
* UDisksObjectInfo:
*
* The #UDisksObjectInfo structure contains only private data and
* should only be accessed using the provided API.
*
* Since: 2.1
*/
struct _UDisksObjectInfo
{
GObject parent_instance;
UDisksObject *object;
gchar *name;
gchar *description;
GIcon *icon;
GIcon *icon_symbolic;
gchar *media_description;
GIcon *media_icon;
GIcon *media_icon_symbolic;
gchar *one_liner;
gchar *sort_key;
};
typedef struct _UDisksObjectInfoClass UDisksObjectInfoClass;
struct _UDisksObjectInfoClass
{
GObjectClass parent_class;
};
G_DEFINE_TYPE (UDisksObjectInfo, udisks_object_info, G_TYPE_OBJECT);
/* ---------------------------------------------------------------------------------------------------- */
static void
udisks_object_info_finalize (GObject *object)
{
UDisksObjectInfo *info = UDISKS_OBJECT_INFO (object);
g_clear_object (&info->object);
g_free (info->name);
g_free (info->description);
g_clear_object (&info->icon);
g_clear_object (&info->icon_symbolic);
g_free (info->media_description);
g_clear_object (&info->media_icon);
g_clear_object (&info->media_icon_symbolic);
g_free (info->one_liner);
g_free (info->sort_key);
G_OBJECT_CLASS (udisks_object_info_parent_class)->finalize (object);
}
static void
udisks_object_info_init (UDisksObjectInfo *info)
{
}
static void
udisks_object_info_class_init (UDisksObjectInfoClass *klass)
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = udisks_object_info_finalize;
}
static UDisksObjectInfo *
udisks_object_info_new (UDisksObject *object)
{
UDisksObjectInfo *ret;
g_return_val_if_fail (object == NULL || UDISKS_IS_OBJECT (object), NULL);
ret = g_object_new (UDISKS_TYPE_OBJECT_INFO, NULL);
ret->object = object != NULL ? g_object_ref (object) : NULL;
return ret;
}
/* ---------------------------------------------------------------------------------------------------- */
typedef enum
{
DRIVE_TYPE_UNSET,
DRIVE_TYPE_DRIVE,
DRIVE_TYPE_DISK,
DRIVE_TYPE_CARD,
DRIVE_TYPE_DISC
} DriveType;
static const struct
{
const gchar *id;
const gchar *media_name;
const gchar *media_family;
const gchar *media_icon;
const gchar *media_icon_symbolic;
DriveType media_type;
const gchar *drive_icon;
const gchar *drive_icon_symbolic;
} media_data[] =
{
/* Translators: 'Thumb' here refers to "USB thumb drive", see http://en.wikipedia.org/wiki/Thumb_drive */
{"thumb", NC_("media-type", "Thumb"), NC_("media-type", "Thumb"), "media-removable", "media-removable-symbolic", DRIVE_TYPE_DRIVE, "media-removable", "media-removable-symbolic"},
{"floppy", NC_("media-type", "Floppy"), NC_("media-type", "Floppy"), "media-floppy", "media-floppy-symbolic", DRIVE_TYPE_DISK, "drive-removable-media-floppy", "drive-removable-media-symbolic"},
{"floppy_zip", NC_("media-type", "Zip"), NC_("media-type", "Zip"), "media-floppy-jaz", "media-floppy-symbolic", DRIVE_TYPE_DISK, "drive-removable-media-floppy-jaz", "drive-removable-media-symbolic"},
{"floppy_jaz", NC_("media-type", "Jaz"), NC_("media-type", "Jaz"), "media-floppy-zip", "media-floppy-symbolic", DRIVE_TYPE_DISK, "drive-removable-media-floppy-zip", "drive-removable-media-symbolic"},
{"flash", NC_("media-type", "Flash"), NC_("media-type", "Flash"), "media-flash", "media-flash-symbolic", DRIVE_TYPE_CARD, "drive-removable-media-flash", "drive-removable-media-symbolic"},
{"flash_ms", NC_("media-type", "MemoryStick"), NC_("media-type", "MemoryStick"), "media-flash-ms", "media-flash-symbolic", DRIVE_TYPE_CARD, "drive-removable-media-flash-ms", "drive-removable-media-symbolic"},
{"flash_sm", NC_("media-type", "SmartMedia"), NC_("media-type", "SmartMedia"), "media-flash-sm", "media-flash-symbolic", DRIVE_TYPE_CARD, "drive-removable-media-flash-sm", "drive-removable-media-symbolic"},
{"flash_cf", NC_("media-type", "CompactFlash"), NC_("media-type", "CompactFlash"), "media-flash-cf", "media-flash-symbolic", DRIVE_TYPE_CARD, "drive-removable-media-flash-cf", "drive-removable-media-symbolic"},
{"flash_mmc", NC_("media-type", "MMC"), NC_("media-type", "SD"), "media-flash-mmc", "media-flash-symbolic", DRIVE_TYPE_CARD, "drive-removable-media-flash-mmc", "drive-removable-media-symbolic"},
{"flash_sd", NC_("media-type", "SD"), NC_("media-type", "SD"), "media-flash-sd", "media-flash-symbolic", DRIVE_TYPE_CARD, "drive-removable-media-flash-sd", "drive-removable-media-symbolic"},
{"flash_sdxc", NC_("media-type", "SDXC"), NC_("media-type", "SD"), "media-flash-sd-xc", "media-flash-symbolic", DRIVE_TYPE_CARD, "drive-removable-media-flash-sd-xc", "drive-removable-media-symbolic"},
{"flash_sdhc", NC_("media-type", "SDHC"), NC_("media-type", "SD"), "media-flash-sd-hc", "media-flash-symbolic", DRIVE_TYPE_CARD, "drive-removable-media-flash-sd-hc", "drive-removable-media-symbolic"},
{"optical_cd", NC_("media-type", "CD-ROM"), NC_("media-type", "CD"), "media-optical-cd-rom", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical", "drive-optical-symbolic"},
{"optical_cd_r", NC_("media-type", "CD-R"), NC_("media-type", "CD"), "media-optical-cd-r", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_cd_rw", NC_("media-type", "CD-RW"), NC_("media-type", "CD"), "media-optical-cd-rw", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_dvd", NC_("media-type", "DVD"), NC_("media-type", "DVD"), "media-optical-dvd-rom", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical", "drive-optical-symbolic"},
{"optical_dvd_r", NC_("media-type", "DVD-R"), NC_("media-type", "DVD"), "media-optical-dvd-r", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_dvd_rw", NC_("media-type", "DVD-RW"), NC_("media-type", "DVD"), "media-optical-dvd-rw", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_dvd_ram", NC_("media-type", "DVD-RAM"), NC_("media-type", "DVD"), "media-optical-dvd-ram", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_dvd_plus_r", NC_("media-type", "DVD+R"), NC_("media-type", "DVD"), "media-optical-dvd-r-plus", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_dvd_plus_rw", NC_("media-type", "DVD+RW"), NC_("media-type", "DVD"), "media-optical-dvd-rw-plus", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_dvd_plus_r_dl", NC_("media-type", "DVD+R DL"), NC_("media-type", "DVD"), "media-optical-dvd-dl-r-plus", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_dvd_plus_rw_dl", NC_("media-type", "DVD+RW DL"), NC_("media-type", "DVD"), "media-optical-dvd-dl-r-plus", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_bd", NC_("media-type", "BD-ROM"), NC_("media-type", "Blu-Ray"), "media-optical-bd-rom", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical", "drive-optical-symbolic"},
{"optical_bd_r", NC_("media-type", "BD-R"), NC_("media-type", "Blu-Ray"), "media-optical-bd-r", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_bd_re", NC_("media-type", "BD-RE"), NC_("media-type", "Blu-Ray"), "media-optical-bd-re", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_hddvd", NC_("media-type", "HDDVD"), NC_("media-type", "HDDVD"), "media-optical-hddvd-rom", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical", "drive-optical-symbolic"},
{"optical_hddvd_r", NC_("media-type", "HDDVD-R"), NC_("media-type", "HDDVD"), "media-optical-hddvd-r", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_hddvd_rw", NC_("media-type", "HDDVD-RW"), NC_("media-type", "HDDVD"), "media-optical-hddvd-rw", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_mo", NC_("media-type", "MO"), NC_("media-type", "CD"), "media-optical-mo", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical", "drive-optical-symbolic"},
{"optical_mrw", NC_("media-type", "MRW"), NC_("media-type", "CD"), "media-optical-mrw", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
{"optical_mrw_w", NC_("media-type", "MRW-W"), NC_("media-type", "CD"), "media-optical-mrw-w", "media-optical-symbolic", DRIVE_TYPE_DISC, "drive-optical-recorder", "drive-optical-symbolic"},
};
/* ---------------------------------------------------------------------------------------------------- */
static const gchar *
last_segment (const gchar *str)
{
const gchar *ret = NULL;
gint n;
gint len;
if (str == NULL)
goto out;
len = strlen (str);
if (len == 0)
{
ret = str;
goto out;
}
for (n = len - 1; n >= 0; --n)
{
if (str[n] == '/' && n < len - 1)
{
ret = str + n + 1;
goto out;
}
}
ret = str;
out:
return ret;
}
static void
udisks_client_get_object_info_for_block (UDisksClient *client,
UDisksBlock *block,
UDisksPartition *partition,
UDisksObjectInfo *info)
{
guint64 size = 0;
gchar *size_str = NULL;
gchar *s;
size = udisks_block_get_size (block);
if (size > 0)
size_str = udisks_client_get_size_for_display (client, size, FALSE, FALSE);
info->icon = g_themed_icon_new_with_default_fallbacks ("drive-removable-media");
info->icon_symbolic = g_themed_icon_new_with_default_fallbacks ("drive-removable-media-symbolic");
info->name = udisks_block_dup_preferred_device (block);
if (size_str != NULL)
{
info->description = g_strdup_printf (_("%s Block Device"), size_str);
}
else
{
info->description = g_strdup (_("Block Device"));
}
if (partition != NULL)
{
/* Translators: Used to describe a partition of a block device.
* The %u is the partition number.
* The %s is the description for the block device (e.g. "5 GB Block Device").
*/
s = g_strdup_printf (C_("part-block", "Partition %u of %s"),
udisks_partition_get_number (partition), info->description);
g_free (info->description);
info->description = s;
}
/* Translators: String used for one-liner description of a block device.
* The first %s is the description of the object (e.g. "50 GB Block Device").
* The second %s is the special device file (e.g. "/dev/sda2").
*/
info->one_liner = g_strdup_printf (C_("one-liner-block", "%s (%s)"),
info->description,
udisks_block_get_preferred_device (block));
info->sort_key = g_strdup_printf ("02_block_%s_%u",
last_segment (g_dbus_object_get_object_path (G_DBUS_OBJECT (info->object))),
partition != NULL ? udisks_partition_get_number (partition) : 0);
g_free (size_str);
}
/* ---------------------------------------------------------------------------------------------------- */
static void
udisks_client_get_object_info_for_loop (UDisksClient *client,
UDisksLoop *loop,
UDisksBlock *block,
UDisksPartition *partition,
UDisksObjectInfo *info)
{
guint64 size = 0;
gchar *size_str = NULL;
gchar *s;
size = udisks_block_get_size (block);
if (size > 0)
size_str = udisks_client_get_size_for_display (client, size, FALSE, FALSE);
info->icon = g_themed_icon_new_with_default_fallbacks ("drive-removable-media");
info->icon_symbolic = g_themed_icon_new_with_default_fallbacks ("drive-removable-media-symbolic");
info->name = udisks_loop_dup_backing_file (loop);
if (size_str != NULL)
{
info->description = g_strdup_printf (_("%s Loop Device"), size_str);
}
else
{
info->description = g_strdup (_("Loop Device"));
}
if (partition != NULL)
{
/* Translators: Used to describe a partition of a loop device.
* The %u is the partition number.
* The %s is the description for the loop device (e.g. "5 GB Loop Device").
*/
s = g_strdup_printf (C_("part-loop", "Partition %u of %s"),
udisks_partition_get_number (partition), info->description);
g_free (info->description);
info->description = s;
}
/* Translators: String used for one-liner description of a loop device.
* The first %s is the description of the object (e.g. "2 GB Loop Device").
* The second %s is the name of the backing file (e.g. "/home/davidz/file.iso").
* The third %s is the special device file (e.g. "/dev/loop2").
*/
info->one_liner = g_strdup_printf (C_("one-liner-loop", "%s — %s (%s)"),
info->description,
info->name,
udisks_block_get_preferred_device (block));
info->sort_key = g_strdup_printf ("03_loop_%s_%u",
last_segment (g_dbus_object_get_object_path (G_DBUS_OBJECT (info->object))),
partition != NULL ? udisks_partition_get_number (partition) : 0);
g_free (size_str);
}
/* ---------------------------------------------------------------------------------------------------- */
static const gchar *
format_mdraid_level (const gchar *level)
{
const gchar *ret = NULL;
if (g_strcmp0 (level, "raid0") == 0)
ret = C_("mdraid-desc", "RAID-0 Array");
else if (g_strcmp0 (level, "raid1") == 0)
ret = C_("mdraid-desc", "RAID-1 Array");
else if (g_strcmp0 (level, "raid4") == 0)
ret = C_("mdraid-desc", "RAID-4 Array");
else if (g_strcmp0 (level, "raid5") == 0)
ret = C_("mdraid-desc", "RAID-5 Array");
else if (g_strcmp0 (level, "raid6") == 0)
ret = C_("mdraid-desc", "RAID-6 Array");
else if (g_strcmp0 (level, "raid10") == 0)
ret = C_("mdraid-desc", "RAID-10 Array");
else
ret = C_("mdraid-desc", "RAID Array");
return ret;
}
static void
udisks_client_get_object_info_for_mdraid (UDisksClient *client,
UDisksMDRaid *mdraid,
UDisksPartition *partition,
UDisksObjectInfo *info)
{
UDisksBlock *block = NULL;
guint64 size = 0;
gchar *size_str = NULL;
const gchar *name;
const gchar *level;
gchar *s;
block = udisks_client_get_block_for_mdraid (client, mdraid);
size = udisks_mdraid_get_size (mdraid);
if (size > 0)
size_str = udisks_client_get_size_for_display (client, size, FALSE, FALSE);
name = udisks_mdraid_get_name (mdraid);
s = strstr (name, ":");
if (s != NULL && strlen (s) > 1)
info->name = g_strdup (s + 1);
else
info->name = g_strdup (name);
info->icon = g_themed_icon_new_with_default_fallbacks ("drive-multidisk");
info->icon_symbolic = g_themed_icon_new_with_default_fallbacks ("drive-multidisk-symbolic");
level = udisks_mdraid_get_level (mdraid);
if (size_str != NULL)
{
/* Translators: Used to format the description for a RAID array.
* The first %s is the size (e.g. '42.0 GB').
* The second %s is the level (e.g. 'RAID-5 Array').
*/
info->description = g_strdup_printf (C_("mdraid-desc", "%s %s"),
size_str,
format_mdraid_level (level));
}
else
{
info->description = g_strdup (format_mdraid_level (level));
}
if (partition != NULL)
{
/* Translators: Used to describe a partition of a RAID Array.
* The %u is the partition number.
* The %s is the description for the drive (e.g. "2 TB RAID-5").
*/
s = g_strdup_printf (C_("part-raid", "Partition %u of %s"),
udisks_partition_get_number (partition), info->description);
g_free (info->description);
info->description = s;
}
if (strlen (info->name) > 0)
{
if (block != NULL)
{
/* Translators: String used for one-liner description of running RAID array.
* The first %s is the array name (e.g. "AlphaGo").
* The second %s is the size and level (e.g. "2 TB RAID-5").
* The third %s is the special device file (e.g. "/dev/sda").
*/
info->one_liner = g_strdup_printf (C_("one-liner-mdraid-running", "%s — %s (%s)"),
info->name,
info->description,
udisks_block_get_preferred_device (block));
}
else
{
/* Translators: String used for one-liner description of non-running RAID array.
* The first %s is the array name (e.g. "AlphaGo").
* The second %s is the size and level (e.g. "2 TB RAID-5").
*/
info->one_liner = g_strdup_printf (C_("one-liner-mdraid-not-running", "%s — %s"),
info->name,
info->description);
}
}
else
{
if (block != NULL)
{
/* Translators: String used for one-liner description of running RAID array w/o a name.
* The first %s is the size and level (e.g. "2 TB RAID-5").
* The second %s is the special device file (e.g. "/dev/sda").
*/
info->one_liner = g_strdup_printf (C_("one-liner-mdraid-no-name-running", "%s — %s"),
info->description,
udisks_block_get_preferred_device (block));
}
else
{
/* Translators: String used for one-liner description of non-running RAID array w/o a name.
* The %s is the size and level (e.g. "2 TB RAID-5").
*/
info->one_liner = g_strdup_printf (C_("one-liner-mdraid-no-name-not-running", "%s"),
info->description);
}
}
g_clear_object (&block);
info->sort_key = g_strdup_printf ("01_mdraid_%s_%u", udisks_mdraid_get_uuid (mdraid),
partition != NULL ? udisks_partition_get_number (partition) : 0);
g_free (size_str);
}
/* ---------------------------------------------------------------------------------------------------- */
static gboolean
strv_has (const gchar * const *haystack,
const gchar *needle)
{
gboolean ret;
guint n;
ret = FALSE;
for (n = 0; haystack != NULL && haystack[n] != NULL; n++)
{
if (g_strcmp0 (haystack[n], needle) == 0)
{
ret = TRUE;
goto out;
}
}
out:
return ret;
}
/* ---------------------------------------------------------------------------------------------------- */
static void
udisks_client_get_object_info_for_drive (UDisksClient *client,
UDisksDrive *drive,
UDisksPartition *partition,
UDisksObjectInfo *info)
{
const gchar *vendor;
const gchar *model;
const gchar *media;
const gchar *const *media_compat;
gboolean media_available;
gboolean media_removable;
gint rotation_rate;
guint64 size;
gchar *size_str;
guint n;
GString *desc_str;
DriveType desc_type;
gchar *hyphenated_connection_bus;
const gchar *connection_bus;
UDisksBlock *block = NULL;
gchar *s;
const gchar *cs;
UDisksBlock *block_for_partition = NULL;
g_return_if_fail (UDISKS_IS_DRIVE (drive));
size_str = NULL;
vendor = udisks_drive_get_vendor (drive);
model = udisks_drive_get_model (drive);
size = udisks_drive_get_size (drive);
media_removable = udisks_drive_get_media_removable (drive);
media_available = udisks_drive_get_media_available (drive);
rotation_rate = udisks_drive_get_rotation_rate (drive);
if (size > 0)
size_str = udisks_client_get_size_for_display (client, size, FALSE, FALSE);
media = udisks_drive_get_media (drive);
media_compat = udisks_drive_get_media_compatibility (drive);
connection_bus = udisks_drive_get_connection_bus (drive);
if (strlen (connection_bus) > 0)
hyphenated_connection_bus = g_strdup_printf ("-%s", connection_bus);
else
hyphenated_connection_bus = g_strdup ("");
/* Name is easy - that's just "$vendor $model" */
if (strlen (vendor) == 0)
vendor = NULL;
if (strlen (model) == 0)
model = NULL;
info->name = g_strdup_printf ("%s%s%s",
vendor != NULL ? vendor : "",
vendor != NULL ? " " : "",
model != NULL ? model : "");
desc_type = DRIVE_TYPE_UNSET;
desc_str = g_string_new (NULL);
for (n = 0; n < G_N_ELEMENTS (media_data) - 1; n++)
{
/* media_compat */
if (strv_has (media_compat, media_data[n].id))
{
if (info->icon == NULL)
info->icon = g_themed_icon_new_with_default_fallbacks (media_data[n].drive_icon);
if (info->icon_symbolic == NULL)
info->icon_symbolic = g_themed_icon_new_with_default_fallbacks (media_data[n].drive_icon_symbolic);
if (strstr (desc_str->str, media_data[n].media_family) == NULL)
{
if (desc_str->len > 0)
g_string_append (desc_str, "/");
g_string_append (desc_str, g_dpgettext2 (GETTEXT_PACKAGE, "media-type", media_data[n].media_family));
}
desc_type = media_data[n].media_type;
}
if (media_removable && media_available)
{
/* media */
if (g_strcmp0 (media, media_data[n].id) == 0)
{
if (info->media_description == NULL)
{
switch (media_data[n].media_type)
{
case DRIVE_TYPE_UNSET:
g_assert_not_reached ();
break;
case DRIVE_TYPE_DRIVE:
/* Translators: Used to describe drive without removable media. The %s is the type, e.g. 'Thumb' */
info->media_description = g_strdup_printf (C_("drive-with-fixed-media", "%s Drive"), g_dpgettext2 (GETTEXT_PACKAGE, "media-type", media_data[n].media_name));
break;
case DRIVE_TYPE_DISK:
/* Translators: Used to describe generic media. The %s is the type, e.g. 'Zip' or 'Floppy' */
info->media_description = g_strdup_printf (C_("drive-with-generic-media", "%s Disk"), g_dpgettext2 (GETTEXT_PACKAGE, "media-type", media_data[n].media_name));
break;
case DRIVE_TYPE_CARD:
/* Translators: Used to describe flash media. The %s is the type, e.g. 'SD' or 'CompactFlash' */
info->media_description = g_strdup_printf (C_("flash-media", "%s Card"), g_dpgettext2 (GETTEXT_PACKAGE, "media-type", media_data[n].media_name));
break;
case DRIVE_TYPE_DISC:
/* Translators: Used to describe optical discs. The %s is the type, e.g. 'CD-R' or 'DVD-ROM' */
info->media_description = g_strdup_printf (C_("optical-media", "%s Disc"), g_dpgettext2 (GETTEXT_PACKAGE, "media-type", media_data[n].media_name));
break;
}
}
if (info->media_icon == NULL)
info->media_icon = g_themed_icon_new_with_default_fallbacks (media_data[n].media_icon);
if (info->media_icon_symbolic == NULL)
info->media_icon_symbolic = g_themed_icon_new_with_default_fallbacks (media_data[n].media_icon_symbolic);
}
}
}
switch (desc_type)
{
case DRIVE_TYPE_UNSET:
if (media_removable)
{
if (size_str != NULL)
{
/* Translators: Used to describe a drive. The %s is the size, e.g. '20 GB' */
info->description = g_strdup_printf (C_("drive-with-size", "%s Drive"), size_str);
}
else
{
/* Translators: Used to describe a drive we know very little about (removable media or size not known) */
info->description = g_strdup (C_("generic-drive", "Drive"));
}
}
else
{
if (rotation_rate == 0)
{
if (size_str != NULL)
{
/* Translators: Used to describe a non-rotating drive (rotation rate either unknown
* or it's a solid-state drive). The %s is the size, e.g. '20 GB'. */
info->description = g_strdup_printf (C_("disk-non-rotational", "%s Disk"), size_str);
}
else
{
/* Translators: Used to describe a non-rotating drive (rotation rate either unknown
* or it's a solid-state drive). The drive is either using removable media or its
* size not known. */
info->description = g_strdup (C_("disk-non-rotational", "Disk"));
}
}
else
{
if (size_str != NULL)
{
/* Translators: Used to describe a hard-disk drive (HDD). The %s is the size, e.g. '20 GB'. */
info->description = g_strdup_printf (C_("disk-hdd", "%s Hard Disk"), size_str);
}
else
{
/* Translators: Used to describe a hard-disk drive (HDD) (removable media or size not known) */
info->description = g_strdup (C_("disk-hdd", "Hard Disk"));
}
}
}
break;
case DRIVE_TYPE_CARD:
/* Translators: Used to describe a card reader. The %s is the card type e.g. 'CompactFlash'. */
info->description = g_strdup_printf (C_("drive-card-reader", "%s Card Reader"), desc_str->str);
break;
case DRIVE_TYPE_DRIVE: /* explicit fall-through */
case DRIVE_TYPE_DISK: /* explicit fall-through */
case DRIVE_TYPE_DISC:
if (!media_removable && size_str != NULL)
{
/* Translators: Used to describe drive. The first %s is the size e.g. '20 GB' and the
* second %s is the drive type e.g. 'Thumb'.
*/
info->description = g_strdup_printf (C_("drive-with-size-and-type", "%s %s Drive"), size_str, desc_str->str);
}
else
{
/* Translators: Used to describe drive. The first %s is the drive type e.g. 'Thumb'.
*/
info->description = g_strdup_printf (C_("drive-with-type", "%s Drive"), desc_str->str);
}
break;
}
g_string_free (desc_str, TRUE);
/* fallback for icon */
if (info->icon == NULL)
{
if (media_removable)
{
s = g_strdup_printf ("drive-removable-media%s", hyphenated_connection_bus);
}
else
{
if (rotation_rate == 0)
s = g_strdup_printf ("drive-harddisk-solidstate%s", hyphenated_connection_bus);
else
s = g_strdup_printf ("drive-harddisk%s", hyphenated_connection_bus);
}
info->icon = g_themed_icon_new_with_default_fallbacks (s);
g_free (s);
}
/* fallback for icon_symbolic */
if (info->icon_symbolic == NULL)
{
if (media_removable)
{
s = g_strdup_printf ("drive-removable-media%s-symbolic", hyphenated_connection_bus);
}
else
{
if (rotation_rate == 0)
s = g_strdup_printf ("drive-harddisk-solidstate%s-symbolic", hyphenated_connection_bus);
else
s = g_strdup_printf ("drive-harddisk%s-symbolic", hyphenated_connection_bus);
}
info->icon_symbolic = g_themed_icon_new_with_default_fallbacks (s);
g_free (s);
}
/* fallback for media_icon */
if (media_available && info->media_icon == NULL)
{
if (media_removable)
{
s = g_strdup_printf ("drive-removable-media%s", hyphenated_connection_bus);
}
else
{
if (rotation_rate == 0)
s = g_strdup_printf ("drive-harddisk-solidstate%s", hyphenated_connection_bus);
else
s = g_strdup_printf ("drive-harddisk%s", hyphenated_connection_bus);
}
info->media_icon = g_themed_icon_new_with_default_fallbacks (s);
g_free (s);
}
/* fallback for media_icon_symbolic */
if (media_available && info->media_icon_symbolic == NULL)
{
if (media_removable)
{
s = g_strdup_printf ("drive-removable-media%s-symbolic", hyphenated_connection_bus);
}
else
{
if (rotation_rate == 0)
s = g_strdup_printf ("drive-harddisk-solidstate%s-symbolic", hyphenated_connection_bus);
else
s = g_strdup_printf ("drive-harddisk%s-symbolic", hyphenated_connection_bus);
}
info->media_icon_symbolic = g_themed_icon_new_with_default_fallbacks (s);
g_free (s);
}
/* prepend a qualifier to the media description, based on the disc state */
if (udisks_drive_get_optical_blank (drive))
{
/* Translators: String used for a blank disc. The %s is the disc type e.g. "CD-RW Disc" */
s = g_strdup_printf (C_("optical-media", "Blank %s"), info->media_description);
g_free (info->media_description);
info->media_description = s;
}
else if (udisks_drive_get_optical_num_audio_tracks (drive) > 0 &&
udisks_drive_get_optical_num_data_tracks (drive) > 0)
{
/* Translators: String used for a mixed disc. The %s is the disc type e.g. "CD-ROM Disc" */
s = g_strdup_printf (C_("optical-media", "Mixed %s"), info->media_description);
g_free (info->media_description);
info->media_description = s;
}
else if (udisks_drive_get_optical_num_audio_tracks (drive) > 0 &&
udisks_drive_get_optical_num_data_tracks (drive) == 0)
{
/* Translators: String used for an audio disc. The %s is the disc type e.g. "CD-ROM Disc" */
s = g_strdup_printf (C_("optical-media", "Audio %s"), info->media_description);
g_free (info->media_description);
info->media_description = s;
}
/* Apply UDISKS_NAME, UDISKS_ICON_NAME, UDISKS_SYMBOLIC_ICON_NAME hints, if available */
block = udisks_client_get_block_for_drive (client, drive, TRUE);
if (block != NULL)
{
cs = udisks_block_get_hint_name (block);
if (cs != NULL && strlen (cs) > 0)
{
g_free (info->description);
g_free (info->media_description);
info->description = g_strdup (cs);
info->media_description = g_strdup (cs);
}
cs = udisks_block_get_hint_icon_name (block);
if (cs != NULL && strlen (cs) > 0)
{
g_clear_object (&info->icon);
g_clear_object (&info->media_icon);
info->icon = g_themed_icon_new_with_default_fallbacks (cs);
info->media_icon = g_themed_icon_new_with_default_fallbacks (cs);
}
cs = udisks_block_get_hint_symbolic_icon_name (block);
if (cs != NULL && strlen (cs) > 0)
{
g_clear_object (&info->icon_symbolic);
g_clear_object (&info->media_icon_symbolic);
info->icon_symbolic = g_themed_icon_new_with_default_fallbacks (cs);
info->media_icon_symbolic = g_themed_icon_new_with_default_fallbacks (cs);
}
}
if (partition != NULL)
{
GDBusObject *object_for_partition;
object_for_partition = g_dbus_interface_get_object (G_DBUS_INTERFACE (partition));
if (object_for_partition != NULL)
block_for_partition = udisks_object_peek_block (UDISKS_OBJECT (object_for_partition));
}
if (block_for_partition == NULL)
block_for_partition = block;
if (partition != NULL)
{
/* Translators: Used to describe a partition of a drive.
* The %u is the partition number.
* The %s is the description for the drive (e.g. "2 GB Thumb Drive").
*/
s = g_strdup_printf (C_("part-drive", "Partition %u of %s"),
udisks_partition_get_number (partition), info->description);
g_free (info->description);
info->description = s;
}
/* calculate and set one-liner */
if (block != NULL)
{
const gchar *drive_revision = udisks_drive_get_revision (drive);
if (strlen (drive_revision) > 0)
{
/* Translators: String used for one-liner description of drive.
* The first %s is the description of the object (e.g. "80 GB Disk" or "Partition 2 of 2 GB Thumb Drive").
* The second %s is the name of the object (e.g. "INTEL SSDSA2MH080G1GC").
* The third %s is the fw revision (e.g "45ABX21").
* The fourth %s is the special device file (e.g. "/dev/sda").
*/
info->one_liner = g_strdup_printf (C_("one-liner-drive", "%s — %s [%s] (%s)"),
info->description,
info->name,
drive_revision,
udisks_block_get_preferred_device (block_for_partition));
}
else
{
/* Translators: String used for one-liner description of drive w/o known fw revision.
* The first %s is the description of the object (e.g. "80 GB Disk").
* The second %s is the name of the object (e.g. "INTEL SSDSA2MH080G1GC").
* The third %s is the special device file (e.g. "/dev/sda").
*/
info->one_liner = g_strdup_printf (C_("one-liner-drive", "%s — %s (%s)"),
info->description,
info->name,
udisks_block_get_preferred_device (block_for_partition));
}
}
g_free (hyphenated_connection_bus);
g_free (size_str);
info->sort_key = g_strdup_printf ("00_drive_%s", udisks_drive_get_sort_key (drive));
g_clear_object (&block);
}
/**
* udisks_client_get_object_info:
* @client: A #UDisksClient.
* @object: A #UDisksObject.
*
* Gets information about a #UDisksObject instance that is suitable to
* present in an user interface. Information is returned in the
* #UDisksObjectInfo object and is localized.
*
* Returns: (transfer full): A #UDisksObjectInfo instance that should be freed with g_object_unref().
*
* Since: 2.1
*/
UDisksObjectInfo *
udisks_client_get_object_info (UDisksClient *client,
UDisksObject *object)
{
UDisksObjectInfo *ret = NULL;
UDisksDrive *drive = NULL;
UDisksBlock *block = NULL;
UDisksPartition *partition = NULL;
UDisksMDRaid *mdraid = NULL;
UDisksLoop *loop = NULL;
g_return_val_if_fail (UDISKS_IS_CLIENT (client), NULL);
g_return_val_if_fail (UDISKS_IS_OBJECT (object), NULL);
ret = udisks_object_info_new (object);
drive = udisks_object_get_drive (object);
block = udisks_object_get_block (object);
loop = udisks_object_get_loop (object);
partition = udisks_object_get_partition (object);
mdraid = udisks_object_get_mdraid (object);
if (drive != NULL)
{
udisks_client_get_object_info_for_drive (client, drive, NULL, ret);
}
else if (mdraid != NULL)
{
udisks_client_get_object_info_for_mdraid (client, mdraid, NULL, ret);
}
else if (block != NULL)
{
drive = udisks_client_get_drive_for_block (client, block);
if (drive != NULL)
{
udisks_client_get_object_info_for_drive (client, drive, partition, ret);
goto out;
}
mdraid = udisks_client_get_mdraid_for_block (client, block);
if (mdraid != NULL)
{
udisks_client_get_object_info_for_mdraid (client, mdraid, partition, ret);
goto out;
}
if (loop != NULL)
udisks_client_get_object_info_for_loop (client, loop, block, partition, ret);
else
udisks_client_get_object_info_for_block (client, block, partition, ret);
}
out:
g_clear_object (&loop);
g_clear_object (&mdraid);
g_clear_object (&partition);
g_clear_object (&block);
g_clear_object (&drive);
#if 0
/* for debugging */
g_print ("%s -> dd='%s', md='%s', ol='%s' and di='%s', mi='%s' sk='%s'\n",
g_dbus_object_get_object_path (G_DBUS_OBJECT (object)),
ret->description,
ret->media_description,
ret->one_liner,
ret->icon == NULL ? "" : g_icon_to_string (ret->icon),
ret->media_icon == NULL ? "" : g_icon_to_string (ret->media_icon),
ret->sort_key);
#endif
return ret;
}
/* ---------------------------------------------------------------------------------------------------- */
static gpointer
_g_object_ref0 (gpointer object)
{
if (object != NULL)
return g_object_ref (G_OBJECT (object));
else
return NULL;
}
/**
* udisks_client_get_drive_info:
* @client: A #UDisksClient.
* @drive: A #UDisksDrive.
* @out_name: (out) (allow-none): Return location for name or %NULL.
* @out_description: (out) (allow-none): Return location for description or %NULL.
* @out_drive_icon: (out) (allow-none): Return location for icon representing the drive or %NULL.
* @out_media_description: (out) (allow-none): Return location for description of the media or %NULL.
* @out_media_icon: (out) (allow-none): Return location for icon representing the media or %NULL.
*
* Gets information about a #UDisksDrive object that is suitable to
* present in an user interface. The returned strings are localized.
*
* Deprecated: 2.1: Use udisks_client_get_object_info() instead.
*/
void
udisks_client_get_drive_info (UDisksClient *client,
UDisksDrive *drive,
gchar **out_name,
gchar **out_description,
GIcon **out_icon,
gchar **out_media_description,
GIcon **out_media_icon)
{
UDisksObjectInfo *info;
g_return_if_fail (UDISKS_IS_CLIENT (client));
g_return_if_fail (UDISKS_IS_DRIVE (drive));
info = udisks_object_info_new (NULL);
udisks_client_get_object_info_for_drive (client, drive, NULL, info);
if (out_name != NULL)
*out_name = g_strdup (info->name);
if (out_description != NULL)
*out_description = g_strdup (info->description);
if (out_icon != NULL)
*out_icon = _g_object_ref0 (info->icon);
if (out_media_description != NULL)
*out_media_description = g_strdup (info->media_description);
if (out_media_icon != NULL)
*out_media_icon = _g_object_ref0 (info->media_icon);
g_object_unref (info);
}
/* ---------------------------------------------------------------------------------------------------- */
/**
* udisks_object_info_get_object:
* @info: A #UDisksObjectInfo.
*
* Gets the #UDisksObject that @info is for
*
* Returns: (transfer none): The object - do not free or unref, the reference belongs to @info.
*
* Since: 2.1
*/
UDisksObject *
udisks_object_info_get_object (UDisksObjectInfo *info)
{
g_return_val_if_fail (UDISKS_IS_OBJECT_INFO (info), NULL);
return info->object;
}
/**
* udisks_object_info_get_name:
* @info: A #UDisksObjectInfo.
*
* Gets the name.
*
* Returns: (transfer none): The value or %NULL. Do not free or unref, the value belongs to @info.
*
* Since: 2.1
*/
const gchar *
udisks_object_info_get_name (UDisksObjectInfo *info)
{
g_return_val_if_fail (UDISKS_IS_OBJECT_INFO (info), NULL);
return info->name;
}
/**
* udisks_object_info_get_description:
* @info: A #UDisksObjectInfo.
*
* Gets the description.
*
* Returns: (transfer none): The value or %NULL. Do not free or unref, the value belongs to @info.
*
* Since: 2.1
*/
const gchar *
udisks_object_info_get_description (UDisksObjectInfo *info)
{
g_return_val_if_fail (UDISKS_IS_OBJECT_INFO (info), NULL);
return info->description;
}
/**
* udisks_object_info_get_icon:
* @info: A #UDisksObjectInfo.
*
* Gets the icon.
*
* Returns: (transfer none): The value or %NULL. Do not free or unref, the value belongs to @info.
*
* Since: 2.1
*/
GIcon *
udisks_object_info_get_icon (UDisksObjectInfo *info)
{
g_return_val_if_fail (UDISKS_IS_OBJECT_INFO (info), NULL);
return info->icon;
}
/**
* udisks_object_info_get_icon_symbolic:
* @info: A #UDisksObjectInfo.
*
* Gets the symbolic icon.
*
* Returns: (transfer none): The value or %NULL. Do not free or unref, the value belongs to @info.
*
* Since: 2.1
*/
GIcon *
udisks_object_info_get_icon_symbolic (UDisksObjectInfo *info)
{
g_return_val_if_fail (UDISKS_IS_OBJECT_INFO (info), NULL);
return info->icon_symbolic;
}
/**
* udisks_object_info_get_media_description:
* @info: A #UDisksObjectInfo.
*
* Gets the media description.
*
* Returns: (transfer none): The value or %NULL. Do not free or unref, the value belongs to @info.
*
* Since: 2.1
*/
const gchar *
udisks_object_info_get_media_description (UDisksObjectInfo *info)
{
g_return_val_if_fail (UDISKS_IS_OBJECT_INFO (info), NULL);
return info->media_description;
}
/**
* udisks_object_info_get_media_icon:
* @info: A #UDisksObjectInfo.
*
* Gets the media icon.
*
* Returns: (transfer none): The value or %NULL. Do not free or unref, the value belongs to @info.
*
* Since: 2.1
*/
GIcon *
udisks_object_info_get_media_icon (UDisksObjectInfo *info)
{
g_return_val_if_fail (UDISKS_IS_OBJECT_INFO (info), NULL);
return info->media_icon;
}
/**
* udisks_object_info_get_media_icon_symbolic:
* @info: A #UDisksObjectInfo.
*
* Gets the symbolic media icon.
*
* Returns: (transfer none): The value or %NULL. Do not free or unref, the value belongs to @info.
*
* Since: 2.1
*/
GIcon *
udisks_object_info_get_media_icon_symbolic (UDisksObjectInfo *info)
{
g_return_val_if_fail (UDISKS_IS_OBJECT_INFO (info), NULL);
return info->media_icon_symbolic;
}
/**
* udisks_object_info_get_one_liner:
* @info: A #UDisksObjectInfo.
*
* Gets a one-line description.
*
* Returns: (transfer none): The value or %NULL. Do not free or unref, the value belongs to @info.
*
* Since: 2.1
*/
const gchar *
udisks_object_info_get_one_liner (UDisksObjectInfo *info)
{
g_return_val_if_fail (UDISKS_IS_OBJECT_INFO (info), NULL);
return info->one_liner;
}
/**
* udisks_object_info_get_sort_key:
* @info: A #UDisksObjectInfo.
*
* Gets the sort-key for @info. This can be used with g_strcmp0() to
* sort objects.
*
* Returns: (transfer none): The sort key or %NULL. Do not free or unref, the value belongs to @info.
*
* Since: 2.1
*/
const gchar *
udisks_object_info_get_sort_key (UDisksObjectInfo *info)
{
g_return_val_if_fail (UDISKS_IS_OBJECT_INFO (info), NULL);
return info->sort_key;
}
|