From 0d1fe2555e90db35eeb531a1b6026ff64f1f5ae5 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 25 Nov 2015 19:41:58 +0100 Subject: Clean up a bit the nautilus-extensio code --- nautilus/nautilus-mat.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'nautilus') diff --git a/nautilus/nautilus-mat.py b/nautilus/nautilus-mat.py index cdce947..c1f25df 100644 --- a/nautilus/nautilus-mat.py +++ b/nautilus/nautilus-mat.py @@ -25,53 +25,52 @@ import libmat.strippers class MatExtension(GObject.GObject, Nautilus.MenuProvider): def __init__(self): logging.debug("nautilus-mat: initialising") - pass def get_file_items(self, window, files): if len(files) != 1: # no multi-files support return - file = files.pop() + current_file = files.pop() # We're only going to put ourselves on supported mimetypes' context menus - if not (file.get_mime_type() + if not (current_file.get_mime_type() in [i["mimetype"] for i in libmat.mat.list_supported_formats()]): - logging.debug("%s is not supported by MAT", file.get_mime_type()) + logging.debug("%s is not supported by MAT", current_file.get_mime_type()) return # MAT can only handle local file: - if file.get_uri_scheme() != 'file': - logging.debug("%s files not supported by MAT", file.get_uri_scheme()) + if current_file.get_uri_scheme() != 'file': + logging.debug("%s files not supported by MAT", current_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()) + if not current_file.can_write(): + logging.debug("%s is not writable by MAT", current_file.get_uri_scheme()) return item = Nautilus.MenuItem(name="Nautilus::clean_metadata", label=_("Clean metadata"), tip=_("Clean file's metadata with MAT"), icon="gtk-clear") - item.connect('activate', self.menu_activate_cb, file) + item.connect('activate', self.menu_activate_cb, current_file) return item, @staticmethod - def show_message(message, type=Gtk.MessageType.INFO): + def show_message(message, msg_type=Gtk.MessageType.INFO): dialog = Gtk.MessageDialog(parent=None, flags=Gtk.DialogFlags.MODAL, - type=type, + type=msg_type, buttons=Gtk.ButtonsType.OK, message_format=message) ret = dialog.run() dialog.destroy() return ret - def menu_activate_cb(self, menu, file): + def menu_activate_cb(self, menu, current_file): if file.is_gone(): return - file_path = urllib.unquote(file.get_uri()[7:]) + file_path = urllib.unquote(current_file.get_uri()[7:]) class_file = libmat.mat.create_class_file(file_path, backup=True, -- cgit v1.3