[rhythmbox] ipod: implement move-to-trash for playlists (bug #586649)
- From: Jonathan Matthew <jmatthew src gnome org>
- To: svn-commits-list gnome org
- Subject: [rhythmbox] ipod: implement move-to-trash for playlists (bug #586649)
- Date: Wed, 24 Jun 2009 13:11:36 +0000 (UTC)
commit 3b13bc39f524f15023dff660090f660c8fa0b7d3
Author: Jonathan Matthew <jonathan d14n org>
Date: Wed Jun 24 19:32:14 2009 +1000
ipod: implement move-to-trash for playlists (bug #586649)
plugins/ipod/rb-ipod-source.c | 32 ++++++++++++++----------
plugins/ipod/rb-ipod-source.h | 3 ++
plugins/ipod/rb-ipod-static-playlist-source.c | 20 ++++++++++++++-
3 files changed, 41 insertions(+), 14 deletions(-)
---
diff --git a/plugins/ipod/rb-ipod-source.c b/plugins/ipod/rb-ipod-source.c
index 8d2c574..3736948 100644
--- a/plugins/ipod/rb-ipod-source.c
+++ b/plugins/ipod/rb-ipod-source.c
@@ -978,28 +978,22 @@ impl_show_popup (RBSource *source)
return TRUE;
}
-static void
-impl_move_to_trash (RBSource *asource)
+void
+rb_ipod_source_trash_entries (RBiPodSource *source, GList *entries)
{
- GList *sel, *tem;
- RBEntryView *songs;
+ RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source);
RhythmDB *db;
- RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (asource);
- RBiPodSource *source = RB_IPOD_SOURCE (asource);
+ GList *tem;
db = get_db_for_source (source);
-
- songs = rb_source_get_entry_view (RB_SOURCE (asource));
- sel = rb_entry_view_get_selected_entries (songs);
- for (tem = sel; tem != NULL; tem = tem->next) {
+ for (tem = entries; tem != NULL; tem = tem->next) {
RhythmDBEntry *entry;
const gchar *uri;
gchar *file;
Itdb_Track *track;
entry = (RhythmDBEntry *)tem->data;
- uri = rhythmdb_entry_get_string (entry,
- RHYTHMDB_PROP_LOCATION);
+ uri = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION);
track = g_hash_table_lookup (priv->entry_map, entry);
if (track == NULL) {
g_warning ("Couldn't find track on ipod! (%s)", uri);
@@ -1013,11 +1007,23 @@ impl_move_to_trash (RBSource *asource)
g_unlink (file);
g_free (file);
rhythmdb_entry_delete (db, entry);
- rhythmdb_commit (db);
}
+ rhythmdb_commit (db);
g_object_unref (db);
+}
+
+static void
+impl_move_to_trash (RBSource *source)
+{
+ GList *sel;
+ RBEntryView *songs;
+
+ songs = rb_source_get_entry_view (source);
+ sel = rb_entry_view_get_selected_entries (songs);
+ rb_ipod_source_trash_entries (RB_IPOD_SOURCE (source), sel);
+ g_list_foreach (sel, (GFunc) rhythmdb_entry_unref, NULL);
g_list_free (sel);
}
diff --git a/plugins/ipod/rb-ipod-source.h b/plugins/ipod/rb-ipod-source.h
index fc09b8f..fd18e33 100644
--- a/plugins/ipod/rb-ipod-source.h
+++ b/plugins/ipod/rb-ipod-source.h
@@ -66,6 +66,9 @@ void rb_ipod_source_remove_playlist (RBiPodSource *ipod_source,
void rb_ipod_source_show_properties (RBiPodSource *source);
+void rb_ipod_source_trash_entries (RBiPodSource *source,
+ GList *entries);
+
G_END_DECLS
#endif /* __RB_IPOD_SOURCE_H */
diff --git a/plugins/ipod/rb-ipod-static-playlist-source.c b/plugins/ipod/rb-ipod-static-playlist-source.c
index bbcb6ea..6c0d5ec 100644
--- a/plugins/ipod/rb-ipod-static-playlist-source.c
+++ b/plugins/ipod/rb-ipod-static-playlist-source.c
@@ -31,6 +31,7 @@
#include "rhythmdb.h"
#include "rb-ipod-static-playlist-source.h"
+#include "rb-ipod-source.h"
static GObject *rb_ipod_static_playlist_source_constructor (GType type,
guint n_construct_properties,
@@ -47,7 +48,7 @@ static void rb_ipod_static_playlist_source_get_property (GObject *object,
static gboolean impl_show_popup (RBSource *source);
static void impl_delete_thyself (RBSource *source);
-
+static void impl_move_to_trash (RBSource *source);
static void source_name_changed_cb (RBIpodStaticPlaylistSource *source,
GParamSpec *spec,
@@ -87,6 +88,8 @@ rb_ipod_static_playlist_source_class_init (RBIpodStaticPlaylistSourceClass *klas
source_class->impl_show_popup = impl_show_popup;
source_class->impl_delete_thyself = impl_delete_thyself;
+ source_class->impl_can_move_to_trash = (RBSourceFeatureFunc) rb_true_function;
+ source_class->impl_move_to_trash = impl_move_to_trash;
g_object_class_install_property (object_class,
PROP_IPOD_SOURCE,
@@ -272,3 +275,18 @@ source_name_changed_cb (RBIpodStaticPlaylistSource *source,
g_free (name);
}
+static void
+impl_move_to_trash (RBSource *source)
+{
+ RBIpodStaticPlaylistSourcePrivate *priv = IPOD_STATIC_PLAYLIST_SOURCE_GET_PRIVATE (source);
+ GList *sel;
+ RBEntryView *songs;
+
+ songs = rb_source_get_entry_view (source);
+ sel = rb_entry_view_get_selected_entries (songs);
+ rb_ipod_source_trash_entries (priv->ipod_source, sel);
+
+ g_list_foreach (sel, (GFunc) rhythmdb_entry_unref, NULL);
+ g_list_free (sel);
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]