[gnome-settings-daemon/wip/hadess/remove-media-keys-dbus: 4/4] media-keys: Add support for Rewind, FastForward, Repeat and Shuffle keys




commit 4a3f4201ea29c03500ce7a6896072e2f4e65dc32
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Oct 18 15:16:17 2021 +0200

    media-keys: Add support for Rewind, FastForward, Repeat and Shuffle keys
    
    As were supported in gnome-settings-daemon's MediaKeys.

 plugins/media-keys/gsd-media-keys-manager.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 48894f82..2f898d59 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -101,6 +101,9 @@
 #define TOUCHPAD_ENABLED_KEY "send-events"
 #define HIGH_CONTRAST "HighContrast"
 
+#define REWIND_MSEC (-10 * 1000)
+#define FASTFORWARD_MSEC (45 * 1000)
+
 #define VOLUME_STEP "volume-step"
 #define VOLUME_STEP_PRECISE 2
 #define MAX_VOLUME 65536.0
@@ -1715,8 +1718,21 @@ do_multimedia_player_action (GsdMediaKeysManager *manager,
         g_debug ("Media key '%s' pressed", key);
 
         if (mpris_controller_get_has_active_player (priv->mpris_controller)) {
-                if (mpris_controller_key (priv->mpris_controller, key))
+                if (g_str_equal (key, "Rewind")) {
+                        if (mpris_controller_seek (priv->mpris_controller, REWIND_MSEC))
+                                return TRUE;
+                } else if (g_str_equal (key, "FastForward")) {
+                        if (mpris_controller_seek (priv->mpris_controller, FASTFORWARD_MSEC))
+                                return TRUE;
+                } else if (g_str_equal (key, "LoopStatus")) {
+                        if (mpris_controller_toggle (priv->mpris_controller, "LoopStatus"))
+                                return TRUE;
+                } else if (g_str_equal (key, "Shuffle")) {
+                        if (mpris_controller_toggle (priv->mpris_controller, "Shuffle"))
+                                return TRUE;
+                } else if (mpris_controller_key (priv->mpris_controller, key)) {
                         return TRUE;
+                }
         }
 
        /* Popup a dialog with an (/) icon */


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