summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/imagedetailspage.py')
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/imagedetailspage.py212
1 files changed, 98 insertions, 114 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
index ba0ad7ed47..07fc3a81e1 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -32,26 +32,6 @@ from bb.ui.crumbs.hig import CrumbsDialog
32# 32#
33class ImageDetailsPage (HobPage): 33class ImageDetailsPage (HobPage):
34 34
35 __columns__ = [{
36 'col_name' : 'Image name',
37 'col_id' : 0,
38 'col_style': 'text',
39 'col_min' : 500,
40 'col_max' : 500
41 },{
42 'col_name' : 'Image size',
43 'col_id' : 1,
44 'col_style': 'text',
45 'col_min' : 100,
46 'col_max' : 100
47 },{
48 'col_name' : 'Select',
49 'col_id' : 2,
50 'col_style': 'radio toggle',
51 'col_min' : 100,
52 'col_max' : 100
53 }]
54
55 class DetailBox (gtk.EventBox): 35 class DetailBox (gtk.EventBox):
56 def __init__(self, widget = None, varlist = None, vallist = None, icon = None, button = None, color = HobColors.LIGHT_GRAY): 36 def __init__(self, widget = None, varlist = None, vallist = None, icon = None, button = None, color = HobColors.LIGHT_GRAY):
57 gtk.EventBox.__init__(self) 37 gtk.EventBox.__init__(self)
@@ -62,7 +42,7 @@ class ImageDetailsPage (HobPage):
62 self.set_style(style) 42 self.set_style(style)
63 43
64 self.hbox = gtk.HBox() 44 self.hbox = gtk.HBox()
65 self.hbox.set_border_width(15) 45 self.hbox.set_border_width(10)
66 self.add(self.hbox) 46 self.add(self.hbox)
67 47
68 total_rows = 0 48 total_rows = 0
@@ -131,7 +111,7 @@ class ImageDetailsPage (HobPage):
131 def __init__(self, builder): 111 def __init__(self, builder):
132 super(ImageDetailsPage, self).__init__(builder, "Image details") 112 super(ImageDetailsPage, self).__init__(builder, "Image details")
133 113
134 self.image_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, gobject.TYPE_STRING) 114 self.image_store = []
135 self.button_ids = {} 115 self.button_ids = {}
136 self.details_bottom_buttons = gtk.HBox(False, 6) 116 self.details_bottom_buttons = gtk.HBox(False, 6)
137 self.create_visual_elements() 117 self.create_visual_elements()
@@ -216,7 +196,7 @@ class ImageDetailsPage (HobPage):
216 self.buttonlist = ["Build new image", "Run image", "Deploy image"] 196 self.buttonlist = ["Build new image", "Run image", "Deploy image"]
217 197
218 # Name 198 # Name
219 self.image_store.clear() 199 self.image_store = []
220 self.toggled_image = "" 200 self.toggled_image = ""
221 default_image_size = 0 201 default_image_size = 0
222 self.num_toggled = 0 202 self.num_toggled = 0
@@ -224,44 +204,47 @@ class ImageDetailsPage (HobPage):
224 for image_name in image_names: 204 for image_name in image_names:
225 image_size = HobPage._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size) 205 image_size = HobPage._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size)
226 206
227 image_attr = ("runnable" if (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) else \ 207 image_attr = ("run" if (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) else \
228 ("deploy" if self.test_deployable(image_name) else "")) 208 ("deploy" if self.test_deployable(image_name) else ""))
229 is_toggled = (image_attr != "") 209 is_toggled = (image_attr != "")
230 210
231 if not self.toggled_image: 211 if not self.toggled_image:
232 if i == (len(image_names) - 1): 212 if i == (len(image_names) - 1):
233 is_toggled = True 213 is_toggled = True
234 self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, is_toggled, 3, image_attr)
235 if is_toggled: 214 if is_toggled:
236 default_image_size = image_size 215 default_image_size = image_size
237 self.toggled_image = image_name 216 self.toggled_image = image_name
238 217
218 split_stuff = image_name.split('.')
219 if "rootfs" in split_stuff:
220 image_type = image_name[(len(split_stuff[0]) + len(".rootfs") + 1):]
239 else: 221 else:
240 self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False, 3, image_attr) 222 image_type = image_name[(len(split_stuff[0]) + 1):]
223
224 self.image_store.append({'name': image_name,
225 'type': image_type,
226 'size': image_size,
227 'is_toggled': is_toggled,
228 'action_attr': image_attr,})
229
241 i = i + 1 230 i = i + 1
242 self.num_toggled += is_toggled 231 self.num_toggled += is_toggled
243 232
244 is_runnable = self.create_bottom_buttons(self.buttonlist, self.toggled_image) 233 is_runnable = self.create_bottom_buttons(self.buttonlist, self.toggled_image)
245 234
246 if self.build_succeeded: 235 #if self.build_succeeded:
247 varlist = ["Name: ", "Directory: "] 236 varlist = ["Name: ", "FileCreated: ", "Directory: "]
248 vallist = [] 237 vallist = []
249 vallist.append(image_name.split('.')[0]) 238
250 vallist.append(image_addr) 239 vallist.append(image_name.split('.')[0])
251 image_table = None 240 vallist.append(', '.join(fileitem['type'] for fileitem in self.image_store))
252 else: 241 vallist.append(image_addr)
253 varlist = None
254 vallist = None
255 image_table = HobViewTable(self.__columns__)
256 image_table.set_model(self.image_store)
257 image_table.connect("row-activated", self.row_activated_cb)
258 image_table.connect_group_selection(self.table_selected_cb)
259 242
260 view_files_button = HobAltButton("View files") 243 view_files_button = HobAltButton("View files")
261 view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr) 244 view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr)
262 view_files_button.set_tooltip_text("Open the directory containing the image files") 245 view_files_button.set_tooltip_text("Open the directory containing the image files")
263 self.image_detail = self.DetailBox(widget=image_table, varlist=varlist, vallist=vallist, button=view_files_button) 246 self.image_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=view_files_button)
264 self.box_group_area.pack_start(self.image_detail, expand=True, fill=True) 247 self.box_group_area.pack_start(self.image_detail, expand=False, fill=True)
265 248
266 # The default kernel box for the qemu images 249 # The default kernel box for the qemu images
267 self.sel_kernel = "" 250 self.sel_kernel = ""
@@ -324,7 +307,12 @@ class ImageDetailsPage (HobPage):
324 self.box_group_area.pack_start(self.package_detail, expand=False, fill=False) 307 self.box_group_area.pack_start(self.package_detail, expand=False, fill=False)
325 308
326 # pack the buttons at the bottom, at this time they are already created. 309 # pack the buttons at the bottom, at this time they are already created.
327 self.box_group_area.pack_end(self.details_bottom_buttons, expand=False, fill=False) 310 if self.build_succeeded:
311 self.box_group_area.pack_end(self.details_bottom_buttons, expand=False, fill=False)
312 else: # for "My images" page
313 self.details_separator = gtk.HSeparator()
314 self.box_group_area.pack_start(self.details_separator, expand=False, fill=False)
315 self.box_group_area.pack_start(self.details_bottom_buttons, expand=False, fill=False)
328 316
329 self.show_all() 317 self.show_all()
330 if not is_runnable: 318 if not is_runnable:
@@ -376,25 +364,57 @@ class ImageDetailsPage (HobPage):
376 364
377 return kernel_name 365 return kernel_name
378 366
379 def show_builded_images_dialog(self, widget): 367 def show_builded_images_dialog(self, widget, primary_action=""):
380 dialog = CrumbsDialog("Your builded images", self.builder, 368 title = primary_action if primary_action else "Your builded images"
369 dialog = CrumbsDialog(title, self.builder,
381 gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) 370 gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
382 dialog.set_size_request(-1, 350) 371 dialog.set_border_width(12)
383 372
384 label = gtk.Label() 373 label = gtk.Label()
385 label.set_use_markup(True) 374 label.set_use_markup(True)
386 label.set_alignment(0.0, 0.5) 375 label.set_alignment(0.0, 0.5)
387 label.set_markup("<span font_desc='12'>Please select a image to run or deploy</span>") 376 label.set_markup("<span font_desc='12'>Select the image file you want to %s</span>" % primary_action)
388 dialog.vbox.pack_start(label, expand=False, fill=False) 377 dialog.vbox.pack_start(label, expand=False, fill=False)
389 378
390 image_table = HobViewTable(self.__columns__) 379 # filter created images as action attribution (deploy or run)
391 image_table.set_model(self.image_store) 380 action_attr = ""
392 image_table.connect("row-activated", self.row_activated_cb) 381 action_images = []
393 image_table.connect_group_selection(self.table_selected_cb) 382 for fileitem in self.image_store:
394 dialog.vbox.pack_start(image_table, expand=True, fill=True) 383 action_attr = fileitem['action_attr']
384 if (action_attr == 'run' and primary_action == "Run image") \
385 or (action_attr == 'deploy' and primary_action == "Deploy image"):
386 action_images.append(fileitem)
387
388 # pack the corresponding 'runnable' or 'deploy' radio_buttons, if there has no more than one file.
389 # assume that there does not both have 'deploy' and 'runnable' files in the same building result
390 # in possible as design.
391 curr_row = 0
392 rows = (len(action_images)) if len(action_images) < 10 else 10
393 table = gtk.Table(rows, 10, True)
394 table.set_row_spacings(6)
395 table.set_col_spacing(0, 12)
396 table.set_col_spacing(5, 12)
397
398 sel_parent_btn = None
399 for fileitem in action_images:
400 sel_btn = gtk.RadioButton(sel_parent_btn, fileitem['type'])
401 sel_parent_btn = sel_btn if not sel_parent_btn else sel_parent_btn
402 sel_btn.set_active(fileitem['is_toggled'])
403 sel_btn.connect('toggled', self.table_selected_cb, fileitem)
404 if curr_row < 10:
405 table.attach(sel_btn, 2, 5, curr_row, curr_row + 1)
406 else:
407 table.attach(sel_btn, 7, 10, curr_row - 10, curr_row - 9)
408 curr_row += 1
409
410 dialog.vbox.pack_start(table, expand=False, fill=False, padding = 6)
395 411
396 button = dialog.add_button(" OK ", gtk.RESPONSE_YES) 412 button = dialog.add_button("Cancel", gtk.RESPONSE_CANCEL)
397 HobButton.style_button(button) 413 HobAltButton.style_button(button)
414
415 if primary_action:
416 button = dialog.add_button(primary_action, gtk.RESPONSE_YES)
417 HobButton.style_button(button)
398 418
399 dialog.show_all() 419 dialog.show_all()
400 420
@@ -404,58 +424,17 @@ class ImageDetailsPage (HobPage):
404 if response != gtk.RESPONSE_YES: 424 if response != gtk.RESPONSE_YES:
405 return 425 return
406 426
407 it = self.image_store.get_iter_first() 427 for fileitem in self.image_store:
408 while it: 428 if fileitem['is_toggled']:
409 image_attr = self.image_store.get_value(it, 3) 429 if fileitem['action_attr'] == 'run':
410 is_select = self.image_store.get_value(it, 2) 430 self.builder.runqemu_image(fileitem['name'], self.sel_kernel)
411 if is_select:
412 image_name = self.image_store.get_value(it, 0)
413 if image_attr == 'runnable':
414 self.builder.runqemu_image(image_name, self.sel_kernel)
415 elif image_attr == 'deploy': 431 elif image_attr == 'deploy':
416 self.builder.deploy_image(image_name) 432 self.builder.deploy_image(fileitem['name'])
417 it = self.image_store.iter_next(it)
418
419 def repack_box_group(self, image_name=None):
420 # remove
421 for button_id, button in self.button_ids.items():
422 button.disconnect(button_id)
423 self._remove_all_widget()
424 # repack
425 self.pack_start(self.details_top_buttons, expand=False, fill=False)
426 self.pack_start(self.group_align, expand=True, fill=True)
427 if self.build_result:
428 self.box_group_area.pack_start(self.build_result, expand=False, fill=False)
429 self.box_group_area.pack_start(self.image_detail, expand=True, fill=True)
430 if self.kernel_detail:
431 self.box_group_area.pack_start(self.kernel_detail, expand=False, fill=False)
432 if self.setting_detail:
433 self.box_group_area.pack_start(self.setting_detail, expand=False, fill=False)
434 self.box_group_area.pack_start(self.package_detail, expand=False, fill=False)
435 is_runnable = self.create_bottom_buttons(self.buttonlist, image_name)
436 self.box_group_area.pack_end(self.details_bottom_buttons, expand=False, fill=False)
437 self.show_all()
438 if not is_runnable:
439 self.kernel_detail.hide()
440 433
441 def table_selected_cb(self, selection): 434 def table_selected_cb(self, tbutton, image):
442 model, paths = selection.get_selected_rows() 435 image['is_toggled'] = tbutton.get_active()
443 if (not model) or (not paths): 436 if image['is_toggled']:
444 return 437 self.toggled_image = image['name']
445
446 path = paths[0]
447 columnid = 2
448 iter = model.get_iter_first()
449 while iter:
450 rowpath = model.get_path(iter)
451 model[rowpath][columnid] = False
452 iter = model.iter_next(iter)
453
454 model[path][columnid] = True
455 self.refresh_package_detail_box(model[path][1])
456
457 self.toggled_image = model[path][0]
458 self.repack_box_group(self.toggled_image)
459 438
460 def change_kernel_cb(self, widget): 439 def change_kernel_cb(self, widget):
461 kernel_path = self.builder.show_load_kernel_dialog() 440 kernel_path = self.builder.show_load_kernel_dialog()
@@ -541,12 +520,11 @@ class ImageDetailsPage (HobPage):
541 # create button "Build new image" 520 # create button "Build new image"
542 if packed: 521 if packed:
543 build_new_button = HobAltButton("Build new image") 522 build_new_button = HobAltButton("Build new image")
544 self.details_bottom_buttons.pack_start(build_new_button, expand=False, fill=False)
545 else: 523 else:
546 build_new_button = HobButton("Build new image") 524 build_new_button = HobButton("Build new image")
547 build_new_button.set_size_request(205, 49)
548 build_new_button.set_flags(gtk.CAN_DEFAULT) 525 build_new_button.set_flags(gtk.CAN_DEFAULT)
549 self.details_bottom_buttons.pack_end(build_new_button, expand=False, fill=False) 526 build_new_button.set_size_request(205, 49)
527 self.details_bottom_buttons.pack_end(build_new_button, expand=False, fill=False)
550 build_new_button.set_tooltip_text("Create a new image from scratch") 528 build_new_button.set_tooltip_text("Create a new image from scratch")
551 button_id = build_new_button.connect("clicked", self.build_new_button_clicked_cb) 529 button_id = build_new_button.connect("clicked", self.build_new_button_clicked_cb)
552 self.button_ids[button_id] = build_new_button 530 self.button_ids[button_id] = build_new_button
@@ -557,16 +535,22 @@ class ImageDetailsPage (HobPage):
557 self.builder.show_save_template_dialog() 535 self.builder.show_save_template_dialog()
558 536
559 def deploy_button_clicked_cb(self, button): 537 def deploy_button_clicked_cb(self, button):
560 if self.build_succeeded and self.num_toggled > 1: 538 if self.toggled_image:
561 self.show_builded_images_dialog() 539 if self.build_succeeded or self.num_toggled > 1:
562 return 540 self.set_sensitive(False)
563 self.builder.deploy_image(self.toggled_image) 541 self.show_builded_images_dialog(None, "Deploy image")
542 self.set_sensitive(True)
543 else:
544 self.builder.deploy_image(self.toggled_image)
564 545
565 def run_button_clicked_cb(self, button): 546 def run_button_clicked_cb(self, button):
566 if self.build_succeeded and self.num_toggled > 1: 547 if self.toggled_image:
567 self.show_builded_images_dialog() 548 if self.num_toggled > 1:
568 return 549 self.set_sensitive(False)
569 self.builder.runqemu_image(self.toggled_image, self.sel_kernel) 550 self.show_builded_images_dialog(None, "Run image")
551 self.set_sensitive(True)
552 else:
553 self.builder.runqemu_image(self.toggled_image, self.sel_kernel)
570 554
571 def build_new_button_clicked_cb(self, button): 555 def build_new_button_clicked_cb(self, button):
572 self.builder.initiate_new_build_async() 556 self.builder.initiate_new_build_async()