[totem/wip/hadess/starttime: 4/6] main: Add totem_playlist_steal_current_starttime()



commit 159e5ae4e884d85d149bd06866a156935eb43d74
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Feb 16 20:25:19 2019 +0100

    main: Add totem_playlist_steal_current_starttime()
    
    Read, and remove starttime from currently playing entry.

 src/totem-playlist.c | 30 ++++++++++++++++++++++++++++++
 src/totem-playlist.h |  1 +
 2 files changed, 31 insertions(+)
---
diff --git a/src/totem-playlist.c b/src/totem-playlist.c
index 734d0435e..7666c0e19 100644
--- a/src/totem-playlist.c
+++ b/src/totem-playlist.c
@@ -1714,6 +1714,36 @@ totem_playlist_get_current_content_type (TotemPlaylist *playlist)
        return content_type;
 }
 
+gint64
+totem_playlist_steal_current_starttime (TotemPlaylist *playlist)
+{
+       GtkTreeIter iter;
+       gint64 starttime;
+
+       g_return_val_if_fail (TOTEM_IS_PLAYLIST (playlist), 0);
+
+       if (update_current_from_playlist (playlist) == FALSE)
+               return 0;
+
+       gtk_tree_model_get_iter (playlist->priv->model,
+                                &iter,
+                                playlist->priv->current);
+
+       gtk_tree_model_get (playlist->priv->model,
+                           &iter,
+                           STARTTIME_COL, &starttime,
+                           -1);
+
+       /* And reset the starttime so it's only used once,
+        * hence the "steal" in the API name */
+       gtk_list_store_set (GTK_LIST_STORE (playlist->priv->model),
+                           &iter,
+                           STARTTIME_COL, 0,
+                           -1);
+
+       return starttime;
+}
+
 char *
 totem_playlist_get_title (TotemPlaylist *playlist, guint title_index)
 {
diff --git a/src/totem-playlist.h b/src/totem-playlist.h
index 819fea25f..13dc1e378 100644
--- a/src/totem-playlist.h
+++ b/src/totem-playlist.h
@@ -130,6 +130,7 @@ char      *totem_playlist_get_current_mrl (TotemPlaylist *playlist,
                                           char **subtitle);
 char      *totem_playlist_get_current_title (TotemPlaylist *playlist);
 char      *totem_playlist_get_current_content_type (TotemPlaylist *playlist);
+gint64     totem_playlist_steal_current_starttime (TotemPlaylist *playlist);
 char      *totem_playlist_get_title (TotemPlaylist *playlist,
                                     guint title_index);
 


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