hob: rework image output type setting

The preferences UI to set the image output type only supported setting a
single value whereas it's common practice, particularly for those making
use of the ADT, to set multiple values. This is also the default in Poky.

This reworked preferences UI dynamically generates check boxes for each
available image type and sets an appropriate string representing all image
types when checkboxes are toggled.

Includes fixes for [YOCTO #1273]

(Bitbake rev: f7f68847dd165f2ad0f39011db4ebfef3ae73f42)

Signed-off-by: Joshua Lock <josh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Lock 2011-07-22 21:47:00 -07:00 committed by Richard Purdie
parent 1f4e6d62f2
commit 9adf01d7be
4 changed files with 56 additions and 26 deletions

View File

@ -90,12 +90,14 @@ class Configurator(gobject.GObject):
pclass = getString('PACKAGE_CLASSES')
if pclass and pclass != self.config.get('PACKAGE_CLASSES', ''):
self.config['PACKAGE_CLASSES'] = pclass
fstypes = getString('IMAGE_FSTYPES')
if fstypes and fstypes != self.config.get('IMAGE_FSTYPES', ''):
self.config['IMAGE_FSTYPES'] = fstypes
self.orig_config = copy.deepcopy(self.config)
def setLocalConfVar(self, var, val):
if var in self.config:
self.config[var] = val
self.config[var] = val
def _loadLayerConf(self, path):
self.bblayers = path

View File

@ -74,6 +74,8 @@ class HobHandler(gobject.GObject):
self.model = taskmodel
self.server = server
self.image_output_types = self.server.runCommand(["getVariable", "IMAGE_FSTYPES"]).split(" ")
self.command_map = {
"findConfigFilePathLocal" : ("findConfigFilePath", ["hob.local.conf"], "findConfigFilePathHobLocal"),
"findConfigFilePathHobLocal" : ("findConfigFilePath", ["bblayers.conf"], "findConfigFilePathLayers"),
@ -258,8 +260,23 @@ class HobHandler(gobject.GObject):
self.building = None
self.emit("build-complete")
def set_image_output_type(self, output_type):
self.server.runCommand(["setVariable", "IMAGE_FSTYPES", output_type])
def set_fstypes(self, fstypes):
self.server.runCommand(["setVariable", "IMAGE_FSTYPES", fstypes])
def add_image_output_type(self, output_type):
if output_type not in self.image_output_types:
self.image_output_types.append(output_type)
fstypes = " ".join(self.image_output_types)
self.set_fstypes(fstypes)
return fstypes
def remove_image_output_type(self, output_type):
if output_type in self.image_output_types:
ind = self.image_output_types.index(output_type)
self.image_output_types.pop(ind)
fstypes = " ".join(self.image_output_types)
self.set_fstypes(fstypes)
return fstypes
def get_image_deploy_dir(self):
return self.server.runCommand(["getVariable", "DEPLOY_DIR_IMAGE"])

View File

@ -30,11 +30,15 @@ class HobPrefs(gtk.Dialog):
if model:
model.clear()
def output_type_changed_cb(self, combo, handler):
ot = combo.get_active_text()
if ot != self.curr_output_type:
self.curr_output_type = ot
handler.set_image_output_type(ot)
def output_type_toggled_cb(self, check, handler):
ot = check.get_label()
enabled = check.get_active()
if enabled:
self.selected_image_types = handler.add_image_output_type(ot)
else:
self.selected_image_types = handler.remove_image_output_type(ot)
self.configurator.setLocalConfVar('IMAGE_FSTYPES', "%s" % self.selected_image_types)
def sdk_machine_combo_changed_cb(self, combo, handler):
sdk_mach = combo.get_active_text()
@ -144,7 +148,7 @@ class HobPrefs(gtk.Dialog):
glib.idle_add(self.handler.reload_data)
def __init__(self, configurator, handler, curr_sdk_mach, curr_distro, pclass,
cpu_cnt, pmake, bbthread, image_types):
cpu_cnt, pmake, bbthread, selected_image_types, all_image_types):
"""
"""
gtk.Dialog.__init__(self, "Preferences", None,
@ -162,7 +166,6 @@ class HobPrefs(gtk.Dialog):
self.curr_sdk_mach = curr_sdk_mach
self.curr_distro = curr_distro
self.curr_package_format = pclass
self.curr_output_type = None
self.cpu_cnt = cpu_cnt
self.pmake = pmake
self.bbthread = bbthread
@ -170,6 +173,7 @@ class HobPrefs(gtk.Dialog):
self.distro_handler_id = None
self.sdk_machine_handler_id = None
self.package_handler_id = None
self.selected_image_types = selected_image_types.split(" ")
left = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
right = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
@ -214,19 +218,25 @@ class HobPrefs(gtk.Dialog):
of the root filesystem and also dictates the package manager used in your image""")
self.package_combo.show()
hbox.pack_start(self.package_combo, expand=False, fill=False, padding=6)
# Image output type selector
label = gtk.Label("Image output type:")
label.show()
hbox.pack_start(label, expand=False, fill=False, padding=6)
output_combo = gtk.combo_box_new_text()
if image_types:
for it in image_types.split(" "):
output_combo.append_text(it)
output_combo.connect("changed", self.output_type_changed_cb, handler)
else:
output_combo.set_sensitive(False)
output_combo.show()
hbox.pack_start(output_combo)
if all_image_types:
# Image output type selector
label = gtk.Label("Image output types:")
label.show()
hbox.pack_start(label, expand=False, fill=False, padding=6)
chk_cnt = 3
for it in all_image_types.split(" "):
chk_cnt = chk_cnt + 1
if chk_cnt % 6 == 0:
hbox = gtk.HBox(False, 12)
hbox.show()
pbox.pack_start(hbox, expand=False, fill=False, padding=6)
chk = gtk.CheckButton(it)
if it in self.selected_image_types:
chk.set_active(True)
chk.set_tooltip_text("Build an %s image" % it)
chk.connect("toggled", self.output_type_toggled_cb, handler)
chk.show()
hbox.pack_start(chk, expand=False, fill=False, padding=3)
# BitBake
label = gtk.Label()
label.set_markup("<b>BitBake</b>")

View File

@ -900,7 +900,8 @@ def main (server, eventHandler):
# up to and including the space
pmake = int(pmake.lstrip("-j "))
image_types = server.runCommand(["getVariable", "IMAGE_TYPES"])
selected_image_types = server.runCommand(["getVariable", "IMAGE_FSTYPES"])
all_image_types = server.runCommand(["getVariable", "IMAGE_TYPES"])
pclasses = server.runCommand(["getVariable", "PACKAGE_CLASSES"]).split(" ")
# NOTE: we're only supporting one value for PACKAGE_CLASSES being set
@ -909,7 +910,7 @@ def main (server, eventHandler):
pkg, sep, pclass = pclasses[0].rpartition("_")
prefs = HobPrefs(configurator, handler, sdk_mach, distro, pclass, cpu_cnt,
pmake, bbthread, image_types)
pmake, bbthread, selected_image_types, all_image_types)
layers = LayerEditor(configurator, None)
window = MainWindow(taskmodel, handler, configurator, prefs, layers, mach)
prefs.set_parent_window(window)