raveit65 113dc30
From a54a8e7bf8e86f87316b5026e6e85d6d3fdab226 Mon Sep 17 00:00:00 2001
raveit65 113dc30
From: Patrick Monnerat <patrick@monnerat.net>
raveit65 113dc30
Date: Wed, 22 May 2019 18:02:59 +0200
raveit65 113dc30
Subject: [PATCH] pythonconsole plugin: change source code for Python 2 & 3
raveit65 113dc30
 compatibility.
raveit65 113dc30
raveit65 113dc30
Also drop mateconf and use gsettings for preferences.
raveit65 113dc30
Preferences are now triggered as a PeasGtk.Configurable.
raveit65 113dc30
---
raveit65 113dc30
 configure.ac                                  |   1 +
raveit65 113dc30
 plugins/pythonconsole/Makefile.am             |  19 +-
raveit65 113dc30
 ...pluma.plugins.pythonconsole.gschema.xml.in |  30 +++
raveit65 113dc30
 .../pythonconsole/pythonconsole/__init__.py   |  37 +--
raveit65 113dc30
 plugins/pythonconsole/pythonconsole/config.py | 158 ++++++------
raveit65 113dc30
 plugins/pythonconsole/pythonconsole/config.ui | 224 +++++++++---------
raveit65 113dc30
 .../pythonconsole/pythonconsole/console.py    |  68 ++++--
raveit65 113dc30
 7 files changed, 304 insertions(+), 233 deletions(-)
raveit65 113dc30
 create mode 100644 plugins/pythonconsole/org.mate.pluma.plugins.pythonconsole.gschema.xml.in
raveit65 113dc30
raveit65 113dc30
diff --git a/configure.ac b/configure.ac
raveit65 113dc30
index 1cdbb7e..ceb9a5c 100644
raveit65 113dc30
--- a/configure.ac
raveit65 113dc30
+++ b/configure.ac
raveit65 113dc30
@@ -250,6 +250,7 @@ plugins/filebrowser/org.mate.pluma.plugins.filebrowser.gschema.xml
raveit65 113dc30
 plugins/modelines/Makefile
raveit65 113dc30
 plugins/pythonconsole/Makefile
raveit65 113dc30
 plugins/pythonconsole/pythonconsole/Makefile
raveit65 113dc30
+plugins/pythonconsole/org.mate.pluma.plugins.pythonconsole.gschema.xml
raveit65 113dc30
 plugins/quickopen/Makefile
raveit65 113dc30
 plugins/quickopen/quickopen/Makefile
raveit65 113dc30
 plugins/snippets/data/lang/Makefile
raveit65 113dc30
diff --git a/plugins/pythonconsole/Makefile.am b/plugins/pythonconsole/Makefile.am
raveit65 113dc30
index 0a9ff96..51a2e4a 100644
raveit65 113dc30
--- a/plugins/pythonconsole/Makefile.am
raveit65 113dc30
+++ b/plugins/pythonconsole/Makefile.am
raveit65 113dc30
@@ -7,9 +7,22 @@ plugin_in_files = pythonconsole.plugin.desktop.in
raveit65 113dc30
 
raveit65 113dc30
 plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
raveit65 113dc30
 
raveit65 113dc30
-EXTRA_DIST = $(plugin_in_files)
raveit65 113dc30
+pythonconsole_gschema_in = org.mate.pluma.plugins.pythonconsole.gschema.xml.in
raveit65 113dc30
+gsettings_SCHEMAS = $(pythonconsole_gschema_in:.xml.in=.xml)
raveit65 113dc30
+@GSETTINGS_RULES@
raveit65 113dc30
 
raveit65 113dc30
-CLEANFILES = $(plugin_DATA)
raveit65 113dc30
-DISTCLEANFILES = $(plugin_DATA)
raveit65 113dc30
+EXTRA_DIST = \
raveit65 113dc30
+	$(plugin_in_files) \
raveit65 113dc30
+	$(pythonconsole_gschema_in)
raveit65 113dc30
+
raveit65 113dc30
+CLEANFILES = \
raveit65 113dc30
+	$(plugin_DATA) \
raveit65 113dc30
+	$(gsettings_SCHEMAS_in)		\
raveit65 113dc30
+	$(gsettings_SCHEMAS)
raveit65 113dc30
+
raveit65 113dc30
+DISTCLEANFILES = \
raveit65 113dc30
+	$(plugin_DATA) \
raveit65 113dc30
+	$(gsettings_SCHEMAS_in)		\
raveit65 113dc30
+	$(gsettings_SCHEMAS)
raveit65 113dc30
 
raveit65 113dc30
 -include $(top_srcdir)/git.mk
raveit65 113dc30
diff --git a/plugins/pythonconsole/org.mate.pluma.plugins.pythonconsole.gschema.xml.in b/plugins/pythonconsole/org.mate.pluma.plugins.pythonconsole.gschema.xml.in
raveit65 113dc30
new file mode 100644
raveit65 113dc30
index 0000000..7897fa9
raveit65 113dc30
--- /dev/null
raveit65 113dc30
+++ b/plugins/pythonconsole/org.mate.pluma.plugins.pythonconsole.gschema.xml.in
raveit65 113dc30
@@ -0,0 +1,30 @@
raveit65 113dc30
+<schemalist>
raveit65 113dc30
+  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.mate.pluma.plugins.pythonconsole" path="/org/mate/pluma/plugins/pythonconsole/">
raveit65 113dc30
+    <key name="command-color" type="s">
raveit65 113dc30
+      <default>'#314e6c'</default>
raveit65 113dc30
+      <summary>Command Color Text</summary>
raveit65 113dc30
+      <description>The command color text</description>
raveit65 113dc30
+    </key>
raveit65 113dc30
+    <key name="error-color" type="s">
raveit65 113dc30
+      <default>'#990000'</default>
raveit65 113dc30
+      <summary>Error Color Text</summary>
raveit65 113dc30
+      <description>The error color text</description>
raveit65 113dc30
+    </key>
raveit65 113dc30
+    <key name="use-system-font" type="b">
raveit65 113dc30
+      <default>true</default>
raveit65 113dc30
+      <summary>Whether to use the system font</summary>
raveit65 113dc30
+      <description>
raveit65 113dc30
+        If true, the terminal will use the desktop-global standard
raveit65 113dc30
+        font if it’s monospace (and the most similar font it can
raveit65 113dc30
+        come up with otherwise).
raveit65 113dc30
+      </description>
raveit65 113dc30
+    </key>
raveit65 113dc30
+    <key name="font" type="s">
raveit65 113dc30
+      <default>'Monospace 10'</default>
raveit65 113dc30
+      <summary>Font</summary>
raveit65 113dc30
+      <description>
raveit65 113dc30
+        A Pango font name. Examples are “Sans 12” or “Monospace Bold 14”.
raveit65 113dc30
+      </description>
raveit65 113dc30
+    </key>
raveit65 113dc30
+  </schema>
raveit65 113dc30
+</schemalist>
raveit65 113dc30
diff --git a/plugins/pythonconsole/pythonconsole/__init__.py b/plugins/pythonconsole/pythonconsole/__init__.py
raveit65 113dc30
index 07d13c7..171b367 100755
raveit65 113dc30
--- a/plugins/pythonconsole/pythonconsole/__init__.py
raveit65 113dc30
+++ b/plugins/pythonconsole/pythonconsole/__init__.py
raveit65 113dc30
@@ -24,22 +24,22 @@
raveit65 113dc30
 # Bits from pluma Python Console Plugin
raveit65 113dc30
 #     Copyrignt (C), 2005 Raphaël Slinckx
raveit65 113dc30
 
raveit65 113dc30
-from gi.repository import GObject, Gtk, Peas, Pluma
raveit65 113dc30
+from gi.repository import GObject, Gtk, Peas, PeasGtk, Pluma
raveit65 113dc30
 
raveit65 113dc30
-from console import PythonConsole
raveit65 113dc30
-from config import PythonConsoleConfigDialog
raveit65 113dc30
-from config import PythonConsoleConfig
raveit65 113dc30
+from .console import PythonConsole
raveit65 113dc30
+from .config import PythonConsoleConfigWidget
raveit65 113dc30
+from .config import PythonConsoleConfig
raveit65 113dc30
 
raveit65 113dc30
 PYTHON_ICON = 'text-x-python'
raveit65 113dc30
 
raveit65 113dc30
-class PythonConsolePlugin(GObject.Object, Peas.Activatable):
raveit65 113dc30
+class PythonConsolePlugin(GObject.Object, Peas.Activatable, PeasGtk.Configurable):
raveit65 113dc30
     __gtype_name__ = "PythonConsolePlugin"
raveit65 113dc30
 
raveit65 113dc30
     object = GObject.Property(type=GObject.Object)
raveit65 113dc30
 
raveit65 113dc30
     def __init__(self):
raveit65 113dc30
         GObject.Object.__init__(self)
raveit65 113dc30
-        self.dlg = None
raveit65 113dc30
+        self.config_widget = None
raveit65 113dc30
 
raveit65 113dc30
     def do_activate(self):
raveit65 113dc30
         window = self.object
raveit65 113dc30
@@ -47,8 +47,8 @@ class PythonConsolePlugin(GObject.Object, Peas.Activatable):
raveit65 113dc30
         self._console = PythonConsole(namespace = {'__builtins__' : __builtins__,
raveit65 113dc30
                                              'pluma' : Pluma,
raveit65 113dc30
                                              'window' : window})
raveit65 113dc30
-        self._console.eval('print "You can access the main window through ' \
raveit65 113dc30
-                     '\'window\' :\\n%s" % window', False)
raveit65 113dc30
+        self._console.eval('print("You can access the main window through ' \
raveit65 113dc30
+                           '\'window\' :\\n%s" % window)', False)
raveit65 113dc30
         bottom = window.get_bottom_panel()
raveit65 113dc30
         image = Gtk.Image()
raveit65 113dc30
         image.set_from_icon_name(PYTHON_ICON, Gtk.IconSize.MENU)
raveit65 113dc30
@@ -61,22 +61,9 @@ class PythonConsolePlugin(GObject.Object, Peas.Activatable):
raveit65 113dc30
         bottom = window.get_bottom_panel()
raveit65 113dc30
         bottom.remove_item(self._console)
raveit65 113dc30
 
raveit65 113dc30
-def create_configure_dialog(self):
raveit65 113dc30
-
raveit65 113dc30
-    if not self.dlg:
raveit65 113dc30
-        self.dlg = PythonConsoleConfigDialog(self.get_data_dir())
raveit65 113dc30
-
raveit65 113dc30
-    dialog = self.dlg.dialog()
raveit65 113dc30
-    window = pluma.app_get_default().get_active_window()
raveit65 113dc30
-    if window:
raveit65 113dc30
-        dialog.set_transient_for(window)
raveit65 113dc30
-
raveit65 113dc30
-    return dialog
raveit65 113dc30
-
raveit65 113dc30
-# Here we dynamically insert create_configure_dialog based on if configuration
raveit65 113dc30
-# is enabled. This has to be done like this because pluma checks if a plugin
raveit65 113dc30
-# is configurable solely on the fact that it has this member defined or not
raveit65 113dc30
-if PythonConsoleConfig.enabled():
raveit65 113dc30
-    PythonConsolePlugin.create_configure_dialog = create_configure_dialog
raveit65 113dc30
+    def do_create_configure_widget(self):
raveit65 113dc30
+        if not self.config_widget:
raveit65 113dc30
+            self.config_widget = PythonConsoleConfigWidget(self.plugin_info.get_data_dir())
raveit65 113dc30
+        return self.config_widget.configure_widget()
raveit65 113dc30
 
raveit65 113dc30
 # ex:et:ts=4:
raveit65 113dc30
diff --git a/plugins/pythonconsole/pythonconsole/config.py b/plugins/pythonconsole/pythonconsole/config.py
raveit65 113dc30
index fce0c9d..f973e38 100755
raveit65 113dc30
--- a/plugins/pythonconsole/pythonconsole/config.py
raveit65 113dc30
+++ b/plugins/pythonconsole/pythonconsole/config.py
raveit65 113dc30
@@ -25,110 +25,126 @@
raveit65 113dc30
 #     Copyrignt (C), 2005 Raphaël Slinckx
raveit65 113dc30
 
raveit65 113dc30
 import os
raveit65 113dc30
-import gtk
raveit65 113dc30
+from gi.repository import Gio, Gtk, Gdk
raveit65 113dc30
 
raveit65 113dc30
-__all__ = ('PythonConsoleConfig', 'PythonConsoleConfigDialog')
raveit65 113dc30
-
raveit65 113dc30
-MATECONF_KEY_BASE = '/apps/pluma/plugins/pythonconsole'
raveit65 113dc30
-MATECONF_KEY_COMMAND_COLOR = MATECONF_KEY_BASE + '/command-color'
raveit65 113dc30
-MATECONF_KEY_ERROR_COLOR = MATECONF_KEY_BASE + '/error-color'
raveit65 113dc30
-
raveit65 113dc30
-DEFAULT_COMMAND_COLOR = '#314e6c' # Blue Shadow
raveit65 113dc30
-DEFAULT_ERROR_COLOR = '#990000' # Accent Red Dark
raveit65 113dc30
+__all__ = ('PythonConsoleConfig', 'PythonConsoleConfigWidget')
raveit65 113dc30
 
raveit65 113dc30
 class PythonConsoleConfig(object):
raveit65 113dc30
-    try:
raveit65 113dc30
-        import mateconf
raveit65 113dc30
-    except ImportError:
raveit65 113dc30
-        mateconf = None
raveit65 113dc30
-
raveit65 113dc30
-    def __init__(self):
raveit65 113dc30
-        pass
raveit65 113dc30
 
raveit65 113dc30
-    @staticmethod
raveit65 113dc30
-    def enabled():
raveit65 113dc30
-        return PythonConsoleConfig.mateconf != None
raveit65 113dc30
+    CONSOLE_KEY_BASE = 'org.mate.pluma.plugins.pythonconsole'
raveit65 113dc30
+    CONSOLE_KEY_COMMAND_COLOR = 'command-color'
raveit65 113dc30
+    CONSOLE_KEY_ERROR_COLOR = 'error-color'
raveit65 113dc30
+    CONSOLE_KEY_USE_SYSTEM_FONT = 'use-system-font'
raveit65 113dc30
+    CONSOLE_KEY_FONT = 'font'
raveit65 113dc30
 
raveit65 113dc30
-    @staticmethod
raveit65 113dc30
-    def add_handler(handler):
raveit65 113dc30
-        if PythonConsoleConfig.mateconf:
raveit65 113dc30
-            PythonConsoleConfig.mateconf.client_get_default().notify_add(MATECONF_KEY_BASE, handler)
raveit65 113dc30
+    INTERFACE_KEY_BASE = 'org.mate.interface'
raveit65 113dc30
+    INTERFACE_KEY_MONOSPACE_FONT_NAME = 'monospace-font-name'
raveit65 113dc30
 
raveit65 113dc30
     color_command = property(
raveit65 113dc30
-        lambda self: self.mateconf_get_str(MATECONF_KEY_COMMAND_COLOR, DEFAULT_COMMAND_COLOR),
raveit65 113dc30
-        lambda self, value: self.mateconf_set_str(MATECONF_KEY_COMMAND_COLOR, value))
raveit65 113dc30
+        lambda self: self.console_settings.get_string(self.CONSOLE_KEY_COMMAND_COLOR),
raveit65 113dc30
+        lambda self, value: self.console_settings.set_string(self.CONSOLE_KEY_COMMAND_COLOR, value)
raveit65 113dc30
+    )
raveit65 113dc30
 
raveit65 113dc30
     color_error = property(
raveit65 113dc30
-        lambda self: self.mateconf_get_str(MATECONF_KEY_ERROR_COLOR, DEFAULT_ERROR_COLOR),
raveit65 113dc30
-        lambda self, value: self.mateconf_set_str(MATECONF_KEY_ERROR_COLOR, value))
raveit65 113dc30
+        lambda self: self.console_settings.get_string(self.CONSOLE_KEY_ERROR_COLOR),
raveit65 113dc30
+        lambda self, value: self.console_settings.set_string(self.CONSOLE_KEY_ERROR_COLOR, value)
raveit65 113dc30
+    )
raveit65 113dc30
 
raveit65 113dc30
-    @staticmethod
raveit65 113dc30
-    def mateconf_get_str(key, default=''):
raveit65 113dc30
-        if not PythonConsoleConfig.mateconf:
raveit65 113dc30
-            return default
raveit65 113dc30
+    use_system_font = property(
raveit65 113dc30
+        lambda self: self.console_settings.get_boolean(self.CONSOLE_KEY_USE_SYSTEM_FONT),
raveit65 113dc30
+        lambda self, value: self.console_settings.set_boolean(self.CONSOLE_KEY_USE_SYSTEM_FONT, value)
raveit65 113dc30
+    )
raveit65 113dc30
 
raveit65 113dc30
-        val = PythonConsoleConfig.mateconf.client_get_default().get(key)
raveit65 113dc30
-        if val is not None and val.type == mateconf.VALUE_STRING:
raveit65 113dc30
-            return val.get_string()
raveit65 113dc30
-        else:
raveit65 113dc30
-            return default
raveit65 113dc30
+    font = property(
raveit65 113dc30
+        lambda self: self.console_settings.get_string(self.CONSOLE_KEY_FONT),
raveit65 113dc30
+        lambda self, value: self.console_settings.set_string(self.CONSOLE_KEY_FONT, value)
raveit65 113dc30
+    )
raveit65 113dc30
 
raveit65 113dc30
-    @staticmethod
raveit65 113dc30
-    def mateconf_set_str(key, value):
raveit65 113dc30
-        if not PythonConsoleConfig.mateconf:
raveit65 113dc30
-            return
raveit65 113dc30
+    monospace_font_name = property(
raveit65 113dc30
+        lambda self: self.interface_settings.get_string(self.INTERFACE_KEY_MONOSPACE_FONT_NAME)
raveit65 113dc30
+    )
raveit65 113dc30
+
raveit65 113dc30
+    console_settings = Gio.Settings.new(CONSOLE_KEY_BASE)
raveit65 113dc30
+    interface_settings = Gio.Settings.new(INTERFACE_KEY_BASE)
raveit65 113dc30
+
raveit65 113dc30
+    def __init__(self):
raveit65 113dc30
+        object.__init__(self)
raveit65 113dc30
+
raveit65 113dc30
+    @classmethod
raveit65 113dc30
+    def enabled(self):
raveit65 113dc30
+        return self.console_settings != None
raveit65 113dc30
+
raveit65 113dc30
+    @classmethod
raveit65 113dc30
+    def add_handler(self, handler):
raveit65 113dc30
+        self.console_settings.connect("changed", handler)
raveit65 113dc30
+        self.interface_settings.connect("changed", handler)
raveit65 113dc30
 
raveit65 113dc30
-        v = PythonConsoleConfig.mateconf.Value(mateconf.VALUE_STRING)
raveit65 113dc30
-        v.set_string(value)
raveit65 113dc30
-        PythonConsoleConfig.mateconf.client_get_default().set(key, v)
raveit65 113dc30
 
raveit65 113dc30
-class PythonConsoleConfigDialog(object):
raveit65 113dc30
+class PythonConsoleConfigWidget(object):
raveit65 113dc30
+
raveit65 113dc30
+    CONSOLE_KEY_BASE = 'org.mate.pluma.plugins.pythonconsole'
raveit65 113dc30
+    CONSOLE_KEY_COMMAND_COLOR = 'command-color'
raveit65 113dc30
+    CONSOLE_KEY_ERROR_COLOR = 'error-color'
raveit65 113dc30
 
raveit65 113dc30
     def __init__(self, datadir):
raveit65 113dc30
         object.__init__(self)
raveit65 113dc30
-        self._dialog = None
raveit65 113dc30
+        self._widget = None
raveit65 113dc30
         self._ui_path = os.path.join(datadir, 'ui', 'config.ui')
raveit65 113dc30
-        self.config = PythonConsoleConfig()
raveit65 113dc30
+        self._config = PythonConsoleConfig()
raveit65 113dc30
+        self._ui = Gtk.Builder()
raveit65 113dc30
 
raveit65 113dc30
-    def dialog(self):
raveit65 113dc30
-        if self._dialog is None:
raveit65 113dc30
-            self._ui = gtk.Builder()
raveit65 113dc30
+    def configure_widget(self):
raveit65 113dc30
+        if self._widget is None:
raveit65 113dc30
             self._ui.add_from_file(self._ui_path)
raveit65 113dc30
 
raveit65 113dc30
             self.set_colorbutton_color(self._ui.get_object('colorbutton-command'),
raveit65 113dc30
-                                        self.config.color_command)
raveit65 113dc30
+                                        self._config.color_command)
raveit65 113dc30
             self.set_colorbutton_color(self._ui.get_object('colorbutton-error'),
raveit65 113dc30
-                                        self.config.color_error)
raveit65 113dc30
-
raveit65 113dc30
+                                        self._config.color_error)
raveit65 113dc30
+            checkbox = self._ui.get_object('checkbox-system-font')
raveit65 113dc30
+            checkbox.set_active(self._config.use_system_font)
raveit65 113dc30
+            self._fontbutton = self._ui.get_object('fontbutton-font')
raveit65 113dc30
+            self._fontbutton.set_font_name(self._config.font)
raveit65 113dc30
+            self.on_checkbox_system_font_toggled(checkbox)
raveit65 113dc30
             self._ui.connect_signals(self)
raveit65 113dc30
 
raveit65 113dc30
-            self._dialog = self._ui.get_object('dialog-config')
raveit65 113dc30
-            self._dialog.show_all()
raveit65 113dc30
-        else:
raveit65 113dc30
-            self._dialog.present()
raveit65 113dc30
+            self._widget = self._ui.get_object('widget-config')
raveit65 113dc30
+            self._widget.show_all()
raveit65 113dc30
 
raveit65 113dc30
-        return self._dialog
raveit65 113dc30
+        return self._widget
raveit65 113dc30
 
raveit65 113dc30
     @staticmethod
raveit65 113dc30
     def set_colorbutton_color(colorbutton, value):
raveit65 113dc30
-        try:
raveit65 113dc30
-            color = gtk.gdk.color_parse(value)
raveit65 113dc30
-        except ValueError:
raveit65 113dc30
-            pass    # Default color in config.ui used
raveit65 113dc30
-        else:
raveit65 113dc30
-            colorbutton.set_color(color)
raveit65 113dc30
+        rgba = Gdk.RGBA()
raveit65 113dc30
+        parsed = rgba.parse(value)
raveit65 113dc30
 
raveit65 113dc30
-    def on_dialog_config_response(self, dialog, response_id):
raveit65 113dc30
-        self._dialog.destroy()
raveit65 113dc30
-
raveit65 113dc30
-    def on_dialog_config_destroy(self, dialog):
raveit65 113dc30
-        self._dialog = None
raveit65 113dc30
-        self._ui = None
raveit65 113dc30
+        if parsed:
raveit65 113dc30
+            colorbutton.set_rgba(rgba)
raveit65 113dc30
 
raveit65 113dc30
     def on_colorbutton_command_color_set(self, colorbutton):
raveit65 113dc30
-        self.config.color_command = colorbutton.get_color().to_string()
raveit65 113dc30
+        self._config.color_command = colorbutton.get_color().to_string()
raveit65 113dc30
 
raveit65 113dc30
     def on_colorbutton_error_color_set(self, colorbutton):
raveit65 113dc30
-        self.config.color_error = colorbutton.get_color().to_string()
raveit65 113dc30
+        self._config.color_error = colorbutton.get_color().to_string()
raveit65 113dc30
+
raveit65 113dc30
+    def on_checkbox_system_font_toggled(self, checkbox):
raveit65 113dc30
+        val = checkbox.get_active()
raveit65 113dc30
+        self._config.use_system_font = val
raveit65 113dc30
+        self._fontbutton.set_sensitive(not val)
raveit65 113dc30
+
raveit65 113dc30
+    def on_fontbutton_font_set(self, fontbutton):
raveit65 113dc30
+        self._config.font = fontbutton.get_font_name()
raveit65 113dc30
+
raveit65 113dc30
+    def on_widget_config_parent_set(self, widget, oldparent):
raveit65 113dc30
+        # Set icon in dialog close button.
raveit65 113dc30
+        try:
raveit65 113dc30
+            actionarea = widget.get_toplevel().get_action_area()
raveit65 113dc30
+            image = Gtk.Image.new_from_icon_name("window-close",
raveit65 113dc30
+                                                 Gtk.IconSize.BUTTON)
raveit65 113dc30
+            for button in actionarea.get_children():
raveit65 113dc30
+                button.set_image(image)
raveit65 113dc30
+                button.set_property("always-show-image", True)
raveit65 113dc30
+        except:
raveit65 113dc30
+            pass
raveit65 113dc30
 
raveit65 113dc30
 # ex:et:ts=4:
raveit65 113dc30
diff --git a/plugins/pythonconsole/pythonconsole/config.ui b/plugins/pythonconsole/pythonconsole/config.ui
raveit65 113dc30
index 8d337d6..392be7d 100644
raveit65 113dc30
--- a/plugins/pythonconsole/pythonconsole/config.ui
raveit65 113dc30
+++ b/plugins/pythonconsole/pythonconsole/config.ui
raveit65 113dc30
@@ -1,126 +1,124 @@
raveit65 113dc30
 
raveit65 113dc30
-
raveit65 113dc30
+
raveit65 113dc30
 <interface>
raveit65 113dc30
   <requires lib="gtk+" version="3.0"/>
raveit65 113dc30
-  <object class="GtkImage" id="image1">
raveit65 113dc30
+  <object class="GtkGrid" id="widget-config">
raveit65 113dc30
     <property name="visible">True</property>
raveit65 113dc30
     <property name="can_focus">False</property>
raveit65 113dc30
-    <property name="icon_name">window-close</property>
raveit65 113dc30
-  </object>
raveit65 113dc30
-  <object class="GtkDialog" id="dialog-config">
raveit65 113dc30
-    <property name="can_focus">False</property>
raveit65 113dc30
-    <property name="window_position">center-on-parent</property>
raveit65 113dc30
-    <property name="destroy_with_parent">True</property>
raveit65 113dc30
-    <property name="type_hint">dialog</property>
raveit65 113dc30
-    <signal name="destroy" handler="on_dialog_config_destroy" swapped="no"/>
raveit65 113dc30
-    <signal name="response" handler="on_dialog_config_response" swapped="no"/>
raveit65 113dc30
-    <child internal-child="vbox">
raveit65 113dc30
-      <object class="GtkBox" id="dialog-vbox1">
raveit65 113dc30
+    <property name="margin_left">6</property>
raveit65 113dc30
+    <property name="margin_right">6</property>
raveit65 113dc30
+    <property name="margin_top">6</property>
raveit65 113dc30
+    <property name="margin_bottom">6</property>
raveit65 113dc30
+    <property name="orientation">vertical</property>
raveit65 113dc30
+    <property name="row_spacing">6</property>
raveit65 113dc30
+    <property name="column_spacing">6</property>
raveit65 113dc30
+    <signal name="parent-set" handler="on_widget_config_parent_set" swapped="no"/>
raveit65 113dc30
+    <child>
raveit65 113dc30
+      <object class="GtkLabel" id="label-error">
raveit65 113dc30
+        <property name="visible">True</property>
raveit65 113dc30
+        <property name="can_focus">False</property>
raveit65 113dc30
+        <property name="label" translatable="yes">_Error color:</property>
raveit65 113dc30
+        <property name="use_underline">True</property>
raveit65 113dc30
+        <property name="xalign">0</property>
raveit65 113dc30
+      </object>
raveit65 113dc30
+      <packing>
raveit65 113dc30
+        <property name="left_attach">0</property>
raveit65 113dc30
+        <property name="top_attach">1</property>
raveit65 113dc30
+      </packing>
raveit65 113dc30
+    </child>
raveit65 113dc30
+    <child>
raveit65 113dc30
+      <object class="GtkColorButton" id="colorbutton-error">
raveit65 113dc30
+        <property name="visible">True</property>
raveit65 113dc30
+        <property name="can_focus">True</property>
raveit65 113dc30
+        <property name="receives_default">True</property>
raveit65 113dc30
+        <property name="rgba">rgb(153,0,0)</property>
raveit65 113dc30
+        <signal name="color-set" handler="on_colorbutton_error_color_set" swapped="no"/>
raveit65 113dc30
+      </object>
raveit65 113dc30
+      <packing>
raveit65 113dc30
+        <property name="left_attach">1</property>
raveit65 113dc30
+        <property name="top_attach">1</property>
raveit65 113dc30
+      </packing>
raveit65 113dc30
+    </child>
raveit65 113dc30
+    <child>
raveit65 113dc30
+      <object class="GtkColorButton" id="colorbutton-command">
raveit65 113dc30
+        <property name="visible">True</property>
raveit65 113dc30
+        <property name="can_focus">True</property>
raveit65 113dc30
+        <property name="receives_default">True</property>
raveit65 113dc30
+        <property name="rgba">rgb(49,78,108)</property>
raveit65 113dc30
+        <signal name="color-set" handler="on_colorbutton_command_color_set" swapped="no"/>
raveit65 113dc30
+      </object>
raveit65 113dc30
+      <packing>
raveit65 113dc30
+        <property name="left_attach">1</property>
raveit65 113dc30
+        <property name="top_attach">0</property>
raveit65 113dc30
+      </packing>
raveit65 113dc30
+    </child>
raveit65 113dc30
+    <child>
raveit65 113dc30
+      <object class="GtkLabel" id="label-command">
raveit65 113dc30
         <property name="visible">True</property>
raveit65 113dc30
         <property name="can_focus">False</property>
raveit65 113dc30
-        <child internal-child="action_area">
raveit65 113dc30
-          <object class="GtkButtonBox" id="dialog-action_area1">
raveit65 113dc30
-            <property name="visible">True</property>
raveit65 113dc30
-            <property name="can_focus">False</property>
raveit65 113dc30
-            <property name="layout_style">end</property>
raveit65 113dc30
-            <child>
raveit65 113dc30
-              <object class="GtkButton" id="button1">
raveit65 113dc30
-                <property name="label" translatable="yes">_Close</property>
raveit65 113dc30
-                <property name="visible">True</property>
raveit65 113dc30
-                <property name="can_focus">True</property>
raveit65 113dc30
-                <property name="receives_default">True</property>
raveit65 113dc30
-                <property name="image">image1</property>
raveit65 113dc30
-                <property name="use_underline">True</property>
raveit65 113dc30
-              </object>
raveit65 113dc30
-              <packing>
raveit65 113dc30
-                <property name="expand">True</property>
raveit65 113dc30
-                <property name="fill">True</property>
raveit65 113dc30
-                <property name="position">0</property>
raveit65 113dc30
-              </packing>
raveit65 113dc30
-            </child>
raveit65 113dc30
-          </object>
raveit65 113dc30
-          <packing>
raveit65 113dc30
-            <property name="expand">False</property>
raveit65 113dc30
-            <property name="fill">False</property>
raveit65 113dc30
-            <property name="pack_type">end</property>
raveit65 113dc30
-            <property name="position">0</property>
raveit65 113dc30
-          </packing>
raveit65 113dc30
-        </child>
raveit65 113dc30
-        <child>
raveit65 113dc30
-          <object class="GtkTable" id="table2">
raveit65 113dc30
-            <property name="visible">True</property>
raveit65 113dc30
-            <property name="can_focus">False</property>
raveit65 113dc30
-            <property name="border_width">6</property>
raveit65 113dc30
-            <property name="n_rows">2</property>
raveit65 113dc30
-            <property name="n_columns">2</property>
raveit65 113dc30
-            <property name="column_spacing">6</property>
raveit65 113dc30
-            <property name="row_spacing">6</property>
raveit65 113dc30
-            <child>
raveit65 113dc30
-              <object class="GtkLabel" id="label-command">
raveit65 113dc30
-                <property name="visible">True</property>
raveit65 113dc30
-                <property name="can_focus">False</property>
raveit65 113dc30
-                <property name="label" translatable="yes">C_ommand color:</property>
raveit65 113dc30
-                <property name="use_underline">True</property>
raveit65 113dc30
-                <property name="mnemonic_widget">colorbutton-command</property>
raveit65 113dc30
-                <property name="xalign">0</property>
raveit65 113dc30
-              </object>
raveit65 113dc30
-            </child>
raveit65 113dc30
-            <child>
raveit65 113dc30
-              <object class="GtkLabel" id="label-error">
raveit65 113dc30
-                <property name="visible">True</property>
raveit65 113dc30
-                <property name="can_focus">False</property>
raveit65 113dc30
-                <property name="label" translatable="yes">_Error color:</property>
raveit65 113dc30
-                <property name="use_underline">True</property>
raveit65 113dc30
-                <property name="mnemonic_widget">colorbutton-error</property>
raveit65 113dc30
-                <property name="xalign">0</property>
raveit65 113dc30
-              </object>
raveit65 113dc30
-              <packing>
raveit65 113dc30
-                <property name="top_attach">1</property>
raveit65 113dc30
-                <property name="bottom_attach">2</property>
raveit65 113dc30
-              </packing>
raveit65 113dc30
-            </child>
raveit65 113dc30
-            <child>
raveit65 113dc30
-              <object class="GtkColorButton" id="colorbutton-command">
raveit65 113dc30
-                <property name="visible">True</property>
raveit65 113dc30
-                <property name="can_focus">True</property>
raveit65 113dc30
-                <property name="receives_default">True</property>
raveit65 113dc30
-                <property name="color">#31314e4e6c6c</property>
raveit65 113dc30
-                <signal name="color-set" handler="on_colorbutton_command_color_set" swapped="no"/>
raveit65 113dc30
-              </object>
raveit65 113dc30
-              <packing>
raveit65 113dc30
-                <property name="left_attach">1</property>
raveit65 113dc30
-                <property name="right_attach">2</property>
raveit65 113dc30
-              </packing>
raveit65 113dc30
-            </child>
raveit65 113dc30
-            <child>
raveit65 113dc30
-              <object class="GtkColorButton" id="colorbutton-error">
raveit65 113dc30
-                <property name="visible">True</property>
raveit65 113dc30
-                <property name="can_focus">True</property>
raveit65 113dc30
-                <property name="receives_default">True</property>
raveit65 113dc30
-                <property name="color">#999900000000</property>
raveit65 113dc30
-                <signal name="color-set" handler="on_colorbutton_error_color_set" swapped="no"/>
raveit65 113dc30
-              </object>
raveit65 113dc30
-              <packing>
raveit65 113dc30
-                <property name="left_attach">1</property>
raveit65 113dc30
-                <property name="right_attach">2</property>
raveit65 113dc30
-                <property name="top_attach">1</property>
raveit65 113dc30
-                <property name="bottom_attach">2</property>
raveit65 113dc30
-              </packing>
raveit65 113dc30
-            </child>
raveit65 113dc30
-          </object>
raveit65 113dc30
-          <packing>
raveit65 113dc30
-            <property name="expand">False</property>
raveit65 113dc30
-            <property name="fill">True</property>
raveit65 113dc30
-            <property name="position">1</property>
raveit65 113dc30
-          </packing>
raveit65 113dc30
-        </child>
raveit65 113dc30
+        <property name="label" translatable="yes">C_ommand color:</property>
raveit65 113dc30
+        <property name="use_underline">True</property>
raveit65 113dc30
+        <property name="xalign">0</property>
raveit65 113dc30
       </object>
raveit65 113dc30
+      <packing>
raveit65 113dc30
+        <property name="left_attach">0</property>
raveit65 113dc30
+        <property name="top_attach">0</property>
raveit65 113dc30
+      </packing>
raveit65 113dc30
     </child>
raveit65 113dc30
-    <action-widgets>
raveit65 113dc30
-      <action-widget response="-7">button1</action-widget>
raveit65 113dc30
-    </action-widgets>
raveit65 113dc30
     <child>
raveit65 113dc30
-      <placeholder/>
raveit65 113dc30
+      <object class="GtkLabel">
raveit65 113dc30
+        <property name="visible">True</property>
raveit65 113dc30
+        <property name="can_focus">False</property>
raveit65 113dc30
+        <property name="vexpand">True</property>
raveit65 113dc30
+      </object>
raveit65 113dc30
+      <packing>
raveit65 113dc30
+        <property name="left_attach">0</property>
raveit65 113dc30
+        <property name="top_attach">2</property>
raveit65 113dc30
+        <property name="width">2</property>
raveit65 113dc30
+      </packing>
raveit65 113dc30
+    </child>
raveit65 113dc30
+    <child>
raveit65 113dc30
+      <object class="GtkCheckButton" id="checkbox-system-font">
raveit65 113dc30
+        <property name="label" translatable="yes">Use system fixed width font</property>
raveit65 113dc30
+        <property name="visible">True</property>
raveit65 113dc30
+        <property name="can_focus">True</property>
raveit65 113dc30
+        <property name="receives_default">False</property>
raveit65 113dc30
+        <property name="halign">start</property>
raveit65 113dc30
+        <property name="hexpand">True</property>
raveit65 113dc30
+        <property name="draw_indicator">True</property>
raveit65 113dc30
+        <signal name="toggled" handler="on_checkbox_system_font_toggled" swapped="no"/>
raveit65 113dc30
+      </object>
raveit65 113dc30
+      <packing>
raveit65 113dc30
+        <property name="left_attach">0</property>
raveit65 113dc30
+        <property name="top_attach">3</property>
raveit65 113dc30
+        <property name="width">2</property>
raveit65 113dc30
+      </packing>
raveit65 113dc30
+    </child>
raveit65 113dc30
+    <child>
raveit65 113dc30
+      <object class="GtkLabel">
raveit65 113dc30
+        <property name="visible">True</property>
raveit65 113dc30
+        <property name="can_focus">False</property>
raveit65 113dc30
+        <property name="halign">start</property>
raveit65 113dc30
+        <property name="label" translatable="yes">Font:</property>
raveit65 113dc30
+      </object>
raveit65 113dc30
+      <packing>
raveit65 113dc30
+        <property name="left_attach">0</property>
raveit65 113dc30
+        <property name="top_attach">4</property>
raveit65 113dc30
+      </packing>
raveit65 113dc30
+    </child>
raveit65 113dc30
+    <child>
raveit65 113dc30
+      <object class="GtkFontButton" id="fontbutton-font">
raveit65 113dc30
+        <property name="visible">True</property>
raveit65 113dc30
+        <property name="can_focus">True</property>
raveit65 113dc30
+        <property name="receives_default">True</property>
raveit65 113dc30
+        <property name="font">Sans 12</property>
raveit65 113dc30
+        <property name="preview_text"/>
raveit65 113dc30
+        <signal name="font-set" handler="on_fontbutton_font_set" swapped="no"/>
raveit65 113dc30
+      </object>
raveit65 113dc30
+      <packing>
raveit65 113dc30
+        <property name="left_attach">1</property>
raveit65 113dc30
+        <property name="top_attach">4</property>
raveit65 113dc30
+      </packing>
raveit65 113dc30
     </child>
raveit65 113dc30
   </object>
raveit65 113dc30
 </interface>
raveit65 113dc30
diff --git a/plugins/pythonconsole/pythonconsole/console.py b/plugins/pythonconsole/pythonconsole/console.py
raveit65 113dc30
index 75f60e4..0fd9c7c 100755
raveit65 113dc30
--- a/plugins/pythonconsole/pythonconsole/console.py
raveit65 113dc30
+++ b/plugins/pythonconsole/pythonconsole/console.py
raveit65 113dc30
@@ -30,7 +30,7 @@ import re
raveit65 113dc30
 import traceback
raveit65 113dc30
 from gi.repository import GObject, Gdk, Gtk, Pango
raveit65 113dc30
 
raveit65 113dc30
-from config import PythonConsoleConfig
raveit65 113dc30
+from .config import PythonConsoleConfig
raveit65 113dc30
 
raveit65 113dc30
 __all__ = ('PythonConsole', 'OutFile')
raveit65 113dc30
 
raveit65 113dc30
@@ -40,13 +40,14 @@ class PythonConsole(Gtk.ScrolledWindow):
raveit65 113dc30
         'grab-focus' : 'override',
raveit65 113dc30
     }
raveit65 113dc30
 
raveit65 113dc30
+    DEFAULT_FONT = "Monospace 10"
raveit65 113dc30
+
raveit65 113dc30
     def __init__(self, namespace = {}):
raveit65 113dc30
         Gtk.ScrolledWindow.__init__(self)
raveit65 113dc30
 
raveit65 113dc30
         self.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
raveit65 113dc30
         self.set_shadow_type(Gtk.ShadowType.IN)
raveit65 113dc30
         self.view = Gtk.TextView()
raveit65 113dc30
-        self.view.modify_font(Pango.font_description_from_string('Monospace'))
raveit65 113dc30
         self.view.set_editable(True)
raveit65 113dc30
         self.view.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
raveit65 113dc30
         self.add(self.view)
raveit65 113dc30
@@ -57,7 +58,8 @@ class PythonConsole(Gtk.ScrolledWindow):
raveit65 113dc30
         self.error  = buffer.create_tag("error")
raveit65 113dc30
         self.command = buffer.create_tag("command")
raveit65 113dc30
 
raveit65 113dc30
-        PythonConsoleConfig.add_handler(self.apply_preferences)
raveit65 113dc30
+        self.config = PythonConsoleConfig()
raveit65 113dc30
+        self.config.add_handler(self.apply_preferences)
raveit65 113dc30
         self.apply_preferences()
raveit65 113dc30
 
raveit65 113dc30
         self.__spaces_pattern = re.compile(r'^\s+')
raveit65 113dc30
@@ -88,9 +90,28 @@ class PythonConsole(Gtk.ScrolledWindow):
raveit65 113dc30
         self.view.grab_focus()
raveit65 113dc30
 
raveit65 113dc30
     def apply_preferences(self, *args):
raveit65 113dc30
-        config = PythonConsoleConfig()
raveit65 113dc30
-        self.error.set_property("foreground", config.color_error)
raveit65 113dc30
-        self.command.set_property("foreground", config.color_command)
raveit65 113dc30
+        self.error.set_property("foreground", self.config.color_error)
raveit65 113dc30
+        self.command.set_property("foreground", self.config.color_command)
raveit65 113dc30
+
raveit65 113dc30
+        if self.config.use_system_font:
raveit65 113dc30
+            font_name = self.config.monospace_font_name
raveit65 113dc30
+        else:
raveit65 113dc30
+            font_name = self.config.font
raveit65 113dc30
+
raveit65 113dc30
+        font_desc = None
raveit65 113dc30
+        try:
raveit65 113dc30
+            font_desc = Pango.FontDescription(font_name)
raveit65 113dc30
+        except:
raveit65 113dc30
+            try:
raveit65 113dc30
+                font_desc = Pango.FontDescription(self.config.monospace_font_name)
raveit65 113dc30
+            except:
raveit65 113dc30
+                try:
raveit65 113dc30
+                    font_desc = Pango.FontDescription(self.DEFAULT_FONT)
raveit65 113dc30
+                except:
raveit65 113dc30
+                    pass
raveit65 113dc30
+
raveit65 113dc30
+        if font_desc:
raveit65 113dc30
+            self.view.modify_font(font_desc)
raveit65 113dc30
 
raveit65 113dc30
     def stop(self):
raveit65 113dc30
         self.namespace = None
raveit65 113dc30
@@ -98,11 +119,13 @@ class PythonConsole(Gtk.ScrolledWindow):
raveit65 113dc30
     def __key_press_event_cb(self, view, event):
raveit65 113dc30
         modifier_mask = Gtk.accelerator_get_default_mod_mask()
raveit65 113dc30
         event_state = event.state & modifier_mask
raveit65 113dc30
+        keyname = Gdk.keyval_name(event.keyval)
raveit65 113dc30
 
raveit65 113dc30
-        if event.keyval == Gdk.KEY_D and event_state == Gdk.ModifierType.CONTROL_MASK:
raveit65 113dc30
+        if keyname == "d" and event_state == Gdk.ModifierType.CONTROL_MASK:
raveit65 113dc30
             self.destroy()
raveit65 113dc30
 
raveit65 113dc30
-        elif event.keyval == Gdk.KEY_Return and event_state == Gdk.ModifierType.CONTROL_MASK:
raveit65 113dc30
+        elif keyname == "Return" and \
raveit65 113dc30
+             event_state == Gdk.ModifierType.CONTROL_MASK:
raveit65 113dc30
             # Get the command
raveit65 113dc30
             buffer = view.get_buffer()
raveit65 113dc30
             inp_mark = buffer.get_mark("input")
raveit65 113dc30
@@ -128,7 +151,7 @@ class PythonConsole(Gtk.ScrolledWindow):
raveit65 113dc30
             GObject.idle_add(self.scroll_to_end)
raveit65 113dc30
             return True
raveit65 113dc30
 
raveit65 113dc30
-        elif event.keyval == Gdk.KEY_Return:
raveit65 113dc30
+        elif keyname == "Return":
raveit65 113dc30
             # Get the marks
raveit65 113dc30
             buffer = view.get_buffer()
raveit65 113dc30
             lin_mark = buffer.get_mark("input-line")
raveit65 113dc30
@@ -172,22 +195,22 @@ class PythonConsole(Gtk.ScrolledWindow):
raveit65 113dc30
             GObject.idle_add(self.scroll_to_end)
raveit65 113dc30
             return True
raveit65 113dc30
 
raveit65 113dc30
-        elif event.keyval == Gdk.KEY_KP_Down or event.keyval == Gdk.KEY_Down:
raveit65 113dc30
+        elif keyname == "KP_Down" or keyname == "Down":
raveit65 113dc30
             # Next entry from history
raveit65 113dc30
             view.emit_stop_by_name("key_press_event")
raveit65 113dc30
             self.history_down()
raveit65 113dc30
             GObject.idle_add(self.scroll_to_end)
raveit65 113dc30
             return True
raveit65 113dc30
 
raveit65 113dc30
-        elif event.keyval == Gdk.KEY_KP_Up or event.keyval == Gdk.KEY_Up:
raveit65 113dc30
+        elif keyname == "KP_Up" or keyname == "Up":
raveit65 113dc30
             # Previous entry from history
raveit65 113dc30
             view.emit_stop_by_name("key_press_event")
raveit65 113dc30
             self.history_up()
raveit65 113dc30
             GObject.idle_add(self.scroll_to_end)
raveit65 113dc30
             return True
raveit65 113dc30
 
raveit65 113dc30
-        elif event.keyval == Gdk.KEY_KP_Left or event.keyval == Gdk.KEY_Left or \
raveit65 113dc30
-             event.keyval == Gdk.KEY_BackSpace:
raveit65 113dc30
+        elif keyname == "KP_Left" or keyname == "Left" or \
raveit65 113dc30
+             keyname == "BackSpace":
raveit65 113dc30
             buffer = view.get_buffer()
raveit65 113dc30
             inp = buffer.get_iter_at_mark(buffer.get_mark("input"))
raveit65 113dc30
             cur = buffer.get_iter_at_mark(buffer.get_insert())
raveit65 113dc30
@@ -200,7 +223,7 @@ class PythonConsole(Gtk.ScrolledWindow):
raveit65 113dc30
         # For the console we enable smart/home end behavior incoditionally
raveit65 113dc30
         # since it is useful when editing python
raveit65 113dc30
 
raveit65 113dc30
-        elif (event.keyval == Gdk.KEY_KP_Home or event.keyval == Gdk.KEY_Home) and \
raveit65 113dc30
+        elif (keyname == "KP_Home" or keyname == "Home") and \
raveit65 113dc30
              event_state == event_state & (Gdk.ModifierType.SHIFT_MASK|Gdk.ModifierType.CONTROL_MASK):
raveit65 113dc30
             # Go to the begin of the command instead of the begin of the line
raveit65 113dc30
             buffer = view.get_buffer()
raveit65 113dc30
@@ -219,7 +242,7 @@ class PythonConsole(Gtk.ScrolledWindow):
raveit65 113dc30
                 buffer.place_cursor(iter)
raveit65 113dc30
             return True
raveit65 113dc30
 
raveit65 113dc30
-        elif (event.keyval == Gdk.KEY_KP_End or event.keyval == Gdk.KEY_End) and \
raveit65 113dc30
+        elif (keyname == "KP_End" or keyname == "End") and \
raveit65 113dc30
              event_state == event_state & (Gdk.ModifierType.SHIFT_MASK|Gdk.ModifierType.CONTROL_MASK):
raveit65 113dc30
 
raveit65 113dc30
             buffer = view.get_buffer()
raveit65 113dc30
@@ -323,15 +346,18 @@ class PythonConsole(Gtk.ScrolledWindow):
raveit65 113dc30
         # eval and exec are broken in how they deal with utf8-encoded
raveit65 113dc30
         # strings so we have to explicitly decode the command before
raveit65 113dc30
         # passing it along
raveit65 113dc30
-        command = command.decode('utf8')
raveit65 113dc30
+        try:
raveit65 113dc30
+            command = command.decode('utf8')
raveit65 113dc30
+        except:
raveit65 113dc30
+            pass
raveit65 113dc30
 
raveit65 113dc30
         try:
raveit65 113dc30
             try:
raveit65 113dc30
                 r = eval(command, self.namespace, self.namespace)
raveit65 113dc30
                 if r is not None:
raveit65 113dc30
-                    print `r`
raveit65 113dc30
+                    print(repr(r))
raveit65 113dc30
             except SyntaxError:
raveit65 113dc30
-                exec command in self.namespace
raveit65 113dc30
+                exec(command, self.namespace)
raveit65 113dc30
         except:
raveit65 113dc30
             if hasattr(sys, 'last_type') and sys.last_type == SystemExit:
raveit65 113dc30
                 self.destroy()
raveit65 113dc30
@@ -343,7 +369,7 @@ class PythonConsole(Gtk.ScrolledWindow):
raveit65 113dc30
 
raveit65 113dc30
     def destroy(self):
raveit65 113dc30
         pass
raveit65 113dc30
-        #gtk.ScrolledWindow.destroy(self)
raveit65 113dc30
+        #Gtk.ScrolledWindow.destroy(self)
raveit65 113dc30
 
raveit65 113dc30
 class OutFile:
raveit65 113dc30
     """A fake output file object. It sends output to a TK test widget,
raveit65 113dc30
@@ -361,8 +387,8 @@ class OutFile:
raveit65 113dc30
     def readlines(self):     return []
raveit65 113dc30
     def write(self, s):      self.console.write(s, self.tag)
raveit65 113dc30
     def writelines(self, l): self.console.write(l, self.tag)
raveit65 113dc30
-    def seek(self, a):       raise IOError, (29, 'Illegal seek')
raveit65 113dc30
-    def tell(self):          raise IOError, (29, 'Illegal seek')
raveit65 113dc30
+    def seek(self, a):       raise IOError(29, 'Illegal seek')
raveit65 113dc30
+    def tell(self):          raise IOError(29, 'Illegal seek')
raveit65 113dc30
     truncate = tell
raveit65 113dc30
 
raveit65 113dc30
 # ex:et:ts=4:
raveit65 113dc30
-- 
raveit65 113dc30
2.21.0
raveit65 113dc30