[totem] main: Make mount comparison sturdier
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] main: Make mount comparison sturdier
- Date: Mon, 2 Jul 2012 19:25:16 +0000 (UTC)
commit bbfe9f9e29248b6b581a1d0a6b8e14c1dc5fa6c8
Author: Bastien Nocera <hadess hadess net>
Date: Mon Jul 2 20:21:25 2012 +0100
main: Make mount comparison sturdier
By comparing the default location, rather than comparing pointers.
src/totem-playlist.c | 40 ++++++++++++++++++++++++++++++++++------
1 files changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/src/totem-playlist.c b/src/totem-playlist.c
index 287747f..d3bb120 100644
--- a/src/totem-playlist.c
+++ b/src/totem-playlist.c
@@ -2403,23 +2403,51 @@ totem_playlist_clear_with_compare (TotemPlaylist *playlist,
playlist->priv->current_to_be_removed = FALSE;
}
+static char *
+get_mount_default_location (GMount *mount)
+{
+ GFile *file;
+ char *path;
+
+ file = g_mount_get_root (mount);
+ if (file == NULL)
+ return NULL;
+ path = g_file_get_path (file);
+ g_object_unref (file);
+ return path;
+}
+
static gboolean
totem_playlist_compare_with_mount (TotemPlaylist *playlist, GtkTreeIter *iter, gconstpointer data)
{
GMount *clear_mount = (GMount *) data;
- char *mrl;
-
GMount *mount;
+ char *mount_path, *clear_mount_path;
gboolean retval = FALSE;
gtk_tree_model_get (playlist->priv->model, iter,
- URI_COL, &mrl, -1);
- mount = totem_get_mount_for_media (mrl);
- g_free (mrl);
+ MOUNT_COL, &mount, -1);
+
+ if (mount == NULL)
+ return FALSE;
- if (mount == clear_mount)
+ clear_mount_path = NULL;
+
+ mount_path = get_mount_default_location (mount);
+ if (mount_path == NULL)
+ goto bail;
+
+ clear_mount_path = get_mount_default_location (clear_mount);
+ if (clear_mount_path == NULL)
+ goto bail;
+
+ if (g_str_equal (mount_path, clear_mount_path))
retval = TRUE;
+bail:
+ g_free (mount_path);
+ g_free (clear_mount_path);
+
if (mount != NULL)
g_object_unref (mount);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]