[totem/wip/hadess/stop-button: 2/3] main: Add a useful totem_object_stop() API



commit 82af6b88ebf27482a00c030b1aba157249d1a4dd
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Feb 23 00:48:33 2019 +0100

    main: Add a useful totem_object_stop() API
    
    Which behaves like the Stop button on a CD player.

 docs/reference/totem-sections.txt |  1 +
 src/totem-object.c                | 41 +++++++++++++++++++++++++--------------
 src/totem.h                       |  1 +
 3 files changed, 28 insertions(+), 15 deletions(-)
---
diff --git a/docs/reference/totem-sections.txt b/docs/reference/totem-sections.txt
index bebe5e591..4e69c9f3d 100644
--- a/docs/reference/totem-sections.txt
+++ b/docs/reference/totem-sections.txt
@@ -10,6 +10,7 @@ totem_object_show_error
 totem_object_exit
 totem_object_play
 totem_object_play_pause
+totem_object_stop
 totem_object_seek_next
 totem_object_seek_previous
 totem_object_remote_get_setting
diff --git a/src/totem-object.c b/src/totem-object.c
index f97c7d040..3a02c7e61 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -1573,6 +1573,30 @@ totem_object_play_pause (TotemObject *totem)
        }
 }
 
+/**
+ * totem_object_stop:
+ * @totem: a #TotemObject
+ *
+ * Stops playback, and sets the playlist back at the start.
+ */
+void
+totem_object_stop (TotemObject *totem)
+{
+       char *mrl, *subtitle;
+
+       totem_playlist_set_at_start (totem->playlist);
+       update_buttons (totem);
+       bacon_video_widget_stop (totem->bvw);
+       play_pause_set_label (totem, STATE_STOPPED);
+       mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
+       if (mrl != NULL) {
+               totem_object_set_mrl (totem, mrl, subtitle);
+               bacon_video_widget_pause (totem->bvw);
+               g_free (mrl);
+               g_free (subtitle);
+       }
+}
+
 /**
  * totem_object_pause:
  * @totem: a #TotemObject
@@ -2807,22 +2831,9 @@ totem_object_remote_command (TotemObject *totem, TotemRemoteCommand cmd, const c
        case TOTEM_REMOTE_COMMAND_PAUSE:
                totem_object_pause (totem);
                break;
-       case TOTEM_REMOTE_COMMAND_STOP: {
-               char *mrl, *subtitle;
-
-               totem_playlist_set_at_start (totem->playlist);
-               update_buttons (totem);
-               bacon_video_widget_stop (totem->bvw);
-               play_pause_set_label (totem, STATE_STOPPED);
-               mrl = totem_playlist_get_current_mrl (totem->playlist, &subtitle);
-               if (mrl != NULL) {
-                       totem_object_set_mrl (totem, mrl, subtitle);
-                       bacon_video_widget_pause (totem->bvw);
-                       g_free (mrl);
-                       g_free (subtitle);
-               }
+       case TOTEM_REMOTE_COMMAND_STOP:
+               totem_object_stop (totem);
                break;
-       };
        case TOTEM_REMOTE_COMMAND_SEEK_FORWARD: {
                double offset = 0;
 
diff --git a/src/totem.h b/src/totem.h
index 86dbed01c..69649e0ef 100644
--- a/src/totem.h
+++ b/src/totem.h
@@ -165,6 +165,7 @@ GType       totem_object_get_type                   (void);
 
 void   totem_object_exit                       (TotemObject *totem) G_GNUC_NORETURN;
 void   totem_object_play                       (TotemObject *totem);
+void   totem_object_stop                       (TotemObject *totem);
 void   totem_object_play_pause                 (TotemObject *totem);
 void   totem_object_pause                      (TotemObject *totem);
 gboolean totem_object_can_seek_next            (TotemObject *totem);


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