summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/crumbs/hig/advancedsettingsdialog.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/hig/advancedsettingsdialog.py')
-rw-r--r--bitbake/lib/bb/ui/crumbs/hig/advancedsettingsdialog.py341
1 files changed, 341 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..e0b3553c2f
--- /dev/null
+++ b/bitbake/lib/bb/ui/crumbs/hig/advancedsettingsdialog.py
@@ -0,0 +1,341 @@
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
23import gtk
24import hashlib
25from bb.ui.crumbs.hobwidget import HobInfoButton, HobButton
26from bb.ui.crumbs.progressbar import HobProgressBar
27from bb.ui.crumbs.hig.settingsuihelper import SettingsUIHelper
28from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog
29from bb.ui.crumbs.hig.crumbsmessagedialog import CrumbsMessageDialog
30from bb.ui.crumbs.hig.proxydetailsdialog import ProxyDetailsDialog
31
32"""
33The following are convenience classes for implementing GNOME HIG compliant
34BitBake GUI's
35In summary: spacing = 12px, border-width = 6px
36"""
37
38class 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.sdk_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>"
187 msg = "You need to select at least one image type."
188 dialog = CrumbsMessageDialog(self, lbl, gtk.MESSAGE_WARNING, msg)
189 button = dialog.add_button("OK", gtk.RESPONSE_OK)
190 HobButton.style_button(button)
191 response = dialog.run()
192 dialog.destroy()
193
194 def create_image_types_page(self):
195 main_vbox = gtk.VBox(False, 16)
196 main_vbox.set_border_width(6)
197
198 advanced_vbox = gtk.VBox(False, 6)
199 advanced_vbox.set_border_width(6)
200
201 distro_vbox = gtk.VBox(False, 6)
202 label = self.gen_label_widget("Distro:")
203 tooltip = "Selects the Yocto Project distribution you want"
204 try:
205 i = self.all_distros.index( "defaultsetup" )
206 except ValueError:
207 i = -1
208 if i != -1:
209 self.all_distros[ i ] = "Default"
210 if self.configuration.curr_distro == "defaultsetup":
211 self.configuration.curr_distro = "Default"
212 distro_widget, self.distro_combo = self.gen_combo_widget(self.configuration.curr_distro, self.all_distros,"<b>Distro</b>" + "*" + tooltip)
213 distro_vbox.pack_start(label, expand=False, fill=False)
214 distro_vbox.pack_start(distro_widget, expand=False, fill=False)
215 main_vbox.pack_start(distro_vbox, expand=False, fill=False)
216
217
218 rows = (len(self.image_types)+1)/3
219 table = gtk.Table(rows + 1, 10, True)
220 advanced_vbox.pack_start(table, expand=False, fill=False)
221
222 tooltip = "Image file system types you want."
223 info = HobInfoButton("<b>Image types</b>" + "*" + tooltip, self)
224 label = self.gen_label_widget("Image types:")
225 align = gtk.Alignment(0, 0.5, 0, 0)
226 table.attach(align, 0, 4, 0, 1)
227 align.add(label)
228 table.attach(info, 4, 5, 0, 1)
229
230 i = 1
231 j = 1
232 for image_type in sorted(self.image_types):
233 self.image_types_checkbuttons[image_type] = gtk.CheckButton(image_type)
234 self.image_types_checkbuttons[image_type].connect("toggled", self.image_type_checkbutton_clicked_cb)
235 article = ""
236 if image_type.startswith(("a", "e", "i", "o", "u")):
237 article = "n"
238 if image_type == "live":
239 self.image_types_checkbuttons[image_type].set_tooltip_text("Build iso and hddimg images")
240 else:
241 self.image_types_checkbuttons[image_type].set_tooltip_text("Build a%s %s image" % (article, image_type))
242 table.attach(self.image_types_checkbuttons[image_type], j - 1, j + 3, i, i + 1)
243 if image_type in self.configuration.image_fstypes.split():
244 self.image_types_checkbuttons[image_type].set_active(True)
245 i += 1
246 if i > rows:
247 i = 1
248 j = j + 4
249
250 main_vbox.pack_start(advanced_vbox, expand=False, fill=False)
251 self.set_save_button_state()
252
253 return main_vbox
254
255 def create_output_page(self):
256 advanced_vbox = gtk.VBox(False, 6)
257 advanced_vbox.set_border_width(6)
258
259 advanced_vbox.pack_start(self.gen_label_widget('<span weight="bold">Package format</span>'), expand=False, fill=False)
260 sub_vbox = gtk.VBox(False, 6)
261 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False)
262 tooltip_combo = "Selects the package format used to generate rootfs."
263 tooltip_extra = "Selects extra package formats to build"
264 pkgfmt_widget, self.rootfs_combo, self.check_hbox = self.gen_pkgfmt_widget(self.configuration.curr_package_format, self.all_package_formats,"<b>Root file system package format</b>" + "*" + tooltip_combo,"<b>Additional package formats</b>" + "*" + tooltip_extra)
265 sub_vbox.pack_start(pkgfmt_widget, expand=False, fill=False)
266
267 advanced_vbox.pack_start(self.gen_label_widget('<span weight="bold">Image size</span>'), expand=False, fill=False)
268 sub_vbox = gtk.VBox(False, 6)
269 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False)
270 label = self.gen_label_widget("Image basic size (in MB)")
271 tooltip = "Defines the size for the generated image. The OpenEmbedded build system determines the final size for the generated image using an algorithm that takes into account the initial disk space used for the generated image, the Image basic size value, and the Additional free space value.\n\nFor more information, check the <a href=\"http://www.yoctoproject.org/docs/current/poky-ref-manual/poky-ref-manual.html#var-IMAGE_ROOTFS_SIZE\">Yocto Project Reference Manual</a>."
272 rootfs_size_widget, self.rootfs_size_spinner = self.gen_spinner_widget(int(self.configuration.image_rootfs_size*1.0/1024), 0, 65536,"<b>Image basic size</b>" + "*" + tooltip)
273 sub_vbox.pack_start(label, expand=False, fill=False)
274 sub_vbox.pack_start(rootfs_size_widget, expand=False, fill=False)
275
276 sub_vbox = gtk.VBox(False, 6)
277 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False)
278 label = self.gen_label_widget("Additional free space (in MB)")
279 tooltip = "Sets extra free disk space to be added to the generated image. Use this variable when you want to ensure that a specific amount of free disk space is available on a device after an image is installed and running."
280 extra_size_widget, self.extra_size_spinner = self.gen_spinner_widget(int(self.configuration.image_extra_size*1.0/1024), 0, 65536,"<b>Additional free space</b>" + "*" + tooltip)
281 sub_vbox.pack_start(label, expand=False, fill=False)
282 sub_vbox.pack_start(extra_size_widget, expand=False, fill=False)
283
284 advanced_vbox.pack_start(self.gen_label_widget('<span weight="bold">Licensing</span>'), expand=False, fill=False)
285 self.gplv3_checkbox = gtk.CheckButton("Exclude GPLv3 packages")
286 self.gplv3_checkbox.set_tooltip_text("Check this box to prevent GPLv3 packages from being included in your image")
287 if "GPLv3" in self.configuration.incompat_license.split():
288 self.gplv3_checkbox.set_active(True)
289 else:
290 self.gplv3_checkbox.set_active(False)
291 advanced_vbox.pack_start(self.gplv3_checkbox, expand=False, fill=False)
292
293 advanced_vbox.pack_start(self.gen_label_widget('<span weight="bold">SDK</span>'), expand=False, fill=False)
294 sub_hbox = gtk.HBox(False, 6)
295 advanced_vbox.pack_start(sub_hbox, expand=False, fill=False)
296 self.sdk_checkbox = gtk.CheckButton("Populate SDK")
297 tooltip = "Check this box to generate an SDK tarball that consists of the cross-toolchain and a sysroot that contains development packages for your image."
298 self.sdk_checkbox.set_tooltip_text(tooltip)
299 self.sdk_checkbox.set_active(self.configuration.toolchain_build)
300 sub_hbox.pack_start(self.sdk_checkbox, expand=False, fill=False)
301
302 tooltip = "Select the host platform for which you want to run the toolchain contained in the SDK tarball."
303 sdk_machine_widget, self.sdk_machine_combo = self.gen_combo_widget(self.configuration.curr_sdk_machine, self.all_sdk_machines,"<b>Populate SDK</b>" + "*" + tooltip)
304 sub_hbox.pack_start(sdk_machine_widget, expand=False, fill=False)
305
306 return advanced_vbox
307
308 def response_cb(self, dialog, response_id):
309 package_format = []
310 package_format.append(self.rootfs_combo.get_active_text())
311 for child in self.check_hbox:
312 if isinstance(child, gtk.CheckButton) and child.get_active():
313 package_format.append(child.get_label())
314 self.configuration.curr_package_format = " ".join(package_format)
315
316 distro = self.distro_combo.get_active_text()
317 if distro == "Default":
318 distro = "defaultsetup"
319 self.configuration.curr_distro = distro
320 self.configuration.image_rootfs_size = self.rootfs_size_spinner.get_value_as_int() * 1024
321 self.configuration.image_extra_size = self.extra_size_spinner.get_value_as_int() * 1024
322
323 self.configuration.image_fstypes = ""
324 for image_type in self.image_types:
325 if self.image_types_checkbuttons[image_type].get_active():
326 self.configuration.image_fstypes += (" " + image_type)
327 self.configuration.image_fstypes.strip()
328
329 if self.gplv3_checkbox.get_active():
330 if "GPLv3" not in self.configuration.incompat_license.split():
331 self.configuration.incompat_license += " GPLv3"
332 else:
333 if "GPLv3" in self.configuration.incompat_license.split():
334 self.configuration.incompat_license = self.configuration.incompat_license.split().remove("GPLv3")
335 self.configuration.incompat_license = " ".join(self.configuration.incompat_license or [])
336 self.configuration.incompat_license = self.configuration.incompat_license.strip()
337
338 self.configuration.toolchain_build = self.sdk_checkbox.get_active()
339 self.configuration.curr_sdk_machine = self.sdk_machine_combo.get_active_text()
340 md5 = self.config_md5()
341 self.settings_changed = (self.md5 != md5)