Example #1
0
    def __init__(self):

        Gtk.EventBox.__init__(self)

        vbox = Gtk.VBox()

        self.notebook = NoteBookTerminal()
        self.toolbar = ToolbarTerminal()

        vbox.pack_start(self.notebook, True, True, 0)
        vbox.pack_start(self.toolbar, False, False, 0)

        self.add(vbox)
        self.show_all()

        self.toolbar.connect('accion', self.__accion_terminal)
        self.toolbar.connect('reset', self.__reset_terminal)
        self.toolbar.connect('formato', self.__set_formato)

        self.notebook.agregar_terminal()
        self.notebook.connect("reset", self.__re_emit_reset)
Example #2
0
    def __init__(self):

        Gtk.EventBox.__init__(self)

        vbox = Gtk.VBox()

        self.notebook = NoteBookTerminal()
        self.toolbar = ToolbarTerminal()

        vbox.pack_start(self.notebook, True, True, 0)
        vbox.pack_start(self.toolbar, False, False, 0)

        self.add(vbox)
        self.show_all()

        self.toolbar.connect('accion', self.__accion_terminal)
        self.toolbar.connect('reset', self.__reset_terminal)
        self.toolbar.connect('formato', self.__set_formato)

        self.notebook.agregar_terminal()
        self.notebook.connect("reset", self.__re_emit_reset)
Example #3
0
class Terminal(Gtk.EventBox):
    """
    Terminal (NoteBook + Vtes) + Toolbar.
    """

    #__gtype_name__ = 'JAMediaTerminal'

    __gsignals__ = {
        "ejecucion": (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE,
                      (GObject.TYPE_PYOBJECT, )),
        "reset":
        (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE,
         (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT, GObject.TYPE_INT))
    }

    def __init__(self):

        Gtk.EventBox.__init__(self)

        vbox = Gtk.VBox()

        self.notebook = NoteBookTerminal()
        self.toolbar = ToolbarTerminal()

        vbox.pack_start(self.notebook, True, True, 0)
        vbox.pack_start(self.toolbar, False, False, 0)

        self.add(vbox)
        self.show_all()

        self.toolbar.connect('accion', self.__accion_terminal)
        self.toolbar.connect('reset', self.__reset_terminal)
        self.toolbar.connect('formato', self.__set_formato)

        self.notebook.agregar_terminal()
        self.notebook.connect("reset", self.__re_emit_reset)

    def __set_formato(self, widget):
        """
        Abre el Diálogo de Formato y Setea el tipo y tamaño de
        fuentes en las terminales según selección del usuario.
        """

        string = self.notebook.fuente.to_string()
        tamanio = int(string.split(" ")[-1])
        fuente = string.replace("%s" % tamanio, "").strip()

        self.get_toplevel().set_sensitive(False)

        dialogo = DialogoFormato(parent_window=self.get_toplevel(),
                                 fuente=fuente,
                                 tamanio=tamanio)

        respuesta = dialogo.run()

        font = ""
        if respuesta == Gtk.ResponseType.ACCEPT:
            font = "%s %s" % dialogo.get_font()

        dialogo.destroy()

        self.get_toplevel().set_sensitive(True)

        if font:
            self.notebook.set_font(font)

    def __re_emit_reset(self, notebook, terminal, pag_indice):
        """
        Cuando se resetea una terminal, se emite la señal reset con:
            1- Notebook contenedor de terminales.
            2- Terminal reseteada.
            3- Indice de la página que le corresponde en el notebook.
            4- Botón cerrar de la lengueta específica.
            5- Etiqueta de la lengüeta específica.
        """

        self.emit("reset", notebook, terminal, pag_indice)

    def __reset_terminal(self, widget, interprete):
        """
        Resetea la terminal en interprete según valor.
        """

        self.notebook.reset_terminal(interprete=interprete)

    def __accion_terminal(self, widget, accion):
        """
        Soporte para clipboard.
        """

        self.notebook.accion_terminal(accion)

    def ejecutar(self, archivo):
        """
        Ejecuta un archivo en una nueva terminal.
        """

        if os.path.exists(archivo):

            path = os.path.basename(archivo)

            terminal = self.notebook.agregar_terminal(path=path,
                                                      interprete='/bin/bash',
                                                      ejecutar=archivo)

            self.emit("ejecucion", terminal)

    def ejecute_script(self, dirpath, interprete, path_script, param):
        """
        Ejecuta un script con parámetros, en la terminal activa

        Por ejemplo:
            python setup.py sdist

            dirpath     =   directorio base donde se encuentra setup.py
            interprete  =   python en este caso
            path_script =   dirpath + 'setup.py'
            param       =   'sdist' en est caso
        """

        terminal = self.notebook.get_children()[
            self.notebook.get_current_page()].get_child()

        pty_flags = Vte.PtyFlags(0)

        terminal.fork_command_full(pty_flags, dirpath,
                                   (interprete, path_script, param), "", 0,
                                   None, None)
Example #4
0
class Terminal(Gtk.EventBox):
    """
    Terminal (NoteBook + Vtes) + Toolbar.
    """

    #__gtype_name__ = 'JAMediaTerminal'

    __gsignals__ = {
    "ejecucion": (GObject.SIGNAL_RUN_FIRST,
        GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT,)),
    "reset": (GObject.SIGNAL_RUN_FIRST,
        GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT,
        GObject.TYPE_PYOBJECT, GObject.TYPE_INT))}

    def __init__(self):

        Gtk.EventBox.__init__(self)

        vbox = Gtk.VBox()

        self.notebook = NoteBookTerminal()
        self.toolbar = ToolbarTerminal()

        vbox.pack_start(self.notebook, True, True, 0)
        vbox.pack_start(self.toolbar, False, False, 0)

        self.add(vbox)
        self.show_all()

        self.toolbar.connect('accion', self.__accion_terminal)
        self.toolbar.connect('reset', self.__reset_terminal)
        self.toolbar.connect('formato', self.__set_formato)

        self.notebook.agregar_terminal()
        self.notebook.connect("reset", self.__re_emit_reset)

    def __set_formato(self, widget):
        """
        Abre el Diálogo de Formato y Setea el tipo y tamaño de
        fuentes en las terminales según selección del usuario.
        """

        string = self.notebook.fuente.to_string()
        tamanio = int(string.split(" ")[-1])
        fuente = string.replace("%s" % tamanio, "").strip()

        self.get_toplevel().set_sensitive(False)

        dialogo = DialogoFormato(
            parent_window=self.get_toplevel(),
            fuente=fuente,
            tamanio=tamanio)

        respuesta = dialogo.run()

        font = ""
        if respuesta == Gtk.ResponseType.ACCEPT:
            font = "%s %s" % dialogo.get_font()

        dialogo.destroy()

        self.get_toplevel().set_sensitive(True)

        if font:
            self.notebook.set_font(font)

    def __re_emit_reset(self, notebook, terminal, pag_indice):
        """
        Cuando se resetea una terminal, se emite la señal reset con:
            1- Notebook contenedor de terminales.
            2- Terminal reseteada.
            3- Indice de la página que le corresponde en el notebook.
            4- Botón cerrar de la lengueta específica.
            5- Etiqueta de la lengüeta específica.
        """

        self.emit("reset", notebook, terminal, pag_indice)

    def __reset_terminal(self, widget, interprete):
        """
        Resetea la terminal en interprete según valor.
        """

        self.notebook.reset_terminal(interprete=interprete)

    def __accion_terminal(self, widget, accion):
        """
        Soporte para clipboard.
        """

        self.notebook.accion_terminal(accion)

    def ejecutar(self, archivo):
        """
        Ejecuta un archivo en una nueva terminal.
        """

        if os.path.exists(archivo):

            path = os.path.basename(archivo)

            terminal = self.notebook.agregar_terminal(
                path=path,
                interprete='/bin/bash',
                ejecutar=archivo)

            self.emit("ejecucion", terminal)

    def ejecute_script(self, dirpath, interprete, path_script, param):
        """
        Ejecuta un script con parámetros, en la terminal activa

        Por ejemplo:
            python setup.py sdist

            dirpath     =   directorio base donde se encuentra setup.py
            interprete  =   python en este caso
            path_script =   dirpath + 'setup.py'
            param       =   'sdist' en est caso
        """

        terminal = self.notebook.get_children()[
            self.notebook.get_current_page()].get_child()

        pty_flags = Vte.PtyFlags(0)

        terminal.fork_command_full(
            pty_flags,
            dirpath,
            (interprete, path_script, param),
            "", 0, None, None)