[gnome-media] Show the number of inputs/outputs for a device



commit 14d69e157f531feefac5ec6c66d63514a2d113a1
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Jul 24 01:42:39 2009 +0100

    Show the number of inputs/outputs for a device
    
    on the status line. Makes it a wee bit more useful than
    just showing "Ready" :)

 gnome-volume-control/src/gvc-mixer-card.c    |    1 +
 gnome-volume-control/src/gvc-mixer-card.h    |    1 +
 gnome-volume-control/src/gvc-mixer-control.c |   44 ++++++++++++++++++++++++++
 gnome-volume-control/src/gvc-mixer-dialog.c  |    2 +-
 4 files changed, 47 insertions(+), 1 deletions(-)
---
diff --git a/gnome-volume-control/src/gvc-mixer-card.c b/gnome-volume-control/src/gvc-mixer-card.c
index 9237739..e9a4482 100644
--- a/gnome-volume-control/src/gvc-mixer-card.c
+++ b/gnome-volume-control/src/gvc-mixer-card.c
@@ -454,6 +454,7 @@ free_profile (GvcMixerCardProfile *p)
 {
         g_free (p->profile);
         g_free (p->human_profile);
+        g_free (p->status);
         g_free (p);
 }
 
diff --git a/gnome-volume-control/src/gvc-mixer-card.h b/gnome-volume-control/src/gvc-mixer-card.h
index 24bbd7b..3da3edb 100644
--- a/gnome-volume-control/src/gvc-mixer-card.h
+++ b/gnome-volume-control/src/gvc-mixer-card.h
@@ -52,6 +52,7 @@ typedef struct
 {
         char *profile;
         char *human_profile;
+        char *status;
         guint priority;
 } GvcMixerCardProfile;
 
diff --git a/gnome-volume-control/src/gvc-mixer-control.c b/gnome-volume-control/src/gvc-mixer-control.c
index ccc6584..3d3c639 100644
--- a/gnome-volume-control/src/gvc-mixer-control.c
+++ b/gnome-volume-control/src/gvc-mixer-control.c
@@ -926,6 +926,49 @@ update_client (GvcMixerControl      *control,
                              g_strdup (info->name));
 }
 
+static char *
+card_num_streams_to_status (guint sinks,
+                            guint sources)
+{
+        char *sinks_str;
+        char *sources_str;
+        char *ret;
+
+        if (sinks == 0 && sources == 0) {
+                /* translators:
+                 * The device has been disabled */
+                return g_strdup (_("Disabled"));
+        }
+        if (sinks == 0) {
+                sinks_str = NULL;
+        } else {
+                /* translators:
+                 * The number of sound outputs on a particular device */
+                sinks_str = g_strdup_printf (ngettext ("%u Output",
+                                                       "%u Outputs",
+                                                       sinks),
+                                             sinks);
+        }
+        if (sources == 0) {
+                sources_str = NULL;
+        } else {
+                /* translators:
+                 * The number of sound inputs on a particular device */
+                sources_str = g_strdup_printf (ngettext ("%u Input",
+                                                         "%u Inputs",
+                                                         sources),
+                                               sources);
+        }
+        if (sources_str == NULL)
+                return sinks_str;
+        if (sinks_str == NULL)
+                return sources_str;
+        ret = g_strdup_printf ("%s / %s", sinks_str, sources_str);
+        g_free (sinks_str);
+        g_free (sources_str);
+        return ret;
+}
+
 static void
 update_card (GvcMixerControl      *control,
              const pa_card_info   *info)
@@ -969,6 +1012,7 @@ update_card (GvcMixerControl      *control,
                         profile = g_new0 (GvcMixerCardProfile, 1);
                         profile->profile = g_strdup (pi.name);
                         profile->human_profile = g_strdup (pi.description);
+                        profile->status = card_num_streams_to_status (pi.n_sinks, pi.n_sources);
                         profile->priority = pi.priority;
                         list = g_list_prepend (list, profile);
                 }
diff --git a/gnome-volume-control/src/gvc-mixer-dialog.c b/gnome-volume-control/src/gvc-mixer-dialog.c
index 30a97e1..183c856 100644
--- a/gnome-volume-control/src/gvc-mixer-dialog.c
+++ b/gnome-volume-control/src/gvc-mixer-dialog.c
@@ -947,7 +947,7 @@ add_card (GvcMixerDialog *dialog,
                             HW_ICON_COLUMN, icon,
                             HW_PROFILE_COLUMN, profile->profile,
                             HW_PROFILE_HUMAN_COLUMN, profile->human_profile,
-                            HW_STATUS_COLUMN, "Ready",
+                            HW_STATUS_COLUMN, profile->status,
                             HW_SENSITIVE_COLUMN, g_strcmp0 (profile->profile, "off") != 0,
                             -1);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]