small fixes

This commit is contained in:
LunarEclipse 2024-04-28 15:06:23 +02:00
parent e526de786e
commit 968f18e107
2 changed files with 39 additions and 37 deletions

View File

@ -202,7 +202,12 @@
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="position">800</property> <property name="position">800</property>
<child> <child>
<object class="GtkViewport" id="viewport1"> <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<child> <child>
@ -245,9 +250,11 @@
</object> </object>
</child> </child>
</object> </object>
</child>
</object>
<packing> <packing>
<property name="resize">True</property> <property name="resize">True</property>
<property name="shrink">True</property> <property name="shrink">False</property>
</packing> </packing>
</child> </child>
<child> <child>

View File

@ -41,7 +41,6 @@ class PdfPage(Gtk.DrawingArea):
self.page: fitz.Page = page self.page: fitz.Page = page
pix = self.page.get_pixmap(dpi=96) # type: ignore pix = self.page.get_pixmap(dpi=96) # type: ignore
self.set_size_request(pix.width, pix.height) self.set_size_request(pix.width, pix.height)
print(f"w: {pix.width}, h: {pix.height}")
self.set_app_paintable(True) # type: ignore self.set_app_paintable(True) # type: ignore
self.connect("draw", self.on_draw, {}) self.connect("draw", self.on_draw, {})
@ -49,7 +48,9 @@ class PdfPage(Gtk.DrawingArea):
# app: Application = widget.get_window().get_application() # type: ignore # app: Application = widget.get_window().get_application() # type: ignore
width = widget.get_allocated_width() width = widget.get_allocated_width()
height = widget.get_allocated_height() height = widget.get_allocated_height()
print(f"alloc w: {width}, h: {height}")
cr.set_source_rgba(255, 255, 255)
cr.paint()
sctx = widget.get_style_context() sctx = widget.get_style_context()
Gtk.render_background(sctx, cr, 0, 0, width, height) Gtk.render_background(sctx, cr, 0, 0, width, height)
@ -59,12 +60,6 @@ class PdfPage(Gtk.DrawingArea):
cr.set_source_surface(ims, 0, 0) cr.set_source_surface(ims, 0, 0)
cr.paint() cr.paint()
cr.set_source_rgba(255, 0, 0)
cr.set_line_width(10)
cr.move_to(0, 0)
cr.line_to(width, height)
cr.stroke()
@Gtk.Template.from_file("MainWindow.glade") @Gtk.Template.from_file("MainWindow.glade")
class MainWindow(Gtk.ApplicationWindow): class MainWindow(Gtk.ApplicationWindow):