Esempio n. 1
0
class IntrospectionWidget(Gtk.Box):

    __gtype_name__ = 'PygiHackIntrospectionWidget'

    __gsignals__ = {
    "abrir": (GObject.SIGNAL_RUN_LAST,
        GObject.TYPE_NONE, (GObject.TYPE_STRING,))}

    def __init__(self, paquete, modulo):

        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.introspection_panel = IntrospectionPanel(paquete, modulo)
        self.toolbartray = ToolbarTry()

        self.pack_start(self.introspection_panel, True, True, 0)
        self.pack_end(self.toolbartray, False, False, 0)

        self.show_all()
        self.introspection_panel.connect('info-try', self.__set_info_tray)
        self.introspection_panel.connect('abrir', self.__open_file)

    def __open_file(self, widget, modulo_path):
        self.emit("abrir", modulo_path)

    def __set_info_tray(self, widget, info):
        self.toolbartray.set_info(info)

    def zoom(self, zoom):
        self.introspection_panel.zoom(zoom)

    def buscar_mas(self, accion, texto):
        self.introspection_panel.buscar_mas(accion, texto)
Esempio n. 2
0
class IntrospectionWidget(Gtk.Box):

    __gtype_name__ = 'PygiHackIntrospectionWidget'

    __gsignals__ = {
        "abrir":
        (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (GObject.TYPE_STRING, ))
    }

    def __init__(self, paquete, modulo):

        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.introspection_panel = IntrospectionPanel(paquete, modulo)
        self.toolbartray = ToolbarTry()

        self.pack_start(self.introspection_panel, True, True, 0)
        self.pack_end(self.toolbartray, False, False, 0)

        self.show_all()
        self.introspection_panel.connect('info-try', self.__set_info_tray)
        self.introspection_panel.connect('abrir', self.__open_file)

    def __open_file(self, widget, modulo_path):
        self.emit("abrir", modulo_path)

    def __set_info_tray(self, widget, info):
        self.toolbartray.set_info(info)

    def zoom(self, zoom):
        self.introspection_panel.zoom(zoom)

    def buscar_mas(self, accion, texto):
        self.introspection_panel.buscar_mas(accion, texto)
    def __init__(self, paquete, modulo):

        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.introspection_panel = IntrospectionPanel(paquete, modulo)
        self.toolbartray = ToolbarTry()

        self.pack_start(self.introspection_panel, True, True, 0)
        self.pack_end(self.toolbartray, False, False, 0)

        self.show_all()
        self.introspection_panel.connect('info-try', self.__set_info_tray)
Esempio n. 4
0
    def __init__(self, path):

        Gtk.EventBox.__init__(self)

        self.path = path  # Directorio

        base_box = Gtk.VBox()

        self.toolbar = ToolbarPreviews(path)
        self.iconview = IconView(path)
        self.toolbartry = ToolbarTry()

        base_box.pack_start(self.toolbar, False, False, 0)

        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(
            Gtk.PolicyType.NEVER,
            Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(self.iconview)

        base_box.pack_start(scroll, True, True, 0)
        base_box.pack_end(self.toolbartry, False, False, 0)

        self.add(base_box)

        self.show_all()

        self.iconview.connect('switch_to', self.__emit_switch)

        self.toolbar.connect('camara', self.__emit_camara)
        self.toolbar.connect('switch_to', self.__emit_switch)
        self.toolbar.connect('salir', self.__salir)
        self.toolbar.connect('open', self.__emit_switch)

        ### Activar botón atras solo si no se está en home del usuario.
        if os.path.dirname(self.path) == os.path.dirname(os.environ["HOME"]):
            self.toolbar.hide_button_back()

        self.connect("motion-notify-event",
            self.__do_motion_notify_event)
        self.iconview.connect('motion',
            self.__do_motion_notify_event)
        self.iconview.connect("button-press-event",
            self.__click_derecho_en_lista)
class IntrospectionWidget(Gtk.Box):

    __gtype_name__ = 'PygiHackIntrospectionWidget'

    def __init__(self, paquete, modulo):

        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.introspection_panel = IntrospectionPanel(paquete, modulo)
        self.toolbartray = ToolbarTry()

        self.pack_start(self.introspection_panel, True, True, 0)
        self.pack_end(self.toolbartray, False, False, 0)

        self.show_all()
        self.introspection_panel.connect('info-try', self.__set_info_tray)

    def __set_info_tray(self, widget, info):
        self.toolbartray.set_info(info)
Esempio n. 6
0
class IntrospectionWidget(Gtk.Box):

    __gtype_name__ = 'PygiHackIntrospectionWidget'

    def __init__(self, paquete, modulo):

        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.introspection_panel = IntrospectionPanel(paquete, modulo)
        self.toolbartray = ToolbarTry()

        self.pack_start(self.introspection_panel, True, True, 0)
        self.pack_end(self.toolbartray, False, False, 0)

        self.show_all()
        self.introspection_panel.connect('info-try', self.__set_info_tray)

    def __set_info_tray(self, widget, info):
        self.toolbartray.set_info(info)
Esempio n. 7
0
    def __init__(self, paquete, modulo):

        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.introspection_panel = IntrospectionPanel(paquete, modulo)
        self.toolbartray = ToolbarTry()

        self.pack_start(self.introspection_panel, True, True, 0)
        self.pack_end(self.toolbartray, False, False, 0)

        self.show_all()
        self.introspection_panel.connect('info-try', self.__set_info_tray)
Esempio n. 8
0
class Previews (Gtk.EventBox):
    """
    Vista Preview de directorios con imágenes y albumes.
    """

    __gtype_name__ = 'JAMediaImagenesPreviews'

    __gsignals__ = {
    'salir': (GObject.SIGNAL_RUN_FIRST,
        GObject.TYPE_NONE, []),
    'switch_to': (GObject.SIGNAL_RUN_FIRST,
        GObject.TYPE_NONE, (GObject.TYPE_STRING,)),
    'camara': (GObject.SIGNAL_RUN_LAST,
        GObject.TYPE_NONE, [])}

    def __init__(self, path):

        Gtk.EventBox.__init__(self)

        self.path = path  # Directorio

        base_box = Gtk.VBox()

        self.toolbar = ToolbarPreviews(path)
        self.iconview = IconView(path)
        self.toolbartry = ToolbarTry()

        base_box.pack_start(self.toolbar, False, False, 0)

        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(
            Gtk.PolicyType.NEVER,
            Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(self.iconview)

        base_box.pack_start(scroll, True, True, 0)
        base_box.pack_end(self.toolbartry, False, False, 0)

        self.add(base_box)

        self.show_all()

        self.iconview.connect('switch_to', self.__emit_switch)

        self.toolbar.connect('camara', self.__emit_camara)
        self.toolbar.connect('switch_to', self.__emit_switch)
        self.toolbar.connect('salir', self.__salir)
        self.toolbar.connect('open', self.__emit_switch)

        ### Activar botón atras solo si no se está en home del usuario.
        if os.path.dirname(self.path) == os.path.dirname(os.environ["HOME"]):
            self.toolbar.hide_button_back()

        self.connect("motion-notify-event",
            self.__do_motion_notify_event)
        self.iconview.connect('motion',
            self.__do_motion_notify_event)
        self.iconview.connect("button-press-event",
            self.__click_derecho_en_lista)

    def __click_derecho_en_lista(self, widget, event):
        """
        Esto es para abrir un menu de opciones cuando
        el usuario hace click derecho sobre un elemento en
        la lista de imágenes, permitiendo copiar, mover y
        borrar el archivo o simplemente quitarlo
        de la lista.
        """

        boton = event.button
        pos = (event.x, event.y)
        tiempo = event.time

        if boton == 1:
            return

        elif boton == 3:

            path = widget.get_path_at_pos(
                int(pos[0]), int(pos[1]))
            #iter = widget.get_model().get_iter(path)

            from Widgets import MenuList

            menu = MenuList(
                widget, boton, pos,
                tiempo, path, widget.get_model(),
                self.path)

            menu.connect('accion', self.__set_menu_accion)
            menu.popup(None, None, None, None, boton, tiempo)

        elif boton == 2:
            return

    def __set_menu_accion(self, widget, widget_item, accion, iter, file_path):

        if accion == "Quitar":
            widget_item.get_model().remove(iter)

        elif accion == "Borrar":
            from JAMediaObjects.JAMFileSystem import borrar
            widget_item.get_model().remove(iter)

            borrar(file_path)

        elif accion == "Copiar":
            from Globales import get_imagenes_directory
            from JAMediaObjects.JAMFileSystem import copiar

            copiar(file_path, get_imagenes_directory())

        elif accion == "Mover":
            from Globales import get_imagenes_directory
            from JAMediaObjects.JAMFileSystem import mover
            widget_item.get_model().remove(iter)

            mover(file_path, get_imagenes_directory())

    def __do_motion_notify_event(self, widget, event):
        """
        Cuando se mueve el mouse sobre la ventana se
        muestran u ocultan las toolbars.
        """

        rect = self.toolbar.get_allocation()
        arriba = range(0, rect.height)

        root_rect = self.get_toplevel().get_allocation()
        rect = self.toolbartry.get_allocation()
        abajo = range(root_rect.height - rect.height, root_rect.height)
        x, y = self.get_toplevel().get_pointer()

        if y in arriba or y in abajo:
            self.toolbar.show()
            self.toolbartry.show()
            return

        else:
            self.toolbar.hide()
            self.toolbartry.hide()
            return

    def __emit_camara(self, widget):

        self.emit("camara")

    def __emit_switch(self, widget, path):

        self.emit("switch_to", path)

    def __salir(self, widget):

        self.emit("salir")

    def run(self):

        self.iconview.load_previews(self.path)
        self.toolbartry.set_info("Directorio: %s" % self.path)
Esempio n. 9
0
    def __init__(self, path):

        Gtk.EventBox.__init__(self)

        self.path = path  # Directorio

        base_box = Gtk.VBox()

        self.intervalo = False
        self.actualizador = False

        self.toolbar = ToolbarImagen(path)
        self.visor = Visor()
        self.toolbar_config = ToolbarConfig()
        self.toolbartry = ToolbarTry()

        ### En panel
        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(
            Gtk.PolicyType.AUTOMATIC,
            Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(self.visor)

        panel = Gtk.Paned(orientation=Gtk.Orientation.HORIZONTAL)
        panel.pack1(scroll, resize=True, shrink=False)

        self.listaiconview = ListaIconView(None)

        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(
            Gtk.PolicyType.NEVER,
            Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(self.listaiconview)

        panel.pack2(scroll, resize=False, shrink=False)
        ###

        base_box.pack_start(self.toolbar, False, False, 0)
        base_box.pack_start(self.toolbar_config, False, False, 0)
        base_box.pack_start(panel, True, True, 0)
        base_box.pack_end(self.toolbartry, False, False, 0)

        self.add(base_box)

        self.connect("realize", self.__rescale)
        self.show_all()

        self.toolbar.connect('switch_to', self.__emit_switch)
        self.toolbar.connect('activar', self.__set_accion)
        self.toolbar.connect('salir', self.__salir)
        self.toolbar_config.connect('run', self.__set_presentacion)
        self.visor.connect('changed', self.__set_change_image)
        self.visor.connect('info', self.__set_info)

        self.toolbar_config.hide()
        self.toolbar.set_modo("nochanged")
        self.toolbar.set_modo("edit")

        self.connect("motion-notify-event",
            self.__do_motion_notify_event)

        self.visor.add_events(
            Gdk.EventMask.BUTTON_PRESS_MASK |
            Gdk.EventMask.BUTTON_RELEASE_MASK
        )

        self.visor.connect("button_press_event", self.__clicks_en_pantalla)
        self.listaiconview.connect("selected", self.__show_imagen)
        self.listaiconview.connect("button-press-event",
            self.__click_derecho_en_lista)
Esempio n. 10
0
class VisorImagenes (Gtk.EventBox):

    __gtype_name__ = 'JAMediaImagenesVisorImagenes'

    __gsignals__ = {
    'salir': (GObject.SIGNAL_RUN_LAST,
        GObject.TYPE_NONE, []),
    'switch_to': (GObject.SIGNAL_RUN_LAST,
        GObject.TYPE_NONE, (GObject.TYPE_STRING,))}

    def __init__(self, path):

        Gtk.EventBox.__init__(self)

        self.path = path  # Directorio

        base_box = Gtk.VBox()

        self.intervalo = False
        self.actualizador = False

        self.toolbar = ToolbarImagen(path)
        self.visor = Visor()
        self.toolbar_config = ToolbarConfig()
        self.toolbartry = ToolbarTry()

        ### En panel
        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(
            Gtk.PolicyType.AUTOMATIC,
            Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(self.visor)

        panel = Gtk.Paned(orientation=Gtk.Orientation.HORIZONTAL)
        panel.pack1(scroll, resize=True, shrink=False)

        self.listaiconview = ListaIconView(None)

        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(
            Gtk.PolicyType.NEVER,
            Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(self.listaiconview)

        panel.pack2(scroll, resize=False, shrink=False)
        ###

        base_box.pack_start(self.toolbar, False, False, 0)
        base_box.pack_start(self.toolbar_config, False, False, 0)
        base_box.pack_start(panel, True, True, 0)
        base_box.pack_end(self.toolbartry, False, False, 0)

        self.add(base_box)

        self.connect("realize", self.__rescale)
        self.show_all()

        self.toolbar.connect('switch_to', self.__emit_switch)
        self.toolbar.connect('activar', self.__set_accion)
        self.toolbar.connect('salir', self.__salir)
        self.toolbar_config.connect('run', self.__set_presentacion)
        self.visor.connect('changed', self.__set_change_image)
        self.visor.connect('info', self.__set_info)

        self.toolbar_config.hide()
        self.toolbar.set_modo("nochanged")
        self.toolbar.set_modo("edit")

        self.connect("motion-notify-event",
            self.__do_motion_notify_event)

        self.visor.add_events(
            Gdk.EventMask.BUTTON_PRESS_MASK |
            Gdk.EventMask.BUTTON_RELEASE_MASK
        )

        self.visor.connect("button_press_event", self.__clicks_en_pantalla)
        self.listaiconview.connect("selected", self.__show_imagen)
        self.listaiconview.connect("button-press-event",
            self.__click_derecho_en_lista)

    def __rescale(self, widget):

        #rect = self.get_toplevel().get_allocation()
        self.listaiconview.set_size_request(-1, -1)
        self.listaiconview.hide()

    def __clicks_en_pantalla(self, widget, event):

        pass
        # FIXME: El visor es fullscreen, pero esta funcionalidad puede ser
        # insteresante cuando la aplicación está embebida en otra.
        """
        if event.type.value_name == "GDK_2BUTTON_PRESS":

            self.get_toplevel().set_sensitive(False)

            ventana = self.get_toplevel()
            screen = ventana.get_screen()
            w,h = ventana.get_size()
            ww, hh = (screen.get_width(), screen.get_height())

            if ww == w and hh == h:
                GLib.idle_add(ventana.unfullscreen)

            else:
                GLib.idle_add(ventana.fullscreen)

            self.get_toplevel().set_sensitive(True)
        """

    def __click_derecho_en_lista(self, widget, event):
        """
        Esto es para abrir un menu de opciones cuando
        el usuario hace click derecho sobre un elemento en
        la lista de imágenes, permitiendo copiar, mover y
        borrar el archivo o simplemente quitarlo
        de la lista.
        """

        boton = event.button
        pos = (event.x, event.y)
        tiempo = event.time

        if boton == 1:
            return

        elif boton == 3:

            path = widget.get_path_at_pos(
                int(pos[0]), int(pos[1]))
            #iter = widget.get_model().get_iter(path)

            from Widgets import MenuList

            menu = MenuList(
                widget, boton, pos,
                tiempo, path, widget.get_model(),
                self.path)

            menu.connect('accion', self.__set_menu_accion)
            menu.popup(None, None, None, None, boton, tiempo)

        elif boton == 2:
            return

    def __set_menu_accion(self, widget, widget_item, accion, iter, file_path):

        if accion == "Quitar":
            widget_item.get_model().remove(iter)

        elif accion == "Borrar":
            from JAMediaObjects.JAMFileSystem import borrar
            widget_item.get_model().remove(iter)

            borrar(file_path)

        elif accion == "Copiar":
            from Globales import get_imagenes_directory
            from JAMediaObjects.JAMFileSystem import copiar

            copiar(file_path, get_imagenes_directory())

        elif accion == "Mover":
            from Globales import get_imagenes_directory
            from JAMediaObjects.JAMFileSystem import mover
            widget_item.get_model().remove(iter)

            mover(file_path, get_imagenes_directory())

    def __do_motion_notify_event(self, widget, event):
        """
        Cuando se mueve el mouse sobre la ventana se
        muestran u ocultan las toolbars.
        """

        if self.toolbar_config.get_visible():
            return

        rect = self.toolbar.get_allocation()
        arriba = range(0, rect.height)

        root_rect = self.get_toplevel().get_allocation()
        rect = self.toolbartry.get_allocation()
        abajo = range(root_rect.height - rect.height, root_rect.height)
        x, y = self.get_toplevel().get_pointer()

        rect = self.listaiconview.get_allocation()
        derecha = range(root_rect.width - rect.width, root_rect.width)

        if y in arriba or y in abajo or x in derecha:
            if not self.toolbar.get_visible():
                self.toolbar.show()

            if not self.toolbartry.get_visible():
                self.toolbartry.show()

            if not self.listaiconview.get_visible():
                self.listaiconview.show()

            return

        else:
            if self.toolbar.get_visible():
                self.toolbar.hide()

            if self.toolbartry.get_visible():
                self.toolbartry.hide()

            if self.listaiconview.get_visible():
                self.listaiconview.hide()

            return

    def __set_presentacion(self, widget=None, intervalo=False):
        """
        Lanza el modo diapositivas.
        """

        if self.actualizador:
            GLib.source_remove(self.actualizador)
            self.actualizador = False

        if intervalo:
            self.intervalo = intervalo
            self.toolbar.set_modo("player")

        self.toolbar.set_playing()
        self.actualizador = GLib.timeout_add(
            self.intervalo, self.__handle_presentacion)

    def __stop_presentacion(self):

        if self.actualizador:
            GLib.source_remove(self.actualizador)
            self.actualizador = False

        self.toolbar.set_paused()

    def __handle_presentacion(self):
        """
        Cuando está en modo Diapositivas.
        """

        self.listaiconview.seleccionar_siguiente()
        return True

    def __set_accion(self, widget, accion):

        self.get_toplevel().set_sensitive(False)

        if accion == "Configurar Presentación":

            self.__stop_presentacion()

            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            else:
                self.toolbar_config.show()

        elif accion == "Reproducir":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            if self.actualizador:
                self.__stop_presentacion()

            else:
                self.__set_presentacion()

        elif accion == "Anterior":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.__stop_presentacion()
            self.listaiconview.seleccionar_anterior()

        elif accion == "Siguiente":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.__stop_presentacion()
            self.listaiconview.seleccionar_siguiente()

        elif accion == "Detener":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.__stop_presentacion()

        elif accion == "Rotar Izquierda":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.visor.rotar(-1)

        elif accion == "Rotar Derecha":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.visor.rotar(1)

        elif accion == "Acercar":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.visor.zoom(1)

        elif accion == "Alejar":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.visor.zoom(-1)

        elif accion == "Centrar en Pantalla":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.visor.center_image()

        elif accion == "Navegar Imágenes":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.__stop_presentacion()

            if self.toolbar.modo != "edit":
                self.toolbar.set_modo("edit")

            elif self.toolbar.modo == "edit":
                self.toolbar.set_modo("player")

        elif accion == "Guardar":
            self.visor.guardar()

        self.get_toplevel().set_sensitive(True)

    def __set_change_image(self, widget, valor):
        """
        Cuando el usuario rota la imagen, puede guardarla.
        """

        if valor:
            self.toolbar.set_modo("changed")

        else:
            self.toolbar.set_modo("nochanged")

    def __emit_switch(self, widget, path):

        self.__stop_presentacion()
        self.emit("switch_to", path)

    def __salir(self, widget):

        self.__stop_presentacion()
        self.emit("salir")

    def run(self):

        self.listaiconview.load_previews(self.path)

    def __show_imagen(self, widget, imagen):

        self.visor.load(imagen)

        '''
        while Gtk.events_pending():
            Gtk.main_iteration()
        '''
        self.queue_draw()

    def __set_info(self, widget, info):

        self.toolbartry.set_info(info)
Esempio n. 11
0
    def setup_init(self):
        """
        Se crea la interfaz grafica, se setea todo y
        se empaqueta todo.
        """

        ### Contenedor secundario para toda la interfaz.
        basebox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        ### Contenedor para todas las toolbars.
        self.toolbar_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        ### Panel para lector y barra de navegación de páginas.
        hpanel = Gtk.HPaned()

        self.toolbar = Toolbar()
        self.toolbar_salir = ToolbarSalir()
        self.toolbar_config = ToolbarConfig()

        self.toolbarlector = ToolbarLector()
        self.toolbartry = ToolbarTry()

        ### Empaquetado de las tres toolbars superiores de la aplicacion.
        self.toolbar_box.pack_start(self.toolbar, False, False, 0)
        self.toolbar_box.pack_start(self.toolbar_salir, False, False, 0)
        self.toolbar_box.pack_start(self.toolbar_config, False, False, 0)

        self.visor = DrawingLector()

        self.previewcontainer = PreviewContainer()
        self.toolbarpaginas = ToolbarPaginas()

        self.textview = TextView()

        # Izquierda
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        scroll = Gtk.ScrolledWindow()

        scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)

        scroll.add_with_viewport(self.visor)

        vbox.pack_start(self.toolbarlector, False, False, 0)
        vbox.pack_start(scroll, True, True, 0)

        self.controlespdf = [self.toolbarlector, scroll]

        scroll = Gtk.ScrolledWindow()

        scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)

        scroll.add_with_viewport(self.textview)

        vbox.pack_start(scroll, True, True, 0)

        self.controlestexto = [scroll]

        hpanel.pack1(vbox, resize=True, shrink=True)

        ### Derecha
        self.derecha_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        scroll = Gtk.ScrolledWindow()

        scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)

        scroll.add_with_viewport(self.previewcontainer)

        self.derecha_vbox.pack_start(self.toolbarpaginas, False, False, 0)
        self.derecha_vbox.pack_start(scroll, True, True, 0)

        self.controlespdf.append(self.derecha_vbox)

        hpanel.pack2(self.derecha_vbox, resize=False, shrink=False)

        basebox.pack_start(self.toolbar_box, False, False, 0)
        basebox.pack_start(hpanel, True, True, 0)
        basebox.pack_start(self.toolbartry, False, False, 0)

        self.controles_dinamicos = [
            self.toolbar_box, self.derecha_vbox, self.toolbartry
        ]

        self.add(basebox)
        self.show_all()

        self.toolbar_salir.hide()
        self.toolbar.abrir.hide()  # Solo cuando no esta embebido
        self.toolbar_config.hide()

        self.toolbarlector.connect('original', self.visor.original)
        self.toolbarlector.connect('alejar', self.visor.alejar)
        self.toolbarlector.connect('acercar', self.visor.acercar)
        #self.toolbarlector.connect('rotar_izquierda', self.visor.acercar)
        #self.toolbarlector.connect('rotar_derecha', self.visor.acercar)

        self.toolbarpaginas.connect('activar', self.activar)

        self.previewcontainer.connect('nueva_seleccion', self.nueva_pagina)

        self.visor.connect("button_press_event", self.clicks_en_pantalla)

        self.toolbar.connect('abrir', self.show_filechooser)
        self.toolbar.connect('config', self.mostrar_config)
        self.toolbar.connect('salir', self.confirmar_salir)
        self.toolbar_salir.connect('salir', self.emit_salir)

        map(self.ocultar, self.controlestexto)
        map(self.ocultar, self.controlespdf)
Esempio n. 12
0
    def __init__(self, path):

        Gtk.EventBox.__init__(self)

        self.path = path  # Directorio

        base_box = Gtk.VBox()

        self.intervalo = False
        self.actualizador = False

        self.toolbar = ToolbarImagen(path)
        self.visor = Visor()
        self.toolbar_config = ToolbarConfig()
        self.toolbartry = ToolbarTry()

        ### En panel
        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(self.visor)

        panel = Gtk.Paned(orientation=Gtk.Orientation.HORIZONTAL)
        panel.pack1(scroll, resize=True, shrink=False)

        self.listaiconview = ListaIconView(None)

        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(self.listaiconview)

        panel.pack2(scroll, resize=False, shrink=False)
        ###

        base_box.pack_start(self.toolbar, False, False, 0)
        base_box.pack_start(self.toolbar_config, False, False, 0)
        base_box.pack_start(panel, True, True, 0)
        base_box.pack_end(self.toolbartry, False, False, 0)

        self.add(base_box)

        self.connect("realize", self.__rescale)
        self.show_all()

        self.toolbar.connect('switch_to', self.__emit_switch)
        self.toolbar.connect('activar', self.__set_accion)
        self.toolbar.connect('salir', self.__salir)
        self.toolbar_config.connect('run', self.__set_presentacion)
        self.visor.connect('changed', self.__set_change_image)
        self.visor.connect('info', self.__set_info)

        self.toolbar_config.hide()
        self.toolbar.set_modo("nochanged")
        self.toolbar.set_modo("edit")

        self.connect("motion-notify-event", self.__do_motion_notify_event)

        self.visor.add_events(Gdk.EventMask.BUTTON_PRESS_MASK
                              | Gdk.EventMask.BUTTON_RELEASE_MASK)

        self.visor.connect("button_press_event", self.__clicks_en_pantalla)
        self.listaiconview.connect("selected", self.__show_imagen)
        self.listaiconview.connect("button-press-event",
                                   self.__click_derecho_en_lista)
Esempio n. 13
0
class VisorImagenes(Gtk.EventBox):

    __gtype_name__ = 'JAMediaImagenesVisorImagenes'

    __gsignals__ = {
        'salir': (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, []),
        'switch_to':
        (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (GObject.TYPE_STRING, ))
    }

    def __init__(self, path):

        Gtk.EventBox.__init__(self)

        self.path = path  # Directorio

        base_box = Gtk.VBox()

        self.intervalo = False
        self.actualizador = False

        self.toolbar = ToolbarImagen(path)
        self.visor = Visor()
        self.toolbar_config = ToolbarConfig()
        self.toolbartry = ToolbarTry()

        ### En panel
        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(self.visor)

        panel = Gtk.Paned(orientation=Gtk.Orientation.HORIZONTAL)
        panel.pack1(scroll, resize=True, shrink=False)

        self.listaiconview = ListaIconView(None)

        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(self.listaiconview)

        panel.pack2(scroll, resize=False, shrink=False)
        ###

        base_box.pack_start(self.toolbar, False, False, 0)
        base_box.pack_start(self.toolbar_config, False, False, 0)
        base_box.pack_start(panel, True, True, 0)
        base_box.pack_end(self.toolbartry, False, False, 0)

        self.add(base_box)

        self.connect("realize", self.__rescale)
        self.show_all()

        self.toolbar.connect('switch_to', self.__emit_switch)
        self.toolbar.connect('activar', self.__set_accion)
        self.toolbar.connect('salir', self.__salir)
        self.toolbar_config.connect('run', self.__set_presentacion)
        self.visor.connect('changed', self.__set_change_image)
        self.visor.connect('info', self.__set_info)

        self.toolbar_config.hide()
        self.toolbar.set_modo("nochanged")
        self.toolbar.set_modo("edit")

        self.connect("motion-notify-event", self.__do_motion_notify_event)

        self.visor.add_events(Gdk.EventMask.BUTTON_PRESS_MASK
                              | Gdk.EventMask.BUTTON_RELEASE_MASK)

        self.visor.connect("button_press_event", self.__clicks_en_pantalla)
        self.listaiconview.connect("selected", self.__show_imagen)
        self.listaiconview.connect("button-press-event",
                                   self.__click_derecho_en_lista)

    def __rescale(self, widget):

        #rect = self.get_toplevel().get_allocation()
        self.listaiconview.set_size_request(-1, -1)
        self.listaiconview.hide()

    def __clicks_en_pantalla(self, widget, event):

        pass
        # FIXME: El visor es fullscreen, pero esta funcionalidad puede ser
        # insteresante cuando la aplicación está embebida en otra.
        """
        if event.type.value_name == "GDK_2BUTTON_PRESS":

            self.get_toplevel().set_sensitive(False)

            ventana = self.get_toplevel()
            screen = ventana.get_screen()
            w,h = ventana.get_size()
            ww, hh = (screen.get_width(), screen.get_height())

            if ww == w and hh == h:
                GLib.idle_add(ventana.unfullscreen)

            else:
                GLib.idle_add(ventana.fullscreen)

            self.get_toplevel().set_sensitive(True)
        """

    def __click_derecho_en_lista(self, widget, event):
        """
        Esto es para abrir un menu de opciones cuando
        el usuario hace click derecho sobre un elemento en
        la lista de imágenes, permitiendo copiar, mover y
        borrar el archivo o simplemente quitarlo
        de la lista.
        """

        boton = event.button
        pos = (event.x, event.y)
        tiempo = event.time

        if boton == 1:
            return

        elif boton == 3:

            path = widget.get_path_at_pos(int(pos[0]), int(pos[1]))
            #iter = widget.get_model().get_iter(path)

            from Widgets import MenuList

            menu = MenuList(widget, boton, pos, tiempo, path,
                            widget.get_model(), self.path)

            menu.connect('accion', self.__set_menu_accion)
            menu.popup(None, None, None, None, boton, tiempo)

        elif boton == 2:
            return

    def __set_menu_accion(self, widget, widget_item, accion, iter, file_path):

        if accion == "Quitar":
            widget_item.get_model().remove(iter)

        elif accion == "Borrar":
            from JAMediaObjects.JAMFileSystem import borrar
            widget_item.get_model().remove(iter)

            borrar(file_path)

        elif accion == "Copiar":
            from Globales import get_imagenes_directory
            from JAMediaObjects.JAMFileSystem import copiar

            copiar(file_path, get_imagenes_directory())

        elif accion == "Mover":
            from Globales import get_imagenes_directory
            from JAMediaObjects.JAMFileSystem import mover
            widget_item.get_model().remove(iter)

            mover(file_path, get_imagenes_directory())

    def __do_motion_notify_event(self, widget, event):
        """
        Cuando se mueve el mouse sobre la ventana se
        muestran u ocultan las toolbars.
        """

        if self.toolbar_config.get_visible():
            return

        rect = self.toolbar.get_allocation()
        arriba = range(0, rect.height)

        root_rect = self.get_toplevel().get_allocation()
        rect = self.toolbartry.get_allocation()
        abajo = range(root_rect.height - rect.height, root_rect.height)
        x, y = self.get_toplevel().get_pointer()

        rect = self.listaiconview.get_allocation()
        derecha = range(root_rect.width - rect.width, root_rect.width)

        if y in arriba or y in abajo or x in derecha:
            if not self.toolbar.get_visible():
                self.toolbar.show()

            if not self.toolbartry.get_visible():
                self.toolbartry.show()

            if not self.listaiconview.get_visible():
                self.listaiconview.show()

            return

        else:
            if self.toolbar.get_visible():
                self.toolbar.hide()

            if self.toolbartry.get_visible():
                self.toolbartry.hide()

            if self.listaiconview.get_visible():
                self.listaiconview.hide()

            return

    def __set_presentacion(self, widget=None, intervalo=False):
        """
        Lanza el modo diapositivas.
        """

        if self.actualizador:
            GLib.source_remove(self.actualizador)
            self.actualizador = False

        if intervalo:
            self.intervalo = intervalo
            self.toolbar.set_modo("player")

        self.toolbar.set_playing()
        self.actualizador = GLib.timeout_add(self.intervalo,
                                             self.__handle_presentacion)

    def __stop_presentacion(self):

        if self.actualizador:
            GLib.source_remove(self.actualizador)
            self.actualizador = False

        self.toolbar.set_paused()

    def __handle_presentacion(self):
        """
        Cuando está en modo Diapositivas.
        """

        self.listaiconview.seleccionar_siguiente()
        return True

    def __set_accion(self, widget, accion):

        self.get_toplevel().set_sensitive(False)

        if accion == "Configurar Presentación":

            self.__stop_presentacion()

            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            else:
                self.toolbar_config.show()

        elif accion == "Reproducir":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            if self.actualizador:
                self.__stop_presentacion()

            else:
                self.__set_presentacion()

        elif accion == "Anterior":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.__stop_presentacion()
            self.listaiconview.seleccionar_anterior()

        elif accion == "Siguiente":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.__stop_presentacion()
            self.listaiconview.seleccionar_siguiente()

        elif accion == "Detener":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.__stop_presentacion()

        elif accion == "Rotar Izquierda":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.visor.rotar(-1)

        elif accion == "Rotar Derecha":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.visor.rotar(1)

        elif accion == "Acercar":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.visor.zoom(1)

        elif accion == "Alejar":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.visor.zoom(-1)

        elif accion == "Centrar en Pantalla":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.visor.center_image()

        elif accion == "Navegar Imágenes":
            if self.toolbar_config.get_visible():
                self.toolbar_config.hide()

            self.__stop_presentacion()

            if self.toolbar.modo != "edit":
                self.toolbar.set_modo("edit")

            elif self.toolbar.modo == "edit":
                self.toolbar.set_modo("player")

        elif accion == "Guardar":
            self.visor.guardar()

        self.get_toplevel().set_sensitive(True)

    def __set_change_image(self, widget, valor):
        """
        Cuando el usuario rota la imagen, puede guardarla.
        """

        if valor:
            self.toolbar.set_modo("changed")

        else:
            self.toolbar.set_modo("nochanged")

    def __emit_switch(self, widget, path):

        self.__stop_presentacion()
        self.emit("switch_to", path)

    def __salir(self, widget):

        self.__stop_presentacion()
        self.emit("salir")

    def run(self):

        self.listaiconview.load_previews(self.path)

    def __show_imagen(self, widget, imagen):

        self.visor.load(imagen)
        '''
        while Gtk.events_pending():
            Gtk.main_iteration()
        '''
        self.queue_draw()

    def __set_info(self, widget, info):

        self.toolbartry.set_info(info)
Esempio n. 14
0
    def setup_init(self):
        """Se crea la interfaz grafica, se setea todo y
        se empaqueta todo."""

        basebox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        hpanel = Gtk.HPaned()
        self.toolbar = Toolbar()
        self.toolbar_config = ToolbarConfig()
        self.toolbarlector = ToolbarLector()
        self.toolbartry = ToolbarTry()
        self.visor = Drawing()
        self.previewcontainer = PreviewContainer()
        self.toolbarpaginas = ToolbarPaginas()
        self.textview = TextView()

        # Izquierda
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(self.visor)
        vbox.pack_start(self.toolbarlector, False, False, 0)
        vbox.pack_start(scroll, True, True, 0)

        self.controlespdf = [self.toolbarlector, scroll]

        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(self.textview)
        vbox.pack_start(scroll, True, True, 0)

        self.controlestexto = [scroll]

        hpanel.pack1(vbox, resize=True, shrink=True)

        # Derecha
        ev_box = Gtk.EventBox()  # Para poder pintarlo
        ev_box.modify_bg(0, Gdk.Color(65000, 65000, 65000))
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        scroll = Gtk.ScrolledWindow()
        scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scroll.add_with_viewport(self.previewcontainer)
        vbox.pack_start(self.toolbarpaginas, False, False, 0)
        vbox.pack_start(scroll, True, True, 0)
        ev_box.add(vbox)

        self.controlespdf.append(ev_box)

        hpanel.pack2(ev_box, resize=False, shrink=False)

        basebox.pack_start(self.toolbar, False, False, 0)
        basebox.pack_start(self.toolbar_config, False, False, 0)
        basebox.pack_start(hpanel, True, True, 0)
        basebox.pack_start(self.toolbartry, False, False, 0)

        self.controles_dinamicos = [
            self.toolbar, self.toolbarlector, ev_box, self.toolbartry
        ]

        self.add(basebox)
        self.show_all()

        self.toolbar.abrir.hide()  # Solo cuando no esta embebido
        self.toolbar_config.hide()

        self.toolbarlector.connect('original', self.visor.original)
        self.toolbarlector.connect('alejar', self.visor.alejar)
        self.toolbarlector.connect('acercar', self.visor.acercar)
        #self.toolbarlector.connect('rotar_izquierda', self.visor.acercar)
        #self.toolbarlector.connect('rotar_derecha', self.visor.acercar)

        self.toolbarpaginas.connect('activar', self.activar)

        self.previewcontainer.connect('nueva_seleccion', self.nueva_pagina)

        self.visor.connect("ocultar_controles", self.ocultar_controles)
        self.visor.connect("button_press_event", self.clicks_en_pantalla)

        self.toolbar.connect('abrir', self.show_filechooser)
        self.toolbar.connect('config', self.mostrar_config)
        self.toolbar.connect('salir', self.emit_salir)

        map(self.ocultar, self.controlestexto)
        map(self.ocultar, self.controlespdf)