Set text view padding in Python instead of CSS

Otherwise scrolling calculations will be slightly offset, as the CSS
padding is added *on top* of any other margin.
github/fork/yochananmarqos/patch-1
Gonçalo Silva 2019-04-20 05:09:02 +01:00
parent 81f9104d9f
commit ddcf76df47
3 changed files with 7 additions and 11 deletions

View File

@ -31,8 +31,6 @@
.uberwriter-window .uberwriter-editor {
font-family: 'Fira Mono', monospace;
font-size: 16px;
padding-top: 80px;
padding-bottom: 16px;
}
.uberwriter-window.small .uberwriter-editor {

View File

@ -84,8 +84,6 @@ class TextView(Gtk.TextView):
# Focus mode
self.focus_mode = False
self.original_top_margin = self.props.top_margin
self.original_bottom_margin = self.props.bottom_margin
self.connect('button-release-event', self.on_button_release_event)
# Hemingway mode
@ -127,8 +125,8 @@ class TextView(Gtk.TextView):
self.props.top_margin = height / 2
self.props.bottom_margin = height / 2
else:
self.props.top_margin = self.original_top_margin
self.props.bottom_margin = self.original_bottom_margin
self.props.top_margin = 80
self.props.bottom_margin = 64
def on_button_release_event(self, _widget, _event):
if self.focus_mode:
@ -159,7 +157,7 @@ class TextView(Gtk.TextView):
If mark is unspecified, the cursor is used."""
margin = 80
margin = 32
scrolled_window = self.get_ancestor(Gtk.ScrolledWindow.__gtype__)
if not scrolled_window:
return

View File

@ -701,7 +701,7 @@ class Window(Gtk.ApplicationWindow):
"""
bg_color = self.get_style_context().get_background_color(Gtk.StateFlags.ACTIVE)
lg_top = cairo.LinearGradient(0, 0, 0, 35) # pylint: disable=no-member
lg_top = cairo.LinearGradient(0, 0, 0, 32) # pylint: disable=no-member
lg_top.add_color_stop_rgba(
0, bg_color.red, bg_color.green, bg_color.blue, 1)
lg_top.add_color_stop_rgba(
@ -710,12 +710,12 @@ class Window(Gtk.ApplicationWindow):
width = self.scrolled_window.get_allocation().width
height = self.scrolled_window.get_allocation().height
cr.rectangle(0, 0, width, 35)
cr.rectangle(0, 0, width, 32)
cr.set_source(lg_top)
cr.fill()
cr.rectangle(0, height - 35, width, height)
cr.rectangle(0, height - 32, width, height)
lg_btm = cairo.LinearGradient(0, height - 35, 0, height) # pylint: disable=no-member
lg_btm = cairo.LinearGradient(0, height - 32, 0, height) # pylint: disable=no-member
lg_btm.add_color_stop_rgba(
1, bg_color.red, bg_color.green, bg_color.blue, 1)
lg_btm.add_color_stop_rgba(