Commits

Anonymous committed 84a995a

Fix refresh issues

Comments (0)

Files changed (2)

plugins/filebrowser/filebrowser/CHANGELOG

 Author: Cody Precord
 License: wxWindows
 
+Version 2.2:
+xx/xx/20xx
+- Fix naming error in duplicate file
+- Fix various refresh issues
+
 Version 2.1:
 08/12/2012
   - Handle PyDeadObject errors.

plugins/filebrowser/filebrowser/browser.py

         if path:
             newpath = os.path.join(os.path.dirname(path), newlabel)
             try:
-                dobj = None
-                parent = self.GetItemParent(item)
-                if parent.IsOk():
-                    dpath = self.GetPyData(parent)
-                    dobj = ebmlib.GetDirectoryObject(dpath, False, True)
+                dobjs = TakeSnapshots([path,])
                 os.rename(path, newpath)
                 editOk = True
-                if dobj:
-                    self.RefreshView([dobj,])
+                if dobjs:
+                    self.RefreshView(dobjs)
             except OSError:
                 editOk = False # TODO: notify user of error
         return editOk
         for item in needsort:
             self.SortChildren(item)
 
-    @refreshAfter
     def OnMenu(self, evt):
         """Handle the context menu events for performing
         filesystem operations
             """
             for fname in paths:
                 subprocess.call([FILEMAN_CMD, fname])
+                time.sleep(.25)
 
         if e_id == ID_EDIT:
             self.OpenFiles(paths)
             name = wx.GetTextFromUser(_("Enter folder name:"), _("New Folder"),
                                       parent=self.TopLevelParent)
             if name:
+                dobjs = TakeSnapshots([path,])
                 err, msg = ebmlib.MakeNewFolder(path, name)
                 if not err:
                     wx.MessageBox(msg, _("Failed to create folder"),
                                   style=wx.OK|wx.CENTER|wx.ICON_ERROR)
-            
+                else:
+                    self.RefreshView(dobjs)
         elif e_id == ID_NEW_FILE:
             name = wx.GetTextFromUser(_("Enter file name:"), _("New File"),
                                       parent=self.TopLevelParent)
             if name:
+                dobjs = TakeSnapshots([path,])
                 err, msg = ebmlib.MakeNewFile(path, name)
                 if not err:
                     wx.MessageBox(msg, _("Failed to create file"),
                                   style=wx.OK|wx.CENTER|wx.ICON_ERROR)
+                else:
+                    self.RefreshView(dobjs)
         elif e_id == ID_DUPLICATE:
+            dobjs = TakeSnapshots(paths)
             for fname in paths:
                 DuplicatePath(fname)
+            self.RefreshView(dobjs)
         elif e_id == ID_ARCHIVE:
+            dobjs = TakeSnapshots([path,])
             MakeArchive(path)
+            self.RefreshView(dobjs)
         elif e_id == ID_DELETE:
+            dobjs = TakeSnapshots(paths)
             ebmlib.MoveToTrash(paths)
+            self.RefreshView(dobjs)
         else:
             evt.Skip()
             return
 
     return (ok, name)
 
+def TakeSnapshots(paths):
+    """Take snapshots of the given paths
+    @param paths: list of paths to snapshot
+    @return: list of DirectoryObjects or None
+
+    """
+    assert isinstance(paths, list)
+    rlist = list()
+    tpaths = list()
+    for path in paths:
+        path = os.path.dirname(path)
+        if os.path.exists(path) and path not in tpaths:
+            tpaths.append(path)
+    for dpath in tpaths:
+        dobj = ebmlib.GetDirectoryObject(dpath, False, True)
+        rlist.append(dobj)
+    if not len(rlist):
+        rlist = None
+
+    return rlist
+
 #-----------------------------------------------------------------------------#