diff options
| -rw-r--r-- | nautilus/nautilus-mat.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/nautilus/nautilus-mat.py b/nautilus/nautilus-mat.py index 7e2e78a..2a84600 100644 --- a/nautilus/nautilus-mat.py +++ b/nautilus/nautilus-mat.py | |||
| @@ -1,8 +1,13 @@ | |||
| 1 | #! /usr/bin/python | 1 | #! /usr/bin/python |
| 2 | 2 | ||
| 3 | ''' This file is an extension for the Nautilus | ||
| 4 | file manager, to provide a contextual menu to | ||
| 5 | clean metadata | ||
| 6 | ''' | ||
| 7 | |||
| 8 | import logging | ||
| 3 | import os | 9 | import os |
| 4 | import urllib | 10 | import urllib |
| 5 | import logging | ||
| 6 | try: | 11 | try: |
| 7 | import gettext | 12 | import gettext |
| 8 | gettext.install("mat") | 13 | gettext.install("mat") |
| @@ -23,10 +28,10 @@ class MatExtension(GObject.GObject, Nautilus.MenuProvider): | |||
| 23 | pass | 28 | pass |
| 24 | 29 | ||
| 25 | def get_file_items(self, window, files): | 30 | def get_file_items(self, window, files): |
| 26 | if len(files) != 1: | 31 | if len(files) != 1: # no multi-files support |
| 27 | return | 32 | return |
| 28 | 33 | ||
| 29 | file = files[0] | 34 | file = files.pop() |
| 30 | 35 | ||
| 31 | # We're only going to put ourselves on supported mimetypes' context menus | 36 | # We're only going to put ourselves on supported mimetypes' context menus |
| 32 | if not (file.get_mime_type() | 37 | if not (file.get_mime_type() |
| @@ -39,6 +44,11 @@ class MatExtension(GObject.GObject, Nautilus.MenuProvider): | |||
| 39 | logging.debug("%s files not supported by MAT" % file.get_uri_scheme()) | 44 | logging.debug("%s files not supported by MAT" % file.get_uri_scheme()) |
| 40 | return | 45 | return |
| 41 | 46 | ||
| 47 | # MAT can not clean non-writable files | ||
| 48 | if not file.can_write(): | ||
| 49 | logging.debug("%s is not writable by MAT" % file.get_uri_scheme()) | ||
| 50 | return | ||
| 51 | |||
| 42 | item = Nautilus.MenuItem(name="Nautilus::clean_metadata", | 52 | item = Nautilus.MenuItem(name="Nautilus::clean_metadata", |
| 43 | label=_("Clean metadata"), | 53 | label=_("Clean metadata"), |
| 44 | tip=_("Clean file's metadata with MAT"), | 54 | tip=_("Clean file's metadata with MAT"), |
| @@ -73,5 +83,3 @@ class MatExtension(GObject.GObject, Nautilus.MenuProvider): | |||
| 73 | self.show_message(_("Unable to clean %s") % file_path, Gtk.MessageType.ERROR) | 83 | self.show_message(_("Unable to clean %s") % file_path, Gtk.MessageType.ERROR) |
| 74 | else: | 84 | else: |
| 75 | self.show_message(_("Unable to process %s") % file_path, Gtk.MessageType.ERROR) | 85 | self.show_message(_("Unable to process %s") % file_path, Gtk.MessageType.ERROR) |
| 76 | |||
| 77 | |||
