diff options
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/hig/advancedsettingsdialog.py')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig/advancedsettingsdialog.py | 336 |
1 files changed, 336 insertions, 0 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hig/advancedsettingsdialog.py b/bitbake/lib/bb/ui/crumbs/hig/advancedsettingsdialog.py new file mode 100644 index 0000000000..f5397c3ac0 --- /dev/null +++ b/bitbake/lib/bb/ui/crumbs/hig/advancedsettingsdialog.py | |||
@@ -0,0 +1,336 @@ | |||
1 | # | ||
2 | # BitBake Graphical GTK User Interface | ||
3 | # | ||
4 | # Copyright (C) 2011-2012 Intel Corporation | ||
5 | # | ||
6 | # Authored by Joshua Lock <josh@linux.intel.com> | ||
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 hashlib | ||
25 | from bb.ui.crumbs.hobwidget import HobInfoButton, HobButton | ||
26 | from bb.ui.crumbs.progressbar import HobProgressBar | ||
27 | from bb.ui.crumbs.hig.settingsuihelper import SettingsUIHelper | ||
28 | from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog | ||
29 | from bb.ui.crumbs.hig.crumbsmessagedialog import CrumbsMessageDialog | ||
30 | from bb.ui.crumbs.hig.proxydetailsdialog import ProxyDetailsDialog | ||
31 | |||
32 | """ | ||
33 | The following are convenience classes for implementing GNOME HIG compliant | ||
34 | BitBake GUI's | ||
35 | In summary: spacing = 12px, border-width = 6px | ||
36 | """ | ||
37 | |||
38 | class AdvancedSettingsDialog (CrumbsDialog, SettingsUIHelper): | ||
39 | |||
40 | def details_cb(self, button, parent, protocol): | ||
41 | dialog = ProxyDetailsDialog(title = protocol.upper() + " Proxy Details", | ||
42 | user = self.configuration.proxies[protocol][1], | ||
43 | passwd = self.configuration.proxies[protocol][2], | ||
44 | parent = parent, | ||
45 | flags = gtk.DIALOG_MODAL | ||
46 | | gtk.DIALOG_DESTROY_WITH_PARENT | ||
47 | | gtk.DIALOG_NO_SEPARATOR) | ||
48 | dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_OK) | ||
49 | response = dialog.run() | ||
50 | if response == gtk.RESPONSE_OK: | ||
51 | self.configuration.proxies[protocol][1] = dialog.user | ||
52 | self.configuration.proxies[protocol][2] = dialog.passwd | ||
53 | self.refresh_proxy_components() | ||
54 | dialog.destroy() | ||
55 | |||
56 | def set_save_button(self, button): | ||
57 | self.save_button = button | ||
58 | |||
59 | def rootfs_combo_changed_cb(self, rootfs_combo, all_package_format, check_hbox): | ||
60 | combo_item = self.rootfs_combo.get_active_text() | ||
61 | modified = False | ||
62 | for child in check_hbox.get_children(): | ||
63 | if isinstance(child, gtk.CheckButton): | ||
64 | check_hbox.remove(child) | ||
65 | modified = True | ||
66 | for format in all_package_format: | ||
67 | if format != combo_item: | ||
68 | check_button = gtk.CheckButton(format) | ||
69 | check_hbox.pack_start(check_button, expand=False, fill=False) | ||
70 | modified = True | ||
71 | if modified: | ||
72 | check_hbox.remove(self.pkgfmt_info) | ||
73 | check_hbox.pack_start(self.pkgfmt_info, expand=False, fill=False) | ||
74 | check_hbox.show_all() | ||
75 | |||
76 | def gen_pkgfmt_widget(self, curr_package_format, all_package_format, tooltip_combo="", tooltip_extra=""): | ||
77 | pkgfmt_vbox = gtk.VBox(False, 6) | ||
78 | |||
79 | label = self.gen_label_widget("Root file system package format") | ||
80 | pkgfmt_vbox.pack_start(label, expand=False, fill=False) | ||
81 | |||
82 | rootfs_format = "" | ||
83 | if curr_package_format: | ||
84 | rootfs_format = curr_package_format.split()[0] | ||
85 | |||
86 | rootfs_format_widget, rootfs_combo = self.gen_combo_widget(rootfs_format, all_package_format, tooltip_combo) | ||
87 | pkgfmt_vbox.pack_start(rootfs_format_widget, expand=False, fill=False) | ||
88 | |||
89 | label = self.gen_label_widget("Additional package formats") | ||
90 | pkgfmt_vbox.pack_start(label, expand=False, fill=False) | ||
91 | |||
92 | check_hbox = gtk.HBox(False, 12) | ||
93 | pkgfmt_vbox.pack_start(check_hbox, expand=False, fill=False) | ||
94 | for format in all_package_format: | ||
95 | if format != rootfs_format: | ||
96 | check_button = gtk.CheckButton(format) | ||
97 | is_active = (format in curr_package_format.split()) | ||
98 | check_button.set_active(is_active) | ||
99 | check_hbox.pack_start(check_button, expand=False, fill=False) | ||
100 | |||
101 | self.pkgfmt_info = HobInfoButton(tooltip_extra, self) | ||
102 | check_hbox.pack_start(self.pkgfmt_info, expand=False, fill=False) | ||
103 | |||
104 | rootfs_combo.connect("changed", self.rootfs_combo_changed_cb, all_package_format, check_hbox) | ||
105 | |||
106 | pkgfmt_vbox.show_all() | ||
107 | |||
108 | return pkgfmt_vbox, rootfs_combo, check_hbox | ||
109 | |||
110 | def __init__(self, title, configuration, all_image_types, | ||
111 | all_package_formats, all_distros, all_sdk_machines, | ||
112 | max_threads, parent, flags, buttons=None): | ||
113 | super(AdvancedSettingsDialog, self).__init__(title, parent, flags, buttons) | ||
114 | |||
115 | # class members from other objects | ||
116 | # bitbake settings from Builder.Configuration | ||
117 | self.configuration = configuration | ||
118 | self.image_types = all_image_types | ||
119 | self.all_package_formats = all_package_formats | ||
120 | self.all_distros = all_distros[:] | ||
121 | self.all_sdk_machines = all_sdk_machines | ||
122 | self.max_threads = max_threads | ||
123 | |||
124 | # class members for internal use | ||
125 | self.distro_combo = None | ||
126 | self.dldir_text = None | ||
127 | self.sstatedir_text = None | ||
128 | self.sstatemirror_text = None | ||
129 | self.bb_spinner = None | ||
130 | self.pmake_spinner = None | ||
131 | self.rootfs_size_spinner = None | ||
132 | self.extra_size_spinner = None | ||
133 | self.gplv3_checkbox = None | ||
134 | self.toolchain_checkbox = None | ||
135 | self.image_types_checkbuttons = {} | ||
136 | |||
137 | self.md5 = self.config_md5() | ||
138 | self.settings_changed = False | ||
139 | |||
140 | # create visual elements on the dialog | ||
141 | self.save_button = None | ||
142 | self.create_visual_elements() | ||
143 | self.connect("response", self.response_cb) | ||
144 | |||
145 | def _get_sorted_value(self, var): | ||
146 | return " ".join(sorted(str(var).split())) + "\n" | ||
147 | |||
148 | def config_md5(self): | ||
149 | data = "" | ||
150 | data += ("PACKAGE_CLASSES: " + self.configuration.curr_package_format + '\n') | ||
151 | data += ("DISTRO: " + self._get_sorted_value(self.configuration.curr_distro)) | ||
152 | data += ("IMAGE_ROOTFS_SIZE: " + self._get_sorted_value(self.configuration.image_rootfs_size)) | ||
153 | data += ("IMAGE_EXTRA_SIZE: " + self._get_sorted_value(self.configuration.image_extra_size)) | ||
154 | data += ("INCOMPATIBLE_LICENSE: " + self._get_sorted_value(self.configuration.incompat_license)) | ||
155 | data += ("SDK_MACHINE: " + self._get_sorted_value(self.configuration.curr_sdk_machine)) | ||
156 | data += ("TOOLCHAIN_BUILD: " + self._get_sorted_value(self.configuration.toolchain_build)) | ||
157 | data += ("IMAGE_FSTYPES: " + self._get_sorted_value(self.configuration.image_fstypes)) | ||
158 | return hashlib.md5(data).hexdigest() | ||
159 | |||
160 | def create_visual_elements(self): | ||
161 | self.nb = gtk.Notebook() | ||
162 | self.nb.set_show_tabs(True) | ||
163 | self.nb.append_page(self.create_image_types_page(), gtk.Label("Image types")) | ||
164 | self.nb.append_page(self.create_output_page(), gtk.Label("Output")) | ||
165 | self.nb.set_current_page(0) | ||
166 | self.vbox.pack_start(self.nb, expand=True, fill=True) | ||
167 | self.vbox.pack_end(gtk.HSeparator(), expand=True, fill=True) | ||
168 | |||
169 | self.show_all() | ||
170 | |||
171 | def get_num_checked_image_types(self): | ||
172 | total = 0 | ||
173 | for b in self.image_types_checkbuttons.values(): | ||
174 | if b.get_active(): | ||
175 | total = total + 1 | ||
176 | return total | ||
177 | |||
178 | def set_save_button_state(self): | ||
179 | if self.save_button: | ||
180 | self.save_button.set_sensitive(self.get_num_checked_image_types() > 0) | ||
181 | |||
182 | def image_type_checkbutton_clicked_cb(self, button): | ||
183 | self.set_save_button_state() | ||
184 | if self.get_num_checked_image_types() == 0: | ||
185 | # Show an error dialog | ||
186 | lbl = "<b>Select an image type</b>\n\nYou need to select at least one image type." | ||
187 | dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_WARNING) | ||
188 | button = dialog.add_button("OK", gtk.RESPONSE_OK) | ||
189 | HobButton.style_button(button) | ||
190 | response = dialog.run() | ||
191 | dialog.destroy() | ||
192 | |||
193 | def create_image_types_page(self): | ||
194 | main_vbox = gtk.VBox(False, 16) | ||
195 | main_vbox.set_border_width(6) | ||
196 | |||
197 | advanced_vbox = gtk.VBox(False, 6) | ||
198 | advanced_vbox.set_border_width(6) | ||
199 | |||
200 | distro_vbox = gtk.VBox(False, 6) | ||
201 | label = self.gen_label_widget("Distro:") | ||
202 | tooltip = "Selects the Yocto Project distribution you want" | ||
203 | try: | ||
204 | i = self.all_distros.index( "defaultsetup" ) | ||
205 | except ValueError: | ||
206 | i = -1 | ||
207 | if i != -1: | ||
208 | self.all_distros[ i ] = "Default" | ||
209 | if self.configuration.curr_distro == "defaultsetup": | ||
210 | self.configuration.curr_distro = "Default" | ||
211 | distro_widget, self.distro_combo = self.gen_combo_widget(self.configuration.curr_distro, self.all_distros, tooltip) | ||
212 | distro_vbox.pack_start(label, expand=False, fill=False) | ||
213 | distro_vbox.pack_start(distro_widget, expand=False, fill=False) | ||
214 | main_vbox.pack_start(distro_vbox, expand=False, fill=False) | ||
215 | |||
216 | |||
217 | rows = (len(self.image_types)+1)/3 | ||
218 | table = gtk.Table(rows + 1, 10, True) | ||
219 | advanced_vbox.pack_start(table, expand=False, fill=False) | ||
220 | |||
221 | tooltip = "Image file system types you want." | ||
222 | info = HobInfoButton(tooltip, self) | ||
223 | label = self.gen_label_widget("Image types:") | ||
224 | align = gtk.Alignment(0, 0.5, 0, 0) | ||
225 | table.attach(align, 0, 4, 0, 1) | ||
226 | align.add(label) | ||
227 | table.attach(info, 4, 5, 0, 1) | ||
228 | |||
229 | i = 1 | ||
230 | j = 1 | ||
231 | for image_type in sorted(self.image_types): | ||
232 | self.image_types_checkbuttons[image_type] = gtk.CheckButton(image_type) | ||
233 | self.image_types_checkbuttons[image_type].connect("toggled", self.image_type_checkbutton_clicked_cb) | ||
234 | article = "" | ||
235 | if image_type.startswith(("a", "e", "i", "o", "u")): | ||
236 | article = "n" | ||
237 | self.image_types_checkbuttons[image_type].set_tooltip_text("Build a%s %s image" % (article, image_type)) | ||
238 | table.attach(self.image_types_checkbuttons[image_type], j - 1, j + 3, i, i + 1) | ||
239 | if image_type in self.configuration.image_fstypes.split(): | ||
240 | self.image_types_checkbuttons[image_type].set_active(True) | ||
241 | i += 1 | ||
242 | if i > rows: | ||
243 | i = 1 | ||
244 | j = j + 4 | ||
245 | |||
246 | main_vbox.pack_start(advanced_vbox, expand=False, fill=False) | ||
247 | self.set_save_button_state() | ||
248 | |||
249 | return main_vbox | ||
250 | |||
251 | def create_output_page(self): | ||
252 | advanced_vbox = gtk.VBox(False, 6) | ||
253 | advanced_vbox.set_border_width(6) | ||
254 | |||
255 | advanced_vbox.pack_start(self.gen_label_widget('<span weight="bold">Package format</span>'), expand=False, fill=False) | ||
256 | sub_vbox = gtk.VBox(False, 6) | ||
257 | advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) | ||
258 | tooltip_combo = "Selects the package format used to generate rootfs." | ||
259 | tooltip_extra = "Selects extra package formats to build" | ||
260 | pkgfmt_widget, self.rootfs_combo, self.check_hbox = self.gen_pkgfmt_widget(self.configuration.curr_package_format, self.all_package_formats, tooltip_combo, tooltip_extra) | ||
261 | sub_vbox.pack_start(pkgfmt_widget, expand=False, fill=False) | ||
262 | |||
263 | advanced_vbox.pack_start(self.gen_label_widget('<span weight="bold">Image size</span>'), expand=False, fill=False) | ||
264 | sub_vbox = gtk.VBox(False, 6) | ||
265 | advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) | ||
266 | label = self.gen_label_widget("Image basic size (in MB)") | ||
267 | tooltip = "Sets the basic size of your target image.\nThis is the basic size of your target image unless your selected package size exceeds this value or you select \'Image Extra Size\'." | ||
268 | rootfs_size_widget, self.rootfs_size_spinner = self.gen_spinner_widget(int(self.configuration.image_rootfs_size*1.0/1024), 0, 65536, tooltip) | ||
269 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
270 | sub_vbox.pack_start(rootfs_size_widget, expand=False, fill=False) | ||
271 | |||
272 | sub_vbox = gtk.VBox(False, 6) | ||
273 | advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) | ||
274 | label = self.gen_label_widget("Additional free space (in MB)") | ||
275 | tooltip = "Sets the extra free space of your target image.\nBy default, the system reserves 30% of your image size as free space. If your image contains zypper, it brings in 50MB more space. The maximum free space is 64GB." | ||
276 | extra_size_widget, self.extra_size_spinner = self.gen_spinner_widget(int(self.configuration.image_extra_size*1.0/1024), 0, 65536, tooltip) | ||
277 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
278 | sub_vbox.pack_start(extra_size_widget, expand=False, fill=False) | ||
279 | |||
280 | advanced_vbox.pack_start(self.gen_label_widget('<span weight="bold">Licensing</span>'), expand=False, fill=False) | ||
281 | self.gplv3_checkbox = gtk.CheckButton("Exclude GPLv3 packages") | ||
282 | self.gplv3_checkbox.set_tooltip_text("Check this box to prevent GPLv3 packages from being included in your image") | ||
283 | if "GPLv3" in self.configuration.incompat_license.split(): | ||
284 | self.gplv3_checkbox.set_active(True) | ||
285 | else: | ||
286 | self.gplv3_checkbox.set_active(False) | ||
287 | advanced_vbox.pack_start(self.gplv3_checkbox, expand=False, fill=False) | ||
288 | |||
289 | advanced_vbox.pack_start(self.gen_label_widget('<span weight="bold">Toolchain</span>'), expand=False, fill=False) | ||
290 | sub_hbox = gtk.HBox(False, 6) | ||
291 | advanced_vbox.pack_start(sub_hbox, expand=False, fill=False) | ||
292 | self.toolchain_checkbox = gtk.CheckButton("Build toolchain") | ||
293 | self.toolchain_checkbox.set_tooltip_text("Check this box to build the related toolchain with your image") | ||
294 | self.toolchain_checkbox.set_active(self.configuration.toolchain_build) | ||
295 | sub_hbox.pack_start(self.toolchain_checkbox, expand=False, fill=False) | ||
296 | |||
297 | tooltip = "Selects the host platform for which you want to run the toolchain" | ||
298 | sdk_machine_widget, self.sdk_machine_combo = self.gen_combo_widget(self.configuration.curr_sdk_machine, self.all_sdk_machines, tooltip) | ||
299 | sub_hbox.pack_start(sdk_machine_widget, expand=False, fill=False) | ||
300 | |||
301 | return advanced_vbox | ||
302 | |||
303 | def response_cb(self, dialog, response_id): | ||
304 | package_format = [] | ||
305 | package_format.append(self.rootfs_combo.get_active_text()) | ||
306 | for child in self.check_hbox: | ||
307 | if isinstance(child, gtk.CheckButton) and child.get_active(): | ||
308 | package_format.append(child.get_label()) | ||
309 | self.configuration.curr_package_format = " ".join(package_format) | ||
310 | |||
311 | distro = self.distro_combo.get_active_text() | ||
312 | if distro == "Default": | ||
313 | distro = "defaultsetup" | ||
314 | self.configuration.curr_distro = distro | ||
315 | self.configuration.image_rootfs_size = self.rootfs_size_spinner.get_value_as_int() * 1024 | ||
316 | self.configuration.image_extra_size = self.extra_size_spinner.get_value_as_int() * 1024 | ||
317 | |||
318 | self.configuration.image_fstypes = "" | ||
319 | for image_type in self.image_types: | ||
320 | if self.image_types_checkbuttons[image_type].get_active(): | ||
321 | self.configuration.image_fstypes += (" " + image_type) | ||
322 | self.configuration.image_fstypes.strip() | ||
323 | |||
324 | if self.gplv3_checkbox.get_active(): | ||
325 | if "GPLv3" not in self.configuration.incompat_license.split(): | ||
326 | self.configuration.incompat_license += " GPLv3" | ||
327 | else: | ||
328 | if "GPLv3" in self.configuration.incompat_license.split(): | ||
329 | self.configuration.incompat_license = self.configuration.incompat_license.split().remove("GPLv3") | ||
330 | self.configuration.incompat_license = " ".join(self.configuration.incompat_license or []) | ||
331 | self.configuration.incompat_license = self.configuration.incompat_license.strip() | ||
332 | |||
333 | self.configuration.toolchain_build = self.toolchain_checkbox.get_active() | ||
334 | self.configuration.curr_sdk_machine = self.sdk_machine_combo.get_active_text() | ||
335 | md5 = self.config_md5() | ||
336 | self.settings_changed = (self.md5 != md5) | ||