From 55e886315901ec9a0532789a5f4cba5ca87e5a71 Mon Sep 17 00:00:00 2001 From: Andre Miranda Date: Wed, 1 Jan 2020 19:30:10 -0300 Subject: [PATCH] Replace deprecated G_FILE_MONITOR_EVENT_MOVED (Bug #16328) --- thunar/thunar-file.c | 20 +++++++++++++++++++- thunar/thunar-folder.c | 14 ++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 1ac9a1e4f..b64725177 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -800,7 +800,13 @@ thunar_file_monitor (GFileMonitor *monitor, if (g_file_equal (event_path, file->gfile)) { /* the event occurred for the monitored ThunarFile */ +#if GLIB_CHECK_VERSION (2, 46, 0) + if (event_type == G_FILE_MONITOR_EVENT_RENAMED || + event_type == G_FILE_MONITOR_EVENT_MOVED_IN || + event_type == G_FILE_MONITOR_EVENT_MOVED_OUT) +#else if (event_type == G_FILE_MONITOR_EVENT_MOVED) +#endif { G_LOCK (file_rename_mutex); thunar_file_monitor_moved (file, other_path); @@ -816,7 +822,13 @@ thunar_file_monitor (GFileMonitor *monitor, /* The event did not occur for the monitored ThunarFile, but for a file that is contained in ThunarFile which is actually a directory. */ +#if GLIB_CHECK_VERSION (2, 46, 0) + if (event_type == G_FILE_MONITOR_EVENT_RENAMED || + event_type == G_FILE_MONITOR_EVENT_MOVED_IN || + event_type == G_FILE_MONITOR_EVENT_MOVED_OUT) +#else if (event_type == G_FILE_MONITOR_EVENT_MOVED) +#endif { /* reload the target file if cached */ if (other_path == NULL) @@ -3950,7 +3962,13 @@ thunar_file_watch (ThunarFile *file) file_watch->watch_count = 1; /* create a file or directory monitor */ - file_watch->monitor = g_file_monitor (file->gfile, G_FILE_MONITOR_WATCH_MOUNTS | G_FILE_MONITOR_SEND_MOVED, NULL, &error); + file_watch->monitor = g_file_monitor (file->gfile, G_FILE_MONITOR_WATCH_MOUNTS | +#if GLIB_CHECK_VERSION (2, 46, 0) + G_FILE_MONITOR_WATCH_MOVES, NULL, &error); +#else + G_FILE_MONITOR_SEND_MOVED, NULL, &error); +#endif + if (G_UNLIKELY (file_watch->monitor == NULL)) { g_debug ("Failed to create file monitor: %s", error->message); diff --git a/thunar/thunar-folder.c b/thunar/thunar-folder.c index 16c825eda..7acd0f1e2 100644 --- a/thunar/thunar-folder.c +++ b/thunar/thunar-folder.c @@ -139,7 +139,12 @@ thunar_folder_constructed (GObject *object) GError *error = NULL; folder->monitor = g_file_monitor_directory (thunar_file_get_file (folder->corresponding_file), - G_FILE_MONITOR_SEND_MOVED, NULL, &error); +#if GLIB_CHECK_VERSION (2, 46, 0) + G_FILE_MONITOR_WATCH_MOVES, NULL, &error); +#else + G_FILE_MONITOR_SEND_MOVED, NULL, &error); +#endif + if (G_LIKELY (folder->monitor != NULL)) g_signal_connect (folder->monitor, "changed", G_CALLBACK (thunar_folder_monitor), folder); else @@ -795,8 +800,13 @@ thunar_folder_monitor (GFileMonitor *monitor, g_object_unref (destroyed); } } - +#if GLIB_CHECK_VERSION (2, 46, 0) + else if (event_type == G_FILE_MONITOR_EVENT_RENAMED || + event_type == G_FILE_MONITOR_EVENT_MOVED_IN || + event_type == G_FILE_MONITOR_EVENT_MOVED_OUT) +#else else if (event_type == G_FILE_MONITOR_EVENT_MOVED) +#endif { /* destroy the old file and update the new one */ thunar_file_destroy (lp->data); -- 2.24.1