[gnome-flashback/wip/muktupavels/lp1875317: 1/4] desktop: fix RENAMED event handling



commit 2c977e34d27a15e03c95be02631792ed702b7599
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Wed Apr 29 22:26:30 2020 +0300

    desktop: fix RENAMED event handling

 gnome-flashback/libdesktop/gf-icon-view.c | 44 ++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 13 deletions(-)
---
diff --git a/gnome-flashback/libdesktop/gf-icon-view.c b/gnome-flashback/libdesktop/gf-icon-view.c
index 459f909..61e875f 100644
--- a/gnome-flashback/libdesktop/gf-icon-view.c
+++ b/gnome-flashback/libdesktop/gf-icon-view.c
@@ -764,6 +764,19 @@ remove_icon_from_view (GfIconView *self,
     self->extend_from_icon = NULL;
 }
 
+static void
+remove_icon (GfIconView *self,
+             GfIconInfo *info)
+{
+  remove_icon_from_view (self, info);
+
+  self->icons = g_list_remove (self->icons, info);
+  gf_icon_info_free (info);
+
+  if (self->placement == GF_PLACEMENT_AUTO_ARRANGE_ICONS)
+    remove_and_readd_icons (self);
+}
+
 static void
 file_deleted (GfIconView *self,
               GFile      *deleted_file)
@@ -775,13 +788,7 @@ file_deleted (GfIconView *self,
   if (info == NULL)
     return;
 
-  remove_icon_from_view (self, info);
-
-  self->icons = g_list_remove (self->icons, info);
-  gf_icon_info_free (info);
-
-  if (self->placement == GF_PLACEMENT_AUTO_ARRANGE_ICONS)
-    remove_and_readd_icons (self);
+  remove_icon (self, info);
 }
 
 static void
@@ -808,14 +815,25 @@ file_renamed (GfIconView *self,
               GFile      *old_file,
               GFile      *new_file)
 {
-  GfIconInfo *info;
-
-  info = find_icon_info_by_file (self, old_file);
+  GfIconInfo *old_info;
+  GfIconInfo *new_info;
 
-  if (info == NULL)
-    return;
+  old_info = find_icon_info_by_file (self, old_file);
+  new_info = find_icon_info_by_file (self, new_file);
 
-  gf_icon_set_file (GF_ICON (info->icon), new_file);
+  if (old_info != NULL && new_info != NULL)
+    {
+      gf_icon_set_file (GF_ICON (new_info->icon), new_file);
+      remove_icon (self, old_info);
+    }
+  else if (old_info != NULL)
+    {
+      gf_icon_set_file (GF_ICON (old_info->icon), new_file);
+    }
+  else if (new_info != NULL)
+    {
+      gf_icon_set_file (GF_ICON (new_info->icon), new_file);
+    }
 }
 
 static void


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