<commit_before>
# --------------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <<EMAIL>> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return -<NAME>
# --------------------------------------------------------------------------------

import gtk
import poppler


class pdfpane:
	
	def __init__(self):

		self.pdffile = None
		self.drawarea = None
		self.page_displayed = 0
		self.page_total = None
		
		self.scale = 1
		self.maxscale = 1.6 
		self.minscale = 1.0	
		self.scale_rate = 0.1

	def create_previewpane(self, pdffile, drawarea):
		self.pdffile = pdffile
		self.drawarea = drawarea	
		self.uri = "file://" + pdffile
		self.document = poppler.document_new_from_file(self.uri, None)
		self.page_total = self.document.get_n_pages()
		self.current_page = self.document.get_page(self.page_displayed)
		self.width, self.height = self.current_page.get_size()
		self.drawarea.set_size_request(int(self.width), int(self.height))
		self.drawarea.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(6400, 6400, 6440))
		self.drawarea.connect("expose-event", self.on_expose)

	def refresh_previewpane(self):
		self.drawarea.show()
		self.uri = "file://" + self.pdffile
		self.document = poppler.document_new_from_file(self.uri, None)
		self.page_total = self.document.get_n_pages()
		self.current_page = self.document.get_page(self.page_displayed)
		self.drawarea.queue_draw() 

	def jump_to_nextpage(self):
		if (self.page_displayed + 1) < self.page_total:
			self.page_displayed = self.page_displayed + 1
			self.uri = "file://" + self.pdffile
			self.document = poppler.document_new_from_file(self.uri, None)
			self.page_total = self.document.get_n_pages()
			self.current_page = self.document.get_page(self.page_displayed)
			self.drawarea.queue_draw()
		
	def jump_to_prevpage(self):
		if (self.page_displayed - 1) >= 0:
			self.page_displayed = self.page_displayed - 1
			self.uri = "file://" + self.pdffile
			self.document = poppler.document_new_from_file(self.uri, None)
			self.page_total = self.document.get_n_pages()
			self.current_page = self.document.get_page(self.page_displayed)<commit_msg>fixed preview render crash when pages were removed<commit_after>
# --------------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <<EMAIL>> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return -<NAME>
# --------------------------------------------------------------------------------

import gtk
import poppler


class pdfpane:
	
	def __init__(self):

		self.pdffile = None
		self.drawarea = None
		self.page_displayed = 0
		self.page_total = None
		
		self.scale = 1
		self.maxscale = 1.6 
		self.minscale = 1.0	
		self.scale_rate = 0.1

	def create_previewpane(self, pdffile, drawarea):
		self.pdffile = pdffile
		self.drawarea = drawarea	
		self.uri = "file://" + pdffile
		self.document = poppler.document_new_from_file(self.uri, None)
		self.page_total = self.document.get_n_pages()
		self.current_page = self.document.get_page(self.page_displayed)
		self.width, self.height = self.current_page.get_size()
		self.drawarea.set_size_request(int(self.width), int(self.height))
		self.drawarea.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(6400, 6400, 6440))
		self.drawarea.connect("expose-event", self.on_expose)

	def refresh_previewpane(self):
		self.drawarea.show()
		self.uri = "file://" + self.pdffile
		self.document = poppler.document_new_from_file(self.uri, None)
		self.page_total = self.document.get_n_pages()
		if self.page_total <= (self.page_displayed):
			self.current_page = self.document.get_page(self.page_total - 1)
		else:		
			self.current_page = self.document.get_page(self.page_displayed)
		self.drawarea.queue_draw() 

	def jump_to_nextpage(self):
		if (self.page_displayed + 1) < self.page_total:
			self.page_displayed = self.page_displayed + 1
			self.uri = "file://" + self.pdffile
			self.document = poppler.document_new_from_file(self.uri, None)
			self.page_total = self.document.get_n_pages()
			self.current_page = self.document.get_page(self.page_displayed)
			self.drawarea.queue_draw()
		
	def jump_to_prevpage(self):
		if (self.page_displayed - 1) >= 0:
			self.page_displayed = self.page_displayed - 1
			self.uri = "file://" + self.pdffile
			self.document = poppler.document_new_from_file(self.uri, None)
			self.page_total = self.document.get_n_pages()
			self.current_page = self.document.get_page(self.page_displayed)
{'fraction_non_alphanumeric': 0.1783761043331931, 'fraction_numerical': 0.011569204880100967, 'mean_word_length': 3.0262489415749365, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6463238', 'n_tokens_mistral': 1789, 'n_tokens_neox': 1636, 'n_words': 321}