diff options
-rwxr-xr-x | bitbake/lib/bb/ui/crumbs/imagedetailspage.py | 122 |
1 files changed, 84 insertions, 38 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py index b4fc15c6fd..ac631b6a20 100755 --- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py +++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py | |||
@@ -113,6 +113,8 @@ class ImageDetailsPage (HobPage): | |||
113 | super(ImageDetailsPage, self).__init__(builder, "Image details") | 113 | super(ImageDetailsPage, self).__init__(builder, "Image details") |
114 | 114 | ||
115 | self.image_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_BOOLEAN) | 115 | self.image_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_BOOLEAN) |
116 | self.button_ids = {} | ||
117 | self.details_bottom_buttons = gtk.HBox(False, 6) | ||
116 | self.create_visual_elements() | 118 | self.create_visual_elements() |
117 | 119 | ||
118 | def create_visual_elements(self): | 120 | def create_visual_elements(self): |
@@ -150,6 +152,9 @@ class ImageDetailsPage (HobPage): | |||
150 | children = self.box_group_area.get_children() or [] | 152 | children = self.box_group_area.get_children() or [] |
151 | for child in children: | 153 | for child in children: |
152 | self.box_group_area.remove(child) | 154 | self.box_group_area.remove(child) |
155 | children = self.details_bottom_buttons.get_children() or [] | ||
156 | for child in children: | ||
157 | self.details_bottom_buttons.remove(child) | ||
153 | 158 | ||
154 | def show_page(self, step): | 159 | def show_page(self, step): |
155 | build_succeeded = (step == self.builder.IMAGE_GENERATED) | 160 | build_succeeded = (step == self.builder.IMAGE_GENERATED) |
@@ -163,10 +168,15 @@ class ImageDetailsPage (HobPage): | |||
163 | else: | 168 | else: |
164 | pkg_num = "N/A" | 169 | pkg_num = "N/A" |
165 | 170 | ||
171 | # remove | ||
172 | for button_id, button in self.button_ids.items(): | ||
173 | button.disconnect(button_id) | ||
166 | self._remove_all_widget() | 174 | self._remove_all_widget() |
175 | # repack | ||
167 | self.pack_start(self.details_top_buttons, expand=False, fill=False) | 176 | self.pack_start(self.details_top_buttons, expand=False, fill=False) |
168 | self.pack_start(self.group_align, expand=True, fill=True) | 177 | self.pack_start(self.group_align, expand=True, fill=True) |
169 | 178 | ||
179 | self.build_result = None | ||
170 | if build_succeeded: | 180 | if build_succeeded: |
171 | # building is the previous step | 181 | # building is the previous step |
172 | icon = gtk.Image() | 182 | icon = gtk.Image() |
@@ -176,43 +186,48 @@ class ImageDetailsPage (HobPage): | |||
176 | icon.set_from_pixbuf(pix_buffer) | 186 | icon.set_from_pixbuf(pix_buffer) |
177 | varlist = [""] | 187 | varlist = [""] |
178 | vallist = ["Your image is ready"] | 188 | vallist = ["Your image is ready"] |
179 | build_result = self.DetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color) | 189 | self.build_result = self.DetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color) |
180 | self.box_group_area.pack_start(build_result, expand=False, fill=False) | 190 | self.box_group_area.pack_start(self.build_result, expand=False, fill=False) |
181 | 191 | ||
182 | # create the buttons at the bottom first because the buttons are used in apply_button_per_image() | 192 | # create the buttons at the bottom first because the buttons are used in apply_button_per_image() |
183 | if build_succeeded: | 193 | if build_succeeded: |
184 | buttonlist = ["Build new image", "Save as template", "Run image", "Deploy image"] | 194 | self.buttonlist = ["Build new image", "Save as template", "Run image", "Deploy image"] |
185 | else: # get to this page from "My images" | 195 | else: # get to this page from "My images" |
186 | buttonlist = ["Build new image", "Run image", "Deploy image"] | 196 | self.buttonlist = ["Build new image", "Run image", "Deploy image"] |
187 | details_bottom_buttons = self.create_bottom_buttons(buttonlist) | ||
188 | 197 | ||
189 | # Name | 198 | # Name |
190 | self.image_store.clear() | 199 | self.image_store.clear() |
191 | default_toggled = False | 200 | default_toggled = False |
192 | default_image_size = 0 | 201 | default_image_size = 0 |
202 | i = 0 | ||
193 | for image_name in image_names: | 203 | for image_name in image_names: |
194 | image_size = HobPage._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size) | 204 | image_size = HobPage._size_to_string(os.stat(os.path.join(image_addr, image_name)).st_size) |
195 | if not default_toggled: | 205 | if not default_toggled: |
196 | default_toggled = (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) \ | 206 | default_toggled = (self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) \ |
197 | or self.test_deployable(image_name) | 207 | or self.test_deployable(image_name) |
208 | if i == (len(image_names) - 1): | ||
209 | default_toggled = True | ||
198 | self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, default_toggled) | 210 | self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, default_toggled) |
199 | if default_toggled: | 211 | if default_toggled: |
200 | default_image_size = image_size | 212 | default_image_size = image_size |
201 | self.apply_buttons_per_image(image_name) | 213 | self.create_bottom_buttons(self.buttonlist, image_name) |
202 | else: | 214 | else: |
203 | self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False) | 215 | self.image_store.set(self.image_store.append(), 0, image_name, 1, image_size, 2, False) |
216 | i = i + 1 | ||
204 | image_table = HobViewTable(self.__columns__) | 217 | image_table = HobViewTable(self.__columns__) |
205 | image_table.set_model(self.image_store) | 218 | image_table.set_model(self.image_store) |
206 | image_table.connect("toggled", self.toggled_cb) | 219 | image_table.connect("toggled", self.toggled_cb) |
207 | view_files_button = HobAltButton("View files") | 220 | view_files_button = HobAltButton("View files") |
208 | view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr) | 221 | view_files_button.connect("clicked", self.view_files_clicked_cb, image_addr) |
209 | view_files_button.set_tooltip_text("Open the directory containing the image files") | 222 | view_files_button.set_tooltip_text("Open the directory containing the image files") |
210 | self.box_group_area.pack_start(self.DetailBox(widget=image_table, button=view_files_button), expand=True, fill=True) | 223 | self.image_detail = self.DetailBox(widget=image_table, button=view_files_button) |
224 | self.box_group_area.pack_start(self.image_detail, expand=True, fill=True) | ||
211 | 225 | ||
212 | # Machine, Base image and Layers | 226 | # Machine, Base image and Layers |
213 | layer_num_limit = 15 | 227 | layer_num_limit = 15 |
214 | varlist = ["Machine: ", "Base image: ", "Layers: "] | 228 | varlist = ["Machine: ", "Base image: ", "Layers: "] |
215 | vallist = [] | 229 | vallist = [] |
230 | self.setting_detail = None | ||
216 | if build_succeeded: | 231 | if build_succeeded: |
217 | vallist.append(machine) | 232 | vallist.append(machine) |
218 | vallist.append(base_image) | 233 | vallist.append(base_image) |
@@ -236,8 +251,8 @@ class ImageDetailsPage (HobPage): | |||
236 | edit_config_button = HobAltButton("Edit configuration") | 251 | edit_config_button = HobAltButton("Edit configuration") |
237 | edit_config_button.set_tooltip_text("Edit machine, base image and recipes") | 252 | edit_config_button.set_tooltip_text("Edit machine, base image and recipes") |
238 | edit_config_button.connect("clicked", self.edit_config_button_clicked_cb) | 253 | edit_config_button.connect("clicked", self.edit_config_button_clicked_cb) |
239 | setting_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_config_button) | 254 | self.setting_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_config_button) |
240 | self.box_group_area.pack_start(setting_detail, expand=False, fill=False) | 255 | self.box_group_area.pack_start(self.setting_detail, expand=False, fill=False) |
241 | 256 | ||
242 | # Packages included, and Total image size | 257 | # Packages included, and Total image size |
243 | varlist = ["Packages included: ", "Total image size: "] | 258 | varlist = ["Packages included: ", "Total image size: "] |
@@ -254,7 +269,7 @@ class ImageDetailsPage (HobPage): | |||
254 | self.box_group_area.pack_start(self.package_detail, expand=False, fill=False) | 269 | self.box_group_area.pack_start(self.package_detail, expand=False, fill=False) |
255 | 270 | ||
256 | # pack the buttons at the bottom, at this time they are already created. | 271 | # pack the buttons at the bottom, at this time they are already created. |
257 | self.box_group_area.pack_end(details_bottom_buttons, expand=False, fill=False) | 272 | self.box_group_area.pack_end(self.details_bottom_buttons, expand=False, fill=False) |
258 | 273 | ||
259 | self.show_all() | 274 | self.show_all() |
260 | 275 | ||
@@ -288,10 +303,6 @@ class ImageDetailsPage (HobPage): | |||
288 | break | 303 | break |
289 | return deployable | 304 | return deployable |
290 | 305 | ||
291 | def apply_buttons_per_image(self, image_name): | ||
292 | self.run_button.set_sensitive(self.test_type_runnable(image_name) and self.test_mach_runnable(image_name)) | ||
293 | self.deploy_button.set_sensitive(self.test_deployable(image_name)) | ||
294 | |||
295 | def toggled_cb(self, table, cell, path, columnid, tree): | 306 | def toggled_cb(self, table, cell, path, columnid, tree): |
296 | model = tree.get_model() | 307 | model = tree.get_model() |
297 | if not model: | 308 | if not model: |
@@ -306,50 +317,86 @@ class ImageDetailsPage (HobPage): | |||
306 | self.refresh_package_detail_box(model[path][1]) | 317 | self.refresh_package_detail_box(model[path][1]) |
307 | 318 | ||
308 | image_name = model[path][0] | 319 | image_name = model[path][0] |
309 | self.apply_buttons_per_image(image_name) | ||
310 | 320 | ||
311 | def create_bottom_buttons(self, buttonlist): | 321 | # remove |
322 | for button_id, button in self.button_ids.items(): | ||
323 | button.disconnect(button_id) | ||
324 | self._remove_all_widget() | ||
325 | # repack | ||
326 | self.pack_start(self.details_top_buttons, expand=False, fill=False) | ||
327 | self.pack_start(self.group_align, expand=True, fill=True) | ||
328 | if self.build_result: | ||
329 | self.box_group_area.pack_start(self.build_result, expand=False, fill=False) | ||
330 | self.box_group_area.pack_start(self.image_detail, expand=True, fill=True) | ||
331 | if self.setting_detail: | ||
332 | self.box_group_area.pack_start(self.setting_detail, expand=False, fill=False) | ||
333 | self.box_group_area.pack_start(self.package_detail, expand=False, fill=False) | ||
334 | self.create_bottom_buttons(self.buttonlist, image_name) | ||
335 | self.box_group_area.pack_end(self.details_bottom_buttons, expand=False, fill=False) | ||
336 | self.show_all() | ||
337 | |||
338 | def create_bottom_buttons(self, buttonlist, image_name): | ||
312 | # Create the buttons at the bottom | 339 | # Create the buttons at the bottom |
313 | bottom_buttons = gtk.HBox(False, 6) | ||
314 | created = False | 340 | created = False |
341 | packed = False | ||
342 | self.button_ids = {} | ||
315 | 343 | ||
316 | # create button "Deploy image" | 344 | # create button "Deploy image" |
317 | name = "Deploy image" | 345 | name = "Deploy image" |
318 | if name in buttonlist: | 346 | if name in buttonlist and self.test_deployable(image_name): |
319 | self.deploy_button = HobButton('Deploy image') | 347 | deploy_button = HobButton('Deploy image') |
320 | self.deploy_button.set_size_request(205, 49) | 348 | deploy_button.set_size_request(205, 49) |
321 | self.deploy_button.set_tooltip_text("Burn a live image to a USB drive or flash memory") | 349 | deploy_button.set_tooltip_text("Burn a live image to a USB drive or flash memory") |
322 | self.deploy_button.set_flags(gtk.CAN_DEFAULT) | 350 | deploy_button.set_flags(gtk.CAN_DEFAULT) |
323 | self.deploy_button.connect("clicked", self.deploy_button_clicked_cb) | 351 | button_id = deploy_button.connect("clicked", self.deploy_button_clicked_cb) |
324 | bottom_buttons.pack_end(self.deploy_button, expand=False, fill=False) | 352 | self.button_ids[button_id] = deploy_button |
353 | self.details_bottom_buttons.pack_end(deploy_button, expand=False, fill=False) | ||
325 | created = True | 354 | created = True |
355 | packed = True | ||
326 | 356 | ||
327 | name = "Run image" | 357 | name = "Run image" |
328 | if name in buttonlist: | 358 | if name in buttonlist and self.test_type_runnable(image_name) and self.test_mach_runnable(image_name): |
329 | if created == True: | 359 | if created == True: |
330 | # separator | 360 | # separator |
331 | label = gtk.Label(" or ") | 361 | label = gtk.Label(" or ") |
332 | bottom_buttons.pack_end(label, expand=False, fill=False) | 362 | self.details_bottom_buttons.pack_end(label, expand=False, fill=False) |
333 | 363 | ||
334 | # create button "Run image" | 364 | # create button "Run image" |
335 | self.run_button = HobAltButton("Run image") | 365 | run_button = HobAltButton("Run image") |
336 | self.run_button.set_tooltip_text("Start up an image with qemu emulator") | 366 | else: |
337 | self.run_button.connect("clicked", self.run_button_clicked_cb) | 367 | # create button "Run image" as the primary button |
338 | bottom_buttons.pack_end(self.run_button, expand=False, fill=False) | 368 | run_button = HobButton("Run image") |
369 | run_button.set_size_request(205, 49) | ||
370 | run_button.set_flags(gtk.CAN_DEFAULT) | ||
371 | packed = True | ||
372 | run_button.set_tooltip_text("Start up an image with qemu emulator") | ||
373 | button_id = run_button.connect("clicked", self.run_button_clicked_cb) | ||
374 | self.button_ids[button_id] = run_button | ||
375 | self.details_bottom_buttons.pack_end(run_button, expand=False, fill=False) | ||
339 | created = True | 376 | created = True |
340 | 377 | ||
378 | if not packed: | ||
379 | box = gtk.HBox(False, 6) | ||
380 | box.show() | ||
381 | subbox = gtk.HBox(False, 0) | ||
382 | subbox.set_size_request(205, 49) | ||
383 | subbox.show() | ||
384 | box.add(subbox) | ||
385 | self.details_bottom_buttons.pack_end(box, False, False) | ||
386 | |||
341 | name = "Save as template" | 387 | name = "Save as template" |
342 | if name in buttonlist: | 388 | if name in buttonlist: |
343 | if created == True: | 389 | if created == True: |
344 | # separator | 390 | # separator |
345 | label = gtk.Label(" or ") | 391 | label = gtk.Label(" or ") |
346 | bottom_buttons.pack_end(label, expand=False, fill=False) | 392 | self.details_bottom_buttons.pack_end(label, expand=False, fill=False) |
347 | 393 | ||
348 | # create button "Save as template" | 394 | # create button "Save as template" |
349 | save_button = HobAltButton("Save as template") | 395 | save_button = HobAltButton("Save as template") |
350 | save_button.set_tooltip_text("Save the image configuration for reuse") | 396 | save_button.set_tooltip_text("Save the image configuration for reuse") |
351 | save_button.connect("clicked", self.save_button_clicked_cb) | 397 | button_id = save_button.connect("clicked", self.save_button_clicked_cb) |
352 | bottom_buttons.pack_end(save_button, expand=False, fill=False) | 398 | self.button_ids[button_id] = save_button |
399 | self.details_bottom_buttons.pack_end(save_button, expand=False, fill=False) | ||
353 | create = True | 400 | create = True |
354 | 401 | ||
355 | name = "Build new image" | 402 | name = "Build new image" |
@@ -357,10 +404,9 @@ class ImageDetailsPage (HobPage): | |||
357 | # create button "Build new image" | 404 | # create button "Build new image" |
358 | build_new_button = HobAltButton("Build new image") | 405 | build_new_button = HobAltButton("Build new image") |
359 | build_new_button.set_tooltip_text("Create a new image from scratch") | 406 | build_new_button.set_tooltip_text("Create a new image from scratch") |
360 | build_new_button.connect("clicked", self.build_new_button_clicked_cb) | 407 | button_id = build_new_button.connect("clicked", self.build_new_button_clicked_cb) |
361 | bottom_buttons.pack_start(build_new_button, expand=False, fill=False) | 408 | self.button_ids[button_id] = build_new_button |
362 | 409 | self.details_bottom_buttons.pack_start(build_new_button, expand=False, fill=False) | |
363 | return bottom_buttons | ||
364 | 410 | ||
365 | def _get_selected_image(self): | 411 | def _get_selected_image(self): |
366 | image_name = "" | 412 | image_name = "" |