class BootManager(gtk.VBox): """BootManager main widget""" def __init__(self): """init""" gtk.VBox.__init__(self, homogeneous=False, spacing=5) self._dbus_loop() self.iface = Interface() self.iface.listenSignals(self.listen_comar_signals) self.entries = self.iface.getEntries() self.options = self.iface.getOptions() self.systems = self.iface.getSystems() self._create_ui() def _dbus_loop(self): # runs dbus main loop DBusGMainLoop(set_as_default=True) def _create_ui(self): # creates ui header = gtk.HBox(homogeneous=False, spacing=5) self.new_btn = NewButton(self.systems) self.new_btn.connect_clicked(self.on_new_btn) header.pack_start(self.new_btn, expand=False, fill=False) self.pack_start(header, expand=False, fill=False) self.container = BootItemContainer(self.entries, self.listen_boot_item_signals) self.pack_start(self.container, expand=True, fill=True) footer = gtk.HBox(homogeneous=False, spacing=5) self.timer = BootTimer(int(self.options["timeout"])) self.timer.listen_signal(self.on_timeout_change) footer.pack_end(self.timer, expand=False, fill=False) self.pack_start(footer, expand=False, fill=False) self.show_all() def listen_boot_item_signals(self, widget, data): """listen BootItem signals Arguments: - `widget`: widget - `data`: {action:(make_default|edit|delete), props: (ex :{index:0, title:'Pardus', root:/dev/sda1, os_type:linux, default:True})} """ action = data["action"] props = data["props"] if action == "make_default": try: self.iface.setOption("default", props["index"]) except Exception, e: self._on_exception(e) elif action == "edit": EditWindow(self.entries[props["index"]], self.on_edit).show()
def _create_ui(self): # creates ui header = gtk.HBox(homogeneous=False, spacing=5) self.new_btn = NewButton(self.systems) self.new_btn.connect_clicked(self.on_new_btn) header.pack_start(self.new_btn, expand=False, fill=False) self.pack_start(header, expand=False, fill=False) self.container = BootItemContainer(self.entries, self.listen_boot_item_signals) self.pack_start(self.container, expand=True, fill=True) footer = gtk.HBox(homogeneous=False, spacing=5) self.timer = BootTimer(int(self.options["timeout"])) self.timer.listen_signal(self.on_timeout_change) footer.pack_end(self.timer, expand=False, fill=False) self.pack_start(footer, expand=False, fill=False) self.show_all()