rhythmbox r5617 - in trunk: . rhythmdb



Author: jmatthew
Date: Sat Mar 15 02:10:07 2008
New Revision: 5617
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=5617&view=rev

Log:
2008-03-15  Jonathan Matthew  <jonathan d14n org>

	* configure.ac:
	* rhythmdb/Makefile.am:
	* rhythmdb/rhythmdb.c: (rhythmdb_entry_move_to_trash):
	Use gio for trashing files when available so it works better on 
	GNOME 2.22 desktops.  From #510392.


Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/rhythmdb/Makefile.am
   trunk/rhythmdb/rhythmdb.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Sat Mar 15 02:10:07 2008
@@ -86,6 +86,11 @@
    AC_MSG_ERROR([totem playlist parsing library not found or too old])
 fi
 
+PKG_CHECK_MODULES(GIO, gio-2.0, have_gio=yes, have_gio=no)
+if test x$have_gio == "xyes"; then
+  AC_DEFINE(HAVE_GIO, 1, [Define to use gio instead of gnome-vfs (for trash only)])
+fi
+
 AC_ARG_WITH(hal,
 	      AC_HELP_STRING([--without-hal],
 			     [Disable HAL support]))

Modified: trunk/rhythmdb/Makefile.am
==============================================================================
--- trunk/rhythmdb/Makefile.am	(original)
+++ trunk/rhythmdb/Makefile.am	Sat Mar 15 02:10:07 2008
@@ -4,6 +4,7 @@
 
 librhythmdb_la_LDFLAGS = -export-dynamic
 librhythmdb_la_LIBADD = 				\
+	$(GIO_LIBS)					\
 	$(GDA_LIBS)
 
 INCLUDES = 						\
@@ -16,6 +17,7 @@
 	-I$(top_builddir)/lib                           \
 	$(GDA_CFLAGS)					\
 	$(RHYTHMBOX_CFLAGS)				\
+	$(GIO_CFLAGS)					\
 	$(NO_STRICT_ALIASING_CFLAGS)
 
 librhythmdb_la_SOURCES =				\

Modified: trunk/rhythmdb/rhythmdb.c
==============================================================================
--- trunk/rhythmdb/rhythmdb.c	(original)
+++ trunk/rhythmdb/rhythmdb.c	Sat Mar 15 02:10:07 2008
@@ -36,6 +36,10 @@
 #include <gdk/gdk.h>
 #include <gconf/gconf-client.h>
 
+#if defined(HAVE_GIO)
+#include <gio/gio.h>
+#endif
+
 #include "rb-marshal.h"
 #include "rb-file-helpers.h"
 #include "rb-debug.h"
@@ -3264,6 +3268,40 @@
 	db->priv->dirty = TRUE;
 }
 
+#if defined(HAVE_GIO)
+
+void
+rhythmdb_entry_move_to_trash (RhythmDB *db,
+			      RhythmDBEntry *entry)
+{
+	const char *uri;
+	GFile *file;
+	GError *error = NULL;
+
+	uri = rb_refstring_get (entry->location);
+	file = g_file_new_for_uri (uri);
+
+	g_file_trash (file, NULL, &error);
+	if (error != NULL) {
+		GValue value = {0,};
+
+		g_value_init (&value, G_TYPE_STRING);
+		g_value_set_string (&value, error->message);
+		rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_PLAYBACK_ERROR, &value);
+		g_value_unset (&value);
+
+		rb_debug ("trashing %s failed: %s",
+			  uri, error->message);
+		g_error_free (error);
+	} else {
+		rhythmdb_entry_set_visibility (db, entry, FALSE);
+	}
+
+	g_object_unref (file);
+}
+
+#else
+
 static gint
 rhythmdb_entry_move_to_trash_cb (GnomeVFSXferProgressInfo *info,
 				 gpointer data)
@@ -3381,6 +3419,8 @@
 	gnome_vfs_uri_unref (uri);
 }
 
+#endif
+
 /**
  * rhythmdb_entry_delete_by_type:
  * @db: a #RhythmDB.



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