summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorShane Wang <shane.wang@intel.com>2012-03-26 19:29:15 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-03-29 21:12:55 +0100
commit3038c0c65d87ebeddd009f1929752585b83cb2c1 (patch)
treef60b499cf2a0c2b7983a580c26e6a42ac43b108c /bitbake
parenteeb0529e138fa95db8fc6ed74bcaee87804fcb6c (diff)
downloadpoky-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')
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/imagedetailspage.py72
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 276281d8a8..7d06124048 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -176,14 +176,30 @@ class ImageDetailsPage (HobPage):
176 build_result = self.DetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color) 176 build_result = self.DetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color)
177 self.box_group_area.pack_start(build_result, expand=False, fill=False) 177 self.box_group_area.pack_start(build_result, expand=False, fill=False)
178 178
179 # create the buttons at the bottom first because the buttons are used in apply_button_per_image()
180 if build_succeeded:
181 buttonlist = ["Build new image", "Save as template", "Run image", "Deploy image"]
182 else: # get to this page from "My images"
183 buttonlist = ["Build new image", "Run image", "Deploy image"]
184 details_bottom_buttons = self.create_bottom_buttons(buttonlist)
185
179 # Name 186 # Name
180 self.image_store.clear() 187 self.image_store.clear()
188 default_toggled = False
189 default_image_size = 0
181 for image_name in image_names: 190 for image_name in image_names:
182 image_size = self._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size) 191 image_size = self._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size)
183 self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False) 192 if not default_toggled:
193 default_toggled = (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) \
194 or self.test_deployable(image_name)
195 self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, default_toggled)
196 if default_toggled:
197 default_image_size = image_size
198 self.apply_buttons_per_image(image_name)
199 else:
200 self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False)
184 image_table = HobViewTable(self.__columns__) 201 image_table = HobViewTable(self.__columns__)
185 image_table.set_model(self.image_store) 202 image_table.set_model(self.image_store)
186 image_size = self._size_to_string(os.stat(os.path.join(image_addr, image_names[0])).st_size)
187 image_table.connect("toggled", self.toggled_cb) 203 image_table.connect("toggled", self.toggled_cb)
188 view_files_button = HobAltButton("View files") 204 view_files_button = HobAltButton("View files")
189 view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr) 205 view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr)
@@ -222,7 +238,7 @@ class ImageDetailsPage (HobPage):
222 varlist = ["Packages included: ", "Total image size: "] 238 varlist = ["Packages included: ", "Total image size: "]
223 vallist = [] 239 vallist = []
224 vallist.append(pkg_num) 240 vallist.append(pkg_num)
225 vallist.append(image_size) 241 vallist.append(default_image_size)
226 if build_succeeded: 242 if build_succeeded:
227 edit_packages_button = HobAltButton("Edit packages") 243 edit_packages_button = HobAltButton("Edit packages")
228 edit_packages_button.connect("clicked", self.edit_packages_button_clicked_cb) 244 edit_packages_button.connect("clicked", self.edit_packages_button_clicked_cb)
@@ -231,11 +247,7 @@ class ImageDetailsPage (HobPage):
231 self.package_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_packages_button) 247 self.package_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_packages_button)
232 self.box_group_area.pack_start(self.package_detail, expand=False, fill=False) 248 self.box_group_area.pack_start(self.package_detail, expand=False, fill=False)
233 249
234 if build_succeeded: 250 # pack the buttons at the bottom, at this time they are already created.
235 buttonlist = ["Build new image", "Save as template", "Run image", "Deploy image"]
236 else: # get to this page from "My images"
237 buttonlist = ["Build new image", "Run image", "Deploy image"]
238 details_bottom_buttons = self.create_bottom_buttons(buttonlist)
239 self.box_group_area.pack_end(details_bottom_buttons, expand=False, fill=False) 251 self.box_group_area.pack_end(details_bottom_buttons, expand=False, fill=False)
240 252
241 self.show_all() 253 self.show_all()
@@ -246,41 +258,49 @@ class ImageDetailsPage (HobPage):
246 def refresh_package_detail_box(self, image_size): 258 def refresh_package_detail_box(self, image_size):
247 self.package_detail.update_line_widgets("Total image size: ", image_size) 259 self.package_detail.update_line_widgets("Total image size: ", image_size)
248 260
249 def toggled_cb(self, table, cell, path, columnid, tree): 261 def test_type_runnable(self, image_name):
250 model = tree.get_model()
251 if not model:
252 return
253 iter = model.get_iter_first()
254 while iter:
255 rowpath = model.get_path(iter)
256 model[rowpath][columnid] = False
257 iter = model.iter_next(iter)
258
259 model[path][columnid] = True
260 self.refresh_package_detail_box(model[path][1])
261
262 type_runnable = False 262 type_runnable = False
263 mach_runnable = False
264 image_name = model[path][0]
265 for t in self.builder.parameters.runnable_image_types: 263 for t in self.builder.parameters.runnable_image_types:
266 if image_name.endswith(t): 264 if image_name.endswith(t):
267 type_runnable = True 265 type_runnable = True
268 break 266 break
267 return type_runnable
269 268
269 def test_mach_runnable(self, image_name):
270 mach_runnable = False
270 for t in self.builder.parameters.runnable_machine_patterns: 271 for t in self.builder.parameters.runnable_machine_patterns:
271 if t in image_name: 272 if t in image_name:
272 mach_runnable = True 273 mach_runnable = True
273 break 274 break
275 return mach_runnable
274 276
275 self.run_button.set_sensitive(type_runnable and mach_runnable) 277 def test_deployable(self, image_name):
276
277 deployable = False 278 deployable = False
278 for t in self.builder.parameters.deployable_image_types: 279 for t in self.builder.parameters.deployable_image_types:
279 if image_name.endswith(t): 280 if image_name.endswith(t):
280 deployable = True 281 deployable = True
281 break 282 break
283 return deployable
282 284
283 self.deploy_button.set_sensitive(deployable) 285 def apply_buttons_per_image(self, image_name):
286 self.run_button.set_sensitive(self.test_type_runnable(image_name) and self.test_mach_runnable(image_name))
287 self.deploy_button.set_sensitive(self.test_deployable(image_name))
288
289 def toggled_cb(self, table, cell, path, columnid, tree):
290 model = tree.get_model()
291 if not model:
292 return
293 iter = model.get_iter_first()
294 while iter:
295 rowpath = model.get_path(iter)
296 model[rowpath][columnid] = False
297 iter = model.iter_next(iter)
298
299 model[path][columnid] = True
300 self.refresh_package_detail_box(model[path][1])
301
302 image_name = model[path][0]
303 self.apply_buttons_per_image(image_name)
284 304
285 def create_bottom_buttons(self, buttonlist): 305 def create_bottom_buttons(self, buttonlist):
286 # Create the buttons at the bottom 306 # Create the buttons at the bottom