text zoom: Put a limit on the min and max zoom (#137)
Text zoom: Put a limit on the min and max zoom
This commit is contained in:
parent
87eb14e9dc
commit
9376dc72da
|
@ -24,6 +24,9 @@
|
||||||
from .signals import Signals
|
from .signals import Signals
|
||||||
from gi.repository import Gtk, Gdk, Pango
|
from gi.repository import Gtk, Gdk, Pango
|
||||||
|
|
||||||
|
MAX_FONT_SIZE = 30
|
||||||
|
MIN_FONT_SIZE = 5
|
||||||
|
|
||||||
class DocumentHelper(Signals):
|
class DocumentHelper(Signals):
|
||||||
def __init__(self, view):
|
def __init__(self, view):
|
||||||
Signals.__init__(self)
|
Signals.__init__(self)
|
||||||
|
@ -94,6 +97,11 @@ class DocumentHelper(Signals):
|
||||||
size = description.get_size() / Pango.SCALE
|
size = description.get_size() / Pango.SCALE
|
||||||
|
|
||||||
if not bounds:
|
if not bounds:
|
||||||
|
if size >= MAX_FONT_SIZE and amount == 1:
|
||||||
|
return;
|
||||||
|
if size <= MIN_FONT_SIZE and amount == -1:
|
||||||
|
return;
|
||||||
|
|
||||||
description.set_size(max(1, (size + amount)) * Pango.SCALE)
|
description.set_size(max(1, (size + amount)) * Pango.SCALE)
|
||||||
|
|
||||||
self._view.override_font(description)
|
self._view.override_font(description)
|
||||||
|
@ -117,6 +125,11 @@ class DocumentHelper(Signals):
|
||||||
|
|
||||||
newsize = round(newsize / len(tags))
|
newsize = round(newsize / len(tags))
|
||||||
|
|
||||||
|
if newsize >= MAX_FONT_SIZE and amount == 1:
|
||||||
|
return;
|
||||||
|
if newsize <= MIN_FONT_SIZE and amount == -1:
|
||||||
|
return;
|
||||||
|
|
||||||
newsize = int(max(1, newsize))
|
newsize = int(max(1, newsize))
|
||||||
|
|
||||||
if not newsize in self._font_tags:
|
if not newsize in self._font_tags:
|
||||||
|
|
Loading…
Reference in New Issue