Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflavio <fdanesse@gmail.com>2013-05-26 15:37:57 (GMT)
committer flavio <fdanesse@gmail.com>2013-05-26 15:37:57 (GMT)
commit5bf98eb56ab217226b43a7c950d683529ed517ac (patch)
tree7620ba7dd8113eb591553423690737e7856736ee
parent69ec6a605f24a675af5bb382126e525b6daebc05 (diff)
Reemplazar Terminal por JAMediaTerminal.
-rw-r--r--BasePanel.py4
-rw-r--r--Iconos/bash.pngbin0 -> 1689 bytes
-rw-r--r--Iconos/python.pngbin0 -> 2125 bytes
-rw-r--r--InfoNotebook.py12
-rw-r--r--Widgets.py232
-rw-r--r--WorkPanel.py117
6 files changed, 254 insertions, 111 deletions
diff --git a/BasePanel.py b/BasePanel.py
index 1406e85..b4b741b 100644
--- a/BasePanel.py
+++ b/BasePanel.py
@@ -62,8 +62,6 @@ class BasePanel(Gtk.Paned):
infonotebook_box.pack_start(self.infonotebook, True, True, 0)
infonotebook_box.pack_end(busca_treeview, False, False, 0)
- infonotebook_box.set_size_request(250, -1)
-
workpanel_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
workpanel_box.pack_start(toolbararchivo, False, False, 0)
@@ -74,6 +72,8 @@ class BasePanel(Gtk.Paned):
self.show_all()
+ #infonotebook_box.set_size_request(250, -1)
+
self.workpanel.connect('new_select', self.__set_introspeccion)
self.infonotebook.connect('new_select', self.__set_linea)
diff --git a/Iconos/bash.png b/Iconos/bash.png
new file mode 100644
index 0000000..4d0d271
--- /dev/null
+++ b/Iconos/bash.png
Binary files differ
diff --git a/Iconos/python.png b/Iconos/python.png
new file mode 100644
index 0000000..4ab5511
--- /dev/null
+++ b/Iconos/python.png
Binary files differ
diff --git a/InfoNotebook.py b/InfoNotebook.py
index 647f25e..e4d02bc 100644
--- a/InfoNotebook.py
+++ b/InfoNotebook.py
@@ -54,8 +54,7 @@ class InfoNotebook(Gtk.Notebook):
scroll.add_with_viewport(self.introspeccion)
- self.page_label = Gtk.Label("Nombre de Archivo")
- self.append_page(scroll, self.page_label)
+ self.append_page(scroll, Gtk.Label("Introspección"))
scroll = Gtk.ScrolledWindow()
@@ -235,6 +234,7 @@ class Introspeccion(Gtk.TreeView):
if tecla == 65293:
if self.row_expanded(path):
self.collapse_row(path)
+
else:
self.expand_to_path(path)
@@ -248,11 +248,13 @@ class Introspeccion(Gtk.TreeView):
elif tecla == 65364:
siguiente = self.get_model().iter_next(iter)
+
if siguiente:
self.get_selection().select_iter(siguiente)
elif tecla == 65362:
anterior = self.get_model().iter_previous(iter)
+
if anterior:
self.get_selection().select_iter(anterior)
@@ -261,9 +263,6 @@ class Introspeccion(Gtk.TreeView):
return False
-
-
-
class Estructura_Proyecto(Gtk.TreeView):
"""
TreeView para la estructura del proyecto.
@@ -435,6 +434,7 @@ class Estructura_Proyecto(Gtk.TreeView):
if tecla == 65293:
if self.row_expanded(path):
self.collapse_row(path)
+
else:
self.expand_to_path(path)
@@ -448,11 +448,13 @@ class Estructura_Proyecto(Gtk.TreeView):
elif tecla == 65364:
siguiente = self.get_model().iter_next(iter)
+
if siguiente:
self.get_selection().select_iter(siguiente)
elif tecla == 65362:
anterior = self.get_model().iter_previous(iter)
+
if anterior:
self.get_selection().select_iter(anterior)
diff --git a/Widgets.py b/Widgets.py
index 190717a..8047ff7 100644
--- a/Widgets.py
+++ b/Widgets.py
@@ -24,8 +24,13 @@ import os
import gi
from gi.repository import Gtk
+from gi.repository import Gdk
from gi.repository import GObject
from gi.repository import GdkPixbuf
+from gi.repository import Vte
+from gi.repository import Pango
+
+BASEPATH = os.path.dirname(__file__)
def get_boton(stock, tooltip):
"""Devuelve un botón generico."""
@@ -779,10 +784,10 @@ class ToolbarProyecto(Gtk.Toolbar):
self.insert(self.abrir_proyecto, -1)
self.insert(self.editar_proyecto, -1)
self.insert(self.guardar_proyecto, -1)
+ self.insert(self.cerrar_proyecto, -1)
self.insert(get_separador(draw = True, ancho = 0, expand = False), -1)
self.insert(self.ejecutar_proyecto, -1)
self.insert(self.detener, -1)
- self.insert(self.cerrar_proyecto, -1)
self.show_all()
@@ -887,4 +892,227 @@ class BuscadorTreeViews(Gtk.Box):
self.treeview_intro.get_selection().select_iter(self.posibles[self.actual])
except:
self.actual = len(self.posibles) - 11
- \ No newline at end of file
+
+class JAMediaTerminal(Gtk.Box):
+ """
+ Terminal Vte + Toolbar. (JAMediaTerminal)
+ """
+
+ def __init__(self, path = os.environ["HOME"],
+ interprete = "/bin/bash"):
+
+ self.path = path
+ self.interprete = interprete
+
+ self.bash_path = None
+ self.python_path = None
+
+ paths = os.environ["PATH"].split(':')
+
+ for path in paths:
+ if 'bash' in os.listdir(path):
+ self.bash_path = os.path.join(path, 'bash')
+
+ if 'python' in os.listdir(path):
+ self.python_path = os.path.join(path, 'python')
+
+ if self.bash_path and self.python_path: break
+
+ for path in paths:
+ if 'ipython' in os.listdir(path):
+ self.python_path = os.path.join(path, 'ipython')
+ break
+
+ Gtk.Box.__init__(self,
+ orientation = Gtk.Orientation.VERTICAL)
+
+ self.terminal = Terminal(
+ path = self.path,
+ interprete = self.interprete)
+
+ self.toolbar = ToolbarTerminal()
+
+ self.pack_start(self.terminal, True, True, 0)
+ self.pack_start(self.toolbar, False, False, 0)
+
+ self.show_all()
+
+ self.toolbar.connect('accion', self.__accion_terminal)
+ self.toolbar.connect('reset', self.__reset_terminal)
+
+ def __reset_terminal(self, widget, valor):
+ """
+ Resetea la terminal para interprete segun valor.
+ """
+
+ if 'bash' in valor:
+ self.terminal.set_interprete(
+ path = os.environ["HOME"],
+ interprete = self.bash_path)
+
+ elif 'python' in valor:
+ self.terminal.set_interprete(
+ path = os.environ["HOME"],
+ interprete = self.python_path)
+
+ self.terminal.child_focus(True)
+
+ def __accion_terminal(self, widget, accion):
+ """
+ Soporte para clipboard.
+ """
+
+ if accion == 'copiar':
+ if self.terminal.get_has_selection():
+ self.terminal.copy_clipboard()
+
+ elif accion == 'pegar':
+ self.terminal.paste_clipboard()
+
+ self.terminal.child_focus(True)
+
+ def set_interprete(self, path = os.environ["HOME"],
+ interprete = "/bin/bash"):
+ """
+ Seteo externo de la terminal a un determinado interprete.
+ """
+
+ self.terminal.set_interprete(
+ path = path, interprete = interprete)
+
+class Terminal(Vte.Terminal):
+ """
+ Terminal Configurable en distintos intérpretes. (JAMediaTerminal)
+ """
+
+ def __init__(self,
+ path = os.environ["HOME"],
+ interprete = "/bin/bash"):
+
+ Vte.Terminal.__init__(self)
+
+ self.set_encoding('utf-8')
+ font = 'Monospace ' + str(10)
+ self.set_font(Pango.FontDescription(font))
+ self.set_colors(
+ Gdk.color_parse('#ffffff'),
+ Gdk.color_parse('#000000'),[])
+
+ self.path = path
+ self.interprete = interprete
+
+ self.__reset()
+
+ self.show_all()
+
+ def do_child_exited(self):
+ """
+ Cuando se hace exit en la terminal,
+ esta se resetea.
+ """
+
+ self.__reset()
+
+ def set_interprete(self, path = os.environ["HOME"],
+ interprete = "/bin/bash"):
+ """
+ Setea la terminal a un determinado interprete.
+ """
+
+ self.path = path
+ self.interprete = interprete
+
+ self.__reset()
+
+ def __reset(self, widget = None):
+ """
+ Reseteo de la Terminal.
+ """
+
+ pty_flags = Vte.PtyFlags(0)
+
+ self.fork_command_full(
+ pty_flags,
+ self.path,
+ (self.interprete,),
+ "", 0, None, None)
+
+class ToolbarTerminal(Gtk.Toolbar):
+ """
+ Toolbar de Terminal. (JAMediaTerminal)
+ """
+
+ __gtype_name__ = 'ToolbarTerminal'
+
+ __gsignals__ = {
+ "accion":(GObject.SIGNAL_RUN_FIRST,
+ GObject.TYPE_NONE, (GObject.TYPE_STRING,)),
+ "reset":(GObject.SIGNAL_RUN_FIRST,
+ GObject.TYPE_NONE, (GObject.TYPE_STRING,))}
+
+ def __init__(self):
+
+ Gtk.Toolbar.__init__(self,
+ orientation = Gtk.Orientation.HORIZONTAL)
+
+ boton = get_boton(Gtk.STOCK_COPY, "Copiar")
+ boton.connect("clicked", self.__emit_copiar)
+ self.insert(boton, -1)
+
+ boton = get_boton(Gtk.STOCK_PASTE, "Pegar")
+ boton.connect("clicked", self.__emit_pegar)
+ self.insert(boton, -1)
+
+ self.insert(get_separador(draw = False,
+ ancho = 0, expand = True), -1)
+
+ archivo = os.path.join(
+ BASEPATH,
+ "Iconos", "bash.png")
+
+ boton = Gtk.ToolButton()
+ imagen = Gtk.Image()
+ pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(archivo, 32, 32)
+ imagen.set_from_pixbuf(pixbuf)
+ boton.set_icon_widget(imagen)
+ imagen.show()
+ boton.show()
+
+ boton.set_tooltip_text("Bash")
+ boton.connect("clicked", self.__emit_reset_bash)
+ self.insert(boton, -1)
+
+ archivo = os.path.join(
+ BASEPATH,
+ "Iconos", "python.png")
+
+ boton = Gtk.ToolButton()
+ imagen = Gtk.Image()
+ pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(archivo, 32, 32)
+ imagen.set_from_pixbuf(pixbuf)
+ boton.set_icon_widget(imagen)
+ imagen.show()
+ boton.show()
+
+ boton.set_tooltip_text("python")
+ boton.connect("clicked", self.__emit_reset_python)
+ self.insert(boton, -1)
+
+ self.show_all()
+
+ def __emit_reset_python(self, widget):
+
+ self.emit('reset', 'python')
+
+ def __emit_reset_bash(self, widget):
+
+ self.emit('reset', 'bash')
+
+ def __emit_copiar(self, widget):
+
+ self.emit('accion', 'copiar')
+
+ def __emit_pegar(self, widget):
+
+ self.emit('accion', 'pegar')
+ \ No newline at end of file
diff --git a/WorkPanel.py b/WorkPanel.py
index 7be2683..ef6af13 100644
--- a/WorkPanel.py
+++ b/WorkPanel.py
@@ -27,10 +27,10 @@ import gi
from gi.repository import Gtk
from gi.repository import GObject
from gi.repository import GtkSource
-from gi.repository import Vte
-from gi.repository import GLib
from gi.repository import Pango
+from Widgets import JAMediaTerminal
+
PATH = os.path.dirname(__file__)
class WorkPanel(Gtk.Paned):
@@ -51,12 +51,11 @@ class WorkPanel(Gtk.Paned):
orientation=Gtk.Orientation.VERTICAL)
self.notebook_sourceview = Notebook_SourceView()
+ self.debug_notebook = DebugNotebook()
+
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
-
- box.set_size_request(-1, 125)
-
- box.pack_start(DebugNotebook(), True, True, 0)
-
+ box.pack_start(self.debug_notebook, False, False, 0)
+
self.pack1(self.notebook_sourceview, resize = False, shrink = False)
self.pack2(box, resize = False, shrink = False)
@@ -115,7 +114,6 @@ class Notebook_SourceView(Gtk.Notebook):
"""
scrolled = self.get_children()[self.get_current_page()]
- #viewport = scrolled.get_children()[0]
view = scrolled.get_children()[0]
buffer = view.get_buffer()
@@ -132,8 +130,7 @@ class Notebook_SourceView(Gtk.Notebook):
buffer.select_range(match_start, match_end)
view.scroll_to_iter(match_end, 0.1, 1, 1, 1)
-
-
+
def __switch_page(self, widget, widget_child, indice):
"""
Cuando el usuario selecciona una lengüeta en
@@ -437,99 +434,15 @@ class AutoCompletado(GObject.Object, GtkSource.CompletionProvider):
else:
context.add_proposals(self, [], True)
-class Terminal(Vte.Terminal):
-
- def __init__(self):
-
- Vte.Terminal.__init__(self)
-
- self.emulacion = '/bin/bash'
-
- self.setear(self.emulacion)
- self.connect('child-exited', self.__reabrir)
-
- def __abriendo(self, widget):
- """
- Cuando recién abre la terminal.
- """
-
- print '\n'
-
- def setear(self, emulacion):
- """
- Setea todo y reinicia.
- """
-
- self.emulacion = emulacion
- self.fork_command_full(Vte.PtyFlags(0),
- os.environ["HOME"],
- (self.emulacion,),
- [],
- GLib.SpawnFlags(0),
- self.__abriendo,
- 'algo')
-
- def __reabrir(self, widget):
- """
- Reinicia la Terminal para que se pueda seguir usando.
- """
-
- self.setear(self.emulacion)
-
class DebugNotebook(Gtk.Notebook):
-
+ """
+ Notebook para terminales y debugs.
+ """
+
def __init__(self):
Gtk.Notebook.__init__(self)
-
- scrolled = Gtk.ScrolledWindow()
- self.terminal = Terminal()
- vbox = Gtk.VBox()
- hbox = Gtk.HBox()
-
- scrolled.add(self.terminal)
- vbox.add(scrolled)
- vbox.pack_start(hbox, False, False, 5)
-
- boton_copiar = Gtk.Button(None, Gtk.STOCK_COPY)
- boton_pegar = Gtk.Button(None, Gtk.STOCK_PASTE)
-
- boton_bash = Gtk.Button('_Bash')
- boton_ipython = Gtk.Button('_Ipython')
-
- boton_bash.set_tooltip_text('Usar bash como línea de ordenes')
- boton_ipython.set_tooltip_text('Usar ipython como línea de ordenes')
-
- boton_bash.set_use_underline(True)
- boton_ipython.set_use_underline(True)
-
- hbox.pack_start(boton_copiar, False, False, 5)
- hbox.pack_start(boton_pegar, False, False, 5)
-
- hbox.pack_end(boton_bash, False, False, 0)
- hbox.pack_end(boton_ipython, False, False, 0)
-
- boton_copiar.connect('clicked', self.__actuar_sobre_terminal, 'copiar')
- boton_pegar.connect('clicked', self.__actuar_sobre_terminal, 'pegar')
- boton_bash.connect('clicked', self.__setear_terminal, '/bin/bash')
- boton_ipython.connect('clicked', self.__setear_terminal, '/usr/bin/ipython')
-
- self.append_page(vbox, Gtk.Label('Terminal'))
-
- def __actuar_sobre_terminal(self, widget, accion):
- """
- Genera una acción sobre la terminal.
- """
-
- if accion == 'copiar' and self.terminal.get_has_selection():
- self.terminal.copy_clipboard()
-
- elif accion == 'pegar':
- self.terminal.paste_clipboard()
-
- def __setear_terminal(self, widget, emulacion):
- """
- Setea la terminal.
- """
-
- self.terminal.setear(emulacion)
+
+ self.terminal = JAMediaTerminal()
+
+ self.append_page(self.terminal, Gtk.Label('Terminal'))