def __init__(self, uri):
        GObject.GObject.__init__(self)

        self._uri = uri

        # Create Evince objects to handle the PDF in the URI:
        EvinceDocument.init()
        self._doc = EvinceDocument.Document.factory_get_document(uri)
        self._view = EvinceView.View()
        self._model = EvinceView.DocumentModel()
        self._model.set_document(self._doc)
        self._view.set_model(self._model)

        self._view.connect('external-link', self.__handle_link_cb)
        self._model.connect('page-changed', self.__page_changed_cb)

        self._back_page_button = None
        self._forward_page_button = None
        self._toolbar_box = self._create_toolbar()
        self._update_nav_buttons()

        self._toolbar_box.set_halign(Gtk.Align.FILL)
        self._toolbar_box.set_valign(Gtk.Align.END)
        self.add_overlay(self._toolbar_box)
        self._toolbar_box.show()

        scrolled_window = Gtk.ScrolledWindow()
        self.add(scrolled_window)
        scrolled_window.show()

        scrolled_window.add(self._view)
        self._view.show()
Esempio n. 2
0
 def add_pdf_viewer(self):
     self.scroll = Gtk.ScrolledWindow()
     self.pane.pack2(self.scroll)
     EvinceDocument.init()
     self.doc_view = EvinceView.View()
     self.doc_view.connect('button-press-event', self.synctex)
     self.doc_model = EvinceView.DocumentModel()
     self.doc_view.set_model(self.doc_model)
     self.load_pdf()
     self.scroll.add(self.doc_view)
Esempio n. 3
0
 def __init__(self, file, w, h):
     # Setup pdf window
     Gtk.ScrolledWindow.__init__(self)
     self.doc = EvinceDocument.Document.factory_get_document(
         "file:///" + path.join(media_path, file))
     # evince view
     self.view = EvinceView.View()
     # evince model
     self.model = EvinceView.DocumentModel()
     self.model.set_document(self.doc)
     self.model.set_continuous(False)
     self.model.set_sizing_mode(EvinceView.PageLayout.SINGLE)
     self.model.set_page_layout(EvinceView.SizingMode.FIT_PAGE)
     self.view.set_model(self.model)
     self.set_size_request(w, h)
     self.add(self.view)
Esempio n. 4
0
    def display(self):
        super().display()
        if self.field and self.record:
            data = self.field.get_data(self.record)
        else:
            data = None

        if not data:
            self.image.hide()
            if self.evince_view:
                self.evince_view.set_model(EvinceView.DocumentModel())
                self.evince_scroll.hide()
            return

        pixbuf = data2pixbuf(data)
        if pixbuf:
            try:
                self.image.disconnect_by_func(self._draw)
            except TypeError:
                pass
            self.image.connect('draw', self._draw, pixbuf)
            self.image.queue_draw()
            self.image.show()
            if self.evince_view:
                self.evince_view.set_model(EvinceView.DocumentModel())
                self.evince_scroll.hide()
        else:
            self.image.hide()
            if self.evince_view:
                self.evince_scroll.show()
                if self.filename_field:
                    suffix = self.filename_field.get(self.record)
                else:
                    suffix = None
                try:
                    with NamedTemporaryFile(suffix=suffix) as fp:
                        fp.write(data)
                        path = Path(fp.name)
                        document = (
                            EvinceDocument.Document.factory_get_document(
                                path.as_uri()))
                    model = EvinceView.DocumentModel()
                    model.set_document(document)
                    self.evince_view.set_model(model)
                except GLib.GError:
                    self.evince_view.set_model(EvinceView.DocumentModel())
                    self.evince_scroll.hide()
Esempio n. 5
0
	def populate_pdf_viewer (self, bytes):
		with tempfile.NamedTemporaryFile() as pdf_contents:
			pdf_contents.file.write(bytes)
			file_url = 'file://' + pdf_contents.name
			doc = EvinceDocument.Document.factory_get_document(file_url)
		self.model = EvinceView.DocumentModel()
		self.model.set_document(doc)
		self.view.set_model(self.model)
Esempio n. 6
0
	def view_file (self):
		self.model = EvinceView.DocumentModel()
		doc = EvinceDocument.Document.factory_get_document("file:///tmp/opt.pdf")
		self.model.set_document(doc)
		self.view.set_model(self.model)
		self.builder.get_object('button8').set_sensitive (True)
		self.builder.get_object('stack1').set_visible_child_name('view_page')
		self.dialog.show_all()
		self.parent_window.present()
Esempio n. 7
0
File: pdf.py Progetto: brpaz/hawkeye
    def build_ui(self):
        """ Builds the UI widgets """
        self.search_bar = SearchBar()
        self.search_bar.set_key_press_handler(self.on_search)

        self.view = EvinceView.View()
        self.doc = EvinceDocument.Document.factory_get_document(self.uri)

        model = EvinceView.DocumentModel()
        model.set_document(self.doc)

        self.view.set_model(model)

        self.scrolled_window = Gtk.ScrolledWindow()
        self.scrolled_window.add(self.view)
        self.pack_start(self.search_bar, False, False, 0)
        self.pack_start(self.scrolled_window, True, True, 0)
        self.show_all()
Esempio n. 8
0
 def set_book(self, book):
     doc = EvDocument.Document.factory_get_document('file://' +
                                                    book.filename())
     model = EvView.DocumentModel(document=doc)
     model.set_sizing_mode(EvView.SizingMode.FIT_PAGE)
     model.set_continuous(False)
     model.set_page_layout(EvView.PageLayout.DUAL if app().
                           is_landscape else EvView.PageLayout.SINGLE)
     self.viewer.set_model(model)
 def play_internal(self, theFile):
     theFile = "file:///%s" % (os.path.abspath(theFile))
     if self.wvMain.get_parent() != None:
         # Force stopping of any previously played media
         self.wvMain.load_html(
             "<html> <head><title> Browser </title></head> <body> <center> Satyameva Jayate </center> </body> </html>"
         )
         self.swMain.remove(self.wvMain)
     if (self.evMain != None) and (self.evMain.get_parent() != None):
         self.swMain.remove(self.evMain)
     if theFile.lower().endswith(".pdf"):
         self.evMain = EvinceView.View()
         self.evDoc = EvinceDocument.Document.factory_get_document(theFile)
         self.evModel = EvinceView.DocumentModel()
         self.evModel.set_document(self.evDoc)
         self.evMain.set_model(self.evModel)
         self.swMain.add(self.evMain)
     else:
         self.swMain.add(self.wvMain)
         self.wvMain.load_uri(theFile)
Esempio n. 10
0
    def __init__(self, uri):
        GObject.GObject.__init__(self)

        self._uri = uri

        # delay Evince import until is needed to improve activity startup time
        gi.require_version('EvinceDocument', '3.0')
        gi.require_version('EvinceView', '3.0')
        from gi.repository import EvinceDocument
        from gi.repository import EvinceView

        # Create Evince objects to handle the PDF in the URI:
        EvinceDocument.init()
        self._doc = EvinceDocument.Document.factory_get_document(uri)
        self._view = EvinceView.View()
        self._model = EvinceView.DocumentModel()
        self._model.set_document(self._doc)
        self._view.set_model(self._model)

        self._EVINCE_MODE_FREE = EvinceView.SizingMode.FREE

        self._view.connect('external-link', self.__handle_link_cb)
        self._model.connect('page-changed', self.__page_changed_cb)

        self._back_page_button = None
        self._forward_page_button = None
        self._toolbar_box = self._create_toolbar()
        self._update_nav_buttons()

        self._toolbar_box.set_halign(Gtk.Align.FILL)
        self._toolbar_box.set_valign(Gtk.Align.END)
        self.pack_end(self._toolbar_box, False, True, 0)
        self._toolbar_box.show()

        scrolled_window = Gtk.ScrolledWindow()
        self.pack_start(scrolled_window, True, True, 0)
        scrolled_window.show()

        scrolled_window.add(self._view)
        self._view.show()
Esempio n. 11
0
    def __init__(self, treeview):

        Gtk.Builder.__init__(self)
        self.add_from_file(UI_FILE)
        self.connect_signals(self)
        self.treeview = treeview
        self.store = treeview.get_model()

        EvinceDocument.init()
        self.view = EvinceView.View()
        self.get_object('pdf_view_scrolled_window').add(self.view)
        self.window = self.get_object('window')
        self.window.show_all()
Esempio n. 12
0
    def load_document(self, file_path):
        try:
            self._document = \
                EvinceDocument.Document.factory_get_document(file_path)
        except GObject.GError as e:
            _logger.error('Can not load document: %s', e)
            return
        else:
            self._model = EvinceView.DocumentModel()
            self._model.set_document(self._document)
            self._view.set_model(self._model)

            # set dpi
            # TODO why we need set this?
            """
Esempio n. 13
0
	def __init__(self, invoice_id):

		Gtk.Builder.__init__(self)
		self.add_from_file(UI_FILE)
		self.connect_signals(self)
		self.invoice_id = invoice_id
		EvinceDocument.init()
		self.view = EvinceView.View()
		self.get_object('pdf_view_scrolled_window').add(self.view)
		window = self.get_object('window')
		window.show_all()
		window.set_title("Invoice hub (%s)" % invoice_id)
		self.populate_items()
		self.populate_metadata ()
		DB.rollback()
Esempio n. 14
0
    def __init__(self, view, attrs):
        super().__init__(view, attrs)

        self.widget = Gtk.VBox(spacing=3)
        self.image = Gtk.DrawingArea()
        self.widget.pack_start(
            self.image, expand=True, fill=True, padding=0)

        if EvinceView:
            self.evince_view = EvinceView.View()
            self.evince_scroll = Gtk.ScrolledWindow()
            self.evince_scroll.add(self.evince_view)
            self.widget.pack_start(
                self.evince_scroll, expand=True, fill=True, padding=0)
        else:
            self.evince_view = self.evince_scroll = None
Esempio n. 15
0
    def __init__(self, main_instance, app):
        Gtk.ScrolledWindow.__init__(self)
        DocumentViewerCommonUtils.__init__(self, main_instance, app)

        EvinceDocument.init()

        self._app = app
        self._view = EvinceView.View()
        self._view.find_set_highlight_search(True)

        self.add(self._view)

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

        self._find_job = None
        self._new_text = False
Esempio n. 16
0
 def view_file(self):
     v_adjust = self.get_object('v_adjustment').get_value()
     try:
         f = "file://" + self.file
         doc = EvinceDocument.Document.factory_get_document(f)
         self.get_object('button8').set_sensitive(True)
         self.get_object('notify_revealer').set_reveal_child(False)
     except Exception as e:  # show in app error notify bar
         print(e)
         self.get_object('error_label').set_text(str(e))
         self.get_object('notify_revealer').set_reveal_child(True)
         self.get_object('button8').set_sensitive(False)
         return
     # create model to load the pdf from after validating the pdf
     self.model = EvinceView.DocumentModel()
     self.model.set_document(doc)
     self.view.set_model(self.model)
     GLib.idle_add(self.get_object('v_adjustment').set_value, v_adjust)
Esempio n. 17
0
	def __init__ (self, parent_window):
		
		self.parent_window = parent_window
		self.builder = Gtk.Builder()
		self.builder.add_from_file(UI_FILE)
		self.builder.connect_signals(self)
		dialog = self.builder.get_object("scan_dialog")
		dialog.set_transient_for(parent_window)

		self.data_queue = Queue()
		self.scanner_store = self.builder.get_object("scanner_store")
		thread = Process(target=self.get_scanners)
		thread.start()
		
		GObject.timeout_add(100, self.populate_scanners)
		
		EvinceDocument.init()
		self.view = EvinceView.View()
		self.builder.get_object('pdf_view_scrolled_window').add(self.view)

		self.dialog = self.builder.get_object('scan_dialog')
Esempio n. 18
0
    def build_ui(self):
        """Init the UI of the TexCompanion"""

        # Construct a Box that will hold the status bar
        # and that will display the errors when needed
        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)

        EvinceDocument.init()
        self._view = EvinceView.View()

        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.add(self._view)

        box.pack_start(scrolled_window, True, True, 0)

        # Status bar creation
        self._status_bar = Gtk.Label("")
        self._status_bar.set_justify(Gtk.Justification.LEFT)
        self._status_bar.set_alignment(0.0, 0.5)
        self._status_bar.set_padding(6, 0)
        box.pack_start(self._status_bar, False, True, 0)

        self.add(box)
Esempio n. 19
0
    def __init__(self, parent_window):

        self.parent_window = parent_window
        Gtk.Builder.__init__(self)
        self.add_from_file(UI_FILE)
        self.connect_signals(self)

        self.terminal = Vte.Terminal()
        self.terminal.show()
        self.terminal.set_scroll_on_output(True)
        self.terminal.connect("child-exited", self.terminal_child_exited)
        self.get_object('scrolledwindow3').add(self.terminal)

        self.data_queue = Queue()
        self.scanner_store = self.get_object("scanner_store")
        thread = Process(target=self.get_scanners)
        thread.start()

        GLib.timeout_add(100, self.populate_scanners)
        style_provider = Gtk.CssProvider()
        css_data = b'''
		#red-background {
		background-color: #FF2A2A;
		}
		'''
        style_provider.load_from_data(css_data)
        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(), style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        EvinceDocument.init()
        self.view = EvinceView.View()
        self.get_object('pdf_view_scrolled_window').add(self.view)

        self.window = self.get_object("window")
        self.window.set_transient_for(parent_window)
        self.window.show_all()
Esempio n. 20
0
 def load_document(self, file_path):
     self.model = EvinceView.DocumentModel()
     document = EvinceDocument.Document.factory_get_document(file_path)
     self.model.set_document(document)
     self.set_model(self.model)
Esempio n. 21
0
    def __init__(self):

        # create main window
        self.window = Gtk.Window()
        # set title, size, position
        self.window.set_title("Pdf Reader - " + os.path.basename(docfile))
        self.window.set_default_size(WWIDTH, WHEIGHT)
        pixbuf = Gtk.IconTheme.get_default().load_icon(
            "accessories-text-editor", 24, 0)
        self.window.set_icon(pixbuf)
        # connect destroy and delete events to quit
        self.window.connect('destroy', Gtk.main_quit)
        self.window.connect('delete-event', Gtk.main_quit)
        self.window.connect("key-press-event", self.keypress)
        self.window.connect('scroll-event', self.fscroll_event)
        # headbar
        if USE_HEADBAR:
            header = Gtk.HeaderBar(title="Pdf Reader - " +
                                   os.path.basename(docfile))
            header.props.show_close_button = True
            self.window.set_titlebar(header)

        # horizontal box
        self.hbox = Gtk.Box(orientation=0, spacing=0)
        self.window.add(self.hbox)
        #
        self.main_box = Gtk.Box(orientation=1, spacing=0)
        self.hbox.pack_end(self.main_box, True, True, 0)
        # box for buttons - orizzontale
        button_box = Gtk.Box(orientation=0, spacing=5)
        self.main_box.add(button_box)

        # show history button
        pixbuf = Gtk.IconTheme.get_default().load_icon("address-book-new", 24,
                                                       0)
        hist_image = Gtk.Image.new_from_pixbuf(pixbuf)
        hist_button = Gtk.Button(image=hist_image)
        hist_button.set_tooltip_text("Show the history")
        button_box.add(hist_button)
        hist_button.connect("clicked", self.on_hist_button)
        hist_button.set_sensitive(False)
        if ftype == "application/pdf":
            hist_button.set_sensitive(True)

        # separator
        separator = Gtk.Separator()
        button_box.add(separator)
        # open file button
        pixbuf = Gtk.IconTheme.get_default().load_icon("document-open", 24, 0)
        openf_image = Gtk.Image.new_from_pixbuf(pixbuf)
        button_openf = Gtk.Button(image=openf_image)
        button_openf.set_tooltip_text("Open a new file")
        button_box.add(button_openf)
        button_openf.connect("clicked", self.on_open_file)

        # separator
        separator = Gtk.Separator()
        button_box.add(separator)
        # print button
        pixbuf = Gtk.IconTheme.get_default().load_icon("document-print", 24, 0)
        print_image = Gtk.Image.new_from_pixbuf(pixbuf)
        button_print = Gtk.Button(image=print_image)
        button_print.set_tooltip_text("Print")
        button_box.add(button_print)

        # separator
        separator = Gtk.Separator()
        button_box.add(separator)
        # dual/single page button
        pixbuf = Gtk.IconTheme.get_default().load_icon("gtk-copy", 24, 0)
        dpage_image = Gtk.Image.new_from_pixbuf(pixbuf)
        button_dpage = Gtk.Button(image=dpage_image)
        self.dpage_state = False
        button_dpage.set_tooltip_text("Dual/Single page")
        button_box.add(button_dpage)
        button_dpage.connect("clicked", self.on_dual_page)
        # separator
        separator = Gtk.Separator()
        button_box.add(separator)
        # entry
        self.curr_entry = Gtk.Entry()
        self.curr_entry.props.xalign = 1
        self.curr_entry.props.width_chars = 5
        self.curr_entry.set_text("1")
        button_box.add(self.curr_entry)
        #
        self.total_label = Gtk.Label()
        button_box.add(self.total_label)
        # previous page button
        pixbuf = Gtk.IconTheme.get_default().load_icon("go-previous", 24, 0)
        p_image = Gtk.Image.new_from_pixbuf(pixbuf)
        p_button = Gtk.Button(image=p_image)
        p_button.set_tooltip_text("Previous page")
        p_button.connect("clicked", self.prev_button)
        button_box.add(p_button)
        # next page button
        pixbuf = Gtk.IconTheme.get_default().load_icon("go-next", 24, 0)
        n_image = Gtk.Image.new_from_pixbuf(pixbuf)
        n_button = Gtk.Button(image=n_image)
        n_button.set_tooltip_text("Next page")
        n_button.connect("clicked", self.next_button)
        button_box.add(n_button)
        # separator
        separator = Gtk.Separator()
        button_box.add(separator)
        # zoom +
        pixbuf = Gtk.IconTheme.get_default().load_icon("zoom-in", 24, 0)
        zoomp_image = Gtk.Image.new_from_pixbuf(pixbuf)
        self.bt_zoomp = Gtk.Button(image=zoomp_image)
        self.bt_zoomp.set_tooltip_text("Zoom+")
        button_box.add(self.bt_zoomp)
        self.bt_zoomp.connect("clicked", self.fbt_zoomp)
        # label per lo zoom
        self.zoom_label = Gtk.Label()

        button_box.add(self.zoom_label)
        # zoom -
        pixbuf = Gtk.IconTheme.get_default().load_icon("zoom-out", 24, 0)
        zoomm_image = Gtk.Image.new_from_pixbuf(pixbuf)
        self.bt_zoomm = Gtk.Button(image=zoomm_image)
        self.bt_zoomm.set_tooltip_text("Zoom-")
        button_box.add(self.bt_zoomm)
        self.bt_zoomm.connect("clicked", self.fbt_zoomm)

        # separator
        separator = Gtk.Separator()
        button_box.add(separator)
        # rotate left button
        pixbuf = Gtk.IconTheme.get_default().load_icon("object-rotate-left",
                                                       24, 0)
        rl_image = Gtk.Image.new_from_pixbuf(pixbuf)
        rl_button = Gtk.Button(image=rl_image)
        rl_button.set_tooltip_text("Rotate left")
        button_box.add(rl_button)
        rl_button.connect("clicked", self.on_rotate_left)
        # rotate right button
        pixbuf = Gtk.IconTheme.get_default().load_icon("object-rotate-right",
                                                       24, 0)
        rr_image = Gtk.Image.new_from_pixbuf(pixbuf)
        rr_button = Gtk.Button(image=rr_image)
        rr_button.set_tooltip_text("Rotate right")
        button_box.add(rr_button)
        rr_button.connect("clicked", self.on_rotate_right)

        # separator
        separator = Gtk.Separator()
        button_box.add(separator)
        # search button
        pixbuf = Gtk.IconTheme.get_default().load_icon("edit-find", 24, 0)
        search_image = Gtk.Image.new_from_pixbuf(pixbuf)
        search_button = Gtk.Button(image=search_image)
        search_button.set_tooltip_text("Find")
        button_box.add(search_button)
        # creating a popover
        sb_pover = Gtk.Popover.new(search_button)
        sb_box = Gtk.Box(orientation=0, spacing=0)
        # widgets
        self.sb_entry = Gtk.Entry()
        self.sb_entry.set_alignment(1)
        self.sb_entry.set_size_request(300, -1)
        sb_box.add(self.sb_entry)
        self.sb_entry.connect("activate", self.on_entry_activate, sb_pover)
        sb_button = Gtk.Button(label="Search")
        sb_box.add(sb_button)
        sb_pover.add(sb_box)
        search_button.connect("clicked", self.on_sb_button_click, sb_pover)
        sb_button.connect("clicked", self.on_enter, sb_pover)
        #
        # next result button
        pixbuf = Gtk.IconTheme.get_default().load_icon("go-next", 24, 0)
        fnext_image = Gtk.Image.new_from_pixbuf(pixbuf)
        fnext_button = Gtk.Button(image=fnext_image)
        fnext_button.set_tooltip_text("Next result")
        button_box.add(fnext_button)
        fnext_button.connect("clicked", self.ffnext_button)
        # previous result button
        pixbuf = Gtk.IconTheme.get_default().load_icon("go-previous", 24, 0)
        fprev_image = Gtk.Image.new_from_pixbuf(pixbuf)
        fprev_button = Gtk.Button(image=fprev_image)
        fprev_button.set_tooltip_text("Previous result")
        button_box.add(fprev_button)
        fprev_button.connect("clicked", self.ffprev_button)

        # copy to clipboard
        # variable
        self.copy_text_to_clipboard = ""
        # separator
        separator = Gtk.Separator()
        button_box.add(separator)
        # copy to clipboard button
        pixbuf = Gtk.IconTheme.get_default().load_icon("edit-paste", 24, 0)
        clip_image = Gtk.Image.new_from_pixbuf(pixbuf)
        clip_button = Gtk.Button(image=clip_image)
        clip_button.set_tooltip_text("Copy to clipboard")
        button_box.add(clip_button)
        clip_button.connect("clicked", self.on_clip_button)

        # separator
        separator = Gtk.Separator()
        button_box.add(separator)
        # info button
        pixbuf = Gtk.IconTheme.get_default().load_icon("gnome-help", 24, 0)
        info_image = Gtk.Image.new_from_pixbuf(pixbuf)
        info_button = Gtk.Button(image=info_image)
        info_button.set_tooltip_text("Document info")
        button_box.add(info_button)
        # DISATTIVATO
        ## separator
        #separator = Gtk.Separator()
        #button_box.add(separator)
        ## save document button
        #pixbuf = Gtk.IconTheme.get_default().load_icon("gtk-save", 24, 0)
        #save_image = Gtk.Image.new_from_pixbuf(pixbuf)
        #save_button = Gtk.Button(image=save_image)
        #save_button.set_tooltip_text("Save this document")
        #button_box.add(save_button)
        #save_button.connect("clicked", self.fsave_button)

        # separator
        #separator = Gtk.Separator()
        #button_box.add(separator)
        # quit the program button
        pixbuf = Gtk.IconTheme.get_default().load_icon("exit", 24, 0)
        quit_image = Gtk.Image.new_from_pixbuf(pixbuf)
        quit_button = Gtk.Button(image=quit_image)
        quit_button.set_tooltip_text("Quit")
        button_box.pack_end(quit_button, False, False, 0)
        quit_button.connect("clicked", Gtk.main_quit)

        # scrolled window for the viewer
        scroll = Gtk.ScrolledWindow()
        self.main_box.pack_start(scroll, True, True, 0)
        # EVINCE DOCUMENT
        EvinceDocument.init()
        # load the document or exit
        try:
            self.doc = EvinceDocument.Document.factory_get_document('file://' +
                                                                    docfile)
        except:
            print(
                os.path.basename(sys.argv[1]) +
                " :\nError while opening the file\nor type not supported.")
            self.info_dialog(
                os.path.basename(sys.argv[1]) +
                ":\nError while opening the file\nor type not supported.")
            sys.exit()
        #
        self.total_label.set_label(str(self.doc.get_n_pages()))
        # TOC of doc by links
        try:
            if self.doc.has_document_links():
                self.job_links = EvinceView.JobLinks.new(self.doc)
                EvinceView.Job.scheduler_push_job(
                    self.job_links, EvinceView.JobPriority.PRIORITY_NONE)
                self.job_links.connect('finished', self.index_load)
            else:
                hist_button.set_sensitive(False)
        except:
            pass
        # evince view
        self.view = EvinceView.View()
        self.view.can_zoom_in()
        self.view.can_zoom_out()
        # evince model
        self.model = EvinceView.DocumentModel()
        self.model.set_document(self.doc)
        self.view.set_model(self.model)
        self.model.props.sizing_mode = EvinceView.SizingMode.FIT_WIDTH  #AUTOMATIC FIT_PAGE FIT_WIDTH
        self.page = EvinceDocument.Page.new(0)

        # add to scroll window
        scroll.add(self.view)
        self.window.show_all()
        self.fullscreen = False

        # print the page - needed to show the print dialog
        # workaround for the cbr file types and maybe others
        try:
            self.evprint = EvinceView.PrintOperation.new(self.doc)
            button_print.connect("clicked", self.button_clicked)
        except:
            pass
        #
        self.window.connect("check-resize", self.on_win_resize)
        self.view.connect("selection-changed", self.view_sel_changed)
        self.model.connect("page-changed", self.model_page_changed)
        #button_print.connect("clicked", self.button_clicked)
        self.curr_entry.connect("activate", self.curr_entry_activate)
        #
        gi = self.doc.get_info()
        info_list = []
        info_list.append(gi.author or "")
        info_list.append(gi.modified_date or "")
        info_list.append(gi.creator or "")
        info_list.append(gi.format or "")
        info_list.append(gi.n_pages or "")
        info_list.append(gi.producer or "")
        info_button.connect("clicked", self.finfo_button, info_list)
        # window size constants
        self.win_width = self.window.get_size().width
        self.win_height = self.window.get_size().height
        # treemodel
        self.hstore = Gtk.TreeStore(str, int)
        self.tree = Gtk.TreeView.new_with_model(self.hstore)
        self.tree.set_show_expanders(True)
        self.tree.set_activate_on_single_click(True)
        self.tree.connect("row-activated", self.on_single_click)
        renderer1 = Gtk.CellRendererText()
        column1 = Gtk.TreeViewColumn("Title", renderer1, text=0)
        self.tree.append_column(column1)
        renderer2 = Gtk.CellRendererText()
        column2 = Gtk.TreeViewColumn("Page", renderer2, text=1)
        self.tree.append_column(column2)
        self.sw = Gtk.ScrolledWindow()
        # the width of the scrollbar
        self.sw.set_size_request(250, -1)
        self.sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.sw.add(self.tree)
        self.hbox.pack_start(self.sw, False, False, 1)
        self.tree.set_expander_column(column1)
Esempio n. 22
0
import os
import sys
os.environ["GDK_CORE_DEVICE_EVENTS"] = "1"

import gi
gi.require_version('Gtk', '3.0')
gi.require_version('EvinceDocument', '3.0')
gi.require_version('EvinceView', '3.0')
from gi.repository import Gtk, GLib
from gi.repository import EvinceDocument
from gi.repository import EvinceView

wid = int(sys.argv[1])
uri = GLib.filename_to_uri(sys.argv[2])
plug = Gtk.Plug()
plug.construct(wid)
scroll = Gtk.ScrolledWindow()
EvinceDocument.init()
doc = EvinceDocument.Document.factory_get_document(uri)
view = EvinceView.View()
model = EvinceView.DocumentModel()
model.set_document(doc)
view.set_model(model)
scroll.add(view)
plug.add(scroll)

plug.connect("delete-event", Gtk.main_quit)
plug.show_all()
Gtk.main()
Esempio n. 23
0
 def load_pdf(self):
     self.model = EvinceView.DocumentModel()
     doc = EvinceDocument.Document.factory_get_document(
         "/tmp/pdf_export.pdf")
     self.model.set_document(doc)
     self.view.set_model(self.model)
Esempio n. 24
0
        self._view.connect('event', self.__view_touch_event_cb)

        activity._hbox.pack_start(activity._scrolled, True, True, 0)
        activity._scrolled.show()

        self.dpi = activity.dpi

    def load_document(self, file_path):
        try:
            self._document = \
                EvinceDocument.Document.factory_get_document(file_path)
        except GObject.GError, e:
            _logger.error('Can not load document: %s', e)
            return
        else:
            self._model = EvinceView.DocumentModel()
            self._model.set_document(self._document)
            self._view.set_model(self._model)

            # set dpi
            # TODO why we need set this?
            """
            min_scale = self._model.get_min_scale()
            max_scale = self._model.get_max_scale()
            logging.error("min scale %s max_scale %s", min_scale, max_scale)
            logging.error("setting min scale %s", min_scale * self.dpi / 72.0)
            logging.error("setting max scale %s", max_scale * self.dpi / 72.0)
            self._model.set_min_scale(min_scale * self.dpi / 72.0)
            self._model.set_max_scale(max_scale * self.dpi / 72.0)
            """
Esempio n. 25
0
 def __init__(self):
     self._view_notify_zoom_handler = None
     EvinceDocument.init()
     self._view = EvinceView.View()
Esempio n. 26
0
 def __init__(self):
     super().__init__()
     self.viewer = EvView.View()
     self.add(self.viewer)