Web · Wiki · Activities · Blog · Lists · Chat · Meeting · Bugs · Git · Translate · Archive · People · Donate

Commit 678210eff0604cd49fecdbfe2cdea4f1e59589af

  • avatar
  • Agustin Zubiaga <aguzubiaga97 @gm…l.com>
  • Sat Dec 17 15:07:48 EST 2011
Add a python console and a button for hide and show the console. Also added a module view_changes but is inactive

Signed-off-by: Agustin Zubiaga <aguzubiaga97@gmail.com>
activity.py
(38 / 10)
  
4545from pep8_check import PEP8_Check
4646from font_options import FontToolbarButton
4747from editor import Editor, LANGUAGE_MANAGER, LANGUAGES
48from python_console import PythonConsole
4849import file_choosers
4950file_choosers.langsmanager = LANGUAGE_MANAGER
5051file_choosers.langs = LANGUAGES
208208 self._search_next.connect('clicked',
209209 self.editor._search_next_cb)
210210 self.toolbox.toolbar.insert(self._search_next, -1)
211
212 # Barra de estado de PEP8 / PEP8 status bar
213 self.pep8 = PEP8_Check(self)
214
215 self.pep8_bar = gtk.Statusbar()
216 #self.pep8.connect("show-bar", (lambda w, bar: bar.show_all()), self.pep8_bar)
217 #self.pep8.connect("hide-bar", (lambda w, bar: bar.hide()), self.pep8_bar)
218 self.pep8_bar.label = gtk.Label()
219 #self.pep8.connect("bar-text", (lambda w, t, l: l.set_text(t)), self.pep8_bar.label)
220 self.pep8_bar.add(self.pep8_bar.label)
221 vbox.pack_end(self.pep8_bar, False, True, 0)
211222
212223 # Preferencias / preferences
213224
235235
236236 self.editor._make_languages_combo(preferences_toolbar)
237237 self.editor.make_style_combo(preferences_toolbar)
238
239 separator = gtk.SeparatorToolItem()
240 separator.set_draw(False)
241 separator.set_expand(True)
242 preferences_toolbar.insert(separator, -1)
243 separator.show_all()
244
245 self.python_console = PythonConsole()
246 self.python_console.showed = False
247 vbox.pack_end(self.python_console, False, True, 0)
248
249 self.python_console.hide()
250
251 python_console_btn = ToolButton("python-console")
252 python_console_btn.set_tooltip(_("Show or hide the python console"))
253 python_console_btn.connect("clicked", self.show_python_console)
254 preferences_toolbar.insert(python_console_btn, -1)
255 python_console_btn.show_all()
238256
239257 preferences = ToolbarButton()
240258 preferences.props.page = preferences_toolbar
284284 self.toolbar_box.show_all()
285285
286286 self.set_toolbar_box(self.toolbar_box)
287
288 # Barra de estado de PEP8 / PEP8 status bar
289 self.pep8 = PEP8_Check()
290287
291 self.pep8_bar = gtk.Statusbar()
292 self.pep8.connect("show-bar", (lambda w, bar: bar.show_all()), self.pep8_bar)
293 self.pep8.connect("hide-bar", (lambda w, bar: bar.hide()), self.pep8_bar)
294 self.pep8_bar.label = gtk.Label()
295 self.pep8.connect("bar-text", (lambda w, t, l: l.set_text(t)), self.pep8_bar.label)
296 self.pep8_bar.add(self.pep8_bar.label)
297 vbox.pack_end(self.pep8_bar, False, True, 0)
288 def show_python_console(self, widget):
289 if not self.python_console.showed:
290 self.python_console.show()
291 self.python_console.showed = True
292
293 else:
294 self.python_console.hide()
295 self.python_console.showed = False
298296
299297 def _search_entry_activate_cb(self, entry):
300298 self.editor.set_search_text(entry.props.text)
  
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<svg
3 xmlns:dc="http://purl.org/dc/elements/1.1/"
4 xmlns:cc="http://creativecommons.org/ns#"
5 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6 xmlns:svg="http://www.w3.org/2000/svg"
7 xmlns="http://www.w3.org/2000/svg"
8 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10 enable-background="new 0 0 55 55"
11 height="55px"
12 version="1.1"
13 viewBox="0 0 55 55"
14 width="55px"
15 x="0px"
16 xml:space="preserve"
17 y="0px"
18 id="svg2"
19 inkscape:version="0.48.2 r9819"
20 sodipodi:docname="new.svg"><metadata
21 id="metadata23"><rdf:RDF><cc:Work
22 rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
23 rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
24 id="defs21"><inkscape:path-effect
25 effect="spiro"
26 id="path-effect2994"
27 is_visible="true" /><inkscape:path-effect
28 effect="spiro"
29 id="path-effect2994-7"
30 is_visible="true" /><inkscape:path-effect
31 effect="spiro"
32 id="path-effect2994-8"
33 is_visible="true" /></defs><sodipodi:namedview
34 pagecolor="#ffffff"
35 bordercolor="#666666"
36 borderopacity="1"
37 objecttolerance="10"
38 gridtolerance="10"
39 guidetolerance="10"
40 inkscape:pageopacity="0"
41 inkscape:pageshadow="2"
42 inkscape:window-width="1280"
43 inkscape:window-height="746"
44 id="namedview19"
45 showgrid="false"
46 inkscape:zoom="3.7297716"
47 inkscape:cx="5.5537966"
48 inkscape:cy="27.502882"
49 inkscape:window-x="0"
50 inkscape:window-y="26"
51 inkscape:window-maximized="1"
52 inkscape:current-layer="svg2" /><path
53 style="fill:#ffffff;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
54 d="M 5.8984845,16.659851 22.789599,26.311916 6.9709362,35.695869 23.057712,26.311916 5.8984845,16.659851"
55 id="path2992"
56 inkscape:path-effect="#path-effect2994"
57 inkscape:original-d="M 5.8984845,16.659851 22.789599,26.311916 6.9709362,35.695869 23.057712,26.311916 z"
58 inkscape:connector-curvature="0" /><path
59 style="fill:#ffffff;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
60 d="M 20.10847,17.06202 36.999584,26.714085 21.180922,36.098038 37.267697,26.714085 20.10847,17.06202"
61 id="path2992-8"
62 inkscape:path-effect="#path-effect2994-7"
63 inkscape:original-d="m 20.10847,17.06202 16.891114,9.652065 -15.818662,9.383953 16.086775,-9.383953 z"
64 inkscape:connector-curvature="0" /><path
65 style="fill:#ffffff;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
66 d="M 33.514116,16.525794 50.40523,26.177859 34.586568,35.561812 50.673343,26.177859 33.514116,16.525794"
67 id="path2992-84"
68 inkscape:path-effect="#path-effect2994-8"
69 inkscape:original-d="M 33.514116,16.525794 50.40523,26.177859 34.586568,35.561812 50.673343,26.177859 z"
70 inkscape:connector-curvature="0" /></svg>
  
1#!/usr/bin/env python
2# -*- coding: UTF-8 -*-
3
4# python_console.py by/por:
5# Agustin Zubiaga <aguszs97@gmail.com>
6# Daniel Francis <santiago.danielfrancis@gmail.com>
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21# MA 02110-1301, USA.
22
23
24import gtk
25import vte
26
27from signal import SIGTERM
28
29import os
30import sys
31
32
33class PythonConsole(vte.Terminal):
34
35 def __init__(self):
36 vte.Terminal.__init__(self)
37
38 self.fork_command("python")
39
40 self.set_size_request(800, 150)
41
42 def _clear_console(self):
43 self.grab_focus()
44 self.feed("\x1B[H\x1B[J\x1B[0;39m")
45
46class PythonCodeRun(vte.Terminal):
47
48 def __init__(self):
49 vte.Terminal.__init__(self)
50
51 self.set_size_request(800, 150)
52
53 def _run(self, file):
54 self.process_id = self.fork_command \
55 (command = "/bin/sh",
56 argv = ["/bin/sh", "-c",
57 "python %s; sleep 1" % file])
58 def _stop(self):
59 try:
60 os.kill(self.process_id, SIGTERM)
61 self._clear_console()
62 except:
63 pass
64
65 def _clear_console(self):
66 self.grab_focus()
67 self.feed("\x1B[H\x1B[J\x1B[0;39m")
  
1#!/usr/bin/env python
2# -*- coding: UTF-8 -*-
3
4# view_changes.py by/por:
5# Agustin Zubiaga <aguszs97@gmail.com>
6# Daniel Francis <santiago.danielfrancis@gmail.com>
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21# MA 02110-1301, USA.
22
23import os
24import shutil
25import gtksourceview2
26
27LANGUAGE_MANAGER = gtksourceview2.language_manager_get_default()
28DIFF_LANG = LANGUAGE_MANAGER.get_language("diff")
29STYLE_MANAGER = gtksourceview2.style_scheme_manager_get_default()
30STYLE_MANAGER.append_search_path(os.path.join(os.environ["PWD"],
31 "styles"))
32JAMEDIT_CHANGES_STYLE = STYLE_MANAGER.get_scheme("jamedit-changes")
33
34TMP = "/tmp/"
35
36
37class View_Changes():
38
39 def __init__(self):
40 self.tmp_file = None
41 self.patch_name = None
42
43 def save_old_file(self, file):
44 tmp_file = os.path.join(TMP, "jamedit-changes-file-1")
45 num = 0
46
47 # If tmp_file exists:
48 while os.path.exists(tmp_file):
49 num += 1
50 tmp_file = os.path.join(TMP, "jamedit-changes-file-"+str(num))
51
52 shutil.copyfile(file, tmp_file)
53
54 self.old_file = tmp_file
55
56 def get_patch_name(self):
57 num = self.old_file.split("-")[-1]
58 patch = os.path.join(TMP, "jamedit-changes-patch-"+num+".patch")
59 self.patch_name = patch
60
61 return patch
62
63 def get_changes(self, new_file):
64 os.system("diff %s %s > %s" % (self.old_file,
65 new_file,
66 self.get_patch_name()))
67
68 os.remove(self.old_file)
69 self.old_file = new_file
70
71 changes = open(self.patch_name, "r")
72 changes_text = changes.read()
73 changes.close()
74
75 os.remove(self.patch_name)
76
77 return changes_text
78
79 def get_changes_with_textview(self, new_file):
80 changes = self.get_changes(new_file)
81
82 textview = gtksourceview2.View()
83 textview.buffer = gtksourceview2.Buffer()
84 textview.set_buffer(textview.buffer)
85 textview.buffer.set_text(changes)
86 textview.set_editable(False)
87 textview.set_cursor_visible(False)
88 textview.buffer.set_highlight_syntax(True)
89 textview.buffer.set_language(DIFF_LANG)
90 textview.buffer.set_style_scheme(JAMEDIT_CHANGES_STYLE)
91 textview.show_all()
92
93 return textview