base_panel: layout simplification
This commit is contained in:
parent
05b25cda15
commit
da26bf3143
@ -33,6 +33,7 @@ class KlippyGtk:
|
|||||||
elif fontsize_type == "large":
|
elif fontsize_type == "large":
|
||||||
self.font_size = round(self.font_size * 1.09)
|
self.font_size = round(self.font_size * 1.09)
|
||||||
self.header_size = int(round((self.width / self.width_ratio) / 1.33))
|
self.header_size = int(round((self.width / self.width_ratio) / 1.33))
|
||||||
|
self.titlebar_height = self.font_size * 2
|
||||||
self.img_width = int(round(self.width / self.width_ratio))
|
self.img_width = int(round(self.width / self.width_ratio))
|
||||||
self.img_height = int(round(self.height / self.height_ratio))
|
self.img_height = int(round(self.height / self.height_ratio))
|
||||||
if self.screen.vertical_mode:
|
if self.screen.vertical_mode:
|
||||||
@ -62,11 +63,17 @@ class KlippyGtk:
|
|||||||
return self.width - self.action_bar_width
|
return self.width - self.action_bar_width
|
||||||
|
|
||||||
def get_content_height(self):
|
def get_content_height(self):
|
||||||
return self.height - self.header_size
|
if self.screen.vertical_mode:
|
||||||
|
return self.height - self.titlebar_height - self.action_bar_height
|
||||||
|
else:
|
||||||
|
return self.height - self.titlebar_height
|
||||||
|
|
||||||
def get_font_size(self):
|
def get_font_size(self):
|
||||||
return self.font_size
|
return self.font_size
|
||||||
|
|
||||||
|
def get_titlebar_height(self):
|
||||||
|
return self.titlebar_height
|
||||||
|
|
||||||
def get_header_size(self):
|
def get_header_size(self):
|
||||||
return self.header_size
|
return self.header_size
|
||||||
|
|
||||||
|
@ -25,7 +25,9 @@ class ScreenPanel:
|
|||||||
self.layout = Gtk.Layout()
|
self.layout = Gtk.Layout()
|
||||||
self.layout.set_size(self._screen.width, self._screen.height)
|
self.layout.set_size(self._screen.width, self._screen.height)
|
||||||
|
|
||||||
self.content = Gtk.Box(spacing=0)
|
self.content = Gtk.VBox(spacing=0)
|
||||||
|
self.content.set_hexpand(True)
|
||||||
|
self.content.set_vexpand(True)
|
||||||
|
|
||||||
def initialize(self, panel_name):
|
def initialize(self, panel_name):
|
||||||
# Create gtk items here
|
# Create gtk items here
|
||||||
|
@ -16,25 +16,15 @@ class BasePanel(ScreenPanel):
|
|||||||
self.current_panel = None
|
self.current_panel = None
|
||||||
self.time_min = -1
|
self.time_min = -1
|
||||||
self.time_format = self._config.get_main_config_option("24htime")
|
self.time_format = self._config.get_main_config_option("24htime")
|
||||||
self.title_spacing = self._gtk.font_size * 2
|
|
||||||
self.time_update = None
|
self.time_update = None
|
||||||
self.titlebar_name_type = None
|
self.titlebar_name_type = None
|
||||||
self.buttons_showing = {
|
self.buttons_showing = {
|
||||||
'back': False if back else True,
|
'back': not(back),
|
||||||
'macros_shortcut': False,
|
'macros_shortcut': False,
|
||||||
'printer_select': False
|
'printer_select': False
|
||||||
}
|
}
|
||||||
|
|
||||||
self.layout = Gtk.Layout()
|
# Action bar buttons
|
||||||
self.layout.set_size(self._screen.width, self._screen.height)
|
|
||||||
|
|
||||||
action_bar_width = self._gtk.get_action_bar_width() if action_bar is True else 0
|
|
||||||
action_bar_height = self._gtk.get_action_bar_height() if action_bar is True else 0
|
|
||||||
|
|
||||||
self.control_grid = self._gtk.HomogeneousGrid()
|
|
||||||
self.control_grid.set_size_request(action_bar_width, action_bar_height)
|
|
||||||
self.control_grid.get_style_context().add_class('action_bar')
|
|
||||||
|
|
||||||
self.control['back'] = self._gtk.ButtonImage('back', None, None, 1)
|
self.control['back'] = self._gtk.ButtonImage('back', None, None, 1)
|
||||||
self.control['back'].connect("clicked", self.back)
|
self.control['back'].connect("clicked", self.back)
|
||||||
self.control['home'] = self._gtk.ButtonImage('main', None, None, 1)
|
self.control['home'] = self._gtk.ButtonImage('main', None, None, 1)
|
||||||
@ -44,8 +34,8 @@ class BasePanel(ScreenPanel):
|
|||||||
self.control['printer_select'] = self._gtk.ButtonImage('shuffle', None, None, 1)
|
self.control['printer_select'] = self._gtk.ButtonImage('shuffle', None, None, 1)
|
||||||
self.control['printer_select'].connect("clicked", self._screen.show_printer_select)
|
self.control['printer_select'].connect("clicked", self._screen.show_printer_select)
|
||||||
|
|
||||||
self.control['macro_shortcut'] = self._gtk.ButtonImage('custom-script', None, None, 1)
|
self.control['macros_shortcut'] = self._gtk.ButtonImage('custom-script', None, None, 1)
|
||||||
self.control['macro_shortcut'].connect("clicked", self.menu_item_clicked, "gcode_macros", {
|
self.control['macros_shortcut'].connect("clicked", self.menu_item_clicked, "gcode_macros", {
|
||||||
"name": "Macros",
|
"name": "Macros",
|
||||||
"panel": "gcode_macros"
|
"panel": "gcode_macros"
|
||||||
})
|
})
|
||||||
@ -53,87 +43,77 @@ class BasePanel(ScreenPanel):
|
|||||||
self.control['estop'] = self._gtk.ButtonImage('emergency', None, None, 1)
|
self.control['estop'] = self._gtk.ButtonImage('emergency', None, None, 1)
|
||||||
self.control['estop'].connect("clicked", self.emergency_stop)
|
self.control['estop'].connect("clicked", self.emergency_stop)
|
||||||
|
|
||||||
self.locations = {
|
# Action bar
|
||||||
'macro_shortcut': 2,
|
self.action_bar = Gtk.VBox(spacing=5)
|
||||||
'printer_select': 2
|
|
||||||
}
|
|
||||||
button_range = 3
|
|
||||||
if len(self._config.get_printers()) > 1:
|
|
||||||
self.locations['macro_shortcut'] = 3
|
|
||||||
if self._config.get_main_config_option('side_macro_shortcut') == "True":
|
|
||||||
button_range = 4
|
|
||||||
|
|
||||||
for i in range(button_range):
|
|
||||||
self.control['space%s' % i] = Gtk.Label("")
|
|
||||||
if self._screen.vertical_mode:
|
|
||||||
self.control_grid.attach(self.control['space%s' % i], i, 0, 1, 1)
|
|
||||||
else:
|
|
||||||
self.control_grid.attach(self.control['space%s' % i], 0, i, 1, 1)
|
|
||||||
if self._screen.vertical_mode:
|
if self._screen.vertical_mode:
|
||||||
self.control_grid.attach(self.control['estop'], 4, 0, 1, 1)
|
self.action_bar.set_hexpand(True)
|
||||||
|
self.action_bar.set_vexpand(False)
|
||||||
|
self.action_bar.set_size_request(0, self._gtk.get_action_bar_height())
|
||||||
else:
|
else:
|
||||||
self.control_grid.attach(self.control['estop'], 0, 4, 1, 1)
|
self.action_bar.set_hexpand(False)
|
||||||
|
self.action_bar.set_vexpand(True)
|
||||||
|
self.action_bar.set_size_request(self._gtk.get_action_bar_width(), 0)
|
||||||
|
|
||||||
try:
|
self.action_bar.get_style_context().add_class('action_bar')
|
||||||
env = Environment(extensions=["jinja2.ext.i18n"])
|
self.action_bar.add(self.control['back'])
|
||||||
env.install_gettext_translations(self.lang)
|
self.action_bar.add(self.control['home'])
|
||||||
j2_temp = env.from_string(title)
|
if len(self._config.get_printers()) > 1:
|
||||||
title = j2_temp.render()
|
self.action_bar.add(self.control['printer_select'])
|
||||||
except Exception:
|
self.action_bar.add(self.control['macros_shortcut'])
|
||||||
logging.debug("Error parsing jinja for title: %s" % title)
|
self.action_bar.add(self.control['estop'])
|
||||||
|
|
||||||
|
# Titlebar
|
||||||
|
|
||||||
|
# This box will be populated by show_heaters
|
||||||
|
self.control['temp_box'] = Gtk.Box(spacing=10)
|
||||||
|
|
||||||
self.titlelbl = Gtk.Label()
|
self.titlelbl = Gtk.Label()
|
||||||
self.titlelbl.set_hexpand(True)
|
self.titlelbl.set_hexpand(True)
|
||||||
self.titlelbl.set_vexpand(True)
|
|
||||||
self.titlelbl.set_halign(Gtk.Align.CENTER)
|
self.titlelbl.set_halign(Gtk.Align.CENTER)
|
||||||
self.titlelbl.set_ellipsize(Pango.EllipsizeMode.END)
|
self.titlelbl.set_ellipsize(Pango.EllipsizeMode.END)
|
||||||
self.set_title(title)
|
self.set_title(title)
|
||||||
|
|
||||||
self.hmargin = 5
|
self.control['time'] = Gtk.Label("00:00 AM")
|
||||||
self.content = Gtk.VBox(spacing=0)
|
|
||||||
if self._screen.vertical_mode:
|
|
||||||
self.content.set_size_request(self._screen.width - self.hmargin * 2,
|
|
||||||
self._screen.height - self.title_spacing - action_bar_height)
|
|
||||||
else:
|
|
||||||
self.content.set_size_request(self._screen.width - action_bar_width - self.hmargin,
|
|
||||||
self._screen.height - self.title_spacing)
|
|
||||||
|
|
||||||
if action_bar is True:
|
|
||||||
if self._screen.vertical_mode:
|
|
||||||
self.layout.put(self.control_grid, 0, self._screen.height - action_bar_height)
|
|
||||||
else:
|
|
||||||
self.layout.put(self.control_grid, 0, 0)
|
|
||||||
|
|
||||||
self.control['time_box'] = Gtk.Box()
|
self.control['time_box'] = Gtk.Box()
|
||||||
self.control['time_box'].set_halign(Gtk.Align.END)
|
self.control['time_box'].set_halign(Gtk.Align.END)
|
||||||
self.control['time'] = Gtk.Label("00:00 AM")
|
self.control['time_box'].pack_end(self.control['time'], True, True, 5)
|
||||||
self.control['time_box'].pack_end(self.control['time'], True, True, self.hmargin)
|
|
||||||
|
|
||||||
self.control['temp_box'] = Gtk.Box()
|
self.titlebar = Gtk.HBox(spacing=5)
|
||||||
|
self.titlebar.set_size_request(0, self._gtk.get_titlebar_height())
|
||||||
self.titlebar = Gtk.Grid()
|
|
||||||
self.titlebar.set_valign(Gtk.Align.CENTER)
|
self.titlebar.set_valign(Gtk.Align.CENTER)
|
||||||
self.titlebar.set_property("column-spacing", 5)
|
self.titlebar.add(self.control['temp_box'])
|
||||||
if self._screen.vertical_mode:
|
self.titlebar.add(self.titlelbl)
|
||||||
self.titlebar.set_size_request(self._screen.width, self.title_spacing)
|
self.titlebar.add(self.control['time_box'])
|
||||||
else:
|
|
||||||
self.titlebar.set_size_request(self._screen.width - action_bar_width, self.title_spacing)
|
# Main layout
|
||||||
self.titlebar.attach(self.control['temp_box'], 0, 0, 1, 1)
|
self.main_grid = Gtk.Grid()
|
||||||
self.titlebar.attach(self.titlelbl, 1, 0, 1, 1)
|
# To achieve rezisability this needs to be removed
|
||||||
self.titlebar.attach(self.control['time_box'], 2, 0, 1, 1)
|
# The main issue is that currently the content doesn't expand correctly
|
||||||
|
self.main_grid.set_size_request(self._screen.width, self._screen.height)
|
||||||
|
|
||||||
if self._screen.vertical_mode:
|
if self._screen.vertical_mode:
|
||||||
self.layout.put(self.titlebar, 0, 0)
|
self.main_grid.attach(self.titlebar, 0, 0, 1, 1)
|
||||||
self.layout.put(self.content, self.hmargin, self.title_spacing)
|
self.main_grid.attach(self.content, 0, 1, 1, 1)
|
||||||
|
self.main_grid.attach(self.action_bar, 0, 2, 1, 1)
|
||||||
|
self.action_bar.set_orientation(orientation=Gtk.Orientation.HORIZONTAL)
|
||||||
else:
|
else:
|
||||||
self.layout.put(self.titlebar, action_bar_width, 0)
|
self.main_grid.attach(self.action_bar, 0, 0, 1, 2)
|
||||||
self.layout.put(self.content, action_bar_width + self.hmargin, self.title_spacing)
|
self.action_bar.set_orientation(orientation=Gtk.Orientation.VERTICAL)
|
||||||
|
self.main_grid.attach(self.titlebar, 1, 0, 1, 1)
|
||||||
|
self.main_grid.attach(self.content, 1, 1, 1, 1)
|
||||||
|
|
||||||
|
# Layout is and content are on screen_panel
|
||||||
|
self.layout.add(self.main_grid)
|
||||||
|
|
||||||
def initialize(self, panel_name):
|
def initialize(self, panel_name):
|
||||||
self.update_time()
|
self.update_time()
|
||||||
return
|
return
|
||||||
|
|
||||||
def show_heaters(self, show=True):
|
def show_heaters(self, show=True):
|
||||||
|
printer_cfg = self._config.get_printer_config(self._screen.connected_printer)
|
||||||
|
self.titlebar_name_type = printer_cfg.get("titlebar_name_type", None)
|
||||||
|
logging.info("Titlebar name type: %s", self.titlebar_name_type)
|
||||||
|
|
||||||
for child in self.control['temp_box'].get_children():
|
for child in self.control['temp_box'].get_children():
|
||||||
self.control['temp_box'].remove(child)
|
self.control['temp_box'].remove(child)
|
||||||
|
|
||||||
@ -141,33 +121,36 @@ class BasePanel(ScreenPanel):
|
|||||||
return
|
return
|
||||||
|
|
||||||
for device in self._screen.printer.get_temp_store_devices():
|
for device in self._screen.printer.get_temp_store_devices():
|
||||||
logging.info(device)
|
|
||||||
self.labels[device + '_box'] = Gtk.Box(spacing=0)
|
|
||||||
self.labels[device] = Gtk.Label(label="100º")
|
|
||||||
self.labels[device].set_ellipsize(Pango.EllipsizeMode.START)
|
|
||||||
if device.startswith("extruder"):
|
if device.startswith("extruder"):
|
||||||
if self._screen.printer.extrudercount > 1:
|
if self._screen.printer.extrudercount > 1:
|
||||||
if device == "extruder":
|
if device == "extruder":
|
||||||
ext_img = self._gtk.Image("extruder-0", .5)
|
icon = self._gtk.Image("extruder-0", .5)
|
||||||
else:
|
else:
|
||||||
ext_img = self._gtk.Image("extruder-%s" % device[8:], .5)
|
icon = self._gtk.Image("extruder-%s" % device[8:], .5)
|
||||||
else:
|
else:
|
||||||
ext_img = self._gtk.Image("extruder", .5)
|
icon = self._gtk.Image("extruder", .5)
|
||||||
self.labels[device + '_box'].pack_start(ext_img, True, True, 3)
|
|
||||||
elif device.startswith("heater_bed"):
|
elif device.startswith("heater_bed"):
|
||||||
bed_img = self._gtk.Image("bed", .5)
|
icon = self._gtk.Image("bed", .5)
|
||||||
self.labels[device + '_box'].pack_start(bed_img, True, True, 3)
|
# Extra items
|
||||||
|
elif self.titlebar_name_type is not None:
|
||||||
|
# The item has a name, do not use an icon
|
||||||
|
icon = None
|
||||||
elif device.startswith("temperature_fan"):
|
elif device.startswith("temperature_fan"):
|
||||||
fan_img = self._gtk.Image("fan", .5)
|
icon = self._gtk.Image("fan", .5)
|
||||||
self.labels[device + '_box'].pack_start(fan_img, True, True, 3)
|
|
||||||
elif device.startswith("heater_generic"):
|
elif device.startswith("heater_generic"):
|
||||||
heat_img = self._gtk.Image("heater", .5)
|
icon = self._gtk.Image("heater", .5)
|
||||||
self.labels[device + '_box'].pack_start(heat_img, True, True, 3)
|
|
||||||
else:
|
else:
|
||||||
temp_img = self._gtk.Image("heat-up", .5)
|
icon = self._gtk.Image("heat-up", .5)
|
||||||
self.labels[device + '_box'].pack_start(temp_img, True, True, 3)
|
|
||||||
self.labels[device + '_box'].pack_start(self.labels[device], True, True, 0)
|
|
||||||
|
|
||||||
|
self.labels[device] = Gtk.Label(label="100º")
|
||||||
|
self.labels[device].set_ellipsize(Pango.EllipsizeMode.START)
|
||||||
|
|
||||||
|
self.labels[device + '_box'] = Gtk.Box()
|
||||||
|
if icon is not None:
|
||||||
|
self.labels[device + '_box'].pack_start(icon, False, False, 3)
|
||||||
|
self.labels[device + '_box'].pack_start(self.labels[device], False, False, 0)
|
||||||
|
|
||||||
|
# Limit the number of items according to resolution
|
||||||
if self._screen.width <= 480:
|
if self._screen.width <= 480:
|
||||||
nlimit = 3
|
nlimit = 3
|
||||||
elif self._screen.width <= 800:
|
elif self._screen.width <= 800:
|
||||||
@ -178,22 +161,19 @@ class BasePanel(ScreenPanel):
|
|||||||
n = 0
|
n = 0
|
||||||
if self._screen.printer.get_tools():
|
if self._screen.printer.get_tools():
|
||||||
self.current_extruder = self._screen.printer.get_stat("toolhead", "extruder")
|
self.current_extruder = self._screen.printer.get_stat("toolhead", "extruder")
|
||||||
self.control['temp_box'].pack_start(self.labels["%s_box" % self.current_extruder], True, True, 3)
|
self.control['temp_box'].add(self.labels["%s_box" % self.current_extruder])
|
||||||
n += 1
|
n += 1
|
||||||
|
|
||||||
if self._screen.printer.has_heated_bed():
|
if self._screen.printer.has_heated_bed():
|
||||||
self.control['temp_box'].pack_start(self.labels['heater_bed_box'], True, True, 3)
|
self.control['temp_box'].add(self.labels['heater_bed_box'])
|
||||||
n += 1
|
n += 1
|
||||||
|
|
||||||
# Options in the config have priority
|
# Options in the config have priority
|
||||||
printer_cfg = self._config.get_printer_config(self._screen.connected_printer)
|
|
||||||
if printer_cfg is not None:
|
if printer_cfg is not None:
|
||||||
titlebar_items = printer_cfg.get("titlebar_items", "")
|
titlebar_items = printer_cfg.get("titlebar_items", "")
|
||||||
if titlebar_items is not None:
|
if titlebar_items is not None:
|
||||||
titlebar_items = [str(i.strip()) for i in titlebar_items.split(',')]
|
titlebar_items = [str(i.strip()) for i in titlebar_items.split(',')]
|
||||||
logging.info("Titlebar items: %s", titlebar_items)
|
logging.info("Titlebar items: %s", titlebar_items)
|
||||||
self.titlebar_name_type = printer_cfg.get("titlebar_name_type", None)
|
|
||||||
logging.info("Titlebar name type: %s", self.titlebar_name_type)
|
|
||||||
for device in self._screen.printer.get_temp_store_devices():
|
for device in self._screen.printer.get_temp_store_devices():
|
||||||
# Users can fill the bar if they want
|
# Users can fill the bar if they want
|
||||||
if n >= nlimit + 1:
|
if n >= nlimit + 1:
|
||||||
@ -204,7 +184,7 @@ class BasePanel(ScreenPanel):
|
|||||||
name = device
|
name = device
|
||||||
for item in titlebar_items:
|
for item in titlebar_items:
|
||||||
if name == item:
|
if name == item:
|
||||||
self.control['temp_box'].pack_start(self.labels["%s_box" % device], True, True, 3)
|
self.control['temp_box'].add(self.labels["%s_box" % device])
|
||||||
n += 1
|
n += 1
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -213,7 +193,7 @@ class BasePanel(ScreenPanel):
|
|||||||
if n >= nlimit:
|
if n >= nlimit:
|
||||||
break
|
break
|
||||||
if device.startswith("heater_generic"):
|
if device.startswith("heater_generic"):
|
||||||
self.control['temp_box'].pack_start(self.labels["%s_box" % device], True, True, 3)
|
self.control['temp_box'].add(self.labels["%s_box" % device])
|
||||||
n += 1
|
n += 1
|
||||||
self.control['temp_box'].show_all()
|
self.control['temp_box'].show_all()
|
||||||
|
|
||||||
@ -230,8 +210,7 @@ class BasePanel(ScreenPanel):
|
|||||||
if self.current_panel is None:
|
if self.current_panel is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
if self._screen.is_keyboard_showing():
|
self._screen.remove_keyboard()
|
||||||
self._screen.remove_keyboard()
|
|
||||||
|
|
||||||
if hasattr(self.current_panel, "back"):
|
if hasattr(self.current_panel, "back"):
|
||||||
if not self.current_panel.back():
|
if not self.current_panel.back():
|
||||||
@ -239,9 +218,6 @@ class BasePanel(ScreenPanel):
|
|||||||
else:
|
else:
|
||||||
self._screen._menu_go_back()
|
self._screen._menu_go_back()
|
||||||
|
|
||||||
def get(self):
|
|
||||||
return self.layout
|
|
||||||
|
|
||||||
def process_update(self, action, data):
|
def process_update(self, action, data):
|
||||||
if action != "notify_status_update" or self._screen.printer is None:
|
if action != "notify_status_update" or self._screen.printer is None:
|
||||||
return
|
return
|
||||||
@ -249,14 +225,14 @@ class BasePanel(ScreenPanel):
|
|||||||
devices = self._screen.printer.get_temp_store_devices()
|
devices = self._screen.printer.get_temp_store_devices()
|
||||||
if devices is not None:
|
if devices is not None:
|
||||||
for device in devices:
|
for device in devices:
|
||||||
name = ""
|
|
||||||
if not (device.startswith("extruder") or device.startswith("heater_bed")):
|
|
||||||
if self.titlebar_name_type == "full":
|
|
||||||
name = device.split(" ")[1:][0].capitalize().replace("_", " ") + ": "
|
|
||||||
elif self.titlebar_name_type == "short":
|
|
||||||
name = device.split(" ")[1:][0][:1].upper() + ": "
|
|
||||||
temp = self._screen.printer.get_dev_stat(device, "temperature")
|
temp = self._screen.printer.get_dev_stat(device, "temperature")
|
||||||
if temp is not None:
|
if temp is not None:
|
||||||
|
name = ""
|
||||||
|
if not (device.startswith("extruder") or device.startswith("heater_bed")):
|
||||||
|
if self.titlebar_name_type == "full":
|
||||||
|
name = device.split(" ")[1:][0].capitalize().replace("_", " ") + ": "
|
||||||
|
elif self.titlebar_name_type == "short":
|
||||||
|
name = device.split(" ")[1:][0][:1].upper() + ": "
|
||||||
self.labels[device].set_label("%s%d°" % (name, round(temp)))
|
self.labels[device].set_label("%s%d°" % (name, round(temp)))
|
||||||
|
|
||||||
if "toolhead" in data and "extruder" in data["toolhead"]:
|
if "toolhead" in data and "extruder" in data["toolhead"]:
|
||||||
@ -272,99 +248,39 @@ class BasePanel(ScreenPanel):
|
|||||||
|
|
||||||
def show_back(self, show=True):
|
def show_back(self, show=True):
|
||||||
if show is True and self.buttons_showing['back'] is False:
|
if show is True and self.buttons_showing['back'] is False:
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(0, 0))
|
self.control['back'].set_sensitive(True)
|
||||||
self.control_grid.attach(self.control['back'], 0, 0, 1, 1)
|
self.control['home'].set_sensitive(True)
|
||||||
if self._screen.vertical_mode:
|
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(1, 0))
|
|
||||||
self.control_grid.attach(self.control['home'], 1, 0, 1, 1)
|
|
||||||
else:
|
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(0, 1))
|
|
||||||
self.control_grid.attach(self.control['home'], 0, 1, 1, 1)
|
|
||||||
self.buttons_showing['back'] = True
|
self.buttons_showing['back'] = True
|
||||||
elif show is False and self.buttons_showing['back'] is True:
|
elif show is False and self.buttons_showing['back'] is True:
|
||||||
for i in range(0, 2):
|
self.control['back'].set_sensitive(False)
|
||||||
if self._screen.vertical_mode:
|
self.control['home'].set_sensitive(False)
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(i, 0))
|
|
||||||
self.control_grid.attach(self.control['space%s' % i], i, 0, 1, 1)
|
|
||||||
else:
|
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(0, i))
|
|
||||||
self.control_grid.attach(self.control['space%s' % i], 0, i, 1, 1)
|
|
||||||
self.buttons_showing['back'] = False
|
self.buttons_showing['back'] = False
|
||||||
self.control_grid.show()
|
|
||||||
|
|
||||||
def show_macro_shortcut(self, show=True, mod_row=False):
|
def show_macro_shortcut(self, show=True, mod_row=False):
|
||||||
if show == "True":
|
if show == "True":
|
||||||
show = True
|
show = True
|
||||||
|
|
||||||
if show is True and self.buttons_showing['macros_shortcut'] is False:
|
if show is True and self.buttons_showing['macros_shortcut'] is False:
|
||||||
if len(self._config.get_printers()) > 1 and mod_row is True:
|
self.action_bar.add(self.control['macros_shortcut'])
|
||||||
if self._screen.vertical_mode:
|
if self.buttons_showing['printer_select'] is False:
|
||||||
self.control_grid.insert_column(self.locations['macro_shortcut'])
|
self.action_bar.reorder_child(self.control['macros_shortcut'], 2)
|
||||||
else:
|
|
||||||
self.control_grid.insert_row(self.locations['macro_shortcut'])
|
|
||||||
else:
|
else:
|
||||||
if self._screen.vertical_mode:
|
self.action_bar.reorder_child(self.control['macros_shortcut'], 3)
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(self.locations['macro_shortcut'], 0))
|
|
||||||
else:
|
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['macro_shortcut']))
|
|
||||||
if 'space%s' % self.locations['macro_shortcut'] in self.control:
|
|
||||||
self.control_grid.remove(self.control['space%s' % self.locations['macro_shortcut']])
|
|
||||||
if self._screen.vertical_mode:
|
|
||||||
self.control_grid.attach(self.control['macro_shortcut'], self.locations['macro_shortcut'], 0, 1, 1)
|
|
||||||
else:
|
|
||||||
self.control_grid.attach(self.control['macro_shortcut'], 0, self.locations['macro_shortcut'], 1, 1)
|
|
||||||
self.buttons_showing['macros_shortcut'] = True
|
self.buttons_showing['macros_shortcut'] = True
|
||||||
elif show is not True and self.buttons_showing['macros_shortcut'] is True:
|
elif show is False and self.buttons_showing['macros_shortcut'] is True:
|
||||||
if ('space%s' % self.locations['macro_shortcut']) not in self.control:
|
self.action_bar.remove(self.control['macros_shortcut'])
|
||||||
self.control['space%s' % self.locations['macro_shortcut']] = Gtk.Label("")
|
|
||||||
if len(self._config.get_printers()) > 1 and mod_row is True:
|
|
||||||
if self._screen.vertical_mode:
|
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(self.locations['macro_shortcut'], 0))
|
|
||||||
self.control_grid.remove_column(self.locations['macro_shortcut'])
|
|
||||||
else:
|
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['macro_shortcut']))
|
|
||||||
self.control_grid.remove_row(self.locations['macro_shortcut'])
|
|
||||||
self.control_grid.remove(self.control['macro_shortcut'])
|
|
||||||
else:
|
|
||||||
if self._screen.vertical_mode:
|
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(self.locations['macro_shortcut'], 0))
|
|
||||||
else:
|
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['macro_shortcut']))
|
|
||||||
if ('space%s' % self.locations['macro_shortcut']) not in self.control:
|
|
||||||
self.control['space%s' % self.locations['macro_shortcut']] = Gtk.Label("")
|
|
||||||
if self._screen.vertical_mode:
|
|
||||||
self.control_grid.attach(self.control['space%s' % self.locations['macro_shortcut']],
|
|
||||||
self.locations['macro_shortcut'], 0, 1, 1)
|
|
||||||
else:
|
|
||||||
self.control_grid.attach(self.control['space%s' % self.locations['macro_shortcut']],
|
|
||||||
0, self.locations['macro_shortcut'], 1, 1)
|
|
||||||
self.buttons_showing['macros_shortcut'] = False
|
self.buttons_showing['macros_shortcut'] = False
|
||||||
self._screen.show_all()
|
self._screen.show_all()
|
||||||
|
|
||||||
def show_printer_select(self, show=True):
|
def show_printer_select(self, show=True):
|
||||||
if len(self._config.get_printers()) <= 1:
|
if len(self._config.get_printers()) <= 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
if show and self.buttons_showing['printer_select'] is False:
|
if show and self.buttons_showing['printer_select'] is False:
|
||||||
logging.info("Turning on printer_select button")
|
self.action_bar.add(self.control['printer_select'])
|
||||||
if self._screen.vertical_mode:
|
self.action_bar.reorder_child(self.control['printer_select'], 2)
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(self.locations['printer_select'], 0))
|
|
||||||
self.control_grid.attach(self.control['printer_select'], self.locations['printer_select'], 0, 1, 1)
|
|
||||||
else:
|
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['printer_select']))
|
|
||||||
self.control_grid.attach(self.control['printer_select'], 0, self.locations['printer_select'], 1, 1)
|
|
||||||
self.buttons_showing['printer_select'] = True
|
self.buttons_showing['printer_select'] = True
|
||||||
elif show is False and self.buttons_showing['printer_select']:
|
elif show is False and self.buttons_showing['printer_select']:
|
||||||
logging.info("Turning off printer_select button")
|
self.action_bar.remove(self.control['printer_select'])
|
||||||
if self._screen.vertical_mode:
|
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(self.locations['printer_select'], 0))
|
|
||||||
self.control_grid.attach(self.control['space%s' % self.locations['printer_select']],
|
|
||||||
self.locations['printer_select'], 0, 1, 1)
|
|
||||||
else:
|
|
||||||
self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['printer_select']))
|
|
||||||
self.control_grid.attach(self.control['space%s' % self.locations['printer_select']],
|
|
||||||
0, self.locations['printer_select'], 1, 1)
|
|
||||||
|
|
||||||
self.buttons_showing['printer_select'] = False
|
self.buttons_showing['printer_select'] = False
|
||||||
self._screen.show_all()
|
self._screen.show_all()
|
||||||
|
|
||||||
@ -379,13 +295,6 @@ class BasePanel(ScreenPanel):
|
|||||||
|
|
||||||
self.titlelbl.set_label("%s | %s" % (self._screen.connecting_to_printer, title))
|
self.titlelbl.set_label("%s | %s" % (self._screen.connecting_to_printer, title))
|
||||||
|
|
||||||
def show_back_buttons(self):
|
|
||||||
self.control_grid.attach(self.control['back'], 0, 0, 1, 1)
|
|
||||||
if self._screen.vertical_mode:
|
|
||||||
self.control_grid.attach(self.control['home'], 1, 0, 1, 1)
|
|
||||||
else:
|
|
||||||
self.control_grid.attach(self.control['home'], 0, 1, 1, 1)
|
|
||||||
|
|
||||||
def update_time(self):
|
def update_time(self):
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
confopt = self._config.get_main_config_option("24htime")
|
confopt = self._config.get_main_config_option("24htime")
|
||||||
|
@ -272,7 +272,6 @@ class MovePanel(ScreenPanel):
|
|||||||
scale.set_hexpand(True)
|
scale.set_hexpand(True)
|
||||||
scale.set_digits(0)
|
scale.set_digits(0)
|
||||||
scale.connect("button-release-event", self.scale_moved, option['section'], opt_name)
|
scale.connect("button-release-event", self.scale_moved, option['section'], opt_name)
|
||||||
scale.set_property("width-request", round(self._screen.width / 2.2))
|
|
||||||
dev.add(scale)
|
dev.add(scale)
|
||||||
|
|
||||||
frame = Gtk.Frame()
|
frame = Gtk.Frame()
|
||||||
|
@ -298,7 +298,6 @@ class PrintPanel(ScreenPanel):
|
|||||||
|
|
||||||
grid = Gtk.Grid()
|
grid = Gtk.Grid()
|
||||||
grid.add(label)
|
grid.add(label)
|
||||||
grid.set_size_request(self._screen.width - 60, -1)
|
|
||||||
|
|
||||||
pixbuf = self.get_file_image(filename, 8, 3.2)
|
pixbuf = self.get_file_image(filename, 8, 3.2)
|
||||||
if pixbuf is not None:
|
if pixbuf is not None:
|
||||||
|
@ -16,7 +16,6 @@ class SettingsPanel(ScreenPanel):
|
|||||||
_ = self.lang.gettext
|
_ = self.lang.gettext
|
||||||
self.settings = {}
|
self.settings = {}
|
||||||
self.menu = ['settings_menu']
|
self.menu = ['settings_menu']
|
||||||
|
|
||||||
self.labels['add_printer_button'] = self._gtk.Button(_("Add Printer"), "color1")
|
self.labels['add_printer_button'] = self._gtk.Button(_("Add Printer"), "color1")
|
||||||
|
|
||||||
options = self._config.get_configurable_options().copy()
|
options = self._config.get_configurable_options().copy()
|
||||||
@ -119,7 +118,6 @@ class SettingsPanel(ScreenPanel):
|
|||||||
scale.set_hexpand(True)
|
scale.set_hexpand(True)
|
||||||
scale.set_digits(0)
|
scale.set_digits(0)
|
||||||
scale.connect("button-release-event", self.scale_moved, option['section'], opt_name)
|
scale.connect("button-release-event", self.scale_moved, option['section'], opt_name)
|
||||||
scale.set_property("width-request", round(self._screen.width / 2.2))
|
|
||||||
dev.add(scale)
|
dev.add(scale)
|
||||||
elif option['type'] == "printer":
|
elif option['type'] == "printer":
|
||||||
logging.debug("Option: %s" % option)
|
logging.debug("Option: %s" % option)
|
||||||
|
@ -18,9 +18,6 @@ class SplashScreenPanel(ScreenPanel):
|
|||||||
def __init__(self, screen, title, back=True):
|
def __init__(self, screen, title, back=True):
|
||||||
super().__init__(screen, title, back)
|
super().__init__(screen, title, back)
|
||||||
|
|
||||||
self.layout = Gtk.Layout()
|
|
||||||
self.layout.set_size(self._screen.width, self._screen.height)
|
|
||||||
|
|
||||||
def initialize(self, panel_name):
|
def initialize(self, panel_name):
|
||||||
_ = self.lang.gettext
|
_ = self.lang.gettext
|
||||||
|
|
||||||
|
10
screen.py
10
screen.py
@ -125,7 +125,7 @@ class KlipperScreen(Gtk.Window):
|
|||||||
self.keyboard_height = self.gtk.get_keyboard_height()
|
self.keyboard_height = self.gtk.get_keyboard_height()
|
||||||
self.init_style()
|
self.init_style()
|
||||||
|
|
||||||
self.base_panel = BasePanel(self, "Base Panel", False)
|
self.base_panel = BasePanel(self, title="Base Panel", back=False)
|
||||||
self.add(self.base_panel.get())
|
self.add(self.base_panel.get())
|
||||||
self.show_all()
|
self.show_all()
|
||||||
self.base_panel.activate()
|
self.base_panel.activate()
|
||||||
@ -1034,18 +1034,20 @@ class KlipperScreen(Gtk.Window):
|
|||||||
logging.debug("PID %s" % p.pid)
|
logging.debug("PID %s" % p.pid)
|
||||||
keyboard = Gtk.Socket()
|
keyboard = Gtk.Socket()
|
||||||
|
|
||||||
action_bar_width = self.gtk.get_action_bar_width()
|
|
||||||
|
|
||||||
box = Gtk.VBox()
|
box = Gtk.VBox()
|
||||||
box.set_vexpand(False)
|
box.set_vexpand(False)
|
||||||
box.set_size_request(self.width - action_bar_width, self.keyboard_height)
|
if self._screen.vertical_mode:
|
||||||
|
box.set_size_request(self.width, self.keyboard_height)
|
||||||
|
else:
|
||||||
|
action_bar_width = self.gtk.get_action_bar_width()
|
||||||
|
box.set_size_request(self.width - action_bar_width, self.keyboard_height)
|
||||||
box.add(keyboard)
|
box.add(keyboard)
|
||||||
|
|
||||||
self.base_panel.get_content().pack_end(box, False, 0, 0)
|
self.base_panel.get_content().pack_end(box, False, 0, 0)
|
||||||
|
|
||||||
self.show_all()
|
self.show_all()
|
||||||
keyboard.add_id(xid)
|
keyboard.add_id(xid)
|
||||||
keyboard.show()
|
|
||||||
|
|
||||||
self.keyboard = {
|
self.keyboard = {
|
||||||
"box": box,
|
"box": box,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user