diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | README | 10 | ||||
-rw-r--r-- | src/totem-playlist.c | 88 | ||||
-rw-r--r-- | src/totem-playlist.h | 2 | ||||
-rw-r--r-- | src/totem.c | 21 |
6 files changed, 117 insertions, 19 deletions
@@ -1,6 +1,19 @@ 2004-09-15 Bastien Nocera <hadess@hadess.net> * NEWS: upd + * README: update the Copyright notices + * src/totem-playlist.c: (totem_playlist_current_has_prefix), + (totem_playlist_clear_with_prefix): + * src/totem-playlist.h: add totem_playlist_clear_with_prefix + to remove playlist items with a particular prefix + * src/totem.c: (totem_action_eject): call + totem_playlist_clear_with_prefix when ejecting an optical media + instead of simply stopping the play, so that the stream doesn't + appear in the UI after an eject (Closes: #148480) + +2004-09-15 Bastien Nocera <hadess@hadess.net> + + * NEWS: upd * src/totem-pl-parser.c: (totem_pl_parser_parse_internal), (totem_pl_parser_parse): We now can recurse into 3 levels of subdirectories (enough for drag'n'dropping, say, an "iTunes Music" @@ -1,6 +1,7 @@ New features and significant updates in version... 0.99.16: +* Remove playlist items when ejecting an optical media * Fix addition of optical media via the remote interface * Fix Matroska and Real Audio file-types associations * Fix KDE detection for newer KDE versions @@ -13,6 +14,7 @@ New features and significant updates in version... * Fix properties windows when the file doesn't have audio or video * Fix parsing of ASX playlists for GNOME 2.4 and above * Recurse deeper into sub-directories +* Update to the latest recent-files sources 0.99.15.1: * And again @@ -61,16 +61,6 @@ S: Copyright ========= -gtk-xine.[ch] from gnome-xine by Guenter Bartsch <guenter@users.sourceforge.net> -with the following enhancements by myself: -- port to Gtk+ 2.0 -- real full-screen mode for _NET_WM aware window managers (metacity, sawfish2, - kwin > 2.2, etc.) -- use of signals -- use of properties -- loads of API cleanups -- move all the internal data to a private structure - Nifty media player icon by Jakub Steiner <jimmac@ximian.com> UI help by Seth Nickell <snickell@stanford.edu> diff --git a/src/totem-playlist.c b/src/totem-playlist.c index 4e39f3986..fcf25c53b 100644 --- a/src/totem-playlist.c +++ b/src/totem-playlist.c @@ -1567,6 +1567,94 @@ totem_playlist_clear (TotemPlaylist *playlist) playlist->_priv->current = NULL; } +static gboolean +totem_playlist_current_has_prefix (TotemPlaylist *playlist, + const char *prefix) +{ + char *current; + gboolean retval; + + current = totem_playlist_get_current_mrl (playlist); + retval = g_str_has_prefix (current, prefix); + g_free (current); + return retval; +} + +void +totem_playlist_clear_with_prefix (TotemPlaylist *playlist, const char *prefix) +{ + GList *list = NULL, *l; + guint num_items, i; + + num_items = PL_LEN; + if (num_items == 0) + return; + + if (totem_playlist_current_has_prefix (playlist, prefix) == FALSE) + { + g_warning ("totem_playlist_clear_with_prefix called while current mrl doesn't have prefix '%s'", prefix); + return; + } + + for (i = 0; i < num_items; i++) + { + GtkTreeIter iter; + char *index; + char *mrl; + + index = g_strdup_printf ("%d", i); + if (gtk_tree_model_get_iter_from_string + (playlist->_priv->model, + &iter, index) == FALSE) + { + g_free (index); + continue; + } + g_free (index); + + gtk_tree_model_get (playlist->_priv->model, &iter, + URI_COL, &mrl, -1); + + if (g_str_has_prefix (mrl, prefix) != FALSE) + { + GtkTreePath *path; + GtkTreeRowReference *ref; + + path = gtk_tree_path_new_from_indices (i, -1); + ref = gtk_tree_row_reference_new + (playlist->_priv->model, path); + list = g_list_prepend (list, ref); + gtk_tree_path_free (path); + } + + g_free (mrl); + } + + + for (l = list; l != NULL; l = l->next) + { + GtkTreePath *path; + GtkTreeIter iter; + + path = gtk_tree_row_reference_get_path (l->data); + gtk_tree_model_get_iter (playlist->_priv->model, &iter, path); + gtk_list_store_remove (GTK_LIST_STORE (playlist->_priv->model), + &iter); + gtk_tree_path_free (path); + gtk_tree_row_reference_free (l->data); + } + g_list_free (list); + + playlist->_priv->current_shuffled = -1; + + ensure_shuffled (playlist, playlist->_priv->shuffle); + gtk_tree_path_free (playlist->_priv->current); + playlist->_priv->current = NULL; + g_signal_emit (G_OBJECT (playlist), + totem_playlist_table_signals[CURRENT_REMOVED], + 0, NULL); +} + char *totem_playlist_get_current_mrl (TotemPlaylist *playlist) { diff --git a/src/totem-playlist.h b/src/totem-playlist.h index a8d6519ce..a101b35dc 100644 --- a/src/totem-playlist.h +++ b/src/totem-playlist.h @@ -69,6 +69,8 @@ void totem_playlist_save_current_playlist (TotemPlaylist *playlist, /* totem_playlist_clear doesn't emit the current_removed signal, even if it does * because the caller should know what to do after it's done with clearing */ void totem_playlist_clear (TotemPlaylist *playlist); +void totem_playlist_clear_with_prefix (TotemPlaylist *playlist, + const char *prefix); char *totem_playlist_get_current_mrl (TotemPlaylist *playlist); char *totem_playlist_get_current_title (TotemPlaylist *playlist, gboolean *custom); diff --git a/src/totem.c b/src/totem.c index 376706b6f..2e17304a6 100644 --- a/src/totem.c +++ b/src/totem.c @@ -344,20 +344,23 @@ play_pause_set_label (Totem *totem, TotemStates state) static void totem_action_eject (Totem *totem) { - char *cmd; + GError *err = NULL; + char *cmd, *prefix; + const char *needle; - totem_playlist_set_playing (totem->playlist, FALSE); - play_pause_set_label (totem, STATE_STOPPED); - - bacon_video_widget_close (totem->bvw); - g_free (totem->mrl); - totem->mrl = NULL; + needle = strchr (totem->mrl, ':'); + g_assert (needle != NULL); + /* we want the ':' as well */ + prefix = g_strndup (totem->mrl, needle - totem->mrl + 1); + totem_playlist_clear_with_prefix (totem->playlist, prefix); + g_free (prefix); cmd = g_strdup_printf ("eject %s", gconf_client_get_string (totem->gc, GCONF_PREFIX"/mediadev", NULL)); - if (g_spawn_command_line_sync (cmd, NULL, NULL, NULL, NULL) == FALSE) + if (g_spawn_command_line_sync (cmd, NULL, NULL, NULL, &err) == FALSE) { - totem_action_error (_("Totem could not eject the optical media."), _("No reason given."), totem); + totem_action_error (_("Totem could not eject the optical media."), err->message, totem); + g_error_free (err); } g_free (cmd); } |