diff options
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py | 358 |
1 files changed, 358 insertions, 0 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py b/bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py new file mode 100644 index 0000000000..d3a9ffd710 --- /dev/null +++ b/bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py | |||
@@ -0,0 +1,358 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # | ||
3 | # BitBake Graphical GTK User Interface | ||
4 | # | ||
5 | # Copyright (C) 2012 Intel Corporation | ||
6 | # | ||
7 | # Authored by Dongxiao Xu <dongxiao.xu@intel.com> | ||
8 | # Authored by Shane Wang <shane.wang@intel.com> | ||
9 | # | ||
10 | # This program is free software; you can redistribute it and/or modify | ||
11 | # it under the terms of the GNU General Public License version 2 as | ||
12 | # published by the Free Software Foundation. | ||
13 | # | ||
14 | # This program is distributed in the hope that it will be useful, | ||
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | # GNU General Public License for more details. | ||
18 | # | ||
19 | # You should have received a copy of the GNU General Public License along | ||
20 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
22 | |||
23 | import gtk | ||
24 | import glib | ||
25 | from bb.ui.crumbs.progressbar import HobProgressBar | ||
26 | from bb.ui.crumbs.hobcolor import HobColors | ||
27 | from bb.ui.crumbs.hobwidget import hic, HobXpmLabelButtonBox | ||
28 | from bb.ui.crumbs.hoblistmodel import RecipeListModel | ||
29 | from bb.ui.crumbs.hobpages import HobPage | ||
30 | |||
31 | from bb.ui.crumbs.hig import CrumbsDialog, BinbDialog, \ | ||
32 | AdvancedSettingDialog, LayerSelectionDialog | ||
33 | |||
34 | # | ||
35 | # ImageConfigurationPage | ||
36 | # | ||
37 | class ImageConfigurationPage (HobPage): | ||
38 | |||
39 | __dummy_machine__ = "--select a machine--" | ||
40 | |||
41 | def __init__(self, builder): | ||
42 | super(ImageConfigurationPage, self).__init__(builder, "Image configuration") | ||
43 | |||
44 | self.image_combo_id = None | ||
45 | self.create_visual_elements() | ||
46 | |||
47 | def create_visual_elements(self): | ||
48 | # create visual elements | ||
49 | self.toolbar = gtk.Toolbar() | ||
50 | self.toolbar.set_orientation(gtk.ORIENTATION_HORIZONTAL) | ||
51 | self.toolbar.set_style(gtk.TOOLBAR_BOTH) | ||
52 | |||
53 | _, template_button = self.append_toolbar_button(self.toolbar, | ||
54 | "Template", | ||
55 | hic.ICON_TEMPLATES_DISPLAY_FILE, | ||
56 | hic.ICON_TEMPLATES_HOVER_FILE, | ||
57 | "Load a hob building template saved before", | ||
58 | self.template_button_clicked_cb) | ||
59 | _, my_images_button = self.append_toolbar_button(self.toolbar, | ||
60 | "My images", | ||
61 | hic.ICON_IMAGES_DISPLAY_FILE, | ||
62 | hic.ICON_IMAGES_HOVER_FILE, | ||
63 | "Open images built out previously for running or deployment", | ||
64 | self.my_images_button_clicked_cb) | ||
65 | _, settings_button = self.append_toolbar_button(self.toolbar, | ||
66 | "Settings", | ||
67 | hic.ICON_SETTINGS_DISPLAY_FILE, | ||
68 | hic.ICON_SETTINGS_HOVER_FILE, | ||
69 | "Other advanced settings for build", | ||
70 | self.settings_button_clicked_cb) | ||
71 | |||
72 | self.config_top_button = self.add_onto_top_bar(self.toolbar) | ||
73 | |||
74 | self.gtable = gtk.Table(40, 40, True) | ||
75 | self.create_config_machine() | ||
76 | self.create_config_baseimg() | ||
77 | self.config_build_button = self.create_config_build_button() | ||
78 | |||
79 | def _remove_all_widget(self): | ||
80 | children = self.gtable.get_children() or [] | ||
81 | for child in children: | ||
82 | self.gtable.remove(child) | ||
83 | children = self.box_group_area.get_children() or [] | ||
84 | for child in children: | ||
85 | self.box_group_area.remove(child) | ||
86 | children = self.get_children() or [] | ||
87 | for child in children: | ||
88 | self.remove(child) | ||
89 | |||
90 | def _pack_components(self): | ||
91 | self._remove_all_widget() | ||
92 | self.pack_start(self.config_top_button, expand=False, fill=False) | ||
93 | self.pack_start(self.group_align, expand=True, fill=True) | ||
94 | |||
95 | self.box_group_area.pack_start(self.gtable, expand=True, fill=True) | ||
96 | self.box_group_area.pack_end(self.config_build_button, expand=False, fill=False) | ||
97 | |||
98 | def show_machine(self): | ||
99 | self._pack_components() | ||
100 | self.set_config_machine_layout() | ||
101 | self.show_all() | ||
102 | self.progress_bar.reset() | ||
103 | self.progress_bar.hide() | ||
104 | self.config_build_button.hide_all() | ||
105 | |||
106 | def update_progress_bar(self, title, fraction, status=True): | ||
107 | self.progress_bar.update(fraction) | ||
108 | self.progress_bar.set_title(title) | ||
109 | self.progress_bar.set_rcstyle(status) | ||
110 | |||
111 | def show_info_populating(self): | ||
112 | self._pack_components() | ||
113 | self.set_config_machine_layout() | ||
114 | self.show_all() | ||
115 | self.config_build_button.hide_all() | ||
116 | |||
117 | def show_info_populated(self): | ||
118 | self._pack_components() | ||
119 | self.set_config_machine_layout() | ||
120 | self.set_config_baseimg_layout() | ||
121 | self.show_all() | ||
122 | self.progress_bar.reset() | ||
123 | self.progress_bar.hide() | ||
124 | |||
125 | def create_config_machine(self): | ||
126 | self.machine_title = gtk.Label() | ||
127 | self.machine_title.set_alignment(0.0, 0.5) | ||
128 | mark = "<span %s>Select a machine</span>" % self.span_tag('24px', 'bold') | ||
129 | self.machine_title.set_markup(mark) | ||
130 | |||
131 | self.machine_title_desc = gtk.Label() | ||
132 | self.machine_title_desc.set_alignment(0, 0.5) | ||
133 | mark = ("<span %s>This is the profile of the target machine for which you" | ||
134 | " are building the image.\n</span>") % (self.span_tag(px='14px')) | ||
135 | self.machine_title_desc.set_markup(mark) | ||
136 | |||
137 | self.machine_combo = gtk.combo_box_new_text() | ||
138 | self.machine_combo.connect("changed", self.machine_combo_changed_cb) | ||
139 | |||
140 | icon_file = hic.ICON_LAYERS_DISPLAY_FILE | ||
141 | hover_file = hic.ICON_LAYERS_HOVER_FILE | ||
142 | self.layer_button = HobXpmLabelButtonBox(icon_file, hover_file, | ||
143 | "Layers", "Add support for machines, software, etc") | ||
144 | self.layer_button.connect("button-release-event", self.layer_button_clicked_cb) | ||
145 | |||
146 | icon_file = hic.ICON_INFO_DISPLAY_FILE | ||
147 | self.layer_info_icon = gtk.Image() | ||
148 | pix_buffer = gtk.gdk.pixbuf_new_from_file(icon_file) | ||
149 | self.layer_info_icon.set_from_pixbuf(pix_buffer) | ||
150 | markup = "Layers are a powerful mechanism to extend the Yocto Project " | ||
151 | markup += "with your own functionality.\n" | ||
152 | markup += "For more on layers, check:\n" | ||
153 | markup += "http://www.yoctoproject.org/docs/current/poky-ref-manual/" | ||
154 | markup += "poky-ref-manual.html#usingpoky-changes-layers." | ||
155 | self.layer_info_icon.set_tooltip_markup(markup) | ||
156 | |||
157 | self.progress_bar = HobProgressBar() | ||
158 | self.machine_separator = gtk.HSeparator() | ||
159 | |||
160 | def set_config_machine_layout(self): | ||
161 | self.gtable.attach(self.machine_title, 0, 40, 0, 4) | ||
162 | self.gtable.attach(self.machine_title_desc, 0, 40, 4, 6) | ||
163 | self.gtable.attach(self.machine_combo, 0, 12, 6, 9) | ||
164 | self.gtable.attach(self.layer_button, 12, 36, 6, 10) | ||
165 | self.gtable.attach(self.layer_info_icon, 36, 40, 6, 9) | ||
166 | self.gtable.attach(self.progress_bar, 0, 40, 13, 17) | ||
167 | self.gtable.attach(self.machine_separator, 0, 40, 12, 13) | ||
168 | |||
169 | def create_config_baseimg(self): | ||
170 | self.image_title = gtk.Label() | ||
171 | self.image_title.set_alignment(0, 1.0) | ||
172 | mark = "<span %s>Select a base image</span>" % self.span_tag('24px', 'bold') | ||
173 | self.image_title.set_markup(mark) | ||
174 | |||
175 | self.image_title_desc = gtk.Label() | ||
176 | self.image_title_desc.set_alignment(0, 0.5) | ||
177 | mark = ("<span %s>Base images are a starting point for the type of image you want. " | ||
178 | "You can build them as \n" | ||
179 | "they are or customize them to your specific needs.\n</span>") % self.span_tag('14px') | ||
180 | self.image_title_desc.set_markup(mark) | ||
181 | |||
182 | self.image_combo = gtk.combo_box_new_text() | ||
183 | self.image_combo_id = self.image_combo.connect("changed", self.image_combo_changed_cb) | ||
184 | |||
185 | self.image_desc = gtk.Label() | ||
186 | self.image_desc.set_alignment(0, 0) | ||
187 | self.image_desc.set_line_wrap(True) | ||
188 | |||
189 | # button to view recipes | ||
190 | icon_file = hic.ICON_RCIPE_DISPLAY_FILE | ||
191 | hover_file = hic.ICON_RCIPE_HOVER_FILE | ||
192 | self.view_recipes_button = HobXpmLabelButtonBox(icon_file, hover_file, | ||
193 | "View Recipes", "Add/remove recipes and collections") | ||
194 | self.view_recipes_button.connect("button-release-event", self.view_recipes_button_clicked_cb) | ||
195 | |||
196 | # button to view packages | ||
197 | icon_file = hic.ICON_PACKAGES_DISPLAY_FILE | ||
198 | hover_file = hic.ICON_PACKAGES_HOVER_FILE | ||
199 | self.view_packages_button = HobXpmLabelButtonBox(icon_file, hover_file, | ||
200 | "View Packages", "Add/remove packages") | ||
201 | self.view_packages_button.connect("button-release-event", self.view_packages_button_clicked_cb) | ||
202 | |||
203 | self.image_separator = gtk.HSeparator() | ||
204 | |||
205 | def set_config_baseimg_layout(self): | ||
206 | self.gtable.attach(self.image_title, 0, 40, 13, 17) | ||
207 | self.gtable.attach(self.image_title_desc, 0, 40, 17, 22) | ||
208 | self.gtable.attach(self.image_combo, 0, 12, 22, 25) | ||
209 | self.gtable.attach(self.image_desc, 14, 38, 22, 27) | ||
210 | self.gtable.attach(self.view_recipes_button, 0, 20, 28, 32) | ||
211 | self.gtable.attach(self.view_packages_button, 20, 40, 28, 32) | ||
212 | self.gtable.attach(self.image_separator, 0, 40, 35, 36) | ||
213 | |||
214 | def create_config_build_button(self): | ||
215 | # Create the "Build packages" and "Just bake" buttons at the bottom | ||
216 | button_box = gtk.HBox(False, 5) | ||
217 | |||
218 | # create button "Just bake" | ||
219 | just_bake_button = gtk.Button() | ||
220 | label = gtk.Label() | ||
221 | mark = "<span %s>Just bake</span>" % self.span_tag('24px', 'bold') | ||
222 | label.set_markup(mark) | ||
223 | |||
224 | just_bake_button.set_image(label) | ||
225 | just_bake_button.set_size_request(205, 49) | ||
226 | just_bake_button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(HobColors.ORANGE)) | ||
227 | just_bake_button.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(HobColors.ORANGE)) | ||
228 | just_bake_button.modify_bg(gtk.STATE_SELECTED, gtk.gdk.Color(HobColors.ORANGE)) | ||
229 | just_bake_button.set_tooltip_text("Build image to get your target image") | ||
230 | just_bake_button.set_flags(gtk.CAN_DEFAULT) | ||
231 | just_bake_button.grab_default() | ||
232 | just_bake_button.connect("clicked", self.just_bake_button_clicked_cb) | ||
233 | button_box.pack_end(just_bake_button, expand=False, fill=False) | ||
234 | |||
235 | label = gtk.Label(" or ") | ||
236 | button_box.pack_end(label, expand=False, fill=False) | ||
237 | |||
238 | # create button "Build Packages" | ||
239 | build_packages_button = gtk.LinkButton("Build packages first based on recipe selection " | ||
240 | "for late customization on packages for the target image", "Build Packages") | ||
241 | build_packages_button.connect("clicked", self.build_packages_button_clicked_cb) | ||
242 | button_box.pack_end(build_packages_button, expand=False, fill=False) | ||
243 | |||
244 | return button_box | ||
245 | |||
246 | def machine_combo_changed_cb(self, machine_combo): | ||
247 | combo_item = machine_combo.get_active_text() | ||
248 | if not combo_item or combo_item == self.__dummy_machine__: | ||
249 | self.builder.switch_page(self.builder.MACHINE_SELECTION) | ||
250 | else: | ||
251 | self.builder.configuration.curr_mach = combo_item | ||
252 | # Do reparse recipes | ||
253 | self.builder.switch_page(self.builder.RCPPKGINFO_POPULATING) | ||
254 | |||
255 | def update_machine_combo(self): | ||
256 | all_machines = [self.__dummy_machine__] + self.builder.parameters.all_machines | ||
257 | |||
258 | model = self.machine_combo.get_model() | ||
259 | model.clear() | ||
260 | for machine in all_machines: | ||
261 | self.machine_combo.append_text(machine) | ||
262 | self.machine_combo.set_active(0) | ||
263 | |||
264 | def switch_machine_combo(self): | ||
265 | model = self.machine_combo.get_model() | ||
266 | active = 0 | ||
267 | while active < len(model): | ||
268 | if model[active][0] == self.builder.configuration.curr_mach: | ||
269 | self.machine_combo.set_active(active) | ||
270 | return | ||
271 | active += 1 | ||
272 | self.machine_combo.set_active(0) | ||
273 | |||
274 | def image_combo_changed_idle_cb(self, selected_image, selected_recipes, selected_packages): | ||
275 | self.builder.update_recipe_model(selected_image, selected_recipes) | ||
276 | self.builder.update_package_model(selected_packages) | ||
277 | self.builder.window_sensitive(True) | ||
278 | |||
279 | def image_combo_changed_cb(self, combo): | ||
280 | self.builder.window_sensitive(False) | ||
281 | selected_image = self.image_combo.get_active_text() | ||
282 | if not selected_image: | ||
283 | return | ||
284 | |||
285 | selected_recipes = [] | ||
286 | |||
287 | image_path = self.builder.recipe_model.pn_path[selected_image] | ||
288 | image_iter = self.builder.recipe_model.get_iter(image_path) | ||
289 | selected_packages = self.builder.recipe_model.get_value(image_iter, self.builder.recipe_model.COL_INSTALL).split() | ||
290 | |||
291 | mark = ("<span %s>%s</span>\n") % (self.span_tag('14px'), self.builder.recipe_model.get_value(image_iter, self.builder.recipe_model.COL_DESC)) | ||
292 | self.image_desc.set_markup(mark) | ||
293 | |||
294 | self.builder.recipe_model.reset() | ||
295 | self.builder.package_model.reset() | ||
296 | |||
297 | glib.idle_add(self.image_combo_changed_idle_cb, selected_image, selected_recipes, selected_packages) | ||
298 | |||
299 | def _image_combo_connect_signal(self): | ||
300 | if not self.image_combo_id: | ||
301 | self.image_combo_id = self.image_combo.connect("changed", self.image_combo_changed_cb) | ||
302 | |||
303 | def _image_combo_disconnect_signal(self): | ||
304 | if self.image_combo_id: | ||
305 | self.image_combo.disconnect(self.image_combo_id) | ||
306 | self.image_combo_id = None | ||
307 | |||
308 | def update_image_combo(self, recipe_model, selected_image): | ||
309 | # Update the image combo according to the images in the recipe_model | ||
310 | # populate image combo | ||
311 | filter = {RecipeListModel.COL_TYPE : ['image']} | ||
312 | image_model = recipe_model.tree_model(filter) | ||
313 | active = 0 | ||
314 | cnt = 0 | ||
315 | |||
316 | it = image_model.get_iter_first() | ||
317 | self._image_combo_disconnect_signal() | ||
318 | model = self.image_combo.get_model() | ||
319 | model.clear() | ||
320 | # append and set active | ||
321 | while it: | ||
322 | path = image_model.get_path(it) | ||
323 | image_name = image_model[path][recipe_model.COL_NAME] | ||
324 | self.image_combo.append_text(image_name) | ||
325 | if image_name == selected_image: | ||
326 | active = cnt | ||
327 | it = image_model.iter_next(it) | ||
328 | cnt = cnt + 1 | ||
329 | self._image_combo_connect_signal() | ||
330 | |||
331 | self.image_combo.set_active(-1) | ||
332 | self.image_combo.set_active(active) | ||
333 | |||
334 | def layer_button_clicked_cb(self, event, data): | ||
335 | # Create a layer selection dialog | ||
336 | self.builder.show_layer_selection_dialog() | ||
337 | |||
338 | def view_recipes_button_clicked_cb(self, event, data): | ||
339 | self.builder.show_recipes() | ||
340 | |||
341 | def view_packages_button_clicked_cb(self, event, data): | ||
342 | self.builder.show_packages() | ||
343 | |||
344 | def just_bake_button_clicked_cb(self, button): | ||
345 | self.builder.just_bake() | ||
346 | |||
347 | def build_packages_button_clicked_cb(self, button): | ||
348 | self.builder.build_packages() | ||
349 | |||
350 | def template_button_clicked_cb(self, button): | ||
351 | self.builder.show_load_template_dialog() | ||
352 | |||
353 | def my_images_button_clicked_cb(self, button): | ||
354 | self.builder.show_load_my_images_dialog() | ||
355 | |||
356 | def settings_button_clicked_cb(self, button): | ||
357 | # Create an advanced settings dialog | ||
358 | self.builder.show_adv_settings_dialog() | ||