Blame SOURCES/gedit-disable-python3.patch

6f95c4
From 1cb46d3837804d69c2b2e12317d3c5a7e60a819a Mon Sep 17 00:00:00 2001
6f95c4
From: Matěj Cepl <mcepl@redhat.com>
6f95c4
Date: Fri, 15 May 2015 11:00:19 -0400
6f95c4
Subject: [PATCH] Switch from python3 to python2
6f95c4
6f95c4
---
6f95c4
 configure.ac                                          |  2 +-
6f95c4
 gedit/gedit-plugins-engine.c                          |  2 +-
6f95c4
 plugins/externaltools/data/send-to-fpaste.tool.in     |  2 +-
6f95c4
 plugins/externaltools/externaltools.plugin.desktop.in |  2 +-
6f95c4
 plugins/externaltools/tools/library.py                | 15 ++++++++-------
6f95c4
 plugins/pythonconsole/pythonconsole.plugin.desktop.in |  2 +-
6f95c4
 plugins/quickopen/quickopen.plugin.desktop.in         |  2 +-
6f95c4
 plugins/snippets/snippets.plugin.desktop.in           |  2 +-
6f95c4
 plugins/snippets/snippets/library.py                  |  3 ++-
6f95c4
 plugins/snippets/snippets/shareddata.py               |  3 ++-
6f95c4
 plugins/snippets/snippets/signals.py                  |  2 +-
6f95c4
 11 files changed, 20 insertions(+), 17 deletions(-)
6f95c4
6f95c4
diff --git a/configure.ac b/configure.ac
6f95c4
index cf3d734..3acee28 100644
6f95c4
--- a/configure.ac
6f95c4
+++ b/configure.ac
6f95c4
@@ -276,61 +276,61 @@ if test "x$enable_enchant" = "xyes" ; then
6f95c4
 				have_iso_codes=no
6f95c4
 			fi
6f95c4
 			AC_MSG_RESULT([$result])
6f95c4
 		fi
6f95c4
 
6f95c4
 		if test "x$have_iso_codes" = "xyes"; then
6f95c4
 			AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],["`$PKG_CONFIG --variable=prefix iso-codes`"],[ISO codes prefix])
6f95c4
 			AC_DEFINE([HAVE_ISO_CODES],[1],[Define if you have the iso-codes package])
6f95c4
 		else
6f95c4
 			AC_MSG_ERROR([iso-codes is required to build the spell plugin. Use --disable-spell to build without spell plugin.])
6f95c4
 		fi
6f95c4
 	else
6f95c4
 		enable_enchant=no
6f95c4
 		AC_MSG_ERROR([Enchant library not found or too old. Use --disable-spell to build without spell plugin.])
6f95c4
 	fi
6f95c4
 fi
6f95c4
 
6f95c4
 AM_CONDITIONAL(ENABLE_ENCHANT, test x"$enable_enchant" = "xyes")
6f95c4
 
6f95c4
 AC_ARG_ENABLE([python],
6f95c4
               AS_HELP_STRING([--enable-python[=@<:@no/auto/yes@:>@]],[Build with python support]),
6f95c4
               [enable_python=$enableval],
6f95c4
               [enable_python="auto"])
6f95c4
 
6f95c4
 if test "x$enable_python" = "xauto"; then
6f95c4
 	PKG_CHECK_EXISTS([pygobject-3.0 >= $PYGOBJECT_REQUIRED],
6f95c4
 	                 [enable_python=yes],[enable_python=no])
f620a9
 fi
f620a9
 
f620a9
 if test "x$enable_python" = "xyes"; then
f620a9
-	AM_PATH_PYTHON(3.2.3)
f620a9
+	AM_PATH_PYTHON
f620a9
 	PKG_CHECK_MODULES(PYTHON, [pygobject-3.0 >= $PYGOBJECT_REQUIRED])
f620a9
 
6f95c4
 	pyoverridesdir="\$(pyexecdir)/gi/overrides"
6f95c4
 	AC_SUBST(pyoverridesdir)
6f95c4
 fi
6f95c4
 
6f95c4
 AM_CONDITIONAL(ENABLE_PYTHON, test x"$enable_python" = "xyes")
6f95c4
 
6f95c4
 dnl ================================================================
6f95c4
 dnl Start of pkg-config checks
6f95c4
 dnl ================================================================
6f95c4
 
6f95c4
 # Dependencies
6f95c4
 
6f95c4
 PKG_CHECK_MODULES(GEDIT, [
6f95c4
 	libxml-2.0 >= $LIBXML_REQUIRED
6f95c4
 	glib-2.0 >= $GLIB_REQUIRED
6f95c4
 	gio-2.0 >= $GLIB_REQUIRED
6f95c4
 	gmodule-2.0
6f95c4
 	gtk+-3.0 >= $GTK_REQUIRED
6f95c4
 	gtksourceview-3.0 >= $GTKSOURCEVIEW_REQUIRED
6f95c4
 	libpeas-1.0 >= $LIBPEAS_REQUIRED
6f95c4
 	libpeas-gtk-1.0 >= $LIBPEAS_REQUIRED
6f95c4
 	gsettings-desktop-schemas
6f95c4
 ])
6f95c4
 
6f95c4
 if test "$os_osx" = "no" &&
6f95c4
    test "$os_win32" = "no"; then
6f95c4
 	PKG_CHECK_MODULES(X11, [
6f95c4
 		x11
6f95c4
diff --git a/gedit/gedit-plugins-engine.c b/gedit/gedit-plugins-engine.c
6f95c4
index 725cb3b..678809b 100644
6f95c4
--- a/gedit/gedit-plugins-engine.c
6f95c4
+++ b/gedit/gedit-plugins-engine.c
6f95c4
@@ -28,61 +28,61 @@
6f95c4
 #include <string.h>
6f95c4
 
6f95c4
 #include <glib/gi18n.h>
6f95c4
 #include <girepository.h>
6f95c4
 
6f95c4
 #include "gedit-debug.h"
6f95c4
 #include "gedit-app.h"
6f95c4
 #include "gedit-dirs.h"
6f95c4
 #include "gedit-settings.h"
6f95c4
 #include "gedit-utils.h"
6f95c4
 
6f95c4
 struct _GeditPluginsEnginePrivate
6f95c4
 {
6f95c4
 	GSettings *plugin_settings;
6f95c4
 };
6f95c4
 
6f95c4
 G_DEFINE_TYPE_WITH_PRIVATE (GeditPluginsEngine, gedit_plugins_engine, PEAS_TYPE_ENGINE)
6f95c4
 
6f95c4
 GeditPluginsEngine *default_engine = NULL;
6f95c4
 
6f95c4
 static void
6f95c4
 gedit_plugins_engine_init (GeditPluginsEngine *engine)
6f95c4
 {
6f95c4
 	gchar *typelib_dir;
6f95c4
 	GError *error = NULL;
6f95c4
 
6f95c4
 	gedit_debug (DEBUG_PLUGINS);
6f95c4
 
6f95c4
 	engine->priv = gedit_plugins_engine_get_instance_private (engine);
f620a9
 
f620a9
-	peas_engine_enable_loader (PEAS_ENGINE (engine), "python3");
f620a9
+	peas_engine_enable_loader (PEAS_ENGINE (engine), "python");
f620a9
 
f620a9
 	engine->priv->plugin_settings = g_settings_new ("org.gnome.gedit.plugins");
f620a9
 
6f95c4
 	/* Require gedit's typelib. */
6f95c4
 	typelib_dir = g_build_filename (gedit_dirs_get_gedit_lib_dir (),
6f95c4
 	                                "girepository-1.0",
6f95c4
 	                                NULL);
6f95c4
 
6f95c4
 	if (!g_irepository_require_private (g_irepository_get_default (),
6f95c4
 	                                    typelib_dir, "Gedit", "3.0", 0, &error))
6f95c4
 	{
6f95c4
 		g_warning ("Could not load Gedit repository: %s", error->message);
6f95c4
 		g_error_free (error);
6f95c4
 		error = NULL;
6f95c4
 	}
6f95c4
 
6f95c4
 	g_free (typelib_dir);
6f95c4
 
6f95c4
 	/* This should be moved to libpeas */
6f95c4
 	if (!g_irepository_require (g_irepository_get_default (),
6f95c4
 	                            "Peas", "1.0", 0, &error))
6f95c4
 	{
6f95c4
 		g_warning ("Could not load Peas repository: %s", error->message);
6f95c4
 		g_error_free (error);
6f95c4
 		error = NULL;
6f95c4
 	}
6f95c4
 
6f95c4
 	if (!g_irepository_require (g_irepository_get_default (),
6f95c4
 	                            "PeasGtk", "1.0", 0, &error))
6f95c4
 	{
6f95c4
diff --git a/plugins/externaltools/data/send-to-fpaste.tool.in b/plugins/externaltools/data/send-to-fpaste.tool.in
6f95c4
index d255007..95c2d37 100755
6f95c4
--- a/plugins/externaltools/data/send-to-fpaste.tool.in
6f95c4
+++ b/plugins/externaltools/data/send-to-fpaste.tool.in
6f95c4
@@ -1,27 +1,27 @@
6f95c4
-#!/usr/bin/env python3
6f95c4
+#!/usr/bin/env python
6f95c4
 
6f95c4
 import os, urllib, json, sys, urllib.request
6f95c4
 from gi.repository import Gtk, Gdk
6f95c4
 
6f95c4
 lang = os.getenv('GEDIT_CURRRENT_DOCUMENT_LANGUAGE')
6f95c4
 if lang is None:
6f95c4
     lang = "text"
6f95c4
 
6f95c4
 current_document_path = os.getenv('GEDIT_CURRENT_DOCUMENT_PATH')
6f95c4
 selected_text = os.getenv('GEDIT_SELECTED_TEXT')
6f95c4
 
6f95c4
 if selected_text is None:
6f95c4
     selected_text = sys.stdin.read()
6f95c4
 
6f95c4
 url_params = urllib.parse.urlencode({'paste_data': selected_text, 'paste_lang': lang, 'mode':'json', 'api_submit':'true'})
6f95c4
 openfpaste = urllib.request.urlopen("http://fpaste.org", bytes(url_params, 'utf-8')).read().decode("utf-8")
6f95c4
 final_data = json.loads(openfpaste)
6f95c4
 
6f95c4
 paste_url = "http://fpaste.org/" + final_data['result']['id']
6f95c4
 
6f95c4
 print(paste_url + " has been copied to clipboard.")
6f95c4
 
6f95c4
 disp = Gdk.Display.get_default()
6f95c4
 clipper = Gtk.Clipboard.get_for_display(disp, Gdk.SELECTION_CLIPBOARD)
6f95c4
 clipper.set_text(paste_url, len(paste_url))
6f95c4
 clipper.store()
6f95c4
diff --git a/plugins/externaltools/externaltools.plugin.desktop.in b/plugins/externaltools/externaltools.plugin.desktop.in
6f95c4
index cc7a4da..c56e4e3 100644
f620a9
--- a/plugins/externaltools/externaltools.plugin.desktop.in
f620a9
+++ b/plugins/externaltools/externaltools.plugin.desktop.in
6f95c4
@@ -1,9 +1,9 @@
f620a9
 [Plugin]
f620a9
-Loader=python3
f620a9
+Loader=python
f620a9
 Module=externaltools
f620a9
 IAge=3
f620a9
 _Name=External Tools
6f95c4
 _Description=Execute external commands and shell scripts.
6f95c4
 Authors=Steve Frécinaux <steve@istique.net>
6f95c4
 Copyright=Copyright © 2005 Steve Frécinaux
6f95c4
 Website=http://www.gedit.org
6f95c4
diff --git a/plugins/externaltools/tools/library.py b/plugins/externaltools/tools/library.py
6f95c4
index adfd943..4d4bce0 100644
6f95c4
--- a/plugins/externaltools/tools/library.py
6f95c4
+++ b/plugins/externaltools/tools/library.py
6f95c4
@@ -1,48 +1,49 @@
6f95c4
 # -*- coding: utf-8 -*-
6f95c4
 #    Gedit External Tools plugin
6f95c4
 #    Copyright (C) 2006  Steve Frécinaux <code@istique.net>
6f95c4
 #
6f95c4
 #    This program is free software; you can redistribute it and/or modify
6f95c4
 #    it under the terms of the GNU General Public License as published by
6f95c4
 #    the Free Software Foundation; either version 2 of the License, or
6f95c4
 #    (at your option) any later version.
6f95c4
 #
6f95c4
 #    This program is distributed in the hope that it will be useful,
6f95c4
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
6f95c4
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6f95c4
 #    GNU General Public License for more details.
6f95c4
 #
6f95c4
 #    You should have received a copy of the GNU General Public License
6f95c4
 #    along with this program; if not, write to the Free Software
6f95c4
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
6f95c4
 
6f95c4
+import io
6f95c4
 import os
6f95c4
 import re
6f95c4
 import locale
6f95c4
 import platform
6f95c4
 from gi.repository import GLib
6f95c4
 
6f95c4
 
6f95c4
 class Singleton(object):
6f95c4
     _instance = None
6f95c4
 
6f95c4
     def __new__(cls, *args, **kwargs):
6f95c4
         if not cls._instance:
6f95c4
             cls._instance = super(Singleton, cls).__new__(cls, *args, **kwargs)
6f95c4
             cls._instance.__init_once__()
6f95c4
 
6f95c4
         return cls._instance
6f95c4
 
6f95c4
 
6f95c4
 class ToolLibrary(Singleton):
6f95c4
     def __init_once__(self):
6f95c4
         self.locations = []
6f95c4
 
6f95c4
     def set_locations(self, datadir):
6f95c4
         self.locations = []
6f95c4
 
6f95c4
         if platform.platform() != 'Windows':
6f95c4
             for d in self.get_xdg_data_dirs():
6f95c4
                 self.locations.append(os.path.join(d, 'gedit', 'plugins', 'externaltools', 'tools'))
6f95c4
 
6f95c4
         self.locations.append(datadir)
6f95c4
@@ -219,61 +220,61 @@ class Tool(object):
6f95c4
         self.changed = False
6f95c4
         self._properties = dict()
6f95c4
         self._transform = {
6f95c4
             'Languages': [self._to_list, self._from_list]
6f95c4
         }
6f95c4
         self._load()
6f95c4
 
6f95c4
     def _to_list(self, value):
6f95c4
         if value.strip() == '':
6f95c4
             return []
6f95c4
         else:
6f95c4
             return [x.strip() for x in value.split(',')]
6f95c4
 
6f95c4
     def _from_list(self, value):
6f95c4
         return ','.join(value)
6f95c4
 
6f95c4
     def _parse_value(self, key, value):
6f95c4
         if key in self._transform:
6f95c4
             return self._transform[key][0](value)
6f95c4
         else:
6f95c4
             return value
6f95c4
 
6f95c4
     def _load(self):
6f95c4
         if self.filename is None:
6f95c4
             return
6f95c4
 
6f95c4
         filename = self.library.get_full_path(self.get_path())
6f95c4
         if filename is None:
6f95c4
             return
6f95c4
 
6f95c4
-        fp = open(filename, 'r', 1, encoding='utf-8')
6f95c4
+        fp = io.open(filename, 'r', 1, encoding='utf-8')
6f95c4
         in_block = False
6f95c4
         lang = locale.getlocale(locale.LC_MESSAGES)[0]
6f95c4
 
6f95c4
         for line in fp:
6f95c4
             if not in_block:
6f95c4
                 in_block = line.startswith('# [Gedit Tool]')
6f95c4
                 continue
6f95c4
             if line.startswith('##') or line.startswith('# #'):
6f95c4
                 continue
6f95c4
             if not line.startswith('# '):
6f95c4
                 break
6f95c4
 
6f95c4
             try:
6f95c4
                 (key, value) = [i.strip() for i in line[2:].split('=', 1)]
6f95c4
                 m = self.RE_KEY.match(key)
6f95c4
                 if m.group(3) is None:
6f95c4
                     self._properties[m.group(1)] = self._parse_value(m.group(1), value)
6f95c4
                 elif lang is not None and lang.startswith(m.group(3)):
6f95c4
                     self._properties[m.group(1)] = self._parse_value(m.group(1), value)
6f95c4
             except ValueError:
6f95c4
                 break
6f95c4
         fp.close()
6f95c4
         self.changed = False
6f95c4
 
6f95c4
     def _set_property_if_changed(self, key, value):
6f95c4
         if value != self._properties.get(key):
6f95c4
             self._properties[key] = value
6f95c4
 
6f95c4
             self.changed = True
6f95c4
 
6f95c4
@@ -368,141 +369,141 @@ class Tool(object):
6f95c4
     def get_save_files(self):
6f95c4
         save_files = self._properties.get('Save-files')
6f95c4
         if save_files:
6f95c4
             return save_files
6f95c4
         return 'nothing'
6f95c4
 
6f95c4
     def set_save_files(self, value):
6f95c4
         self._set_property_if_changed('Save-files', value)
6f95c4
 
6f95c4
     save_files = property(get_save_files, set_save_files)
6f95c4
 
6f95c4
     def get_languages(self):
6f95c4
         languages = self._properties.get('Languages')
6f95c4
         if languages:
6f95c4
             return languages
6f95c4
         return []
6f95c4
 
6f95c4
     def set_languages(self, value):
6f95c4
         self._set_property_if_changed('Languages', value)
6f95c4
 
6f95c4
     languages = property(get_languages, set_languages)
6f95c4
 
6f95c4
     def has_hash_bang(self):
6f95c4
         if self.filename is None:
6f95c4
             return True
6f95c4
 
6f95c4
         filename = self.library.get_full_path(self.get_path())
6f95c4
         if filename is None:
6f95c4
             return True
6f95c4
 
6f95c4
-        fp = open(filename, 'r', 1, encoding='utf-8')
6f95c4
+        fp = io.open(filename, 'r', 1, encoding='utf-8')
6f95c4
         for line in fp:
6f95c4
             if line.strip() == '':
6f95c4
                 continue
6f95c4
             return line.startswith('#!')
6f95c4
 
6f95c4
     # There is no property for this one because this function is quite
6f95c4
     # expensive to perform
6f95c4
     def get_script(self):
6f95c4
         if self.filename is None:
6f95c4
             return ["#!/bin/sh\n"]
6f95c4
 
6f95c4
         filename = self.library.get_full_path(self.get_path())
6f95c4
         if filename is None:
6f95c4
             return ["#!/bin/sh\n"]
6f95c4
 
6f95c4
-        fp = open(filename, 'r', 1, encoding='utf-8')
6f95c4
+        fp = io.open(filename, 'r', 1, encoding='utf-8')
6f95c4
         lines = list()
6f95c4
 
6f95c4
         # before entering the data block
6f95c4
         for line in fp:
6f95c4
             if line.startswith('# [Gedit Tool]'):
6f95c4
                 break
6f95c4
             lines.append(line)
6f95c4
         # in the block:
6f95c4
         for line in fp:
6f95c4
             if line.startswith('##'):
6f95c4
                 continue
6f95c4
             if not (line.startswith('# ') and '=' in line):
6f95c4
                 # after the block: strip one emtpy line (if present)
6f95c4
                 if line.strip() != '':
6f95c4
                     lines.append(line)
6f95c4
                 break
6f95c4
         # after the block
6f95c4
         for line in fp:
6f95c4
             lines.append(line)
6f95c4
         fp.close()
6f95c4
         return lines
6f95c4
 
6f95c4
     def _dump_properties(self):
6f95c4
         lines = ['# [Gedit Tool]']
6f95c4
         for item in self._properties.items():
6f95c4
             if item[0] in self._transform:
6f95c4
                 lines.append('# %s=%s' % (item[0], self._transform[item[0]][1](item[1])))
6f95c4
             elif item[1] is not None:
6f95c4
                 lines.append('# %s=%s' % item)
6f95c4
         return '\n'.join(lines) + '\n'
6f95c4
 
6f95c4
     def save_with_script(self, script):
6f95c4
         filename = self.library.get_full_path(self.filename, 'w')
6f95c4
-        fp = open(filename, 'w', 1, encoding='utf-8')
6f95c4
+        fp = io.open(filename, 'w', 1, encoding='utf-8')
6f95c4
 
6f95c4
         # Make sure to first print header (shebang, modeline), then
6f95c4
         # properties, and then actual content
6f95c4
         header = []
6f95c4
         content = []
6f95c4
         inheader = True
6f95c4
 
6f95c4
         # Parse
6f95c4
         for line in script:
6f95c4
             line = line.rstrip("\n")
6f95c4
             if not inheader:
6f95c4
                 content.append(line)
6f95c4
             elif line.startswith('#!'):
6f95c4
                 # Shebang (should be always present)
6f95c4
                 header.append(line)
6f95c4
             elif line.strip().startswith('#') and ('-*-' in line or 'ex:' in line or 'vi:' in line or 'vim:' in line):
6f95c4
                 header.append(line)
6f95c4
             else:
6f95c4
                 content.append(line)
6f95c4
                 inheader = False
6f95c4
 
6f95c4
         # Write out header
6f95c4
         for line in header:
6f95c4
             fp.write(line + "\n")
6f95c4
 
6f95c4
-        fp.write(self._dump_properties())
6f95c4
-        fp.write("\n")
6f95c4
+        fp.write(unicode(self._dump_properties(), 'utf8'))
6f95c4
+        fp.write(u"\n")
6f95c4
 
6f95c4
         for line in content:
6f95c4
-            fp.write(line + "\n")
6f95c4
+            fp.write(unicode(line + "\n", 'utf8'))
6f95c4
 
6f95c4
         fp.close()
6f95c4
         os.chmod(filename, 0o750)
6f95c4
         self.changed = False
6f95c4
 
6f95c4
     def save(self):
6f95c4
         if self.changed:
6f95c4
             self.save_with_script(self.get_script())
6f95c4
 
6f95c4
     def autoset_filename(self):
6f95c4
         if self.filename is not None:
6f95c4
             return
6f95c4
         dirname = self.parent.path
6f95c4
         if dirname != '':
6f95c4
             dirname += os.path.sep
6f95c4
 
6f95c4
         basename = self.name.lower().replace(' ', '-').replace('/', '-')
6f95c4
 
6f95c4
         if self.library.get_full_path(dirname + basename):
6f95c4
             i = 2
6f95c4
             while self.library.get_full_path(dirname + "%s-%d" % (basename, i)):
6f95c4
                 i += 1
6f95c4
             basename = "%s-%d" % (basename, i)
6f95c4
         self.filename = basename
6f95c4
 
6f95c4
 if __name__ == '__main__':
6f95c4
     library = ToolLibrary()
6f95c4
     library.set_locations(os.path.expanduser("~/.config/gedit/tools"))
6f95c4
 
6f95c4
     def print_tool(t, indent):
6f95c4
diff --git a/plugins/pythonconsole/pythonconsole.plugin.desktop.in b/plugins/pythonconsole/pythonconsole.plugin.desktop.in
6f95c4
index 21283e8..4309667 100644
f620a9
--- a/plugins/pythonconsole/pythonconsole.plugin.desktop.in
f620a9
+++ b/plugins/pythonconsole/pythonconsole.plugin.desktop.in
6f95c4
@@ -1,10 +1,10 @@
f620a9
 [Plugin]
f620a9
-Loader=python3
f620a9
+Loader=python
f620a9
 Module=pythonconsole
f620a9
 IAge=3
f620a9
 _Name=Python Console
6f95c4
 _Description=Interactive Python console standing in the bottom panel
6f95c4
 Icon=gnome-mime-text-x-python
6f95c4
 Authors=Steve Frécinaux <steve@istique.net>
6f95c4
 Copyright=Copyright © 2006 Steve Frécinaux
6f95c4
 Website=http://www.gedit.org
6f95c4
diff --git a/plugins/quickopen/quickopen.plugin.desktop.in b/plugins/quickopen/quickopen.plugin.desktop.in
6f95c4
index 68b6faa..17edecc 100644
f620a9
--- a/plugins/quickopen/quickopen.plugin.desktop.in
f620a9
+++ b/plugins/quickopen/quickopen.plugin.desktop.in
6f95c4
@@ -1,10 +1,10 @@
f620a9
 [Plugin]
f620a9
-Loader=python3
f620a9
+Loader=python
f620a9
 Module=quickopen
f620a9
 IAge=3
f620a9
 _Name=Quick Open
6f95c4
 _Description=Quickly open files
6f95c4
 Icon=gtk-open
6f95c4
 Authors=Jesse van den Kieboom  <jessevdk@gnome.org>
6f95c4
 Copyright=Copyright © 2009 Jesse van den Kieboom
6f95c4
 Website=http://www.gedit.org
6f95c4
diff --git a/plugins/snippets/snippets.plugin.desktop.in b/plugins/snippets/snippets.plugin.desktop.in
6f95c4
index 8551b6b..f41a626 100644
f620a9
--- a/plugins/snippets/snippets.plugin.desktop.in
f620a9
+++ b/plugins/snippets/snippets.plugin.desktop.in
6f95c4
@@ -1,9 +1,9 @@
f620a9
 [Plugin]
f620a9
-Loader=python3
f620a9
+Loader=python
f620a9
 Module=snippets
f620a9
 IAge=3
f620a9
 _Name=Snippets
6f95c4
 _Description=Insert often-used pieces of text in a fast way
6f95c4
 Authors=Jesse van den Kieboom <jesse@icecrew.nl>
6f95c4
 Copyright=Copyright © 2005 Jesse van den Kieboom
6f95c4
 Website=http://www.gedit.org
6f95c4
diff --git a/plugins/snippets/snippets/library.py b/plugins/snippets/snippets/library.py
6f95c4
index 455ac91..1b454f3 100644
6f95c4
--- a/plugins/snippets/snippets/library.py
6f95c4
+++ b/plugins/snippets/snippets/library.py
6f95c4
@@ -1,47 +1,48 @@
6f95c4
 #    Gedit snippets plugin
6f95c4
 #    Copyright (C) 2005-2006  Jesse van den Kieboom <jesse@icecrew.nl>
6f95c4
 #
6f95c4
 #    This program is free software; you can redistribute it and/or modify
6f95c4
 #    it under the terms of the GNU General Public License as published by
6f95c4
 #    the Free Software Foundation; either version 2 of the License, or
6f95c4
 #    (at your option) any later version.
6f95c4
 #
6f95c4
 #    This program is distributed in the hope that it will be useful,
6f95c4
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
6f95c4
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6f95c4
 #    GNU General Public License for more details.
6f95c4
 #
6f95c4
 #    You should have received a copy of the GNU General Public License
6f95c4
 #    along with this program; if not, write to the Free Software
6f95c4
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
6f95c4
 
6f95c4
+import io
6f95c4
 import os
6f95c4
 import weakref
6f95c4
 import sys
6f95c4
 import re
6f95c4
 
6f95c4
 from gi.repository import Gdk, Gtk
6f95c4
 
6f95c4
 import xml.etree.ElementTree as et
6f95c4
 from . import helper
6f95c4
 
6f95c4
 class NamespacedId:
6f95c4
     def __init__(self, namespace, id):
6f95c4
         if not id:
6f95c4
             self.id = None
6f95c4
         else:
6f95c4
             if namespace:
6f95c4
                 self.id = namespace + '-'
6f95c4
             else:
6f95c4
                 self.id = 'global-'
6f95c4
 
6f95c4
             self.id += id
6f95c4
 
6f95c4
 class SnippetData:
6f95c4
     PROPS = {'tag': '', 'text': '', 'description': 'New snippet',
6f95c4
             'accelerator': '', 'drop-targets': ''}
6f95c4
 
6f95c4
     def __init__(self, node, library):
6f95c4
         self.priv_id = node.attrib.get('id')
6f95c4
 
6f95c4
         self.set_library(library)
6f95c4
@@ -426,61 +427,61 @@ class SnippetsSystemFile:
6f95c4
 
6f95c4
         return True
6f95c4
 
6f95c4
     def _process_element(self, element):
6f95c4
         if element.tag == 'snippet':
6f95c4
             self._add_snippet(element)
6f95c4
             self.insnippet = False
6f95c4
 
6f95c4
         return True
6f95c4
 
6f95c4
     def ensure(self):
6f95c4
         if not self.ok or self.loaded:
6f95c4
             return
6f95c4
 
6f95c4
         self.load()
6f95c4
 
6f95c4
     def parse_xml(self, readsize=16384):
6f95c4
         if not self.path:
6f95c4
             return
6f95c4
 
6f95c4
         elements = []
6f95c4
 
6f95c4
         builder = SnippetsTreeBuilder( \
6f95c4
                 lambda node: elements.append((node, True)), \
6f95c4
                 lambda node: elements.append((node, False)))
6f95c4
 
6f95c4
         parser = et.XMLParser(target=builder)
6f95c4
         self.insnippet = False
6f95c4
 
6f95c4
         try:
6f95c4
-            f = open(self.path, "r", encoding='utf-8')
6f95c4
+            f = io.open(self.path, "r", encoding='utf-8')
6f95c4
         except IOError:
6f95c4
             self.ok = False
6f95c4
             return
6f95c4
 
6f95c4
         while True:
6f95c4
             try:
6f95c4
                 data = f.read(readsize)
6f95c4
             except IOError:
6f95c4
                 self.ok = False
6f95c4
                 break
6f95c4
 
6f95c4
             if not data:
6f95c4
                 break
6f95c4
 
6f95c4
             try:
6f95c4
                 parser.feed(data)
6f95c4
             except Exception:
6f95c4
                 self.ok = False
6f95c4
                 break
6f95c4
 
6f95c4
             for element in elements:
6f95c4
                 yield element
6f95c4
 
6f95c4
             del elements[:]
6f95c4
 
6f95c4
         f.close()
6f95c4
 
6f95c4
     def load(self):
6f95c4
         if not self.ok:
6f95c4
             return
6f95c4
diff --git a/plugins/snippets/snippets/shareddata.py b/plugins/snippets/snippets/shareddata.py
6f95c4
index be6fd14..64ffcc4 100644
f620a9
--- a/plugins/snippets/snippets/shareddata.py
f620a9
+++ b/plugins/snippets/snippets/shareddata.py
6f95c4
@@ -1,56 +1,57 @@
6f95c4
 #    Gedit snippets plugin
6f95c4
 #    Copyright (C) 2011  Jesse van den Kieboom <jessevdk@gnome.org>
6f95c4
 #
6f95c4
 #    This program is free software; you can redistribute it and/or modify
6f95c4
 #    it under the terms of the GNU General Public License as published by
6f95c4
 #    the Free Software Foundation; either version 2 of the License, or
6f95c4
 #    (at your option) any later version.
6f95c4
 #
6f95c4
 #    This program is distributed in the hope that it will be useful,
6f95c4
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
6f95c4
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6f95c4
 #    GNU General Public License for more details.
6f95c4
 #
6f95c4
 #    You should have received a copy of the GNU General Public License
6f95c4
 #    along with this program; if not, write to the Free Software
6f95c4
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
6f95c4
 
6f95c4
 from .singleton import Singleton
6f95c4
 import os
f620a9
 
f620a9
 from gi.repository import Gtk
f620a9
 
6f95c4
 # To register the GeditSnippetsManager type
6f95c4
 from .manager import Manager
6f95c4
 
f620a9
-class SharedData(object, metaclass=Singleton):
f620a9
+class SharedData(object):
f620a9
+    __metaclass__ = Singleton
f620a9
     def __init__(self):
f620a9
         self.dlg = None
f620a9
         self.dlg_default_size = None
6f95c4
         self.controller_registry = {}
6f95c4
         self.windows = {}
f620a9
 
f620a9
     def register_controller(self, view, controller):
f620a9
         self.controller_registry[view] = controller
6f95c4
     
f620a9
     def unregister_controller(self, view, controller):
f620a9
         if self.controller_registry[view] == controller:
f620a9
             del self.controller_registry[view]
f620a9
 
6f95c4
     def register_window(self, window):
6f95c4
         self.windows[window.window] = window
6f95c4
 
6f95c4
     def unregister_window(self, window):
6f95c4
         if window.window in self.windows:
6f95c4
             del self.windows[window.window]
6f95c4
 
6f95c4
     def update_state(self, window):
6f95c4
         if window in self.windows:
6f95c4
             self.windows[window].do_update_state()
6f95c4
 
6f95c4
     def get_active_controller(self, window):
6f95c4
         view = window.get_active_view()
6f95c4
 
6f95c4
         if not view or not view in self.controller_registry:
6f95c4
             return None
6f95c4
 
6f95c4
diff --git a/plugins/snippets/snippets/signals.py b/plugins/snippets/snippets/signals.py
6f95c4
index 647b616..9aaa95a 100644
6f95c4
--- a/plugins/snippets/snippets/signals.py
6f95c4
+++ b/plugins/snippets/snippets/signals.py
6f95c4
@@ -1,50 +1,50 @@
6f95c4
 # -*- coding: utf-8 -*-
6f95c4
 #
6f95c4
 #  signals.py
6f95c4
 #
6f95c4
 #  Copyright (C) 2009 - Jesse van den Kieboom
6f95c4
 #
6f95c4
 #  This program is free software; you can redistribute it and/or modify
6f95c4
 #  it under the terms of the GNU General Public License as published by
6f95c4
 #  the Free Software Foundation; either version 2 of the License, or
6f95c4
 #  (at your option) any later version.
6f95c4
 #
6f95c4
 #  This program is distributed in the hope that it will be useful,
6f95c4
 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
6f95c4
 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6f95c4
 #  GNU General Public License for more details.
6f95c4
 #
6f95c4
 #  You should have received a copy of the GNU General Public License
6f95c4
 #  along with this program; if not, see <http://www.gnu.org/licenses/>.
6f95c4
 
6f95c4
-class Signals:
6f95c4
+class Signals(object):
6f95c4
     def __init__(self):
6f95c4
         self._signals = {}
6f95c4
 
6f95c4
     def _connect(self, obj, name, handler, connector):
6f95c4
         ret = self._signals.setdefault(obj, {})
6f95c4
 
6f95c4
         hid = connector(name, handler)
6f95c4
         ret.setdefault(name, []).append(hid)
6f95c4
 
6f95c4
         return hid
6f95c4
 
6f95c4
     def connect_signal(self, obj, name, handler):
6f95c4
         return self._connect(obj, name, handler, obj.connect)
6f95c4
 
6f95c4
     def connect_signal_after(self, obj, name, handler):
6f95c4
         return self._connect(obj, name, handler, obj.connect_after)
6f95c4
 
6f95c4
     def disconnect_signals(self, obj):
6f95c4
         if obj not in self._signals:
6f95c4
             return False
6f95c4
 
6f95c4
         for name in self._signals[obj]:
6f95c4
             for hid in self._signals[obj][name]:
6f95c4
                 obj.disconnect(hid)
6f95c4
 
6f95c4
         del self._signals[obj]
6f95c4
         return True
f620a9
 
6f95c4
     def block_signal(self, obj, name):
6f95c4
         if obj not in self._signals:
6f95c4
-- 
6f95c4
2.3.7
f620a9