Re: [Tails-dev] MAT nautilus

このメッセージを削除

このメッセージに返信
著者: alan
日付:  
To: tails-dev
題目: Re: [Tails-dev] MAT nautilus

> From: alan@???
> Date: Fri, 10 Aug 2012 10:34:40 +0200
>

[...]

> I had fun writing a basic MAT nautilus extension. It works fine for me
> under Tails, with nautilus 2.x.
>
> For now, it doesn't work with nautilus 3.x under wheezy. If I understood
> the problem well, Nautilus 3.x imports Gtk through GI, while poppler and
> cairo (imported by MAT) import Gtk2 through python bindings. Result:
>

Find attached a patchset that works under wheezy. It includes a
transition from pygtk to gi.

Cheers



--
From 95e84fc66c28dd61c92b24ca549a07f7526c0de9 Mon Sep 17 00:00:00 2001
From: Tails developers <tails@???>
Date: Sun, 5 Aug 2012 22:53:32 +0200
Subject: [PATCH 1/3] Add nautilus extension

---
 nautilus/nautilus-mat.py |   91 ++++++++++++++++++++++++++++++++++++++++++++++
 setup.py                 |    1 +
 2 files changed, 92 insertions(+)
 create mode 100644 nautilus/nautilus-mat.py


diff --git a/nautilus/nautilus-mat.py b/nautilus/nautilus-mat.py
new file mode 100644
index 0000000..df0c3a6
--- /dev/null
+++ b/nautilus/nautilus-mat.py
@@ -0,0 +1,91 @@
+#! /usr/bin/python
+
+import os
+import urllib
+import logging
+import gettext
+gettext.install("mat")
+
+import xml.sax
+
+from gi.repository import Nautilus, GObject, Gtk
+
+# mat package is called lib
+import lib.mat as mat
+import lib.strippers as strippers
+
+class MatExtension(GObject.GObject, Nautilus.MenuProvider):
+    def __init__(self):
+        logging.debug("nautilus-mat: initializing")
+        pass
+    
+    def get_file_items(self, window, files):
+        if len(files) != 1:
+            return
+
+        file = files[0]
+
+        # We're only going to put ourselves on supported mimetypes' context menus
+        if not file.get_mime_type() in [i["mimetype"] for i in self.__list_supported()]:
+            logging.debug("%s is not supported by MAT" % 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())
+            return
+
+        item = Nautilus.MenuItem(name="Nautilus::clean_metadata",
+                                 label=_("Clean metadata"),
+                                 tip=_("Clean file's metadata with MAT"))
+        item.connect('activate', self.menu_activate_cb, file)
+        return item,
+
+    def show_message(self, message, type = Gtk.MessageType.INFO):
+        dialog = Gtk.MessageDialog(parent=None,
+                                   flags=Gtk.DialogFlags.MODAL,
+                                   type=type,
+                                   buttons=Gtk.ButtonsType.OK,
+                                   message_format=message)
+        ret = dialog.run()
+        dialog.destroy()
+        return ret
+
+    # Convenience functions that should be merged into MAT core
+    def __list_supported(self):
+        '''
+            Print all supported fileformat, and exit
+        '''
+        handler = mat.XMLParser()
+        parser = xml.sax.make_parser()
+        parser.setContentHandler(handler)
+        path = os.path.join(mat.get_sharedir('FORMATS'))
+        with open(path, 'r') as xmlfile:
+            parser.parse(xmlfile)
+
+        localy_supported = []
+        for item in handler.list:
+            if strippers.STRIPPERS.has_key(item['mimetype'].split(',')[0]):
+                localy_supported.append(item)
+
+        return localy_supported
+
+    def menu_activate_cb(self, menu, file):
+        if file.is_gone():
+            return
+        
+        file_path = urllib.unquote(file.get_uri()[7:])
+
+        class_file = mat.create_class_file(file_path,
+                                           backup=True,
+                                           add2archive=False)
+        if class_file:
+            if class_file.is_clean():
+                self.show_message(_("%s is already clean") % file_path)
+            else:
+                if not class_file.remove_all():
+                    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)
+
+
diff --git a/setup.py b/setup.py
index 22a6718..e7a0b0c 100644
--- a/setup.py
+++ b/setup.py
@@ -29,6 +29,7 @@ setup(
         ( 'share/applications', ['mat.desktop'] ),
         ( 'share/mat', ['FORMATS', 'logo.png'] ),
         ( 'share/doc/mat', ['README', 'TODO'] ),
+        ( 'share/nautilus-python/extensions', ['nautilus/nautilus-mat.py'])
     ],
     cmdclass          = {
         'build': build_extra.build_extra,
-- 
1.7.10.4



From 741e678d2138f1fa3fcc59829abf3db3f564373e Mon Sep 17 00:00:00 2001
From: Tails developers <tails@???>
Date: Sun, 5 Aug 2012 22:50:13 +0200
Subject: [PATCH 2/3] Use gi instead of python modules

This prevents from importing gtk2 which conflicts with Gtk3
---
 lib/office.py    |    7 +++----
 lib/strippers.py |    3 ++-
 2 files changed, 5 insertions(+), 5 deletions(-)


diff --git a/lib/office.py b/lib/office.py
index d14125b..85c2604 100644
--- a/lib/office.py
+++ b/lib/office.py
@@ -7,13 +7,12 @@ import logging
 import zipfile
 import fileinput
 import xml.dom.minidom as minidom
-
+import gi
 try:
     import cairo
-    import poppler
+    from gi.repository import Poppler
 except ImportError:
     pass
-
 import mat
 import parser
 import archive
@@ -125,7 +124,7 @@ class PdfStripper(parser.GenericParser):
             add2archive)
         uri = 'file://' + os.path.abspath(self.filename)
         self.password = None
-        self.document = poppler.document_new_from_file(uri, self.password)
+        self.document = Poppler.Document.new_from_file(uri, self.password)
         self.meta_list = frozenset(['title', 'author', 'subject', 'keywords', 'creator',
             'producer', 'metadata'])


diff --git a/lib/strippers.py b/lib/strippers.py
index 61030a7..eaf9444 100644
--- a/lib/strippers.py
+++ b/lib/strippers.py
@@ -23,8 +23,9 @@ STRIPPERS = {

 # PDF support
 pdfSupport = True
+
 try:
-    import poppler
+    from gi.repository import Poppler
 except ImportError:
     print('Unable to import python-poppler: not PDF support')
     pdfSupport = False
-- 
1.7.10.4



From eaecd80f0ac41857c559e36d8595cd2fc8a8b859 Mon Sep 17 00:00:00 2001
From: Tails developers <amnesia@???>
Date: Fri, 10 Aug 2012 11:58:06 +0200
Subject: [PATCH 3/3] Convert mat-gui to Gtk 3

---
mat-gui | 200 ++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 102 insertions(+), 98 deletions(-)

diff --git a/mat-gui b/mat-gui
index 18c7467..5601759 100755
--- a/mat-gui
+++ b/mat-gui
@@ -5,9 +5,6 @@
     Metadata anonymisation toolkit - GUI edition
 '''


-import gtk
-import gobject
-
import gettext
import locale
import logging
@@ -17,6 +14,10 @@ import mimetypes
import xml.sax
import urllib2

+import gi
+from gi.repository import GObject
+from gi.repository import Gtk, Gdk, GdkPixbuf
+
from lib import mat
from lib import strippers

@@ -28,7 +29,7 @@ class CFile(object):
     '''
         Contain the "parser" class of the file "filename"
         This class exist just to be "around" my parser.Generic_parser class,
-        since the gtk.ListStore does not accept it.
+        since the Gtk.ListStore does not accept it.
     '''
     def __init__(self, filename, backup, add2archive):
         try:
@@ -48,32 +49,32 @@ class GUI:
         self.add2archive = True


         # Main window
-        self.window = gtk.Window()
+        self.window = Gtk.Window()
         self.window.set_title('Metadata Anonymisation Toolkit')
-        self.window.connect('destroy', gtk.main_quit)
+        self.window.connect('destroy', Gtk.main_quit)
         self.window.set_default_size(800, 600)
         self.logo = mat.get_sharedir('logo.png')
-        icon = gtk.gdk.pixbuf_new_from_file_at_size(self.logo, 50, 50)
+        icon = GdkPixbuf.Pixbuf.new_from_file_at_size(self.logo, 50, 50)
         self.window.set_icon(icon)


-        self.accelerator = gtk.AccelGroup()
+        self.accelerator = Gtk.AccelGroup()
         self.window.add_accel_group(self.accelerator)


-        vbox = gtk.VBox()
+        vbox = Gtk.VBox()
         self.window.add(vbox)


         menubar = self.__create_menu()
         toolbar = self.__create_toolbar()
-        content = gtk.ScrolledWindow()
-        content.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+        content = Gtk.ScrolledWindow()
+        content.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
         vbox.pack_start(menubar, False, True, 0)
         vbox.pack_start(toolbar, False, True, 0)
         vbox.pack_start(content, True, True, 0)


         # parser.class - name - path - type - cleaned
-        self.liststore = gtk.ListStore(object, str, str, str, str, str)
+        self.liststore = Gtk.ListStore(object, str, str, str, str, str)


-        self.treeview = gtk.TreeView(model=self.liststore)
+        self.treeview = Gtk.TreeView(model=self.liststore)
         self.treeview.set_search_column(1)  # filename column is searchable
         self.treeview.set_rules_hint(True)  # alternate colors for rows
         self.treeview.set_rubber_banding(True)  # mouse selection
@@ -81,16 +82,19 @@ class GUI:
         self.treeview.connect('row-activated', self.__popup_metadata)
         self.treeview.connect('drag_data_received',
                 self.__on_drag_data_received)
-        self.treeview.drag_dest_set(gtk.DEST_DEFAULT_MOTION |
-                gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP,
-                [('text/uri-list', 0, 80), ], gtk.gdk.ACTION_COPY)
+        self.treeview.drag_dest_set(Gtk.DestDefaults.MOTION |
+                Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP,
+                [], Gdk.DragAction.COPY)
+        targets = Gtk.TargetList.new([])
+        targets.add_uri_targets(80)
+        self.treeview.drag_dest_set_target_list(targets)
         self.__add_columns()
         self.selection = self.treeview.get_selection()
-        self.selection.set_mode(gtk.SELECTION_MULTIPLE)
+        self.selection.set_mode(Gtk.SelectionMode.MULTIPLE)


         content.add(self.treeview)


-        self.statusbar = gtk.Statusbar()
+        self.statusbar = Gtk.Statusbar()
         self.statusbar.push(1, _('Ready'))
         vbox.pack_start(self.statusbar, False, False, 0)


@@ -100,32 +104,32 @@ class GUI:
         '''
             Returns a vbox object, which contains a toolbar with buttons
         '''
-        toolbar = gtk.Toolbar()
+        toolbar = Gtk.Toolbar()


-        toolbutton = gtk.ToolButton(gtk.STOCK_ADD)
+        toolbutton = Gtk.ToolButton(Gtk.STOCK_ADD)
         toolbutton.set_label(_('Add'))
         toolbutton.connect('clicked', self.__add_files)
         toolbutton.set_tooltip_text(_('Add files'))
         toolbar.add(toolbutton)


-        toolbutton = gtk.ToolButton(gtk.STOCK_CLEAR)
+        toolbutton = Gtk.ToolButton(Gtk.STOCK_CLEAR)
         toolbutton.set_label(_('Clean'))
         toolbutton.connect('clicked', self.__process_files, self.__mat_clean)
         toolbutton.set_tooltip_text(_('Clean selected files'))
         toolbar.add(toolbutton)


-        toolbutton = gtk.ToolButton(gtk.STOCK_FIND)
+        toolbutton = Gtk.ToolButton(Gtk.STOCK_FIND)
         toolbutton.set_label(_('Check'))
         toolbutton.connect('clicked', self.__process_files, self.__mat_check)
         toolbutton.set_tooltip_text(_('Check selected files for harmful meta'))
         toolbar.add(toolbutton)


-        toolbutton = gtk.ToolButton(stock_id=gtk.STOCK_QUIT)
+        toolbutton = Gtk.ToolButton(stock_id=Gtk.STOCK_QUIT)
         toolbutton.set_label(_('Quit'))
-        toolbutton.connect('clicked', gtk.main_quit)
+        toolbutton.connect('clicked', Gtk.main_quit)
         toolbar.add(toolbutton)


-        vbox = gtk.VBox(spacing=3)
+        vbox = Gtk.VBox(spacing=3)
         vbox.pack_start(toolbar, False, False, 0)
         return vbox


@@ -137,8 +141,8 @@ class GUI:
             _('Cleaned file')]


         for i, j in enumerate(colname, 1):
-            filename_column = gtk.CellRendererText()
-            column = gtk.TreeViewColumn(j, filename_column, text=i)
+            filename_column = Gtk.CellRendererText()
+            column = Gtk.TreeViewColumn(j, filename_column, text=i)
             column.set_sort_column_id(i)
             column.set_resizable(True)  # column is resizeable
             self.treeview.append_column(column)
@@ -147,13 +151,13 @@ class GUI:
         '''
             Create a MenuItem() like Preferences, Quit, Add, Clean, ...
         '''
-        item = gtk.ImageMenuItem()
+        item = Gtk.ImageMenuItem()
         if shortcut:
-            key, mod = gtk.accelerator_parse(shortcut)
+            key, mod = Gtk.accelerator_parse(shortcut)
             item.add_accelerator('activate', self.accelerator,
-                key, mod, gtk.ACCEL_VISIBLE)
-        picture = gtk.Image()
-        picture.set_from_stock(pix, gtk.ICON_SIZE_MENU)
+                key, mod, Gtk.AccelFlags.VISIBLE)
+        picture = Gtk.Image()
+        picture.set_from_stock(pix, Gtk.IconSize.MENU)
         item.set_image(picture)
         item.set_label('_' + name)
         item.set_use_underline(True)
@@ -164,8 +168,8 @@ class GUI:
         '''
             Create a submenu like File, Edit, Clean, ...
         '''
-        submenu = gtk.Menu()
-        menuitem = gtk.MenuItem()
+        submenu = Gtk.Menu()
+        menuitem = Gtk.MenuItem()
         menuitem.set_submenu(submenu)
         menuitem.set_label('_' + name)
         menuitem.set_use_underline(True)
@@ -176,39 +180,39 @@ class GUI:
         '''
             Return a MenuBar
         '''
-        menubar = gtk.MenuBar()
+        menubar = Gtk.MenuBar()


         file_menu = self.__create_sub_menu(_('Files'), menubar)
         self.__create_menu_item(_('Add files'), self.__add_files, file_menu,
-            gtk.STOCK_ADD, '<Control>O')
-        self.__create_menu_item(_('Quit'), gtk.main_quit, file_menu,
-            gtk.STOCK_QUIT, '<Control>Q')
+            Gtk.STOCK_ADD, '<Control>O')
+        self.__create_menu_item(_('Quit'), Gtk.main_quit, file_menu,
+            Gtk.STOCK_QUIT, '<Control>Q')


         edit_menu = self.__create_sub_menu(_('Edit'), menubar)
         self.__create_menu_item(_('Clear the filelist'),
-            lambda x: self.liststore.clear(), edit_menu, gtk.STOCK_REMOVE,
+            lambda x: self.liststore.clear(), edit_menu, Gtk.STOCK_REMOVE,
             None)
         self.__create_menu_item(_('Preferences'), self.__preferences,
-                edit_menu, gtk.STOCK_PREFERENCES, '<Control>P')
+                edit_menu, Gtk.STOCK_PREFERENCES, '<Control>P')


         process_menu = self.__create_sub_menu(_('Process'), menubar)
-        item = gtk.ImageMenuItem()
-        key, mod = gtk.accelerator_parse('<Control>L')
+        item = Gtk.ImageMenuItem()
+        key, mod = Gtk.accelerator_parse('<Control>L')
         item.add_accelerator('activate', self.accelerator,
-            key, mod, gtk.ACCEL_VISIBLE)
-        picture = gtk.Image()
-        picture.set_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_MENU)
+            key, mod, Gtk.AccelFlags.VISIBLE)
+        picture = Gtk.Image()
+        picture.set_from_stock(Gtk.STOCK_CLEAR, Gtk.IconSize.MENU)
         item.set_image(picture)
         item.set_label(_('Clean'))
         item.connect('activate', self.__process_files, self.__mat_clean)
         process_menu.append(item)


-        item = gtk.ImageMenuItem()
-        key, mod = gtk.accelerator_parse('<Control>h')
+        item = Gtk.ImageMenuItem()
+        key, mod = Gtk.accelerator_parse('<Control>h')
         item.add_accelerator('activate', self.accelerator,
-            key, mod, gtk.ACCEL_VISIBLE)
-        picture = gtk.Image()
-        picture.set_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_MENU)
+            key, mod, Gtk.AccelFlags.VISIBLE)
+        picture = Gtk.Image()
+        picture.set_from_stock(Gtk.STOCK_FIND, Gtk.IconSize.MENU)
         item.set_image(picture)
         item.set_label(_('Check'))
         item.connect('activate', self.__process_files, self.__mat_check)
@@ -216,9 +220,9 @@ class GUI:


         help_menu = self.__create_sub_menu(_('Help'), menubar)
         self.__create_menu_item(_('Supported formats'), self.__supported,
-            help_menu, gtk.STOCK_INFO, False)
+            help_menu, Gtk.STOCK_INFO, False)
         self.__create_menu_item(_('About'), self.__about, help_menu,
-                gtk.STOCK_ABOUT, False)
+                Gtk.STOCK_ABOUT, False)


         return menubar


@@ -227,7 +231,7 @@ class GUI:
             Remove selected files from the treeview
             when the use hit the 'suppr' key
         '''
-        if gtk.gdk.keyval_name(event.keyval) == "Delete":
+        if Gdk.keyval_name(event.keyval) == "Delete":
             rows = []
             self.selection.selected_foreach(
                     lambda model, path, iter: rows.append(iter))
@@ -237,18 +241,18 @@ class GUI:
         '''
             Add the files chosed by the filechoser ("Add" button)
         '''
-        chooser = gtk.FileChooserDialog(title=_('Choose files'),
-            parent=self.window, action=gtk.FILE_CHOOSER_ACTION_OPEN,
-            buttons=(gtk.STOCK_OK, 0, gtk.STOCK_CANCEL, 1))
+        chooser = Gtk.FileChooserDialog(title=_('Choose files'),
+            parent=self.window, action=Gtk.FileChooserAction.OPEN,
+            buttons=(Gtk.STOCK_OK, 0, Gtk.STOCK_CANCEL, 1))
         chooser.set_default_response(0)
         chooser.set_select_multiple(True)


-        all_filter = gtk.FileFilter()  # filter that shows all files
+        all_filter = Gtk.FileFilter()  # filter that shows all files
         all_filter.set_name(_('All files'))
         all_filter.add_pattern('*')
         chooser.add_filter(all_filter)


-        supported_filter = gtk.FileFilter()
+        supported_filter = Gtk.FileFilter()
         # filter that shows only supported formats
         [supported_filter.add_mime_type(i) for i in strippers.STRIPPERS.keys()]
         supported_filter.set_name(_('Supported files'))
@@ -256,10 +260,10 @@ class GUI:


         response = chooser.run()


-        if response is 0:  # gtk.STOCK_OK
+        if response is 0:  # Gtk.STOCK_OK
             filenames = chooser.get_filenames()
             task = self.populate(filenames)
-            gobject.idle_add(task.next)  # asynchrone processing
+            GObject.idle_add(task.next)  # asynchrone processing
         chooser.destroy()


     def populate(self, filenames):
@@ -316,15 +320,15 @@ class GUI:
                 name = '-<b>' + str(i) + '</b> : '
                 meta += (name + str(j) + '\n')


-        w = gtk.MessageDialog(self.window,
-                gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
-                gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, label)
+        w = Gtk.MessageDialog(self.window,
+                Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
+                Gtk.MessageType.INFO, Gtk.ButtonsType.CLOSE, label)
         w.set_resizable(True)
         w.set_size_request(400, 300)
-        scrolled_window = gtk.ScrolledWindow()
-        scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+        scrolled_window = Gtk.ScrolledWindow()
+        scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
         w.vbox.pack_start(scrolled_window, True, True, 0)
-        content = gtk.Label(meta)
+        content = Gtk.Label(label=meta)
         content.set_selectable(True)
         content.set_alignment(0, 0)
         content.set_use_markup(True)
@@ -340,11 +344,11 @@ class GUI:
             Popup that warn the user about the unsupported files
             that he want to process
         '''
-        dialog = gtk.Dialog(title=_('Not-supported'), parent=self.window,
-                flags=0, buttons=(gtk.STOCK_OK, 0))
-        vbox = gtk.VBox(spacing=5)
+        dialog = Gtk.Dialog(title=_('Not-supported'), parent=self.window,
+                flags=0, buttons=(Gtk.STOCK_OK, 0))
+        vbox = Gtk.VBox(spacing=5)
         dialog.get_content_area().pack_start(vbox, True, True, 0)
-        store = gtk.ListStore(str, str)
+        store = Gtk.ListStore(str, str)


         # append filename - mimetype to the store
         #FIXME : I'm ugly
@@ -355,14 +359,14 @@ class GUI:
             else:
                 store.append([item, 'unknown'])


-        treeview = gtk.TreeView(store)
+        treeview = Gtk.TreeView(store)
         vbox.pack_start(treeview, True, True, 0)


         #create column
-        rendererText = gtk.CellRendererText()
-        column = gtk.TreeViewColumn(_('Filename'), rendererText, text=0)
+        rendererText = Gtk.CellRendererText()
+        column = Gtk.TreeViewColumn(_('Filename'), rendererText, text=0)
         treeview.append_column(column)
-        column = gtk.TreeViewColumn(_('Mimetype'), rendererText, text=1)
+        column = Gtk.TreeViewColumn(_('Mimetype'), rendererText, text=1)
         treeview.append_column(column)


         dialog.show_all()
@@ -374,17 +378,17 @@ class GUI:
         '''
             About popup
         '''
-        w = gtk.AboutDialog()
+        w = Gtk.AboutDialog()
         w.set_authors(['Julien (jvoisin) Voisin', ])
         w.set_artists(['Marine Benoît', ])
         w.set_copyright('GNU Public License v2')
         w.set_comments(_('This software was coded during the GSoC 2011'))
-        w.set_logo(gtk.gdk.pixbuf_new_from_file_at_size(self.logo, 400, 200))
+        w.set_logo(GdkPixbuf.Pixbuf.new_from_file_at_size(self.logo, 400, 200))
         w.set_program_name('Metadata Anonymisation Toolkit')
         w.set_version(mat.__version__)
         w.set_website('https://mat.boum.org')
         w.set_website_label(_('Website'))
-        w.set_position(gtk.WIN_POS_CENTER)
+        w.set_position(Gtk.WindowPosition.CENTER)
         w.run()
         w.destroy()


@@ -392,12 +396,12 @@ class GUI:
         '''
             List the supported formats
         '''
-        dialog = gtk.Dialog(_('Supported formats'), self.window, 0,
-            (gtk.STOCK_CLOSE, 0))
-        vbox = gtk.VBox(spacing=5)
+        dialog = Gtk.Dialog(_('Supported formats'), self.window, 0,
+            (Gtk.STOCK_CLOSE, 0))
+        vbox = Gtk.VBox(spacing=5)
         dialog.get_content_area().pack_start(vbox, True, True, 0)


-        label = gtk.Label()
+        label = Gtk.Label()
         label.set_markup('<big><u>Supported fileformats</u></big>')
         vbox.pack_start(label, True, True, 0)


@@ -411,7 +415,7 @@ class GUI:

         def expander_callback(current):
             ''' Close every expander except the current one '''
-            for i in vbox.get_children()[1:]:  # first child is a gtk.Label
+            for i in vbox.get_children()[1:]:  # first child is a Gtk.Label
                 if i != current:
                     i.set_expanded(False)


@@ -428,9 +432,9 @@ class GUI:
                 if item['support'] == 'partial':
                     content += '\n\t<b>remaining</b> : ' + item['remaining']


-                expander = gtk.Expander(title)
+                expander = Gtk.Expander(title)
                 vbox.pack_start(expander, False, False, 0)
-                label = gtk.Label()
+                label = Gtk.Label()
                 label.set_markup(content)
                 expander.add(label)
                 expander.connect('activate', expander_callback)
@@ -444,32 +448,32 @@ class GUI:
         '''
             Preferences popup
         '''
-        dialog = gtk.Dialog(_('Preferences'), self.window, 0,
-                (gtk.STOCK_OK, 0))
-        hbox = gtk.HBox()
+        dialog = Gtk.Dialog(_('Preferences'), self.window, 0,
+                (Gtk.STOCK_OK, 0))
+        hbox = Gtk.HBox()
         dialog.get_content_area().pack_start(hbox, False, False, 0)


-        icon = gtk.Image()
-        icon.set_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_DIALOG)
+        icon = Gtk.Image()
+        icon.set_from_stock(Gtk.STOCK_PREFERENCES, Gtk.IconSize.DIALOG)
         hbox.pack_start(icon, False, False, 20)


-        table = gtk.Table(3, 2, False)  # nb rows, nb lines
+        table = Gtk.Table(3, 2, False)  # nb rows, nb lines
         hbox.pack_start(table, True, True, 0)


-        force = gtk.CheckButton(_('Force Clean'), False)
+        force = Gtk.CheckButton(_('Force Clean'), False)
         force.set_active(self.force)
         force.connect('toggled', self.__invert, 'force')
         force.set_tooltip_text(_('Do not check if already clean before \
 cleaning'))
         table.attach(force, 0, 1, 0, 1)


-        backup = gtk.CheckButton(_('Backup'), False)
+        backup = Gtk.CheckButton(_('Backup'), False)
         backup.set_active(self.backup)
         backup.connect('toggled', self.__invert, 'backup')
         backup.set_tooltip_text(_('Keep a backup copy'))
         table.attach(backup, 0, 1, 1, 2)


-        add2archive = gtk.CheckButton(_('Add unsupported file to archives'),
+        add2archive = Gtk.CheckButton(_('Add unsupported file to archives'),
             False)
         add2archive.set_active(self.add2archive)
         add2archive.connect('toggled', self.__invert, 'add2archive')
@@ -479,7 +483,7 @@ non-anonymised) file to output archive'))


         hbox.show_all()
         response = dialog.run()
-        if response is 0:  # gtk.STOCK_OK
+        if response is 0:  # Gtk.STOCK_OK
             dialog.destroy()


     def __invert(self, button, name):
@@ -507,7 +511,7 @@ non-anonymised) file to output archive'))
         urls = selection.data.strip('\r\n\x00')  # strip stupid characters
         cleaned_urls = map(self.__clean_draged_file_path, urls.split('\n'))
         task = self.populate(cleaned_urls)
-        gobject.idle_add(task.next)  # asynchrone processing
+        GObject.idle_add(task.next)  # asynchrone processing


     def __clean_draged_file_path(self, url):
         '''
@@ -530,7 +534,7 @@ non-anonymised) file to output archive'))
         if not iterator:  # if nothing is selected : select everything
             iterator = xrange(len(self.liststore))
         task = func(iterator)  # launch func() in an asynchrone way
-        gobject.idle_add(task.next)
+        GObject.idle_add(task.next)


     def __mat_check(self, iterator):
         '''
@@ -575,6 +579,6 @@ if __name__ == '__main__':
     infiles = [arg for arg in sys.argv[1:] if os.path.exists(arg)]
     if infiles:
         task = gui.populate(infiles)
-        gobject.idle_add(task.next)
+        GObject.idle_add(task.next)


-    gtk.main()
+    Gtk.main()
-- 
1.7.10.4