Skip to content

Commit

Permalink
Fixed refreshing of TTG, filaments and spoolman panels after Gtk update
Browse files Browse the repository at this point in the history
  • Loading branch information
moggieuk committed Jan 19, 2024
1 parent e125012 commit 8482eca
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions panels/mmu_filaments.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ def __init__(self, screen, title):
layers.insert_page(edit_grid, None, 1)

self.content.add(layers)
self.gate_tool_map = self.build_gate_tool_map()

def post_attach(self):
# Gtk Notebook will only change layer after show_all() hence this extra callback to fix state
Expand Down Expand Up @@ -264,6 +263,7 @@ def query_spoolman(self):

def refresh(self):
self.use_spoolman = self._printer.spoolman and self._config.get_main_config().getboolean("mmu_use_spoolman", False)
self.gate_tool_map = self.build_gate_tool_map()

mmu = self._printer.get_stat("mmu")
gate_status = mmu['gate_status']
Expand Down Expand Up @@ -320,7 +320,7 @@ def get_tool_details(self, tools):
tool_str = ''
if len(tools) > 0:
tool_str = 'T' + ', '.join(map(str, tools[:2]))
tool_str += ', ...' if len(tools) > 2 else ''
tool_str += '...' if len(tools) > 2 else ''
return tool_str

def get_color_details(self, gate_color):
Expand Down
6 changes: 3 additions & 3 deletions panels/mmu_spoolman.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def __init__(self, screen, title):
layers.insert_page(scroll, None, 0)

self.content.add(layers)
self.gate_tool_map = self.build_gate_tool_map()

def async_spools_refresh(self):
while self.is_running:
Expand Down Expand Up @@ -148,6 +147,7 @@ def activate(self):
self.refresh()

def refresh(self):
self.gate_tool_map = self.build_gate_tool_map()
mmu = self._printer.get_stat("mmu")
gate_status = mmu['gate_status']
gate_material = mmu['gate_material']
Expand Down Expand Up @@ -253,8 +253,8 @@ def get_status_details(self, gate_status):
def get_tool_details(self, tools):
tool_str = ''
if len(tools) > 0:
tool_str = 'T' + ', '.join(map(str, tools[:2]))
tool_str += ', ...' if len(tools) > 2 else ''
tool_str = 'T' + ', '.join(map(str, tools[:1]))
tool_str += '..' if len(tools) > 1 else ''
return tool_str

def get_color_details(self, gate_color):
Expand Down
10 changes: 6 additions & 4 deletions panels/mmu_toolmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def __init__(self, screen, title):
self.labels['reset'].set_halign(Gtk.Align.CENTER)
self.labels['reset'].set_valign(Gtk.Align.START)
self.labels['reset'].set_vexpand(False)
self.labels['reset'].get_style_context().add_class("mmu_es_gate")
self.labels['reset'].get_style_context().add_class("mmu_es_gate_selected")
self.labels['es_group'].set_xalign(0)
self.labels['es_group'].get_style_context().add_class("mmu_endless_spool_toggle")
self.labels['endless_spool'].get_style_context().add_class("mmu_endless_spool_toggle")
Expand Down Expand Up @@ -151,13 +153,13 @@ def __init__(self, screen, title):
scroll.add(grid)
self.content.add(scroll)

def activate(self):
mmu = self._printer.get_stat("mmu")
self.ui_ttg_map = mmu['ttg_map']
self.ui_endless_spool_groups = self.map_unique_groups(mmu['endless_spool_groups'])
self.ui_sel_es_group = self.ui_endless_spool_groups[self.ui_ttg_map[self.ui_sel_tool]]
self.ui_es_enabled = mmu['endless_spool']

def activate(self):
self.labels['endless_spool'].set_active(self.ui_es_enabled == 1)
self.update_map()
self.update_es_group()
Expand Down Expand Up @@ -242,17 +244,17 @@ def update_map(self):
else:
msg += ' ' if cnt == 0 else '┃'
self.labels[f'toolmap{y}'].set_text(msg)
self.labels[f'es_gate{gate}'].get_style_context().add_class("distbutton_active")
self.labels[f'es_gate{gate}'].get_style_context().add_class("mmu_es_gate_selected")
self.labels['tool'].set_label(f"T{tool}")
self.labels['gate'].set_label(f"Gate #{gate}")

def update_es_group(self):
gates_in_group = self.build_es_spool_gate_group(self.ui_sel_es_group)
for g in range(len(self.ui_ttg_map)):
if g in gates_in_group:
self.labels[f"es_gate{g}"].get_style_context().add_class("distbutton_active")
self.labels[f"es_gate{g}"].get_style_context().add_class("mmu_es_gate_selected")
else:
self.labels[f"es_gate{g}"].get_style_context().remove_class("distbutton_active")
self.labels[f"es_gate{g}"].get_style_context().remove_class("mmu_es_gate_selected")
self.labels[f"es_gate{g}"].set_sensitive(self.ui_es_enabled == 1)
grp = self.convert_number_to_letter(self.ui_sel_es_group)
self.labels['es_group'].set_markup(f"<b>ES Group: {grp}</b>")
Expand Down
9 changes: 9 additions & 0 deletions styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,15 @@ trough progress {
min-height: 2em;
}

.mmu_es_gate_selected {
background: @active;
}

.mmu_es_gate_reset {
padding-top: 1em;
background: @active;
}

.mmu_endless_spool_toggle {
padding-bottom: .6em;
}
Expand Down

0 comments on commit 8482eca

Please sign in to comment.