diff options
Diffstat (limited to 'bitbake')
| -rwxr-xr-x | bitbake/lib/bb/ui/crumbs/builder.py | 3 | ||||
| -rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py | 136 | ||||
| -rw-r--r-- | bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 3 | ||||
| -rw-r--r-- | bitbake/lib/bb/ui/crumbs/hoblistmodel.py | 3 | ||||
| -rwxr-xr-x | bitbake/lib/bb/ui/crumbs/imagedetailspage.py | 20 |
5 files changed, 163 insertions, 2 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py index a7bd21c923..317a2fe16d 100755 --- a/bitbake/lib/bb/ui/crumbs/builder.py +++ b/bitbake/lib/bb/ui/crumbs/builder.py | |||
| @@ -1451,3 +1451,6 @@ class Builder(gtk.Window): | |||
| 1451 | self.consolelog.setFormatter(format) | 1451 | self.consolelog.setFormatter(format) |
| 1452 | 1452 | ||
| 1453 | self.logger.addHandler(self.consolelog) | 1453 | self.logger.addHandler(self.consolelog) |
| 1454 | |||
| 1455 | def get_topdir(self): | ||
| 1456 | return self.handler.get_topdir() | ||
diff --git a/bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py b/bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py new file mode 100644 index 0000000000..3fc389aaa1 --- /dev/null +++ b/bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py | |||
| @@ -0,0 +1,136 @@ | |||
| 1 | # | ||
| 2 | # BitBake Graphical GTK User Interface | ||
| 3 | # | ||
| 4 | # Copyright (C) 2013 Intel Corporation | ||
| 5 | # | ||
| 6 | # Authored by Cristiana Voicu <cristiana.voicu@intel.com> | ||
| 7 | # | ||
| 8 | # This program is free software; you can redistribute it and/or modify | ||
| 9 | # it under the terms of the GNU General Public License version 2 as | ||
| 10 | # published by the Free Software Foundation. | ||
| 11 | # | ||
| 12 | # This program is distributed in the hope that it will be useful, | ||
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | # GNU General Public License for more details. | ||
| 16 | # | ||
| 17 | # You should have received a copy of the GNU General Public License along | ||
| 18 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 20 | |||
| 21 | import gtk | ||
| 22 | import glib | ||
| 23 | from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog | ||
| 24 | from bb.ui.crumbs.hig.crumbsmessagedialog import CrumbsMessageDialog | ||
| 25 | from bb.ui.crumbs.hobwidget import HobButton | ||
| 26 | |||
| 27 | class SaveImageDialog (CrumbsDialog): | ||
| 28 | """ | ||
| 29 | This class is used to create a dialog that permits to save | ||
| 30 | a custom image in a predefined directory. | ||
| 31 | """ | ||
| 32 | def __init__(self, directory, title, parent, flags, buttons=None): | ||
| 33 | super(SaveImageDialog, self).__init__(title, parent, flags, buttons) | ||
| 34 | self.directory = directory | ||
| 35 | self.builder = parent | ||
| 36 | |||
| 37 | # create visual elements on the dialog | ||
| 38 | self.create_visual_elements() | ||
| 39 | |||
| 40 | def create_visual_elements(self): | ||
| 41 | self.set_default_response(gtk.RESPONSE_OK) | ||
| 42 | self.vbox.set_border_width(6) | ||
| 43 | |||
| 44 | sub_vbox = gtk.VBox(False, 12) | ||
| 45 | self.vbox.pack_start(sub_vbox, expand=False, fill=False) | ||
| 46 | label = gtk.Label() | ||
| 47 | label.set_alignment(0, 0) | ||
| 48 | label.set_markup("<b>Name</b>") | ||
| 49 | sub_label = gtk.Label() | ||
| 50 | sub_label.set_alignment(0, 0) | ||
| 51 | content = "Image recipe names should be all lowercase and include only alphanumeric\n" | ||
| 52 | content += "characters. The only special character you can use is the ASCII hyphen (-)." | ||
| 53 | sub_label.set_markup(content) | ||
| 54 | self.name_entry = gtk.Entry() | ||
| 55 | self.name_entry.set_size_request(350,30) | ||
| 56 | self.name_entry.connect("changed", self.name_entry_changed) | ||
| 57 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
| 58 | sub_vbox.pack_start(sub_label, expand=False, fill=False) | ||
| 59 | sub_vbox.pack_start(self.name_entry, expand=False, fill=False) | ||
| 60 | |||
| 61 | sub_vbox = gtk.VBox(False, 12) | ||
| 62 | self.vbox.pack_start(sub_vbox, expand=False, fill=False) | ||
| 63 | label = gtk.Label() | ||
| 64 | label.set_alignment(0, 0) | ||
| 65 | label.set_markup("<b>Description</b> (optional)") | ||
| 66 | sub_label = gtk.Label() | ||
| 67 | sub_label.set_alignment(0, 0) | ||
| 68 | sub_label.set_markup("The description should be less than 150 characters long.") | ||
| 69 | self.description_entry = gtk.TextView() | ||
| 70 | self.description_entry.set_wrap_mode(gtk.WRAP_WORD) | ||
| 71 | self.description_entry.set_size_request(350,150) | ||
| 72 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
| 73 | sub_vbox.pack_start(sub_label, expand=False, fill=False) | ||
| 74 | sub_vbox.pack_start(self.description_entry, expand=False, fill=False) | ||
| 75 | |||
| 76 | sub_vbox = gtk.VBox(False, 12) | ||
| 77 | self.vbox.pack_start(sub_vbox, expand=False, fill=False) | ||
| 78 | label = gtk.Label() | ||
| 79 | label.set_alignment(0, 0) | ||
| 80 | label.set_markup("Your image recipe will be saved to:") | ||
| 81 | sub_label = gtk.Label() | ||
| 82 | sub_label.set_alignment(0, 0) | ||
| 83 | sub_label.set_markup(self.directory) | ||
| 84 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
| 85 | sub_vbox.pack_start(sub_label, expand=False, fill=False) | ||
| 86 | |||
| 87 | table = gtk.Table(1, 4, True) | ||
| 88 | |||
| 89 | cancel_button = gtk.Button() | ||
| 90 | cancel_button.set_label("Cancel") | ||
| 91 | cancel_button.connect("clicked", self.cancel_button_cb) | ||
| 92 | cancel_button.set_size_request(110, 30) | ||
| 93 | |||
| 94 | self.save_button = gtk.Button() | ||
| 95 | self.save_button.set_label("Save") | ||
| 96 | self.save_button.connect("clicked", self.save_button_cb) | ||
| 97 | self.save_button.set_size_request(110, 30) | ||
| 98 | self.save_button.set_sensitive(False) | ||
| 99 | |||
| 100 | table.attach(cancel_button, 2, 3, 0, 1) | ||
| 101 | table.attach(self.save_button, 3, 4, 0, 1) | ||
| 102 | self.vbox.pack_end(table, expand=False, fill=False) | ||
| 103 | |||
| 104 | self.show_all() | ||
| 105 | |||
| 106 | def name_entry_changed(self, entry): | ||
| 107 | text = entry.get_text() | ||
| 108 | if text == '': | ||
| 109 | self.save_button.set_sensitive(False) | ||
| 110 | else: | ||
| 111 | self.save_button.set_sensitive(True) | ||
| 112 | |||
| 113 | def cancel_button_cb(self, button): | ||
| 114 | self.destroy() | ||
| 115 | |||
| 116 | def save_button_cb(self, button): | ||
| 117 | text = self.name_entry.get_text() | ||
| 118 | new_text = text.replace("-","") | ||
| 119 | if new_text.islower() and new_text.isalnum(): | ||
| 120 | print(text) | ||
| 121 | self.destroy() | ||
| 122 | else: | ||
| 123 | self.show_invalid_input_error_dialog() | ||
| 124 | |||
| 125 | def show_invalid_input_error_dialog(self): | ||
| 126 | lbl = "<b>Invalid characters in image recipe name</b>\n" | ||
| 127 | msg = "Image recipe names should be all lowercase and\n" | ||
| 128 | msg += "include only alphanumeric characters. The only\n" | ||
| 129 | msg += "special character you can use is the ASCII hyphen (-)." | ||
| 130 | lbl = lbl + "\n%s\n" % glib.markup_escape_text(msg) | ||
| 131 | dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_ERROR) | ||
| 132 | button = dialog.add_button("Close", gtk.RESPONSE_OK) | ||
| 133 | HobButton.style_button(button) | ||
| 134 | |||
| 135 | res = dialog.run() | ||
| 136 | dialog.destroy() | ||
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py index 4c6e6fd06e..294eb5dd1f 100644 --- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py +++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py | |||
| @@ -452,6 +452,9 @@ class HobHandler(gobject.GObject): | |||
| 452 | def get_logfile(self): | 452 | def get_logfile(self): |
| 453 | return self.server.runCommand(["getVariable", "BB_CONSOLELOG"])[0] | 453 | return self.server.runCommand(["getVariable", "BB_CONSOLELOG"])[0] |
| 454 | 454 | ||
| 455 | def get_topdir(self): | ||
| 456 | return self.runCommand(["getVariable", "TOPDIR"]) or "" | ||
| 457 | |||
| 455 | def _remove_redundant(self, string): | 458 | def _remove_redundant(self, string): |
| 456 | ret = [] | 459 | ret = [] |
| 457 | for i in string.split(): | 460 | for i in string.split(): |
diff --git a/bitbake/lib/bb/ui/crumbs/hoblistmodel.py b/bitbake/lib/bb/ui/crumbs/hoblistmodel.py index 94c2453abd..d8f3256e10 100644 --- a/bitbake/lib/bb/ui/crumbs/hoblistmodel.py +++ b/bitbake/lib/bb/ui/crumbs/hoblistmodel.py | |||
| @@ -882,3 +882,6 @@ class RecipeListModel(gtk.ListStore): | |||
| 882 | 882 | ||
| 883 | def get_custom_image_version(self): | 883 | def get_custom_image_version(self): |
| 884 | return self.custom_image_version | 884 | return self.custom_image_version |
| 885 | |||
| 886 | def is_custom_image(self): | ||
| 887 | return self.get_selected_image() == self.__custom_image__ | ||
diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py index 4b0e7498cd..a02ab610c0 100755 --- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py +++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py | |||
| @@ -27,6 +27,7 @@ from bb.ui.crumbs.hobwidget import hic, HobViewTable, HobAltButton, HobButton | |||
| 27 | from bb.ui.crumbs.hobpages import HobPage | 27 | from bb.ui.crumbs.hobpages import HobPage |
| 28 | import subprocess | 28 | import subprocess |
| 29 | from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog | 29 | from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog |
| 30 | from bb.ui.crumbs.hig.saveimagedialog import SaveImageDialog | ||
| 30 | 31 | ||
| 31 | # | 32 | # |
| 32 | # ImageDetailsPage | 33 | # ImageDetailsPage |
| @@ -259,7 +260,7 @@ class ImageDetailsPage (HobPage): | |||
| 259 | self.build_result = self.BuildDetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color) | 260 | self.build_result = self.BuildDetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color) |
| 260 | self.box_group_area.pack_start(self.build_result, expand=False, fill=False) | 261 | self.box_group_area.pack_start(self.build_result, expand=False, fill=False) |
| 261 | 262 | ||
| 262 | self.buttonlist = ["Build new image", "Run image", "Deploy image"] | 263 | self.buttonlist = ["Build new image", "Save image recipe", "Run image", "Deploy image"] |
| 263 | 264 | ||
| 264 | # Name | 265 | # Name |
| 265 | self.image_store = [] | 266 | self.image_store = [] |
| @@ -340,7 +341,7 @@ class ImageDetailsPage (HobPage): | |||
| 340 | self.setting_detail = None | 341 | self.setting_detail = None |
| 341 | if self.build_succeeded: | 342 | if self.build_succeeded: |
| 342 | vallist.append(machine) | 343 | vallist.append(machine) |
| 343 | if base_image == self.builder.recipe_model.__custom_image__: | 344 | if self.builder.recipe_model.is_custom_image(): |
| 344 | if self.builder.configuration.initial_selected_image == self.builder.recipe_model.__custom_image__: | 345 | if self.builder.configuration.initial_selected_image == self.builder.recipe_model.__custom_image__: |
| 345 | base_image ="New image recipe" | 346 | base_image ="New image recipe" |
| 346 | else: | 347 | else: |
| @@ -579,6 +580,13 @@ class ImageDetailsPage (HobPage): | |||
| 579 | created = True | 580 | created = True |
| 580 | is_runnable = True | 581 | is_runnable = True |
| 581 | 582 | ||
| 583 | name = "Save image recipe" | ||
| 584 | if name in buttonlist and self.builder.recipe_model.is_custom_image(): | ||
| 585 | save_button = HobAltButton("Save image recipe") | ||
| 586 | button_id = save_button.connect("clicked", self.save_button_clicked_cb) | ||
| 587 | self.button_ids[button_id] = save_button | ||
| 588 | self.details_bottom_buttons.pack_end(save_button, expand=False, fill=False) | ||
| 589 | |||
| 582 | name = "Build new image" | 590 | name = "Build new image" |
| 583 | if name in buttonlist: | 591 | if name in buttonlist: |
| 584 | # create button "Build new image" | 592 | # create button "Build new image" |
| @@ -613,6 +621,14 @@ class ImageDetailsPage (HobPage): | |||
| 613 | else: | 621 | else: |
| 614 | self.builder.runqemu_image(self.toggled_image, self.sel_kernel) | 622 | self.builder.runqemu_image(self.toggled_image, self.sel_kernel) |
| 615 | 623 | ||
| 624 | def save_button_clicked_cb(self, button): | ||
| 625 | topdir = self.builder.get_topdir() | ||
| 626 | images_dir = topdir + "/recipes/images/" | ||
| 627 | dialog = SaveImageDialog(images_dir, "Save image recipe", self.builder, | ||
| 628 | gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) | ||
| 629 | response = dialog.run() | ||
| 630 | dialog.destroy() | ||
| 631 | |||
| 616 | def build_new_button_clicked_cb(self, button): | 632 | def build_new_button_clicked_cb(self, button): |
| 617 | self.builder.initiate_new_build_async() | 633 | self.builder.initiate_new_build_async() |
| 618 | 634 | ||
