[nautilus] content-bar: move content type handling to nautilus-file
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] content-bar: move content type handling to nautilus-file
- Date: Mon, 7 Mar 2016 11:37:38 +0000 (UTC)
commit 0bfae7052961487d531b26273684fc1956ab211d
Author: Carlos Soriano <csoriano gnome org>
Date: Fri Mar 4 16:48:49 2016 +0100
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
libnautilus-private/nautilus-file-utilities.c | 74 +++++++++++++++++++++++
libnautilus-private/nautilus-file-utilities.h | 2 +
src/nautilus-x-content-bar.c | 79 +------------------------
3 files changed, 79 insertions(+), 76 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c
index b51921c..87b53f6 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)
diff --git a/libnautilus-private/nautilus-file-utilities.h b/libnautilus-private/nautilus-file-utilities.h
index 23afde9..81dfa0a 100644
--- a/libnautilus-private/nautilus-file-utilities.h
+++ b/libnautilus-private/nautilus-file-utilities.h
@@ -88,6 +88,8 @@ void nautilus_get_x_content_types_for_mount_async (GMount *mount,
NautilusMountGetContent callback,
GCancellable *cancellable,
gpointer user_data);
+char * get_message_for_content_type (const char *content_type);
+char * get_message_for_two_content_types (char **content_types);
gboolean nautilus_file_selection_equal (GList *selection_a, GList *selection_b);
diff --git a/src/nautilus-x-content-bar.c b/src/nautilus-x-content-bar.c
index d2933eb..e783dc9 100644
--- a/src/nautilus-x-content-bar.c
+++ b/src/nautilus-x-content-bar.c
@@ -29,6 +29,7 @@
#include "nautilus-x-content-bar.h"
#include <libnautilus-private/nautilus-icon-info.h>
+#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-program-choosing.h>
#define NAUTILUS_X_CONTENT_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o),
NAUTILUS_TYPE_X_CONTENT_BAR, NautilusXContentBarPrivate))
@@ -78,80 +79,6 @@ content_bar_response_cb (GtkInfoBar *infobar,
}
}
-static char *
-get_message_for_x_content_type (const char *x_content_type)
-{
- char *message;
- char *description;
-
- description = g_content_type_get_description (x_content_type);
-
- /* Customize greeting for well-known x-content types */
- /* translators: these describe the contents of removable media */
- if (strcmp (x_content_type, "x-content/audio-cdda") == 0) {
- message = g_strdup (_("Audio CD"));
- } else if (strcmp (x_content_type, "x-content/audio-dvd") == 0) {
- message = g_strdup (_("Audio DVD"));
- } else if (strcmp (x_content_type, "x-content/video-dvd") == 0) {
- message = g_strdup (_("Video DVD"));
- } else if (strcmp (x_content_type, "x-content/video-vcd") == 0) {
- message = g_strdup (_("Video CD"));
- } else if (strcmp (x_content_type, "x-content/video-svcd") == 0) {
- message = g_strdup (_("Super Video CD"));
- } else if (strcmp (x_content_type, "x-content/image-photocd") == 0) {
- message = g_strdup (_("Photo CD"));
- } else if (strcmp (x_content_type, "x-content/image-picturecd") == 0) {
- message = g_strdup (_("Picture CD"));
- } else if (strcmp (x_content_type, "x-content/image-dcf") == 0) {
- message = g_strdup (_("Contains digital photos"));
- } else if (strcmp (x_content_type, "x-content/audio-player") == 0) {
- message = g_strdup (_("Contains music"));
- } else if (strcmp (x_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;
-}
-
-static char *
-get_message_for_two_x_content_types (char **x_content_types)
-{
- char *message;
-
- g_assert (x_content_types[0] != NULL);
- g_assert (x_content_types[1] != NULL);
-
- /* few combinations make sense */
- if (strcmp (x_content_types[0], "x-content/image-dcf") == 0
- || strcmp (x_content_types[1], "x-content/image-dcf") == 0) {
-
- /* translators: these describe the contents of removable media */
- if (strcmp (x_content_types[0], "x-content/audio-player") == 0) {
- message = g_strdup (_("Contains music and photos"));
- } else if (strcmp (x_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 (x_content_types[0], "x-content/video-vcd") == 0
- || strcmp (x_content_types[1], "x-content/video-vcd") == 0)
- && (strcmp (x_content_types[0], "x-content/video-dvd") == 0
- || strcmp (x_content_types[1], "x-content/video-dvd") == 0)) {
- message = g_strdup_printf ("%s/%s",
- get_message_for_x_content_type (x_content_types[0]),
- get_message_for_x_content_type (x_content_types[1]));
- } else {
- message = get_message_for_x_content_type (x_content_types[0]);
- }
-
- return message;
-}
-
static void
nautilus_x_content_bar_set_x_content_types (NautilusXContentBar *bar, const char **x_content_types)
{
@@ -192,10 +119,10 @@ nautilus_x_content_bar_set_x_content_types (NautilusXContentBar *bar, const char
message = NULL;
break;
case 1:
- message = get_message_for_x_content_type (bar->priv->x_content_types[0]);
+ message = get_message_for_content_type (bar->priv->x_content_types[0]);
break;
case 2:
- message = get_message_for_two_x_content_types (bar->priv->x_content_types);
+ message = get_message_for_two_content_types (bar->priv->x_content_types);
break;
default:
message = g_strdup (_("Open with:"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]