screen: Put font size setting into KlippyGtk
This commit is contained in:
parent
857b4a9bab
commit
36aaece846
@ -15,7 +15,7 @@ class KlippyGtk:
|
||||
width_ratio = 16
|
||||
height_ratio = 9.375
|
||||
|
||||
def __init__(self, screen, width, height, theme, cursor):
|
||||
def __init__(self, screen, width, height, theme, cursor, fontsize_type):
|
||||
self.screen = screen
|
||||
self.width = width
|
||||
self.height = height
|
||||
@ -24,6 +24,10 @@ class KlippyGtk:
|
||||
self.width / self.font_ratio[0],
|
||||
self.height / self.font_ratio[1]
|
||||
))
|
||||
if fontsize_type == "small":
|
||||
self.font_size = round(self.font_size * 0.91)
|
||||
elif (fontsize_type == "large"):
|
||||
self.font_size = round(self.font_size * 1.09)
|
||||
self.header_size = int(round((self.width / self.width_ratio) / 1.33))
|
||||
self.img_width = int(round(self.width / self.width_ratio))
|
||||
self.img_height = int(round(self.height / self.height_ratio))
|
||||
|
@ -17,7 +17,7 @@ class BasePanel(ScreenPanel):
|
||||
self.current_panel = None
|
||||
self.time_min = -1
|
||||
self.time_format = self._config.get_main_config_option("24htime")
|
||||
self.title_spacing = self._screen.font_size * 2
|
||||
self.title_spacing = self._gtk.font_size * 2
|
||||
|
||||
self.buttons_showing = {
|
||||
'back': False if back else True,
|
||||
|
12
screen.py
12
screen.py
@ -123,7 +123,8 @@ class KlipperScreen(Gtk.Window):
|
||||
|
||||
self.theme = self._config.get_main_config_option('theme')
|
||||
self.gtk = KlippyGtk(self, self.width, self.height, self.theme,
|
||||
self._config.get_main_config().getboolean("show_cursor", fallback=False))
|
||||
self._config.get_main_config().getboolean("show_cursor", fallback=False),
|
||||
self._config.get_main_config_option("font_size", "medium"))
|
||||
self.keyboard_height = self.gtk.get_keyboard_height()
|
||||
self.init_style()
|
||||
|
||||
@ -440,14 +441,7 @@ class KlipperScreen(Gtk.Window):
|
||||
css_data = css_base_data + css.read()
|
||||
css.close()
|
||||
|
||||
self.font_size = self.gtk.get_font_size()
|
||||
fontsize_type = self._config.get_main_config_option("font_size", "medium")
|
||||
if fontsize_type != "medium":
|
||||
if fontsize_type == "small":
|
||||
self.font_size = round(self.font_size * 0.91)
|
||||
elif (fontsize_type == "large"):
|
||||
self.font_size = round(self.font_size * 1.09)
|
||||
css_data = css_data.replace("KS_FONT_SIZE", str(self.font_size))
|
||||
css_data = css_data.replace("KS_FONT_SIZE", str(self.gtk.get_font_size()))
|
||||
|
||||
style_provider = Gtk.CssProvider()
|
||||
style_provider.load_from_data(css_data.encode())
|
||||
|
Loading…
x
Reference in New Issue
Block a user