From 6cc200701cebdaa9df079926a3fd6efad7662330 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 28 Oct 2013 20:37:06 +0000 Subject: The nautilus plugin warns if the file is non-writable --- nautilus/nautilus-mat.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'nautilus') 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 @@ #! /usr/bin/python +''' This file is an extension for the Nautilus + file manager, to provide a contextual menu to + clean metadata +''' + +import logging import os import urllib -import logging try: import gettext gettext.install("mat") @@ -23,10 +28,10 @@ class MatExtension(GObject.GObject, Nautilus.MenuProvider): pass def get_file_items(self, window, files): - if len(files) != 1: + if len(files) != 1: # no multi-files support return - file = files[0] + file = files.pop() # We're only going to put ourselves on supported mimetypes' context menus if not (file.get_mime_type() @@ -39,6 +44,11 @@ class MatExtension(GObject.GObject, Nautilus.MenuProvider): logging.debug("%s files not supported by MAT" % file.get_uri_scheme()) return + # MAT can not clean non-writable files + if not file.can_write(): + logging.debug("%s is not writable by MAT" % file.get_uri_scheme()) + return + item = Nautilus.MenuItem(name="Nautilus::clean_metadata", label=_("Clean metadata"), tip=_("Clean file's metadata with MAT"), @@ -73,5 +83,3 @@ class MatExtension(GObject.GObject, Nautilus.MenuProvider): self.show_message(_("Unable to clean %s") % file_path, Gtk.MessageType.ERROR) else: self.show_message(_("Unable to process %s") % file_path, Gtk.MessageType.ERROR) - - -- cgit v1.3