--- a/activity.py
+++ b/activity.py
@@ -45,6 +45,7 @@
from pep8_check import PEP8_Check
from font_options import FontToolbarButton
from editor import Editor, LANGUAGE_MANAGER, LANGUAGES
+from python_console import PythonConsole
import file_choosers
file_choosers.langsmanager = LANGUAGE_MANAGER
file_choosers.langs = LANGUAGES
@@ -207,6 +208,17 @@
self._search_next.connect('clicked',
self.editor._search_next_cb)
self.toolbox.toolbar.insert(self._search_next, -1)
+
+ # Barra de estado de PEP8 / PEP8 status bar
+ self.pep8 = PEP8_Check(self)
+
+ self.pep8_bar = gtk.Statusbar()
+ #self.pep8.connect("show-bar", (lambda w, bar: bar.show_all()), self.pep8_bar)
+ #self.pep8.connect("hide-bar", (lambda w, bar: bar.hide()), self.pep8_bar)
+ self.pep8_bar.label = gtk.Label()
+ #self.pep8.connect("bar-text", (lambda w, t, l: l.set_text(t)), self.pep8_bar.label)
+ self.pep8_bar.add(self.pep8_bar.label)
+ vbox.pack_end(self.pep8_bar, False, True, 0)
# Preferencias / preferences
@@ -223,6 +235,24 @@
self.editor._make_languages_combo(preferences_toolbar)
self.editor.make_style_combo(preferences_toolbar)
+
+ separator = gtk.SeparatorToolItem()
+ separator.set_draw(False)
+ separator.set_expand(True)
+ preferences_toolbar.insert(separator, -1)
+ separator.show_all()
+
+ self.python_console = PythonConsole()
+ self.python_console.showed = False
+ vbox.pack_end(self.python_console, False, True, 0)
+
+ self.python_console.hide()
+
+ python_console_btn = ToolButton("python-console")
+ python_console_btn.set_tooltip(_("Show or hide the python console"))
+ python_console_btn.connect("clicked", self.show_python_console)
+ preferences_toolbar.insert(python_console_btn, -1)
+ python_console_btn.show_all()
preferences = ToolbarButton()
preferences.props.page = preferences_toolbar
@@ -254,17 +284,15 @@
self.toolbar_box.show_all()
self.set_toolbar_box(self.toolbar_box)
-
- # Barra de estado de PEP8 / PEP8 status bar
- self.pep8 = PEP8_Check()
- self.pep8_bar = gtk.Statusbar()
- self.pep8.connect("show-bar", (lambda w, bar: bar.show_all()), self.pep8_bar)
- self.pep8.connect("hide-bar", (lambda w, bar: bar.hide()), self.pep8_bar)
- self.pep8_bar.label = gtk.Label()
- self.pep8.connect("bar-text", (lambda w, t, l: l.set_text(t)), self.pep8_bar.label)
- self.pep8_bar.add(self.pep8_bar.label)
- vbox.pack_end(self.pep8_bar, False, True, 0)
+ def show_python_console(self, widget):
+ if not self.python_console.showed:
+ self.python_console.show()
+ self.python_console.showed = True
+
+ else:
+ self.python_console.hide()
+ self.python_console.showed = False
def _search_entry_activate_cb(self, entry):
self.editor.set_search_text(entry.props.text)
--- /dev/null
+++ b/icons/python-console.svg
@@ -1 +1,71 @@
+
+
--- /dev/null
+++ b/python_console.py
@@ -1 +1,68 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+
+# python_console.py by/por:
+# Agustin Zubiaga
+# Daniel Francis
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+
+import gtk
+import vte
+
+from signal import SIGTERM
+
+import os
+import sys
+
+
+class PythonConsole(vte.Terminal):
+
+ def __init__(self):
+ vte.Terminal.__init__(self)
+
+ self.fork_command("python")
+
+ self.set_size_request(800, 150)
+
+ def _clear_console(self):
+ self.grab_focus()
+ self.feed("\x1B[H\x1B[J\x1B[0;39m")
+
+class PythonCodeRun(vte.Terminal):
+
+ def __init__(self):
+ vte.Terminal.__init__(self)
+
+ self.set_size_request(800, 150)
+
+ def _run(self, file):
+ self.process_id = self.fork_command \
+ (command = "/bin/sh",
+ argv = ["/bin/sh", "-c",
+ "python %s; sleep 1" % file])
+ def _stop(self):
+ try:
+ os.kill(self.process_id, SIGTERM)
+ self._clear_console()
+ except:
+ pass
+
+ def _clear_console(self):
+ self.grab_focus()
+ self.feed("\x1B[H\x1B[J\x1B[0;39m")
--- /dev/null
+++ b/view_changes.py
@@ -1 +1,94 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+
+# view_changes.py by/por:
+# Agustin Zubiaga
+# Daniel Francis
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import os
+import shutil
+import gtksourceview2
+
+LANGUAGE_MANAGER = gtksourceview2.language_manager_get_default()
+DIFF_LANG = LANGUAGE_MANAGER.get_language("diff")
+STYLE_MANAGER = gtksourceview2.style_scheme_manager_get_default()
+STYLE_MANAGER.append_search_path(os.path.join(os.environ["PWD"],
+ "styles"))
+JAMEDIT_CHANGES_STYLE = STYLE_MANAGER.get_scheme("jamedit-changes")
+
+TMP = "/tmp/"
+
+
+class View_Changes():
+
+ def __init__(self):
+ self.tmp_file = None
+ self.patch_name = None
+
+ def save_old_file(self, file):
+ tmp_file = os.path.join(TMP, "jamedit-changes-file-1")
+ num = 0
+
+ # If tmp_file exists:
+ while os.path.exists(tmp_file):
+ num += 1
+ tmp_file = os.path.join(TMP, "jamedit-changes-file-"+str(num))
+
+ shutil.copyfile(file, tmp_file)
+
+ self.old_file = tmp_file
+
+ def get_patch_name(self):
+ num = self.old_file.split("-")[-1]
+ patch = os.path.join(TMP, "jamedit-changes-patch-"+num+".patch")
+ self.patch_name = patch
+
+ return patch
+
+ def get_changes(self, new_file):
+ os.system("diff %s %s > %s" % (self.old_file,
+ new_file,
+ self.get_patch_name()))
+
+ os.remove(self.old_file)
+ self.old_file = new_file
+
+ changes = open(self.patch_name, "r")
+ changes_text = changes.read()
+ changes.close()
+
+ os.remove(self.patch_name)
+
+ return changes_text
+
+ def get_changes_with_textview(self, new_file):
+ changes = self.get_changes(new_file)
+
+ textview = gtksourceview2.View()
+ textview.buffer = gtksourceview2.Buffer()
+ textview.set_buffer(textview.buffer)
+ textview.buffer.set_text(changes)
+ textview.set_editable(False)
+ textview.set_cursor_visible(False)
+ textview.buffer.set_highlight_syntax(True)
+ textview.buffer.set_language(DIFF_LANG)
+ textview.buffer.set_style_scheme(JAMEDIT_CHANGES_STYLE)
+ textview.show_all()
+
+ return textview