[totem] save-file: Don't offer to save file in ~/Videos subdirs
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] save-file: Don't offer to save file in ~/Videos subdirs
- Date: Fri, 14 Mar 2014 16:29:17 +0000 (UTC)
commit 208db5c3315a13ae4f085470c112231cd9c60b2c
Author: Bastien Nocera <hadess hadess net>
Date: Fri Mar 14 17:27:39 2014 +0100
save-file: Don't offer to save file in ~/Videos subdirs
We were only checking whether the file was a direct descendant of
~/Videos, instead of checking that ~/Videos was somewhere in its
ancestors. This stops videos in ~/Videos subdirectories being made
available for offline downloading.
https://bugzilla.gnome.org/show_bug.cgi?id=725027
src/plugins/save-file/totem-save-file.c | 31 ++++++++++++++++++++++++++++++-
1 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/save-file/totem-save-file.c b/src/plugins/save-file/totem-save-file.c
index 1b4bbcd..52c8c95 100644
--- a/src/plugins/save-file/totem-save-file.c
+++ b/src/plugins/save-file/totem-save-file.c
@@ -195,6 +195,35 @@ totem_save_file_file_closed (TotemObject *totem,
g_simple_action_set_enabled (G_SIMPLE_ACTION (pi->priv->action), FALSE);
}
+static gboolean
+file_has_ancestor (GFile *file,
+ GFile *ancestor)
+{
+ GFile *cursor;
+ gboolean retval = FALSE;
+
+ cursor = g_object_ref (file);
+
+ while (1) {
+ GFile *tmp;
+
+ tmp = g_file_get_parent (cursor);
+ g_object_unref (cursor);
+ cursor = tmp;
+
+ if (cursor == NULL)
+ break;
+
+ if (g_file_has_parent (cursor, ancestor)) {
+ g_object_unref (cursor);
+ retval = TRUE;
+ break;
+ }
+ }
+
+ return retval;
+}
+
static void
totem_save_file_file_opened (TotemObject *totem,
const char *mrl,
@@ -223,7 +252,7 @@ totem_save_file_file_opened (TotemObject *totem,
/* We check whether it's in the Videos dir, in the future,
* we might want to check if it's native instead */
videos_dir = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS));
- if (g_file_has_parent (file, videos_dir)) {
+ if (file_has_ancestor (file, videos_dir)) {
g_debug ("Not enabling offline save, as '%s' already in ~/Videos", mrl);
goto out;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]