5

It seems that the "Notes" tab in the "File Properties" dialog is gone in Nautilus 3.2.1/Ubuntu 11.10. How can you use the notes feature now? What do you do about notes that you have already made? Is there a patch or an extension for this, or is it planning to be fixed in the future? (Why was it removed?) (Related question about portability of notes.)

4 Answers 4

5
+100

Here is the script that I threw together for use with @fossfreedom's answer. It uses GIO to interface to GVFS and Tkinter for the GUI, and is written in Python 2.7. It supports multi-line annotations. The GUI looks like this:

GUI for script

prerequisites You need to install tkinter:

sudo apt-get install python-tk

to use

Save the code as a file using your favourite editor in a known folder location - for example /home/[home-folder-name]/scripts/notesscript

Then - if you are using naultilus-actions, use a command:

python /home/[home-folder-name]/scripts/notesscript

The code:

import gio
class GVFSNotes:
    ATTRIBUTE_KEY = 'metadata::annotation'
    def __init__(self, f):
        self.__f = f
    def _get_attribute(self, key):
        return self.__f.query_info(key).get_attribute_string(key)
    def _make_setter(self, key, val):
        info = gio.FileInfo()
        info.set_attribute_string(key, val)
        return info
    def _set_attribute(self, key, val):
        self.__f.set_attributes_from_info(self._make_setter(key, val))
    def get(self):
        return self._get_attribute(self.ATTRIBUTE_KEY)
    def set(self, val):
        self._set_attribute(self.ATTRIBUTE_KEY, val)
import Tkinter as tk
class Dialog:
    def __init__(self, title, initial):
        self.root = tk.Tk()
        self.text = None
        self._mkGUI(title, initial)
    def settext(self):
        self.text = self.entry.get(1.0, tk.END).rstrip()
    def onCancel(self):
        self.root.destroy()
    def onOkay(self):
        self.settext()
        self.root.destroy()
    def _mkButtons(self):
        (tk.Button(self.root, text="Cancel", width=10, command=self.onCancel)
            .pack(side=tk.LEFT)
        )
        (tk.Button(self.root, text="Okay", width=10, command=self.onOkay)
            .pack(side=tk.RIGHT)
        )
    def _mkEntry(self, initial):
        self.entry = tk.Text(self.root, width=60)
        if initial != '' and initial != None:
            self.entry.insert(tk.END, initial)
        self.entry.pack(fill=tk.X, expand=True)
        self.entry.focus_set()
    def _setTitle(self, title):
        self.root.wm_title(title)
    def _mkGUI(self, title, initial):
        self._mkEntry(initial)
        self._mkButtons()
        self._setTitle(title)
    def show(self):
        self.root.mainloop()
        return self.text
def main(path):
    notes = GVFSNotes(gio.File(path))
    oldtext = notes.get()
    newtext = Dialog('Notes for ' + path, oldtext).show()
    if newtext != None and newtext != oldtext:
        notes.set(newtext)
if __name__ == '__main__':
    import sys
    main(sys.argv[1])
2
  • Returns me the error: ` python /home/torben/bin/notescript Traceback (most recent call last): File "/home/torben/bin/notescript", line 61, in <module> main(sys.argv[1]) IndexError: list index out of range `
    – user49204
    Mar 4, 2012 at 21:22
  • @TorbenBeta That would mean that you aren't passing the file argument to it. If you have configured it through the GUI you have to pass the file argument to it using %f, as I recall. If you use it on the command line, you have to pass it manually.
    – Kazark
    Mar 5, 2012 at 15:01
4

A similar question to this was asked from "Emblems and Backgrounds" and I'm afraid its a similar answer.

The Gnome Devs thought these capabilities were rarely used and in-order to streamline the codebase they removed this as core GUI functionality.

Fortunately, the same terminal based commands can be used since the metadata capabilities have been retained:

for example, here is a v11.10 nautilus screen-shot with notes added via the command line.

enter image description here

As to "is it planning to be fixed" - again a similar answer - like "emblems" - this is regarded as third-party supported - i.e. not core nautilus capabilities.

I'm not aware of anybody deciding to take on this challenge - so here is my poor substitute:

enter image description here

Choosing the right-click menu option Notes displays the notes for a file which you can amend.

enter image description here

To do this I used my answer to this Q&A to execute the following file:

#!/bin/bash

# basic - and I mean basic bash script to display & set notes
# 
# feel free to enhance!
#
# fossfreedom (askubuntu)  27/12/11

notestext=`gvfs-info $1 | grep annotation | sed s/' metadata::annotation: '/''/g`

newnotes=`zenity --entry --width=500 --title=$1 --text="current notes:" --entry-text="$notestext"`

# handle the case where the user has pressed cancel

if [ $? = 1 ]; then 
  exit
fi

# ok - got this far - lets change the notes for the file selected

gvfs-set-attribute -t string $1 metadata::annotation "$newnotes"

Zenity doesn't support multiple line entry - a more robust pythondialog type implementation will be required... my python skills aren't up-to this job though!

2
  • +3 I've upvoted all your related answers. It is good to know about the ability to add actions. I will let you know if I get a more robust script written.
    – Kazark
    Dec 27, 2011 at 21:26
  • Because my more robust script is longish, I've posted it as a second answer.
    – Kazark
    Jan 1, 2012 at 0:56
2

I had slightly modified your solution. It has been merged into "nautilus actions extra". In the next release, the package will be named: nautilus-notes.

1

Here is my script for use with nautilus-scripts (rather bit rough - limited for 1000000 lines, I am not programmer).

You have to create in ~/.gnome2/nautilus-scripts file (named e.g. nautilus-annotations) and make it executable (in properties) with these content:

#!/bin/bash
for arg do
if i=`gvfs-info "$arg" | grep -A 1000000 metadata::annotation: | sed s/\metadata::annotation:\// | grep -v metadata:: | zenity  --text-info --editable  --ok-label="ok" --cancel-label="cancel" --checkbox="change"`; then `gvfs-set-attribute -t string "$arg" metadata::annotation "$i"`; else exit
fi
done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .