summaryrefslogtreecommitdiff
path: root/nautilus/nautilus-mat.py
diff options
context:
space:
mode:
authorjvoisin2013-10-28 20:37:06 +0000
committerjvoisin2013-10-28 20:37:06 +0000
commit6cc200701cebdaa9df079926a3fd6efad7662330 (patch)
tree112aeb1b30ca2da33a388301a52c61bd6295d149 /nautilus/nautilus-mat.py
parentab70324fe5b4dad6a3868056ea47888fabaab44c (diff)
The nautilus plugin warns if the file is non-writable
Diffstat (limited to '')
-rw-r--r--nautilus/nautilus-mat.py18
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
8import logging
3import os 9import os
4import urllib 10import urllib
5import logging
6try: 11try:
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