totem r5839 - in trunk: . src



Author: hadess
Date: Wed Dec 10 13:46:27 2008
New Revision: 5839
URL: http://svn.gnome.org/viewvc/totem?rev=5839&view=rev

Log:
2008-12-10  Bastien Nocera  <hadess hadess net>

	* src/totem-object.c (totem_add_to_playlist_and_play),
	(totem_get_playlist_length):
	* src/totem-playlist.c (totem_playlist_get_current),
	(totem_playlist_get_last):
	* src/totem-playlist.h:
	* src/totem-session.c (totem_save_state_cb):
	* src/totem.h: Fix totem_playlist_get_current() and
	totem_playlist_get_last() returning negative values
	(Closes: #563961)



Modified:
   trunk/ChangeLog
   trunk/src/totem-object.c
   trunk/src/totem-playlist.c
   trunk/src/totem-playlist.h
   trunk/src/totem-session.c
   trunk/src/totem.h

Modified: trunk/src/totem-object.c
==============================================================================
--- trunk/src/totem-object.c	(original)
+++ trunk/src/totem-object.c	Wed Dec 10 13:46:27 2008
@@ -300,7 +300,7 @@
 				gboolean add_to_recent)
 {
 	gboolean playlist_changed;
-	guint end;
+	int end;
 
 	totem_signal_block_by_data (totem->playlist, totem);
 
@@ -311,7 +311,7 @@
 
 	totem_signal_unblock_by_data (totem->playlist, totem);
 
-	if (playlist_changed)
+	if (playlist_changed && end != -1)
 	{
 		char *mrl, *subtitle;
 
@@ -333,10 +333,15 @@
 guint
 totem_get_playlist_length (Totem *totem)
 {
-	return totem_playlist_get_last (totem->playlist) + 1;
+	int last;
+
+	last = totem_playlist_get_last (totem->playlist);
+	if (last == -1)
+		return 0;
+	return last + 1;
 }
 
-guint
+int
 totem_get_playlist_pos (Totem *totem)
 {
 	return totem_playlist_get_current (totem->playlist);

Modified: trunk/src/totem-playlist.c
==============================================================================
--- trunk/src/totem-playlist.c	(original)
+++ trunk/src/totem-playlist.c	Wed Dec 10 13:46:27 2008
@@ -2404,19 +2404,19 @@
 	}
 }
 
-guint
+int
 totem_playlist_get_current (TotemPlaylist *playlist)
 {
 	char *path;
 	double index;
 
-	g_return_val_if_fail (TOTEM_IS_PLAYLIST (playlist), 0);
+	g_return_val_if_fail (TOTEM_IS_PLAYLIST (playlist), -1);
 
 	if (playlist->priv->current == NULL)
-		return 0;
+		return -1;
 	path = gtk_tree_path_to_string (playlist->priv->current);
 	if (path == NULL)
-		return 0;
+		return -1;
 
 	index = g_ascii_strtod (path, NULL);
 	g_free (path);
@@ -2424,12 +2424,17 @@
 	return index;
 }
 
-guint
+int
 totem_playlist_get_last (TotemPlaylist *playlist)
 {
+	guint len = PL_LEN;
+
 	g_return_val_if_fail (TOTEM_IS_PLAYLIST (playlist), -1);
 
-	return PL_LEN - 1;
+	if (len == 0)
+		return -1;
+
+	return len - 1;
 }
 
 void

Modified: trunk/src/totem-playlist.h
==============================================================================
--- trunk/src/totem-playlist.h	(original)
+++ trunk/src/totem-playlist.h	Wed Dec 10 13:46:27 2008
@@ -130,8 +130,8 @@
 void       totem_playlist_set_at_start (TotemPlaylist *playlist);
 void       totem_playlist_set_at_end (TotemPlaylist *playlist);
 
-guint      totem_playlist_get_current (TotemPlaylist *playlist);
-guint      totem_playlist_get_last (TotemPlaylist *playlist);
+int        totem_playlist_get_current (TotemPlaylist *playlist);
+int        totem_playlist_get_last (TotemPlaylist *playlist);
 void       totem_playlist_set_current (TotemPlaylist *playlist, guint index);
 
 void       totem_playlist_foreach (TotemPlaylist *playlist,

Modified: trunk/src/totem-session.c
==============================================================================
--- trunk/src/totem-session.c	(original)
+++ trunk/src/totem-session.c	Wed Dec 10 13:46:27 2008
@@ -55,6 +55,12 @@
 	char *argv[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
 	int i = 0;
 	char *path_id, *current, *seek, *uri;
+	int current_index;
+
+	current_index = totem_playlist_get_current (totem->playlist);
+
+	if (current_index == -1)
+		return;
 
 	path_id = totem_session_create_key ();
 	totem_playlist_save_current_playlist (totem->playlist, path_id);
@@ -67,8 +73,7 @@
 
 	/* How to clone or restart */
 	i = 0;
-	current = g_strdup_printf ("%d",
-			totem_playlist_get_current (totem->playlist));
+	current = g_strdup_printf ("%d", current_index);
 	seek = g_strdup_printf ("%"G_GINT64_FORMAT,
 			bacon_video_widget_get_current_time (totem->bvw));
 	argv[i++] = (char *) totem->argv0;

Modified: trunk/src/totem.h
==============================================================================
--- trunk/src/totem.h	(original)
+++ trunk/src/totem.h	Wed Dec 10 13:46:27 2008
@@ -180,7 +180,7 @@
 guint	totem_get_playlist_length		(Totem *totem);
 void	totem_action_set_playlist_index		(Totem *totem,
 						 guint index);
-guint	totem_get_playlist_pos			(Totem *totem);
+int	totem_get_playlist_pos			(Totem *totem);
 char *	totem_get_title_at_playlist_pos		(Totem *totem,
 						 guint index);
 void totem_add_to_playlist_and_play		(Totem *totem,



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