[gnome-settings-daemon/gnome-3-8] media-keys: Copy get_image_name_for_volume() from gsd-osd-window.c



commit e543760e6adec45f1b8fc20139b817f1fbf71ca5
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Mar 2 18:17:47 2013 +0100

    media-keys: Copy get_image_name_for_volume() from gsd-osd-window.c
    
    Just as we now refer key grabbing to the shell, we will do the same
    for OSD popups. Determining the correct volume icon is something
    we'll still need to do, while the rest of GsdOsdWindow will become
    obsolete and removed, so copy the function over.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695021

 plugins/media-keys/gsd-media-keys-manager.c |   39 +++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 75f7491..3781021 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -385,6 +385,45 @@ ensure_grab_cancellable (GsdMediaKeysManager *manager)
         }
 }
 
+static GIcon *
+get_image_name_for_volume (gboolean is_mic,
+                           gboolean muted,
+                           int volume)
+{
+        static const char *icon_names[] = {
+                "audio-volume-muted-symbolic",
+                "audio-volume-low-symbolic",
+                "audio-volume-medium-symbolic",
+                "audio-volume-high-symbolic",
+                NULL
+        };
+        static const char *mic_icon_names[] = {
+                "microphone-sensitivity-muted-symbolic",
+                "microphone-sensitivity-low-symbolic",
+                "microphone-sensitivity-medium-symbolic",
+                "microphone-sensitivity-high-symbolic",
+                NULL
+        };
+        int n;
+
+        if (muted) {
+                n = 0;
+        } else {
+                /* select image */
+                n = 3 * volume / 100 + 1;
+                if (n < 1) {
+                        n = 1;
+                } else if (n > 3) {
+                        n = 3;
+                }
+        }
+
+       if (is_mic)
+               return g_themed_icon_new_with_default_fallbacks (mic_icon_names[n]);
+       else
+               return g_themed_icon_new_with_default_fallbacks (icon_names[n]);
+}
+
 static gboolean
 retry_grabs (gpointer data)
 {


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