Simplify code
This commit is contained in:
parent
3889fdbe4c
commit
33195f203f
@ -255,6 +255,14 @@ class KlippyGtk:
|
||||
b.connect("clicked", self.screen.reset_screensaver_timeout)
|
||||
return b
|
||||
|
||||
def ScrolledWindow(self):
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
return scroll
|
||||
|
||||
def formatFileName(self, name):
|
||||
name = name.split('/')[-1] if "/" in name else name
|
||||
name = name.split('.gcod')[0] if ".gcode" in name else name
|
||||
|
@ -1,4 +1,5 @@
|
||||
import gi
|
||||
import logging
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
@ -117,3 +118,52 @@ class ScreenPanel:
|
||||
self.labels[dev].set_label(self._gtk.formatTemperatureString(temp, target))
|
||||
else:
|
||||
self.labels[dev].set_label("%s\n%s" % (name, self._gtk.formatTemperatureString(temp, target)))
|
||||
|
||||
def load_menu(self, widget, name):
|
||||
if ("%s_menu" % name) not in self.labels:
|
||||
return
|
||||
|
||||
for child in self.content.get_children():
|
||||
self.content.remove(child)
|
||||
|
||||
self.menu.append('%s_menu' % name)
|
||||
self.content.add(self.labels[self.menu[-1]])
|
||||
self.content.show_all()
|
||||
|
||||
def unload_menu(self, widget=None):
|
||||
logging.debug("self.menu: %s" % self.menu)
|
||||
if len(self.menu) <= 1 or self.menu[-2] not in self.labels:
|
||||
return
|
||||
|
||||
self.menu.pop()
|
||||
for child in self.content.get_children():
|
||||
self.content.remove(child)
|
||||
self.content.add(self.labels[self.menu[-1]])
|
||||
self.content.show_all()
|
||||
|
||||
def on_dropdown_change(self, combo, section, option, callback=None):
|
||||
tree_iter = combo.get_active_iter()
|
||||
if tree_iter is not None:
|
||||
model = combo.get_model()
|
||||
value = model[tree_iter][1]
|
||||
logging.debug("[%s] %s changed to %s" % (section, option, value))
|
||||
self._config.set(section, option, value)
|
||||
self._config.save_user_config_options()
|
||||
if callback is not None:
|
||||
callback(value)
|
||||
|
||||
def scale_moved(self, widget, event, section, option):
|
||||
logging.debug("[%s] %s changed to %s" % (section, option, widget.get_value()))
|
||||
if section not in self._config.get_config().sections():
|
||||
self._config.get_config().add_section(section)
|
||||
self._config.set(section, option, str(int(widget.get_value())))
|
||||
self._config.save_user_config_options()
|
||||
|
||||
def switch_config_option(self, switch, gparam, section, option, callback=None):
|
||||
logging.debug("[%s] %s toggled %s" % (section, option, switch.get_active()))
|
||||
if section not in self._config.get_config().sections():
|
||||
self._config.get_config().add_section(section)
|
||||
self._config.set(section, option, "True" if switch.get_active() else "False")
|
||||
self._config.save_user_config_options()
|
||||
if callback is not None:
|
||||
callback(switch.get_active())
|
||||
|
@ -29,11 +29,7 @@ class BedMeshPanel(ScreenPanel):
|
||||
|
||||
self.show_create = False
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
scroll = self._gtk.ScrolledWindow()
|
||||
|
||||
# Create a grid for all profiles
|
||||
self.labels['profiles'] = Gtk.Grid()
|
||||
|
@ -23,11 +23,7 @@ class FanPanel(ScreenPanel):
|
||||
_ = self.lang.gettext
|
||||
self.devices = {}
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
scroll = self._gtk.ScrolledWindow()
|
||||
|
||||
# Create a grid for all devices
|
||||
self.labels['devices'] = Gtk.Grid()
|
||||
|
@ -18,9 +18,7 @@ class MacroPanel(ScreenPanel):
|
||||
self.loaded_macros = []
|
||||
self.sort_char = [" ↑", " ↓"]
|
||||
self.sort_reverse = False
|
||||
|
||||
macros_box = self.create_box('macros')
|
||||
self.labels['shown_box'] = self.create_box('shown')
|
||||
self.menu = ['macros_menu']
|
||||
|
||||
sort = Gtk.Label(_("Sort:"))
|
||||
sort.set_hexpand(False)
|
||||
@ -29,7 +27,7 @@ class MacroPanel(ScreenPanel):
|
||||
self.sort_btn.connect("clicked", self.change_sort)
|
||||
self.sort_btn.set_hexpand(True)
|
||||
adjust = self._gtk.ButtonImage("settings", None, "color2", 1, Gtk.PositionType.LEFT, False)
|
||||
adjust.connect("clicked", self.load_menu, 'shown')
|
||||
adjust.connect("clicked", self.load_menu, 'options')
|
||||
adjust.set_hexpand(False)
|
||||
|
||||
sbox = Gtk.HBox()
|
||||
@ -38,13 +36,19 @@ class MacroPanel(ScreenPanel):
|
||||
sbox.pack_start(self.sort_btn, True, True, 5)
|
||||
sbox.pack_start(adjust, True, True, 5)
|
||||
|
||||
self.labels['main_box'] = Gtk.VBox()
|
||||
self.labels['main_box'].set_vexpand(True)
|
||||
self.labels['main_box'].pack_start(sbox, False, False, 0)
|
||||
self.labels['main_box'].pack_start(macros_box, True, True, 0)
|
||||
self.labels['macros_list'] = self._gtk.ScrolledWindow()
|
||||
self.labels['macros'] = Gtk.Grid()
|
||||
self.labels['macros_list'].add(self.labels['macros'])
|
||||
|
||||
self.menu = ['main_box']
|
||||
self.content.add(self.labels['main_box'])
|
||||
self.labels['macros_menu'] = Gtk.VBox()
|
||||
self.labels['macros_menu'].set_vexpand(True)
|
||||
self.labels['macros_menu'].pack_start(sbox, False, False, 0)
|
||||
self.labels['macros_menu'].pack_start(self.labels['macros_list'], True, True, 0)
|
||||
|
||||
self.content.add(self.labels['macros_menu'])
|
||||
self.labels['options_menu'] = self._gtk.ScrolledWindow()
|
||||
self.labels['options'] = Gtk.Grid()
|
||||
self.labels['options_menu'].add(self.labels['options'])
|
||||
|
||||
def activate(self):
|
||||
while len(self.menu) > 1:
|
||||
@ -110,7 +114,7 @@ class MacroPanel(ScreenPanel):
|
||||
self.macros = {}
|
||||
self.loaded_macros = []
|
||||
self.allmacros = {}
|
||||
self.labels['shown'].remove_column(0)
|
||||
self.labels['options'].remove_column(0)
|
||||
self.load_gcode_macros()
|
||||
|
||||
def load_gcode_macros(self):
|
||||
@ -139,7 +143,7 @@ class MacroPanel(ScreenPanel):
|
||||
"section": "displayed_macros %s" % self._screen.connected_printer,
|
||||
}
|
||||
for macro in list(self.allmacros):
|
||||
self.add_option('shown', self.allmacros, macro, self.allmacros[macro])
|
||||
self.add_option('options', self.allmacros, macro, self.allmacros[macro])
|
||||
|
||||
self.labels['macros'].show_all()
|
||||
|
||||
@ -187,56 +191,9 @@ class MacroPanel(ScreenPanel):
|
||||
self.labels[boxname].attach(opt_array[opt_name]['row'], 0, pos, 1, 1)
|
||||
self.labels[boxname].show_all()
|
||||
|
||||
def load_menu(self, widget, name):
|
||||
if ("%s_box" % name) not in self.labels:
|
||||
return
|
||||
|
||||
for child in self.content.get_children():
|
||||
self.content.remove(child)
|
||||
|
||||
self.menu.append('%s_box' % name)
|
||||
self.content.add(self.labels[self.menu[-1]])
|
||||
self.content.show_all()
|
||||
|
||||
def unload_menu(self, widget=None):
|
||||
logging.debug("self.menu: %s" % self.menu)
|
||||
if len(self.menu) <= 1 or self.menu[-2] not in self.labels:
|
||||
return
|
||||
|
||||
self.menu.pop()
|
||||
for child in self.content.get_children():
|
||||
self.content.remove(child)
|
||||
self.content.add(self.labels[self.menu[-1]])
|
||||
self.content.show_all()
|
||||
|
||||
def create_box(self, name):
|
||||
# Create a scroll window for the macros
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
|
||||
# Create a grid for all macros
|
||||
self.labels[name] = Gtk.Grid()
|
||||
scroll.add(self.labels[name])
|
||||
|
||||
# Create a box to contain all of the above
|
||||
box = Gtk.VBox(spacing=0)
|
||||
box.set_vexpand(True)
|
||||
box.pack_start(scroll, True, True, 0)
|
||||
return box
|
||||
|
||||
def back(self):
|
||||
if len(self.menu) > 1:
|
||||
self.unload_menu()
|
||||
self.reload_macros()
|
||||
return True
|
||||
return False
|
||||
|
||||
def switch_config_option(self, switch, gparam, section, option):
|
||||
logging.debug("[%s] %s toggled %s" % (section, option, switch.get_active()))
|
||||
if section not in self._config.get_config().sections():
|
||||
self._config.get_config().add_section(section)
|
||||
self._config.set(section, option, "True" if switch.get_active() else "False")
|
||||
self._config.save_user_config_options()
|
||||
|
@ -18,11 +18,7 @@ class LimitsPanel(ScreenPanel):
|
||||
_ = self.lang.gettext
|
||||
self.limits = {}
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
scroll = self._gtk.ScrolledWindow()
|
||||
|
||||
# Create a grid for all limits
|
||||
self.grid = Gtk.Grid()
|
||||
|
@ -212,12 +212,7 @@ class MainPanel(MenuPanel):
|
||||
da.set_vexpand(True)
|
||||
self.labels['da'] = da
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_hexpand(True)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
scroll = self._gtk.ScrolledWindow()
|
||||
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||
scroll.add(self.labels['devices'])
|
||||
|
||||
|
@ -24,10 +24,7 @@ class MenuPanel(ScreenPanel):
|
||||
|
||||
self.grid = self._gtk.HomogeneousGrid()
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_hexpand(True)
|
||||
scroll.set_vexpand(True)
|
||||
scroll = self._gtk.ScrolledWindow()
|
||||
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||
scroll.add(self.grid)
|
||||
|
||||
|
@ -23,6 +23,7 @@ class MovePanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
self.settings = {}
|
||||
self.menu = ['move_menu']
|
||||
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
|
||||
@ -133,16 +134,13 @@ class MovePanel(ScreenPanel):
|
||||
bottomgrid.attach(self.labels['move_dist'], 0, 1, 3, 1)
|
||||
bottomgrid.attach(adjust, 3, 0, 1, 2)
|
||||
|
||||
self.labels['main_box'] = Gtk.VBox()
|
||||
self.labels['main_box'].set_vexpand(True)
|
||||
self.labels['main_box'].pack_start(grid, True, True, 0)
|
||||
self.labels['main_box'].pack_start(bottomgrid, True, True, 0)
|
||||
self.labels['main_box'].pack_start(distgrid, True, True, 0)
|
||||
self.labels['move_menu'] = Gtk.VBox()
|
||||
self.labels['move_menu'].set_vexpand(True)
|
||||
self.labels['move_menu'].pack_start(grid, True, True, 0)
|
||||
self.labels['move_menu'].pack_start(bottomgrid, True, True, 0)
|
||||
self.labels['move_menu'].pack_start(distgrid, True, True, 0)
|
||||
|
||||
self.menu = ['main_box']
|
||||
self.content.add(self.labels['main_box'])
|
||||
|
||||
self.labels['options_box'] = self.create_box('options')
|
||||
self.content.add(self.labels['move_menu'])
|
||||
|
||||
printer_cfg = self._printer.get_config_section("printer")
|
||||
max_velocity = int(float(printer_cfg["max_velocity"]))
|
||||
@ -163,6 +161,9 @@ class MovePanel(ScreenPanel):
|
||||
"range": [1, max_z_velocity], "step": 1}}
|
||||
]
|
||||
|
||||
self.labels['options_menu'] = self._gtk.ScrolledWindow()
|
||||
self.labels['options'] = Gtk.Grid()
|
||||
self.labels['options_menu'].add(self.labels['options'])
|
||||
for option in configurable_options:
|
||||
name = list(option)[0]
|
||||
self.add_option('options', self.settings, name, option[name])
|
||||
@ -292,62 +293,8 @@ class MovePanel(ScreenPanel):
|
||||
self.labels[boxname].attach(opt_array[opt_name]['row'], 0, pos, 1, 1)
|
||||
self.labels[boxname].show_all()
|
||||
|
||||
def load_menu(self, widget, name):
|
||||
if ("%s_box" % name) not in self.labels:
|
||||
return
|
||||
|
||||
for child in self.content.get_children():
|
||||
self.content.remove(child)
|
||||
|
||||
self.menu.append('%s_box' % name)
|
||||
self.content.add(self.labels[self.menu[-1]])
|
||||
self.content.show_all()
|
||||
|
||||
def unload_menu(self, widget=None):
|
||||
logging.debug("self.menu: %s" % self.menu)
|
||||
if len(self.menu) <= 1 or self.menu[-2] not in self.labels:
|
||||
return
|
||||
|
||||
self.menu.pop()
|
||||
for child in self.content.get_children():
|
||||
self.content.remove(child)
|
||||
self.content.add(self.labels[self.menu[-1]])
|
||||
self.content.show_all()
|
||||
|
||||
def create_box(self, name):
|
||||
# Create a scroll window for the options
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
|
||||
# Create a grid for all options
|
||||
self.labels[name] = Gtk.Grid()
|
||||
scroll.add(self.labels[name])
|
||||
|
||||
# Create a box to contain all of the above
|
||||
box = Gtk.VBox(spacing=0)
|
||||
box.set_vexpand(True)
|
||||
box.pack_start(scroll, True, True, 0)
|
||||
return box
|
||||
|
||||
def back(self):
|
||||
if len(self.menu) > 1:
|
||||
self.unload_menu()
|
||||
return True
|
||||
return False
|
||||
|
||||
def switch_config_option(self, switch, gparam, section, option):
|
||||
logging.debug("[%s] %s toggled %s" % (section, option, switch.get_active()))
|
||||
if section not in self._config.get_config().sections():
|
||||
self._config.get_config().add_section(section)
|
||||
self._config.set(section, option, "True" if switch.get_active() else "False")
|
||||
self._config.save_user_config_options()
|
||||
|
||||
def scale_moved(self, widget, event, section, option):
|
||||
logging.debug("[%s] %s changed to %s" % (section, option, widget.get_value()))
|
||||
if section not in self._config.get_config().sections():
|
||||
self._config.get_config().add_section(section)
|
||||
self._config.set(section, option, str(int(widget.get_value())))
|
||||
self._config.save_user_config_options()
|
||||
|
@ -71,11 +71,7 @@ class NetworkPanel(ScreenPanel):
|
||||
sbox.add(self.labels['ip'])
|
||||
sbox.add(reload_networks)
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
scroll = self._gtk.ScrolledWindow()
|
||||
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
|
||||
box.set_vexpand(True)
|
||||
|
@ -17,11 +17,7 @@ class PowerPanel(ScreenPanel):
|
||||
self.devices = {}
|
||||
|
||||
# Create a scroll window for the power devices
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
scroll = self._gtk.ScrolledWindow()
|
||||
|
||||
# Create a grid for all devices
|
||||
self.labels['devices'] = Gtk.Grid()
|
||||
|
@ -35,11 +35,7 @@ class PrintPanel(ScreenPanel):
|
||||
sortdir = ["name", "asc"]
|
||||
self.sort_current = [sortdir[0], 0 if sortdir[1] == "asc" else 1] # 0 for asc, 1 for desc
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
scroll = self._gtk.ScrolledWindow()
|
||||
|
||||
sort = Gtk.Label()
|
||||
sort.set_text(_("Sort by: "))
|
||||
|
@ -22,10 +22,7 @@ class PrinterSelect(ScreenPanel):
|
||||
printers = self._config.get_printers()
|
||||
|
||||
grid = self._gtk.HomogeneousGrid()
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_hexpand(True)
|
||||
scroll.set_vexpand(True)
|
||||
scroll = self._gtk.ScrolledWindow()
|
||||
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||
scroll.add(grid)
|
||||
self.content.add(scroll)
|
||||
|
@ -52,11 +52,7 @@ class FWRetractionPanel(ScreenPanel):
|
||||
for opt in self.options:
|
||||
self.add_option(opt['option'], opt['name'], opt['units'], opt['value'], opt['digits'], opt["maxval"])
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
scroll = self._gtk.ScrolledWindow()
|
||||
scroll.add(self.grid)
|
||||
|
||||
self.content.add(scroll)
|
||||
|
@ -15,15 +15,9 @@ class SettingsPanel(ScreenPanel):
|
||||
def initialize(self, panel_name):
|
||||
_ = self.lang.gettext
|
||||
self.settings = {}
|
||||
self.menu_cur = 'main_box'
|
||||
self.menu = ['main_box']
|
||||
self.menu = ['settings_menu']
|
||||
|
||||
self.labels['main_box'] = self.create_box('main')
|
||||
|
||||
printbox = Gtk.Box(spacing=0)
|
||||
printbox.set_vexpand(False)
|
||||
self.labels['add_printer_button'] = self._gtk.Button(_("Add Printer"), "color1")
|
||||
self.labels['printers_box'] = self.create_box('printers', printbox)
|
||||
|
||||
options = self._config.get_configurable_options().copy()
|
||||
options.append({"printers": {
|
||||
@ -32,10 +26,16 @@ class SettingsPanel(ScreenPanel):
|
||||
"menu": "printers"
|
||||
}})
|
||||
|
||||
self.labels['settings_menu'] = self._gtk.ScrolledWindow()
|
||||
self.labels['settings'] = Gtk.Grid()
|
||||
self.labels['settings_menu'].add(self.labels['settings'])
|
||||
for option in options:
|
||||
name = list(option)[0]
|
||||
self.add_option('main', self.settings, name, option[name])
|
||||
self.add_option('settings', self.settings, name, option[name])
|
||||
|
||||
self.labels['printers_menu'] = self._gtk.ScrolledWindow()
|
||||
self.labels['printers'] = Gtk.Grid()
|
||||
self.labels['printers_menu'].add(self.labels['printers'])
|
||||
self.printers = {}
|
||||
for printer in self._config.get_printers():
|
||||
logging.debug("Printer: %s" % printer)
|
||||
@ -49,7 +49,7 @@ class SettingsPanel(ScreenPanel):
|
||||
}
|
||||
self.add_option("printers", self.printers, pname, self.printers[pname])
|
||||
|
||||
self.content.add(self.labels['main_box'])
|
||||
self.content.add(self.labels['settings_menu'])
|
||||
|
||||
def activate(self):
|
||||
while len(self.menu) > 1:
|
||||
@ -61,26 +61,6 @@ class SettingsPanel(ScreenPanel):
|
||||
return True
|
||||
return False
|
||||
|
||||
def create_box(self, name, insert=None):
|
||||
# Create a scroll window for the options
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
|
||||
# Create a grid for all options
|
||||
self.labels[name] = Gtk.Grid()
|
||||
scroll.add(self.labels[name])
|
||||
|
||||
# Create a box to contain all of the above
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
|
||||
box.set_vexpand(True)
|
||||
if insert is not None:
|
||||
box.pack_start(insert, False, False, 0)
|
||||
box.pack_start(scroll, True, True, 0)
|
||||
return box
|
||||
|
||||
def add_option(self, boxname, opt_array, opt_name, option):
|
||||
if option['type'] is None:
|
||||
return
|
||||
@ -172,52 +152,3 @@ class SettingsPanel(ScreenPanel):
|
||||
self.labels[boxname].insert_row(pos)
|
||||
self.labels[boxname].attach(opt_array[opt_name]['row'], 0, pos, 1, 1)
|
||||
self.labels[boxname].show_all()
|
||||
|
||||
def load_menu(self, widget, name):
|
||||
if ("%s_box" % name) not in self.labels:
|
||||
return
|
||||
|
||||
for child in self.content.get_children():
|
||||
self.content.remove(child)
|
||||
|
||||
self.menu.append('%s_box' % name)
|
||||
self.content.add(self.labels[self.menu[-1]])
|
||||
self.content.show_all()
|
||||
|
||||
def unload_menu(self, widget=None):
|
||||
logging.debug("self.menu: %s" % self.menu)
|
||||
if len(self.menu) <= 1 or self.menu[-2] not in self.labels:
|
||||
return
|
||||
|
||||
self.menu.pop()
|
||||
for child in self.content.get_children():
|
||||
self.content.remove(child)
|
||||
self.content.add(self.labels[self.menu[-1]])
|
||||
self.content.show_all()
|
||||
|
||||
def on_dropdown_change(self, combo, section, option, callback=None):
|
||||
tree_iter = combo.get_active_iter()
|
||||
if tree_iter is not None:
|
||||
model = combo.get_model()
|
||||
value = model[tree_iter][1]
|
||||
logging.debug("[%s] %s changed to %s" % (section, option, value))
|
||||
self._config.set(section, option, value)
|
||||
self._config.save_user_config_options()
|
||||
if callback is not None:
|
||||
callback(value)
|
||||
|
||||
def scale_moved(self, widget, event, section, option):
|
||||
logging.debug("[%s] %s changed to %s" % (section, option, widget.get_value()))
|
||||
if section not in self._config.get_config().sections():
|
||||
self._config.get_config().add_section(section)
|
||||
self._config.set(section, option, str(int(widget.get_value())))
|
||||
self._config.save_user_config_options()
|
||||
|
||||
def switch_config_option(self, switch, gparam, section, option, callback=None):
|
||||
logging.debug("[%s] %s toggled %s" % (section, option, switch.get_active()))
|
||||
if section not in self._config.get_config().sections():
|
||||
self._config.get_config().add_section(section)
|
||||
self._config.set(section, option, "True" if switch.get_active() else "False")
|
||||
self._config.save_user_config_options()
|
||||
if callback is not None:
|
||||
callback(switch.get_active())
|
||||
|
@ -39,12 +39,8 @@ class SystemPanel(ScreenPanel):
|
||||
_("Are you sure you wish to shutdown the system?"), "machine.shutdown")
|
||||
shutdown.set_vexpand(False)
|
||||
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_vexpand(True)
|
||||
scroll = self._gtk.ScrolledWindow()
|
||||
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
|
||||
infogrid = Gtk.Grid()
|
||||
infogrid.get_style_context().add_class("system-program-grid")
|
||||
|
@ -89,13 +89,8 @@ class TemperaturePanel(ScreenPanel):
|
||||
self.labels[option] = self._gtk.Button(option, "color%d" % ((i % 4) + 1))
|
||||
self.labels[option].connect("clicked", self.set_temperature, option)
|
||||
self.labels['preheat_grid'].attach(self.labels[option], (i % 2), int(i / 2), 1, 1)
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
scroll.set_property("overlay-scrolling", False)
|
||||
scroll.set_hexpand(True)
|
||||
scroll.set_vexpand(True)
|
||||
scroll = self._gtk.ScrolledWindow()
|
||||
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||
scroll.add_events(Gdk.EventMask.TOUCH_MASK)
|
||||
scroll.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
||||
scroll.add(self.labels["preheat_grid"])
|
||||
return scroll
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user