Zim

Remove deleted / moved pages from recent pages pathbar

Bug #506813 reported by Tom Eubank
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Zim
Fix Released
Wishlist
Unassigned

Bug Description

Renaming a page yields non-intuitive results since Zim does not clean up //History bar// or //Home Page// entries in configuration files.

1. Assumption: When I open a page and rename or delete it, references to that page in the History bar should also be renamed or deleted. Otherwise, the history bar refers to a non-existent page. Clicking on that button in the History bar displays a page that I though I had gotten rid of.

Specifically, the 'Home' item should be deleted from:

 .zim/state.conf:
 [History]
 history=[Home, ...]

2. Assumption: When I rename the Home page for a notebook, the home page associated with the notebook should also change. (Or a warning message should be issued when the page is renamed informing me that I need to change menu item file/properties/Home Page to the new name.)

Specifically, the value for 'home' in notebook.zim should be changed to the new name:
 notebook.zim:
 [Notebook]
 home=Home
================================================================================================
Linux version 2.6.31-17-generic (buildd@palmer) (gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8) ) #54-Ubuntu SMP Thu Dec 10 16:20:31 UTC 2009

gtkversion.h:
     #define GTK_MAJOR_VERSION (2)
     #define GTK_MINOR_VERSION (18)
     #define GTK_MICRO_VERSION (3)
     #define GTK_BINARY_AGE (1803)
     #define GTK_INTERFACE_AGE (3)

pygtk._get_available_versions(): {'2.0': '/usr/lib/python2.6/dist-packages/gtk-2.0'}

INFO: This is zim 0.42
DEBUG: Python version is (2, 6, 4, 'final', 0)
DEBUG: Zim revision is:
 branch: pyzim-trunk
 revision: 181 <email address hidden>
 date: 2010-01-10 23:00:57 +0100

DEBUG: Running from a source dir: /opt/download/python_packages/zim-0.42
DEBUG: Set XDG_DATA_HOME to /home/USERNAME/.local/share
DEBUG: Set XDG_DATA_DIRS to [<Dir: /opt/download/python_packages/zim-0.42>, <Dir: /usr/local/share>, <Dir: /usr/share>]
DEBUG: Set XDG_CONFIG_HOME to /home/USERNAME/.config
DEBUG: Set XDG_CONFIG_DIRS to [<Dir: /etc/xdg>]
DEBUG: Set XDG_CACHE_HOME to /home/USERNAME/.cache
DEBUG: Running command: gui
DEBUG: Cache dir: /home/USERNAME/data/zim/.zim
DEBUG: Index database file: /home/USERNAME/data/zim/.zim/index.db
TODO: hook slow_fs property
INFO: Opening default notebook
DEBUG: Sending to daemon: ["ping",[],{}]

DEBUG: Daemon replied: "Ack"
DEBUG: Sending to daemon: ["vivicate",["zim.gui.GtkInterface","file:///home/USERNAME/data/zim"],{"usedaemon":true,"notebook":"file:///home/USERNAME/data/zim"}]

DEBUG: Daemon replied: true
DEBUG: Sending to daemon: ["relay",[["zim.gui.GtkInterface","file:///home/USERNAME/data/zim"],"present",null],{"geometry":null,"fullscreen":null}]

DEBUG: Daemon replied: true

Tom Eubank (tom-afcon)
summary: - Counter-intuitive results when renaming Home
+ [pyzim] Counter-intuitive results when renaming Home
Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

I changed the title to reflect that the pathbar needs to reflect the move.

I will not fix 2. The home page need to be configured explicitly.

summary: - [pyzim] Counter-intuitive results when renaming Home
+ [pyzim] Remove delted / moved pages from recent pages pathbar
summary: - [pyzim] Remove delted / moved pages from recent pages pathbar
+ Remove deleted / moved pages from recent pages pathbar
Changed in zim:
status: New → Confirmed
importance: Undecided → Wishlist
Revision history for this message
John Drinkwater (johndrinkwater) wrote :

I think there’s a bug related to current behaviour. If you move a page, then delete it, pyzim will try to return to the page’s location before the move and drop a traceback in debug mode. It also leaves the now-deleted page in the textview.

DEBUG: Opening dialog "Delete Page - Zim"
DEBUG: Dialog response OK
INFO: Remove file: /home/john/Notes/Code/Testing.txt
INFO: Remove file tree: /home/john/Notes/Code/Testing
DEBUG: Wrote /home/john/Notes/.zim/state.conf
INFO: Open page: <FileStorePage: Testing> (<HistoryRecord: Testing>)
DEBUG: Found template '_New' for <FileStorePage: Testing>
INFO: Loading template from: /home/john/code/zim/git-support/data/templates/wiki/_New.txt
Traceback (most recent call last):
  File "/home/john/code/zim/git-support/zim/gui/pageindex.py", line 278, in <lambda>
    lambda o, p, r: self.select_page(p, vivify=True) )
  File "/home/john/code/zim/git-support/zim/gui/pageindex.py", line 432, in select_page
    index.cleanup(self._vivivied)
  File "/home/john/code/zim/git-support/zim/index.py", line 775, in cleanup
    if not (path.hascontent or path.haschildren) \
  File "/home/john/code/zim/git-support/zim/index.py", line 130, in __getattr__
    raise AttributeError, 'This IndexPath does not contain row data'
AttributeError: This IndexPath does not contain row data
DEBUG: Closed dialog "Delete Page"

Revision history for this message
Yelve Yakut (yelve-yakut) wrote :

Here's a patch for the bug.

* No changes to "History" pathbar view
* "Recent Pages" pathbar view handles renamed, recreated and moved pages correctly

Technically:
* history.py connects to notebook for moved, created and deleted signals
* history.py remembers deleted pages so they can be removed from get_unique
* unit test

Thanks to Jaap for helping me!

Revision history for this message
Yelve Yakut (yelve-yakut) wrote :

Minor issues fixed:

* proper handling of moved subpages
* history.append also checks if page really exists

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Patch committed in rev311

Changed in zim:
status: Confirmed → Fix Committed
Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

@mainbrain: btw I just notice a small potential bug in the patch - in the handler for page moves you used "replace(oldpath.name, newpath.name)" this does not enforce replacing the first part of the name but could also match multiple times.

Revision history for this message
Yelve Yakut (yelve-yakut) wrote :

Thanks for the pointer! I wrote a test confirming the bug and fixed it.

Cheers

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Released in 0.49

Changed in zim:
status: Fix Committed → Fix Released
Changed in zim:
status: Fix Released → In Progress
Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Reworked history to use proper Path objects. Will commit in rev329

Changed in zim:
status: In Progress → Fix Committed
Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote :

Fix released in zim 0.50

Changed in zim:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.