コード例 #1
0
    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()
コード例 #2
0
    def produceClipFrames(self):
        clipFrames = []  # for store frame in this clip
        findex = 0
        for frame in self.clipData:
            self.fShowTime.append(frame["FrameTime"])
            ipElements = []
            for element in frame["Elements"]:
                # print(element)
                if element["type"] == "video" and self.hasVideo is False:
                    self.hasVideo = True
                    Gst.init(None)
                if element["type"] == "pdf" and self.hasPdf is False:
                    self.hasPdf = True
                    EvinceDocument.init()
                # create ipElement object
                ipEm = ipElement(
                    element["type"],
                    element["name"],
                    element["src"],
                    element["width"],
                    element["height"],
                    element["px"],
                    element["py"],
                )
                ipElements.append(ipEm)

            clipFrames.append(
                ipFrame(findex, ipElements, frame["FrameTime"], self.mPath))
            findex = findex + 1

        if self.hasPdf is not True:
            EvinceDocument.init()
        if self.hasVideo is not True:
            Gst.init(None)
        return clipFrames
コード例 #3
0
ファイル: pulp.py プロジェクト: roidocampo/pulp
 def __new__(cls, *args, **kws):
     if cls.template is None:
         cls.template = Resource.string("ui_window.xml")
         cls.set_template(GLib.Bytes(cls.template))
         for field in cls.template_fields:
             cls.bind_template_child_full(field, True, 0)
         EvinceDocument.init()
     return super().__new__(cls)
コード例 #4
0
ファイル: __init__.py プロジェクト: cfangmeier/vitex
 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)
コード例 #5
0
ファイル: pdf.py プロジェクト: brpaz/hawkeye
    def __init__(self, uri):
        """ constructor """
        super(PdfViewer, self).__init__()
        self.uri = uri
        self.searched_text = ""
        self.find_job = None

        EvinceDocument.init()

        self.build_ui()
        self.connect_signals()
コード例 #6
0
ファイル: pdfview.py プロジェクト: Yanok35/quick-html-editor
    def __init__(self, filename=None):
        super(pdfview, self).__init__()

        EvinceDocument.init()
        view = EvinceView.View()
        self.view = view
        self.model = None
        self.current_pages = 0

        if filename:
            self.set_document()

        self.add(view)
コード例 #7
0
ファイル: export_to_pdf.py プロジェクト: benreu/PyGtk-Posting
    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()
コード例 #8
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()
コード例 #9
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
コード例 #10
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
コード例 #11
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')
コード例 #12
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()
コード例 #13
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()
コード例 #14
0
ファイル: tex_compiler.py プロジェクト: robol/tex-compiler
    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)
コード例 #15
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()
コード例 #16
0
    def getPlayFrames(self, frmaIndex):
        elements = []
        # frame 1
        if frmaIndex == 0:
            elem1 = playElement("Img0", "image", "img0.jpg", 800, 600, 0, 0)
            elements.append(elem1)
            elem2 = playElement("img1", "image", "img1.jpg", 500, 300, 50, 50)
            elements.append(elem2)
            elem3 = playElement("pdf0", "pdf", "OsmoManual_v1.0_en.pdf", 500,
                                700, 300, 0)
            elements.append(elem3)
        # frame 3
        if frmaIndex == 1:
            elem1 = playElement("Img5", "image", "img5.jpg", 800, 600, 0, 0)
            elements.append(elem1)
            elem2 = playElement("Video1", "video", "Video1280x720b.mp4", 500,
                                300, 0, 0)
            elements.append(elem2)
        # frame 2
        if frmaIndex == 2:
            elem1 = playElement("Img2", "image", "img2.jpg", 800, 600, 10, 10)
            elements.append(elem1)
            # elem2 = playElement("Video2", "video", "Wildlife.mp4", 640, 480, 100, 10)
            # elements.append(elem2)
            elem2 = playElement("webview1", "web", "http://api.jquery.com",
                                700, 500, 10, 10)
            elements.append(elem2)
            elem3 = playElement("ticker1", "ticker", "香港九龍尖沙咀東麼地道", 800, 100,
                                0, 500)
            elements.append(elem3)

        if self.EvinceDocumentInit is not True:
            EvinceDocument.init()
        if self.GstInit is not True:
            Gst.init(None)

        return layoutBox(elements)
コード例 #17
0
ファイル: tex_compiler.py プロジェクト: 106ohm/zsrt
	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)
コード例 #18
0
ファイル: pulp.py プロジェクト: roidocampo/pulp
 def load_doc(self, mime, path, orig_doc_view=None):
     if mime != 'image/vnd.djvu':
         try:
             doc = EvinceDocument.backends_manager_get_document(mime)
             doc.load('file://' + path)
             return doc, path
         except:
             pass
     safe_path = ''.join([random.choice("abcdefghijklmnopqrstuvwxyz") for _ in range(8)])
     safe_path += str(int(time.time()*1000000)) + "z"
     safe_path = os.path.join(self.tempdir, safe_path)
     if mime == 'application/x-dvi':
         if orig_doc_view is None:
             env = os.environ.copy()
             env['PATH'] = '/usr/local/bin:' + env['PATH'] + ':/Library/TeX/texbin'
             subprocess.call(('dvipdf', path, safe_path), env=env)
         else:
             os.symlink(orig_doc_view.path, safe_path)
         mime = 'application/pdf'
     else:
         os.symlink(path, safe_path)
     doc = EvinceDocument.backends_manager_get_document(mime)
     doc.load('file://' + safe_path)
     return doc, safe_path
コード例 #19
0
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

import os

from constants import DATA_DIR
from periodic_elements import ELEMENTS_DATA

import gi
gi.require_version("Gtk", "3.0")

from gi.repository import Gtk
from gi.repository import EvinceDocument
from gi.repository import EvinceView

EvinceDocument.init()


class PDFViewer(EvinceView.View):
    def __init__(self):
        EvinceView.View.__init__(self)

        self.model = None

    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)

コード例 #20
0
ファイル: pdfreader.py プロジェクト: am-rakesh/pdfreader
    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)
コード例 #21
0
 def build_ui(self):
     self.gridMain = Gtk.Grid()
     self.add(self.gridMain)
     # Add the listbox in a scrolled window
     self.swLB = Gtk.ScrolledWindow()
     self.gridLB = Gtk.Grid()
     self.gridLB.set_hexpand(True)
     self.swLB.add(self.gridLB)
     if bLBScrollWidth:
         self.swLB.set_policy(Gtk.PolicyType.AUTOMATIC,
                              Gtk.PolicyType.AUTOMATIC)
     else:
         self.swLB.set_policy(Gtk.PolicyType.NEVER,
                              Gtk.PolicyType.AUTOMATIC)
     self.lbMain = Gtk.ListBox()
     self.lbMain.set_hexpand(True)
     #self.lbMain.set_vexpand(True)
     self.lbLabel = Gtk.Label()
     self.lbLabel.set_label("Vasudhaiva Kutumbakam")
     self.lbLabel.set_hexpand(True)
     self.lbLabel.set_halign(Gtk.Align.START)
     self.gridLB.attach(self.lbMain, 0, 1, 1, 8)
     self.gridLB.attach(self.lbLabel, 0, 0, 1, 1)
     self.gridMain.attach(self.swLB, 1, 1, 4, 9)
     self.update_lb()
     self.lbMain.connect("row-activated", self.on_lb_row_activated)
     self.lbMain.connect("button-release-event", self.on_lb_button_release)
     # Added a separator
     self.vSep = Gtk.VSeparator()
     self.gridMain.attach(self.vSep, 5, 2, 1, 7)
     # Add a WebView
     self.wvMain = WebKit2.WebView()
     self.wvMain.load_html(
         "<html> <head><title> Browser </title></head> <body> <center> Satyameva Jayate </center> </body> </html>"
     )
     # Add the content views' scrolling window
     self.swMain = Gtk.ScrolledWindow()
     self.swMain.set_policy(Gtk.PolicyType.AUTOMATIC,
                            Gtk.PolicyType.AUTOMATIC)
     self.swMain.add(self.wvMain)
     self.gridMain.attach(self.swMain, 6, 1, 9, 9)
     # Add EvinceView
     self.evMain = None
     EvinceDocument.init()
     self.evDoc = None
     # Add the buttons
     self.btnBase = Gtk.Button(label="Base")
     self.btnBase.connect("clicked", self.on_btn_clicked)
     self.gridMain.attach(self.btnBase, 12, 10, 1, 1)
     self.btnLast = Gtk.Button(label="Last")
     self.btnLast.connect("clicked", self.on_btn_clicked)
     self.gridMain.attach(self.btnLast, 13, 10, 1, 1)
     self.btnHide = Gtk.Button(label="[Un]Hide")
     self.btnHide.connect("clicked", self.on_btn_clicked)
     self.gridMain.attach(self.btnHide, 14, 10, 1, 1)
     self.btnUp = Gtk.Button(label="Up")
     self.btnUp.connect("clicked", self.on_btn_clicked)
     self.gridMain.attach(self.btnUp, 6, 10, 1, 1)
     self.btnPrev = Gtk.Button(label="Prev")
     self.btnPrev.connect("clicked", self.on_btn_clicked)
     self.gridMain.attach(self.btnPrev, 7, 10, 1, 1)
     self.btnPlay = Gtk.Button(label="Play")
     self.btnPlay.connect("clicked", self.on_btn_clicked)
     self.gridMain.attach(self.btnPlay, 8, 10, 1, 1)
     self.btnNext = Gtk.Button(label="Next")
     self.btnNext.connect("clicked", self.on_btn_clicked)
     self.gridMain.attach(self.btnNext, 9, 10, 1, 1)
コード例 #22
0
ファイル: read_pdf_index.py プロジェクト: godiard/many-tests
from gi.repository import Gtk
from gi.repository import EvinceDocument
from gi.repository import EvinceView

EvinceDocument.init()

doc =  EvinceDocument.Document.factory_get_document('file:///home/gonzalo/Desktop/Libros/La_gran_manzana.pdf')

def job_finished_cb(job):
    model = job.get_model()
    _iter = model.get_iter_first()
    while True:
        value = model.get_value(_iter, 0)
        print value, model.get_value(_iter, 1)
        _iter = model.iter_next(_iter)
        if _iter is None:
            break

view = EvinceView.View()

model = EvinceView.DocumentModel()
model.set_document(doc)
view.set_model(model)

if not doc.has_document_links():
    print 'The pdf file does not have a index'
else:
    jl = EvinceView.JobLinks.new(document=doc)
    jl.connect('finished', job_finished_cb)
    EvinceView.Job.scheduler_push_job(jl, EvinceView.JobPriority.PRIORITY_NONE)
コード例 #23
0
from nexmark import app
from gi.repository import Gtk, EvinceView as EvView, EvinceDocument as EvDocument

EvDocument.init()


class EvinceView(Gtk.ScrolledWindow):
    def __init__(self):
        super().__init__()
        self.viewer = EvView.View()
        self.add(self.viewer)

    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)
コード例 #24
0
ファイル: evinceadapter.py プロジェクト: quozl/read-activity
 def __init__(self):
     self._view_notify_zoom_handler = None
     EvinceDocument.init()
     self._view = EvinceView.View()