[eog: 1/2] Add G_FILE_MONITOR_EVENT_RENAMED monitor to update the view when only one image
- From: Felix Riemann <friemann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [eog: 1/2] Add G_FILE_MONITOR_EVENT_RENAMED monitor to update the view when only one image
- Date: Thu, 5 Nov 2020 19:42:29 +0000 (UTC)
commit 6d664e2a06b1edcecfbd88294ea24e899419cf1f
Author: Krifa75 <yahiaoui fakhri gmail com>
Date: Mon Oct 19 10:59:05 2020 +0200
Add G_FILE_MONITOR_EVENT_RENAMED monitor to update the view when only one image
src/eog-list-store.c | 36 ++++++++++++++++++++++++++++++++----
1 file changed, 32 insertions(+), 4 deletions(-)
---
diff --git a/src/eog-list-store.c b/src/eog-list-store.c
index a7112814..c7991778 100644
--- a/src/eog-list-store.c
+++ b/src/eog-list-store.c
@@ -414,6 +414,7 @@ file_monitor_changed_cb (GFileMonitor *monitor,
}
g_object_unref (file_info);
break;
+ case G_FILE_MONITOR_EVENT_MOVED_OUT:
case G_FILE_MONITOR_EVENT_DELETED:
if (is_file_in_list_store_file (store, file, &iter)) {
EogImage *image;
@@ -425,6 +426,7 @@ file_monitor_changed_cb (GFileMonitor *monitor,
eog_list_store_remove (store, &iter);
}
break;
+ case G_FILE_MONITOR_EVENT_MOVED_IN:
case G_FILE_MONITOR_EVENT_CREATED:
if (!is_file_in_list_store_file (store, file, NULL)) {
file_info = g_file_query_info (file,
@@ -457,15 +459,41 @@ file_monitor_changed_cb (GFileMonitor *monitor,
eog_image_is_supported_mime_type (mimetype)) {
eog_list_store_thumbnail_refresh (store, &iter);
}
+ g_object_unref (file_info);
+ break;
+ case G_FILE_MONITOR_EVENT_RENAMED:
+ file_info = g_file_query_info (other_file,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
+ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
+ 0, NULL, NULL);
+ if (file_info == NULL) {
+ break;
+ }
+ mimetype = g_file_info_get_content_type (file_info);
+
+ if (is_file_in_list_store_file (store, other_file, &iter)) {
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
+ EOG_LIST_STORE_EOG_IMAGE, &image,
+ -1);
+ eog_image_file_changed (image);
+ g_object_unref (image);
+ eog_list_store_thumbnail_refresh (store, &iter);
+ } else if (eog_image_is_supported_mime_type (mimetype)) {
+ const gchar *caption;
+ caption = g_file_info_get_display_name (file_info);
+ eog_list_store_append_image_from_file (store, other_file, caption);
+ }
+
+ if (is_file_in_list_store_file (store, file, &iter)) {
+ eog_list_store_remove (store, &iter);
+ }
+
g_object_unref (file_info);
break;
case G_FILE_MONITOR_EVENT_CHANGED:
case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
case G_FILE_MONITOR_EVENT_UNMOUNTED:
case G_FILE_MONITOR_EVENT_MOVED:
- case G_FILE_MONITOR_EVENT_RENAMED:
- case G_FILE_MONITOR_EVENT_MOVED_IN:
- case G_FILE_MONITOR_EVENT_MOVED_OUT:
break;
}
}
@@ -514,7 +542,7 @@ eog_list_store_append_directory (EogListStore *store,
g_return_if_fail (file_type == G_FILE_TYPE_DIRECTORY);
file_monitor = g_file_monitor_directory (file,
- 0, NULL, NULL);
+ G_FILE_MONITOR_WATCH_MOVES, NULL, NULL);
if (file_monitor != NULL) {
g_signal_connect (file_monitor, "changed",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]