summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-file-utilities.c
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-03-04 16:48:49 +0100
committerCarlos Soriano <csoriano@gnome.org>2016-03-07 12:37:00 +0100
commit0bfae7052961487d531b26273684fc1956ab211d (patch)
tree46207103f884ea0cf5ae5670f3d338490333bb18 /libnautilus-private/nautilus-file-utilities.c
parent400acdd90402385a0701dde3a16dd1e2f1dd4551 (diff)
downloadnautilus-0bfae7052961487d531b26273684fc1956ab211d.tar.gz
content-bar: move content type handling to nautilus-file
All the other content type functions are there, and we will need it anyway in an upcoming patch. https://bugzilla.gnome.org/show_bug.cgi?id=762703
Diffstat (limited to 'libnautilus-private/nautilus-file-utilities.c')
-rw-r--r--libnautilus-private/nautilus-file-utilities.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c
index b51921cf9..87b53f68e 100644
--- a/libnautilus-private/nautilus-file-utilities.c
+++ b/libnautilus-private/nautilus-file-utilities.c
@@ -990,6 +990,80 @@ nautilus_get_cached_x_content_types_for_mount (GMount *mount)
return NULL;
}
+char *
+get_message_for_content_type (const char *content_type)
+{
+ char *message;
+ char *description;
+
+ description = g_content_type_get_description (content_type);
+
+ /* Customize greeting for well-known content types */
+ /* translators: these describe the contents of removable media */
+ if (strcmp (content_type, "x-content/audio-cdda") == 0) {
+ message = g_strdup (_("Audio CD"));
+ } else if (strcmp (content_type, "x-content/audio-dvd") == 0) {
+ message = g_strdup (_("Audio DVD"));
+ } else if (strcmp (content_type, "x-content/video-dvd") == 0) {
+ message = g_strdup (_("Video DVD"));
+ } else if (strcmp (content_type, "x-content/video-vcd") == 0) {
+ message = g_strdup (_("Video CD"));
+ } else if (strcmp (content_type, "x-content/video-svcd") == 0) {
+ message = g_strdup (_("Super Video CD"));
+ } else if (strcmp (content_type, "x-content/image-photocd") == 0) {
+ message = g_strdup (_("Photo CD"));
+ } else if (strcmp (content_type, "x-content/image-picturecd") == 0) {
+ message = g_strdup (_("Picture CD"));
+ } else if (strcmp (content_type, "x-content/image-dcf") == 0) {
+ message = g_strdup (_("Contains digital photos"));
+ } else if (strcmp (content_type, "x-content/audio-player") == 0) {
+ message = g_strdup (_("Contains music"));
+ } else if (strcmp (content_type, "x-content/unix-software") == 0) {
+ message = g_strdup (_("Contains software"));
+ } else {
+ /* fallback to generic greeting */
+ message = g_strdup_printf (_("Detected as ā€œ%sā€"), description);
+ }
+
+ g_free (description);
+
+ return message;
+}
+
+char *
+get_message_for_two_content_types (char **content_types)
+{
+ char *message;
+
+ g_assert (content_types[0] != NULL);
+ g_assert (content_types[1] != NULL);
+
+ /* few combinations make sense */
+ if (strcmp (content_types[0], "x-content/image-dcf") == 0
+ || strcmp (content_types[1], "x-content/image-dcf") == 0) {
+
+ /* translators: these describe the contents of removable media */
+ if (strcmp (content_types[0], "x-content/audio-player") == 0) {
+ message = g_strdup (_("Contains music and photos"));
+ } else if (strcmp (content_types[1], "x-content/audio-player") == 0) {
+ message = g_strdup (_("Contains photos and music"));
+ } else {
+ message = g_strdup (_("Contains digital photos"));
+ }
+ } else if ((strcmp (content_types[0], "x-content/video-vcd") == 0
+ || strcmp (content_types[1], "x-content/video-vcd") == 0)
+ && (strcmp (content_types[0], "x-content/video-dvd") == 0
+ || strcmp (content_types[1], "x-content/video-dvd") == 0)) {
+ message = g_strdup_printf ("%s/%s",
+ get_message_for_content_type (content_types[0]),
+ get_message_for_content_type (content_types[1]));
+ } else {
+ message = get_message_for_content_type (content_types[0]);
+ }
+
+ return message;
+}
+
gboolean
nautilus_file_selection_equal (GList *selection_a,
GList *selection_b)