diff options
author | Shane Wang <shane.wang@intel.com> | 2012-03-26 19:29:15 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-03-29 21:12:55 +0100 |
commit | 3038c0c65d87ebeddd009f1929752585b83cb2c1 (patch) | |
tree | f60b499cf2a0c2b7983a580c26e6a42ac43b108c /bitbake/lib | |
parent | eeb0529e138fa95db8fc6ed74bcaee87804fcb6c (diff) | |
download | ast2050-yocto-poky-3038c0c65d87ebeddd009f1929752585b83cb2c1.zip ast2050-yocto-poky-3038c0c65d87ebeddd009f1929752585b83cb2c1.tar.gz |
Hob: Set one of deployable images or runnable images as the default toggled item
With this patch, even though there are a lot of images built out, a default image
which is either deployable or runnable is toggled by default. So, for users, one
more action to select an image before running qemu or deploying is not needed any more.
Note: If there are more than one runnable or deployable images (such as ext2, ext3,
jffs2 and btrfs), only the first image is toggled by default for run-qemu or
deployment. If the user wants to run or deploy others, he/she needs to toggle them
manually.
[Yocto #2155]
(Bitbake rev: 4568dfbd5e693cce0e6e947f323eaf08a3176744)
Signed-off-by: Shane Wang <shane.wang@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rwxr-xr-x | bitbake/lib/bb/ui/crumbs/imagedetailspage.py | 72 |
1 files changed, 46 insertions, 26 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py index 276281d..7d06124 100755 --- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py +++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py @@ -176,14 +176,30 @@ class ImageDetailsPage (HobPage): build_result = self.DetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color) self.box_group_area.pack_start(build_result, expand=False, fill=False) + # create the buttons at the bottom first because the buttons are used in apply_button_per_image() + if build_succeeded: + buttonlist = ["Build new image", "Save as template", "Run image", "Deploy image"] + else: # get to this page from "My images" + buttonlist = ["Build new image", "Run image", "Deploy image"] + details_bottom_buttons = self.create_bottom_buttons(buttonlist) + # Name self.image_store.clear() + default_toggled = False + default_image_size = 0 for image_name in image_names: image_size = self._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size) - self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False) + if not default_toggled: + default_toggled = (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) \ + or self.test_deployable(image_name) + self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, default_toggled) + if default_toggled: + default_image_size = image_size + self.apply_buttons_per_image(image_name) + else: + self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False) image_table = HobViewTable(self.__columns__) image_table.set_model(self.image_store) - image_size = self._size_to_string(os.stat(os.path.join(image_addr, image_names[0])).st_size) image_table.connect("toggled", self.toggled_cb) view_files_button = HobAltButton("View files") view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr) @@ -222,7 +238,7 @@ class ImageDetailsPage (HobPage): varlist = ["Packages included: ", "Total image size: "] vallist = [] vallist.append(pkg_num) - vallist.append(image_size) + vallist.append(default_image_size) if build_succeeded: edit_packages_button = HobAltButton("Edit packages") edit_packages_button.connect("clicked", self.edit_packages_button_clicked_cb) @@ -231,11 +247,7 @@ class ImageDetailsPage (HobPage): self.package_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_packages_button) self.box_group_area.pack_start(self.package_detail, expand=False, fill=False) - if build_succeeded: - buttonlist = ["Build new image", "Save as template", "Run image", "Deploy image"] - else: # get to this page from "My images" - buttonlist = ["Build new image", "Run image", "Deploy image"] - details_bottom_buttons = self.create_bottom_buttons(buttonlist) + # pack the buttons at the bottom, at this time they are already created. self.box_group_area.pack_end(details_bottom_buttons, expand=False, fill=False) self.show_all() @@ -246,41 +258,49 @@ class ImageDetailsPage (HobPage): def refresh_package_detail_box(self, image_size): self.package_detail.update_line_widgets("Total image size: ", image_size) - def toggled_cb(self, table, cell, path, columnid, tree): - model = tree.get_model() - if not model: - return - iter = model.get_iter_first() - while iter: - rowpath = model.get_path(iter) - model[rowpath][columnid] = False - iter = model.iter_next(iter) - - model[path][columnid] = True - self.refresh_package_detail_box(model[path][1]) - + def test_type_runnable(self, image_name): type_runnable = False - mach_runnable = False - image_name = model[path][0] for t in self.builder.parameters.runnable_image_types: if image_name.endswith(t): type_runnable = True break + return type_runnable + def test_mach_runnable(self, image_name): + mach_runnable = False for t in self.builder.parameters.runnable_machine_patterns: if t in image_name: mach_runnable = True break + return mach_runnable - self.run_button.set_sensitive(type_runnable and mach_runnable) - + def test_deployable(self, image_name): deployable = False for t in self.builder.parameters.deployable_image_types: if image_name.endswith(t): deployable = True break + return deployable - self.deploy_button.set_sensitive(deployable) + def apply_buttons_per_image(self, image_name): + self.run_button.set_sensitive(self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) + self.deploy_button.set_sensitive(self.test_deployable(image_name)) + + def toggled_cb(self, table, cell, path, columnid, tree): + model = tree.get_model() + if not model: + return + iter = model.get_iter_first() + while iter: + rowpath = model.get_path(iter) + model[rowpath][columnid] = False + iter = model.iter_next(iter) + + model[path][columnid] = True + self.refresh_package_detail_box(model[path][1]) + + image_name = model[path][0] + self.apply_buttons_per_image(image_name) def create_bottom_buttons(self, buttonlist): # Create the buttons at the bottom |