summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/crumbs/hig.py
diff options
context:
space:
mode:
authorShane Wang <shane.wang@intel.com>2012-02-24 07:57:13 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-03-01 15:51:31 +0000
commit73444fb68cae5e2ada44f370443a63bd9e30f4c0 (patch)
tree33ffe7c16394dc1092b59ea991e6809ab3e53b28 /bitbake/lib/bb/ui/crumbs/hig.py
parent7f6165735767fbe2e0017b2c7619746b14a78a65 (diff)
downloadpoky-73444fb68cae5e2ada44f370443a63bd9e30f4c0.tar.gz
Hob: cleanup those class methods in HobWidget
Some dialogs like advanced settings dialog, and layer selection dialog are using the class methods in HobWidget to create widgets for themselves, which is not a good design for OO. Clean up the code, and split the functions into the separate classes which use them actually. Finally, remove the class HobWidget. (Bitbake rev: f9cccea4d1c52ae2173fd94d5b07ceba7e5c0851) Signed-off-by: Shane Wang <shane.wang@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/hig.py')
-rw-r--r--bitbake/lib/bb/ui/crumbs/hig.py486
1 files changed, 459 insertions, 27 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py
index 1f9fcf72b8..74f4f7b98a 100644
--- a/bitbake/lib/bb/ui/crumbs/hig.py
+++ b/bitbake/lib/bb/ui/crumbs/hig.py
@@ -28,7 +28,7 @@ import re
28import subprocess 28import subprocess
29import shlex 29import shlex
30from bb.ui.crumbs.hobcolor import HobColors 30from bb.ui.crumbs.hobcolor import HobColors
31from bb.ui.crumbs.hobwidget import HobWidget, HobViewTable 31from bb.ui.crumbs.hobwidget import HobViewTable
32from bb.ui.crumbs.progressbar import HobProgressBar 32from bb.ui.crumbs.progressbar import HobProgressBar
33 33
34""" 34"""
@@ -102,6 +102,317 @@ class BinbDialog(gtk.Dialog):
102# 102#
103class AdvancedSettingDialog (gtk.Dialog): 103class AdvancedSettingDialog (gtk.Dialog):
104 104
105 def gen_label_widget(self, content):
106 label = gtk.Label()
107 label.set_alignment(0, 0)
108 label.set_markup(content)
109 label.show()
110 return label
111
112 def gen_spinner_widget(self, content, lower, upper, tooltip=""):
113 hbox = gtk.HBox(False, 10)
114 adjust = gtk.Adjustment(value=content, lower=lower, upper=upper, step_incr=1)
115 spinner = gtk.SpinButton(adjustment=adjust, climb_rate=1, digits=0)
116
117 spinner.set_value(content)
118 hbox.pack_start(spinner, expand=False, fill=False)
119
120 image = gtk.Image()
121 image.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
122 image.set_tooltip_text(tooltip)
123 hbox.pack_start(image, expand=False, fill=False)
124
125 hbox.show_all()
126 return hbox, spinner
127
128 def gen_combo_widget(self, curr_item, all_item, tooltip=""):
129 hbox = gtk.HBox(False, 10)
130 combo = gtk.combo_box_new_text()
131 hbox.pack_start(combo, expand=False, fill=False)
132
133 index = 0
134 for item in all_item or []:
135 combo.append_text(item)
136 if item == curr_item:
137 combo.set_active(index)
138 index += 1
139
140 image = gtk.Image()
141 image.show()
142 image.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
143 image.set_tooltip_text(tooltip)
144 hbox.pack_start(image, expand=False, fill=False)
145
146 hbox.show_all()
147 return hbox, combo
148
149 def entry_widget_select_path_cb(self, action, parent, entry):
150 dialog = gtk.FileChooserDialog("", parent,
151 gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
152 (gtk.STOCK_OK, gtk.RESPONSE_YES,
153 gtk.STOCK_CANCEL, gtk.RESPONSE_NO))
154 response = dialog.run()
155 if response == gtk.RESPONSE_YES:
156 path = dialog.get_filename()
157 entry.set_text(path)
158
159 dialog.destroy()
160
161 def gen_entry_widget(self, split_model, content, parent, tooltip=""):
162 hbox = gtk.HBox(False, 10)
163 entry = gtk.Entry()
164 entry.set_text(content)
165
166 if split_model:
167 hbox.pack_start(entry, expand=True, fill=True)
168 else:
169 table = gtk.Table(1, 10, True)
170 hbox.pack_start(table, expand=True, fill=True)
171 table.attach(entry, 0, 9, 0, 1)
172 image = gtk.Image()
173 image.set_from_stock(gtk.STOCK_OPEN,gtk.ICON_SIZE_BUTTON)
174 open_button = gtk.Button()
175 open_button.set_image(image)
176 open_button.connect("clicked", self.entry_widget_select_path_cb, parent, entry)
177 table.attach(open_button, 9, 10, 0, 1)
178
179 image = gtk.Image()
180 image.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
181 image.set_tooltip_text(tooltip)
182 hbox.pack_start(image, expand=False, fill=False)
183
184 hbox.show_all()
185 return hbox, entry
186
187 def pkgfmt_widget_sort_func(self, model, iter1, iter2, data):
188 val1 = model.get_value(iter1, 0)
189 val2 = model.get_value(iter2, 0)
190 inc1 = model.get_value(iter1, 2)
191 inc2 = model.get_value(iter2, 2)
192 if inc1 != inc2:
193 return inc2 - inc1
194 else:
195 return val1 - val2
196
197 def pkgfmt_widget_tree_selection_changed_cb(self, tree_selection, button1, button2):
198 (model, it) = tree_selection.get_selected()
199 inc = model.get_value(it, 2)
200 if inc:
201 button1.set_sensitive(True)
202 button2.set_sensitive(True)
203 else:
204 button1.set_sensitive(False)
205 button2.set_sensitive(False)
206
207 def pkgfmt_widget_up_clicked_cb(self, button, tree_selection):
208 (model, it) = tree_selection.get_selected()
209 if not it:
210 return
211 path = model.get_path(it)
212 if path[0] <= 0:
213 return
214
215 pre_it = model.get_iter_first()
216 if not pre_it:
217 return
218 else:
219 while model.iter_next(pre_it) :
220 if model.get_value(model.iter_next(pre_it), 1) != model.get_value(it, 1):
221 pre_it = model.iter_next(pre_it)
222 else:
223 break
224
225 cur_index = model.get_value(it, 0)
226 pre_index = cur_index
227 if pre_it:
228 model.set(pre_it, 0, pre_index)
229 cur_index = cur_index - 1
230 model.set(it, 0, cur_index)
231
232 def pkgfmt_widget_down_clicked_cb(self, button, tree_selection):
233 (model, it) = tree_selection.get_selected()
234 if not it:
235 return
236 next_it = model.iter_next(it)
237 if not next_it:
238 return
239 cur_index = model.get_value(it, 0)
240 next_index = cur_index
241 model.set(next_it, 0, next_index)
242 cur_index = cur_index + 1
243 model.set(it, 0, cur_index)
244
245 def pkgfmt_widget_toggle_cb(self, cell, path, model, column):
246 it = model.get_iter(path)
247 val = model.get_value(it, column)
248 val = not val
249 model.set(it, column, val)
250
251 def gen_pkgfmt_widget(self, curr_package_format, all_package_format, tooltip=""):
252 pkgfmt_hbox = gtk.HBox(False, 15)
253
254 pkgfmt_store = gtk.ListStore(int, str, gobject.TYPE_BOOLEAN)
255 for format in curr_package_format.split():
256 pkgfmt_store.set(pkgfmt_store.append(), 1, format, 2, True)
257 for format in all_package_format:
258 if format not in curr_package_format:
259 pkgfmt_store.set(pkgfmt_store.append(), 1, format, 2, False)
260 pkgfmt_tree = gtk.TreeView(pkgfmt_store)
261 pkgfmt_tree.set_headers_clickable(True)
262 pkgfmt_tree.set_headers_visible(False)
263 tree_selection = pkgfmt_tree.get_selection()
264 tree_selection.set_mode(gtk.SELECTION_SINGLE)
265
266 col = gtk.TreeViewColumn('NO')
267 col.set_sort_column_id(0)
268 col.set_sort_order(gtk.SORT_ASCENDING)
269 col.set_clickable(False)
270 col1 = gtk.TreeViewColumn('TYPE')
271 col1.set_min_width(130)
272 col1.set_max_width(140)
273 col2 = gtk.TreeViewColumn('INCLUDED')
274 col2.set_min_width(60)
275 col2.set_max_width(70)
276 pkgfmt_tree.append_column(col1)
277 pkgfmt_tree.append_column(col2)
278 cell = gtk.CellRendererText()
279 cell1 = gtk.CellRendererText()
280 cell1.set_property('width-chars', 10)
281 cell2 = gtk.CellRendererToggle()
282 cell2.set_property('activatable', True)
283 cell2.connect("toggled", self.pkgfmt_widget_toggle_cb, pkgfmt_store, 2)
284 col.pack_start(cell, True)
285 col1.pack_start(cell1, True)
286 col2.pack_end(cell2, True)
287 col.set_attributes(cell, text=0)
288 col1.set_attributes(cell1, text=1)
289 col2.set_attributes(cell2, active=2)
290
291 pkgfmt_store.set_sort_func(0, self.pkgfmt_widget_sort_func, None)
292 pkgfmt_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
293
294 scroll = gtk.ScrolledWindow()
295 scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
296 scroll.set_shadow_type(gtk.SHADOW_IN)
297 scroll.add(pkgfmt_tree)
298 scroll.set_size_request(200,60)
299 pkgfmt_hbox.pack_start(scroll, False, False, 0)
300
301 vbox = gtk.VBox(False, 5)
302 pkgfmt_hbox.pack_start(vbox, False, False, 15)
303
304 up = gtk.Button()
305 image = gtk.Image()
306 image.set_from_stock(gtk.STOCK_GO_UP, gtk.ICON_SIZE_MENU)
307 up.set_image(image)
308 up.set_size_request(50,30)
309 up.connect("clicked", self.pkgfmt_widget_up_clicked_cb, tree_selection)
310 vbox.pack_start(up, False, False, 5)
311
312 down = gtk.Button()
313 image = gtk.Image()
314 image.set_from_stock(gtk.STOCK_GO_DOWN, gtk.ICON_SIZE_MENU)
315 down.set_image(image)
316 down.set_size_request(50,30)
317 down.connect("clicked", self.pkgfmt_widget_down_clicked_cb, tree_selection)
318 vbox.pack_start(down, False, False, 5)
319 tree_selection.connect("changed", self.pkgfmt_widget_tree_selection_changed_cb, up, down)
320
321 image = gtk.Image()
322 image.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
323 image.set_tooltip_text(tooltip)
324 pkgfmt_hbox.pack_start(image, expand=False, fill=False)
325
326 pkgfmt_hbox.show_all()
327
328 return pkgfmt_hbox, pkgfmt_store
329
330 def editable_settings_cell_edited(self, cell, path_string, new_text, model):
331 it = model.get_iter_from_string(path_string)
332 column = cell.get_data("column")
333 model.set(it, column, new_text)
334
335 def editable_settings_add_item_clicked(self, button, model):
336 new_item = ["##KEY##", "##VALUE##"]
337
338 iter = model.append()
339 model.set (iter,
340 0, new_item[0],
341 1, new_item[1],
342 )
343
344 def editable_settings_remove_item_clicked(self, button, treeview):
345 selection = treeview.get_selection()
346 model, iter = selection.get_selected()
347
348 if iter:
349 path = model.get_path(iter)[0]
350 model.remove(iter)
351
352 def gen_editable_settings(self, setting, tooltip=""):
353 setting_hbox = gtk.HBox(False, 10)
354
355 vbox = gtk.VBox(False, 10)
356 setting_hbox.pack_start(vbox, expand=True, fill=True)
357
358 setting_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
359 for key in setting.keys():
360 setting_store.set(setting_store.append(), 0, key, 1, setting[key])
361
362 setting_tree = gtk.TreeView(setting_store)
363 setting_tree.set_headers_visible(True)
364 setting_tree.set_size_request(300, 100)
365
366 col = gtk.TreeViewColumn('Key')
367 col.set_min_width(100)
368 col.set_max_width(150)
369 col.set_resizable(True)
370 col1 = gtk.TreeViewColumn('Value')
371 col1.set_min_width(100)
372 col1.set_max_width(150)
373 col1.set_resizable(True)
374 setting_tree.append_column(col)
375 setting_tree.append_column(col1)
376 cell = gtk.CellRendererText()
377 cell.set_property('width-chars', 10)
378 cell.set_property('editable', True)
379 cell.set_data("column", 0)
380 cell.connect("edited", self.editable_settings_cell_edited, setting_store)
381 cell1 = gtk.CellRendererText()
382 cell1.set_property('width-chars', 10)
383 cell1.set_property('editable', True)
384 cell1.set_data("column", 1)
385 cell1.connect("edited", self.editable_settings_cell_edited, setting_store)
386 col.pack_start(cell, True)
387 col1.pack_end(cell1, True)
388 col.set_attributes(cell, text=0)
389 col1.set_attributes(cell1, text=1)
390
391 scroll = gtk.ScrolledWindow()
392 scroll.set_shadow_type(gtk.SHADOW_IN)
393 scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
394 scroll.add(setting_tree)
395 vbox.pack_start(scroll, expand=True, fill=True)
396
397 # some buttons
398 hbox = gtk.HBox(True, 4)
399 vbox.pack_start(hbox, False, False)
400
401 button = gtk.Button(stock=gtk.STOCK_ADD)
402 button.connect("clicked", self.editable_settings_add_item_clicked, setting_store)
403 hbox.pack_start(button)
404
405 button = gtk.Button(stock=gtk.STOCK_REMOVE)
406 button.connect("clicked", self.editable_settings_remove_item_clicked, setting_tree)
407 hbox.pack_start(button)
408
409 image = gtk.Image()
410 image.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
411 image.set_tooltip_text(tooltip)
412 setting_hbox.pack_start(image, expand=False, fill=False)
413
414 return setting_hbox, setting_store
415
105 def __init__(self, title, configuration, all_image_types, 416 def __init__(self, title, configuration, all_image_types,
106 all_package_formats, all_distros, all_sdk_machines, 417 all_package_formats, all_distros, all_sdk_machines,
107 max_threads, split_model, parent, flags, buttons): 418 max_threads, split_model, parent, flags, buttons):
@@ -171,7 +482,7 @@ class AdvancedSettingDialog (gtk.Dialog):
171 image.show() 482 image.show()
172 image.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON) 483 image.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
173 image.set_tooltip_text(tooltip) 484 image.set_tooltip_text(tooltip)
174 label = HobWidget.gen_label_widget("<span weight=\"bold\">Select image types:</span>") 485 label = self.gen_label_widget("<span weight=\"bold\">Select image types:</span>")
175 table.attach(label, 0, 9, 0, 1) 486 table.attach(label, 0, 9, 0, 1)
176 table.attach(image, 9, 10, 0, 1) 487 table.attach(image, 9, 10, 0, 1)
177 488
@@ -196,26 +507,26 @@ class AdvancedSettingDialog (gtk.Dialog):
196 507
197 sub_vbox = gtk.VBox(False, 5) 508 sub_vbox = gtk.VBox(False, 5)
198 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) 509 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False)
199 label = HobWidget.gen_label_widget("<span weight=\"bold\">Packaging Format:</span>") 510 label = self.gen_label_widget("<span weight=\"bold\">Packaging Format:</span>")
200 tooltip = "Select package formats that will be used. " 511 tooltip = "Select package formats that will be used. "
201 tooltip += "The first format will be used for final image" 512 tooltip += "The first format will be used for final image"
202 pkgfmt_widget, self.pkgfmt_store = HobWidget.gen_pkgfmt_widget(self.configuration.curr_package_format, self.all_package_formats, tooltip) 513 pkgfmt_widget, self.pkgfmt_store = self.gen_pkgfmt_widget(self.configuration.curr_package_format, self.all_package_formats, tooltip)
203 sub_vbox.pack_start(label, expand=False, fill=False) 514 sub_vbox.pack_start(label, expand=False, fill=False)
204 sub_vbox.pack_start(pkgfmt_widget, expand=False, fill=False) 515 sub_vbox.pack_start(pkgfmt_widget, expand=False, fill=False)
205 516
206 sub_vbox = gtk.VBox(False, 5) 517 sub_vbox = gtk.VBox(False, 5)
207 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) 518 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False)
208 label = HobWidget.gen_label_widget("<span weight=\"bold\">Image Rootfs Size: (MB)</span>") 519 label = self.gen_label_widget("<span weight=\"bold\">Image Rootfs Size: (MB)</span>")
209 tooltip = "Sets the size of your target image.\nThis is the basic size of your target image, unless your selected package size exceeds this value, or you set value to \"Image Extra Size\"." 520 tooltip = "Sets the size of your target image.\nThis is the basic size of your target image, unless your selected package size exceeds this value, or you set value to \"Image Extra Size\"."
210 rootfs_size_widget, self.rootfs_size_spinner = HobWidget.gen_spinner_widget(int(self.configuration.image_rootfs_size*1.0/1024), 0, 1024, tooltip) 521 rootfs_size_widget, self.rootfs_size_spinner = self.gen_spinner_widget(int(self.configuration.image_rootfs_size*1.0/1024), 0, 1024, tooltip)
211 sub_vbox.pack_start(label, expand=False, fill=False) 522 sub_vbox.pack_start(label, expand=False, fill=False)
212 sub_vbox.pack_start(rootfs_size_widget, expand=False, fill=False) 523 sub_vbox.pack_start(rootfs_size_widget, expand=False, fill=False)
213 524
214 sub_vbox = gtk.VBox(False, 5) 525 sub_vbox = gtk.VBox(False, 5)
215 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) 526 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False)
216 label = HobWidget.gen_label_widget("<span weight=\"bold\">Image Extra Size: (MB)</span>") 527 label = self.gen_label_widget("<span weight=\"bold\">Image Extra Size: (MB)</span>")
217 tooltip = "Sets the extra free space of your target image.\nDefaultly, system will reserve 30% of your image size as your free space. If your image contains zypper, it will bring in 50MB more space. The maximum free space is 1024MB." 528 tooltip = "Sets the extra free space of your target image.\nDefaultly, system will reserve 30% of your image size as your free space. If your image contains zypper, it will bring in 50MB more space. The maximum free space is 1024MB."
218 extra_size_widget, self.extra_size_spinner = HobWidget.gen_spinner_widget(int(self.configuration.image_extra_size*1.0/1024), 0, 1024, tooltip) 529 extra_size_widget, self.extra_size_spinner = self.gen_spinner_widget(int(self.configuration.image_extra_size*1.0/1024), 0, 1024, tooltip)
219 sub_vbox.pack_start(label, expand=False, fill=False) 530 sub_vbox.pack_start(label, expand=False, fill=False)
220 sub_vbox.pack_start(extra_size_widget, expand=False, fill=False) 531 sub_vbox.pack_start(extra_size_widget, expand=False, fill=False)
221 532
@@ -235,7 +546,7 @@ class AdvancedSettingDialog (gtk.Dialog):
235 sub_hbox.pack_start(self.toolchain_checkbox, expand=False, fill=False) 546 sub_hbox.pack_start(self.toolchain_checkbox, expand=False, fill=False)
236 547
237 tooltip = "This is the Host platform you would like to run the toolchain" 548 tooltip = "This is the Host platform you would like to run the toolchain"
238 sdk_machine_widget, self.sdk_machine_combo = HobWidget.gen_combo_widget(self.configuration.curr_sdk_machine, self.all_sdk_machines, tooltip) 549 sdk_machine_widget, self.sdk_machine_combo = self.gen_combo_widget(self.configuration.curr_sdk_machine, self.all_sdk_machines, tooltip)
239 sub_hbox.pack_start(sdk_machine_widget, expand=False, fill=False) 550 sub_hbox.pack_start(sdk_machine_widget, expand=False, fill=False)
240 551
241 return advanced_vbox 552 return advanced_vbox
@@ -246,49 +557,49 @@ class AdvancedSettingDialog (gtk.Dialog):
246 557
247 sub_vbox = gtk.VBox(False, 5) 558 sub_vbox = gtk.VBox(False, 5)
248 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) 559 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False)
249 label = HobWidget.gen_label_widget("<span weight=\"bold\">Select Distro:</span>") 560 label = self.gen_label_widget("<span weight=\"bold\">Select Distro:</span>")
250 tooltip = "This is the Yocto distribution you would like to use" 561 tooltip = "This is the Yocto distribution you would like to use"
251 distro_widget, self.distro_combo = HobWidget.gen_combo_widget(self.configuration.curr_distro, self.all_distros, tooltip) 562 distro_widget, self.distro_combo = self.gen_combo_widget(self.configuration.curr_distro, self.all_distros, tooltip)
252 sub_vbox.pack_start(label, expand=False, fill=False) 563 sub_vbox.pack_start(label, expand=False, fill=False)
253 sub_vbox.pack_start(distro_widget, expand=False, fill=False) 564 sub_vbox.pack_start(distro_widget, expand=False, fill=False)
254 565
255 sub_vbox = gtk.VBox(False, 5) 566 sub_vbox = gtk.VBox(False, 5)
256 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) 567 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False)
257 label = HobWidget.gen_label_widget("<span weight=\"bold\">BB_NUMBER_THREADS:</span>") 568 label = self.gen_label_widget("<span weight=\"bold\">BB_NUMBER_THREADS:</span>")
258 tooltip = "Sets the number of threads that bitbake tasks can run simultaneously" 569 tooltip = "Sets the number of threads that bitbake tasks can run simultaneously"
259 bbthread_widget, self.bb_spinner = HobWidget.gen_spinner_widget(self.configuration.bbthread, 1, self.max_threads, tooltip) 570 bbthread_widget, self.bb_spinner = self.gen_spinner_widget(self.configuration.bbthread, 1, self.max_threads, tooltip)
260 sub_vbox.pack_start(label, expand=False, fill=False) 571 sub_vbox.pack_start(label, expand=False, fill=False)
261 sub_vbox.pack_start(bbthread_widget, expand=False, fill=False) 572 sub_vbox.pack_start(bbthread_widget, expand=False, fill=False)
262 573
263 sub_vbox = gtk.VBox(False, 5) 574 sub_vbox = gtk.VBox(False, 5)
264 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) 575 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False)
265 label = HobWidget.gen_label_widget("<span weight=\"bold\">PARALLEL_MAKE:</span>") 576 label = self.gen_label_widget("<span weight=\"bold\">PARALLEL_MAKE:</span>")
266 tooltip = "Sets the make parallism, as known as 'make -j'" 577 tooltip = "Sets the make parallism, as known as 'make -j'"
267 pmake_widget, self.pmake_spinner = HobWidget.gen_spinner_widget(self.configuration.pmake, 1, self.max_threads, tooltip) 578 pmake_widget, self.pmake_spinner = self.gen_spinner_widget(self.configuration.pmake, 1, self.max_threads, tooltip)
268 sub_vbox.pack_start(label, expand=False, fill=False) 579 sub_vbox.pack_start(label, expand=False, fill=False)
269 sub_vbox.pack_start(pmake_widget, expand=False, fill=False) 580 sub_vbox.pack_start(pmake_widget, expand=False, fill=False)
270 581
271 sub_vbox = gtk.VBox(False, 5) 582 sub_vbox = gtk.VBox(False, 5)
272 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) 583 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False)
273 label = HobWidget.gen_label_widget("<span weight=\"bold\">Set Download Directory:</span>") 584 label = self.gen_label_widget("<span weight=\"bold\">Set Download Directory:</span>")
274 tooltip = "Select a folder that caches the upstream project source code" 585 tooltip = "Select a folder that caches the upstream project source code"
275 dldir_widget, self.dldir_text = HobWidget.gen_entry_widget(self.split_model, self.configuration.dldir, self, tooltip) 586 dldir_widget, self.dldir_text = self.gen_entry_widget(self.split_model, self.configuration.dldir, self, tooltip)
276 sub_vbox.pack_start(label, expand=False, fill=False) 587 sub_vbox.pack_start(label, expand=False, fill=False)
277 sub_vbox.pack_start(dldir_widget, expand=False, fill=False) 588 sub_vbox.pack_start(dldir_widget, expand=False, fill=False)
278 589
279 sub_vbox = gtk.VBox(False, 5) 590 sub_vbox = gtk.VBox(False, 5)
280 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) 591 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False)
281 label = HobWidget.gen_label_widget("<span weight=\"bold\">Select SSTATE Directory:</span>") 592 label = self.gen_label_widget("<span weight=\"bold\">Select SSTATE Directory:</span>")
282 tooltip = "Select a folder that caches your prebuilt results" 593 tooltip = "Select a folder that caches your prebuilt results"
283 sstatedir_widget, self.sstatedir_text = HobWidget.gen_entry_widget(self.split_model, self.configuration.sstatedir, self, tooltip) 594 sstatedir_widget, self.sstatedir_text = self.gen_entry_widget(self.split_model, self.configuration.sstatedir, self, tooltip)
284 sub_vbox.pack_start(label, expand=False, fill=False) 595 sub_vbox.pack_start(label, expand=False, fill=False)
285 sub_vbox.pack_start(sstatedir_widget, expand=False, fill=False) 596 sub_vbox.pack_start(sstatedir_widget, expand=False, fill=False)
286 597
287 sub_vbox = gtk.VBox(False, 5) 598 sub_vbox = gtk.VBox(False, 5)
288 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) 599 advanced_vbox.pack_start(sub_vbox, expand=False, fill=False)
289 label = HobWidget.gen_label_widget("<span weight=\"bold\">Select SSTATE Mirror:</span>") 600 label = self.gen_label_widget("<span weight=\"bold\">Select SSTATE Mirror:</span>")
290 tooltip = "Select the prebuilt mirror that will fasten your build speed" 601 tooltip = "Select the prebuilt mirror that will fasten your build speed"
291 sstatemirror_widget, self.sstatemirror_text = HobWidget.gen_entry_widget(self.split_model, self.configuration.sstatemirror, self, tooltip) 602 sstatemirror_widget, self.sstatemirror_text = self.gen_entry_widget(self.split_model, self.configuration.sstatemirror, self, tooltip)
292 sub_vbox.pack_start(label, expand=False, fill=False) 603 sub_vbox.pack_start(label, expand=False, fill=False)
293 sub_vbox.pack_start(sstatemirror_widget, expand=False, fill=False) 604 sub_vbox.pack_start(sstatemirror_widget, expand=False, fill=False)
294 605
@@ -300,9 +611,9 @@ class AdvancedSettingDialog (gtk.Dialog):
300 611
301 sub_vbox = gtk.VBox(False, 5) 612 sub_vbox = gtk.VBox(False, 5)
302 advanced_vbox.pack_start(sub_vbox, expand=True, fill=True) 613 advanced_vbox.pack_start(sub_vbox, expand=True, fill=True)
303 label = HobWidget.gen_label_widget("<span weight=\"bold\">Add your own variables:</span>") 614 label = self.gen_label_widget("<span weight=\"bold\">Add your own variables:</span>")
304 tooltip = "This is the key/value pair for your extra settings" 615 tooltip = "This is the key/value pair for your extra settings"
305 setting_widget, self.setting_store = HobWidget.gen_editable_settings(self.configuration.extra_setting, tooltip) 616 setting_widget, self.setting_store = self.gen_editable_settings(self.configuration.extra_setting, tooltip)
306 sub_vbox.pack_start(label, expand=False, fill=False) 617 sub_vbox.pack_start(label, expand=False, fill=False)
307 sub_vbox.pack_start(setting_widget, expand=True, fill=True) 618 sub_vbox.pack_start(setting_widget, expand=True, fill=True)
308 619
@@ -485,6 +796,127 @@ class DeployImageDialog (gtk.Dialog):
485# 796#
486class LayerSelectionDialog (gtk.Dialog): 797class LayerSelectionDialog (gtk.Dialog):
487 798
799 def gen_label_widget(self, content):
800 label = gtk.Label()
801 label.set_alignment(0, 0)
802 label.set_markup(content)
803 label.show()
804 return label
805
806 def layer_widget_toggled_cb(self, cell, path, layer_store):
807 name = layer_store[path][0]
808 toggle = not layer_store[path][1]
809 layer_store[path][1] = toggle
810
811 def layer_widget_add_clicked_cb(self, action, layer_store, parent):
812 dialog = gtk.FileChooserDialog("Add new layer", parent,
813 gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
814 (gtk.STOCK_OK, gtk.RESPONSE_YES,
815 gtk.STOCK_CANCEL, gtk.RESPONSE_NO))
816 label = gtk.Label("Select the layer you wish to add")
817 label.show()
818 dialog.set_extra_widget(label)
819 response = dialog.run()
820 path = dialog.get_filename()
821 dialog.destroy()
822
823 lbl = "<b>Error</b>\nUnable to load layer <i>%s</i> because " % path
824 if response == gtk.RESPONSE_YES:
825 import os
826 import os.path
827 layers = []
828 it = layer_store.get_iter_first()
829 while it:
830 layers.append(layer_store.get_value(it, 0))
831 it = layer_store.iter_next(it)
832
833 if not path:
834 lbl += "it is an invalid path."
835 elif not os.path.exists(path+"/conf/layer.conf"):
836 lbl += "there is no layer.conf inside the directory."
837 elif path in layers:
838 lbl += "it is already in loaded layers."
839 else:
840 layer_store.append([path])
841 return
842 dialog = CrumbsDialog(parent, lbl)
843 dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
844 response = dialog.run()
845 dialog.destroy()
846
847 def layer_widget_del_clicked_cb(self, action, tree_selection, layer_store):
848 model, iter = tree_selection.get_selected()
849 if iter:
850 layer_store.remove(iter)
851
852
853 def gen_layer_widget(self, split_model, layers, layers_avail, window, tooltip=""):
854 hbox = gtk.HBox(False, 10)
855
856 layer_tv = gtk.TreeView()
857 layer_tv.set_rules_hint(True)
858 layer_tv.set_headers_visible(False)
859 tree_selection = layer_tv.get_selection()
860 tree_selection.set_mode(gtk.SELECTION_SINGLE)
861
862 col0= gtk.TreeViewColumn('Path')
863 cell0 = gtk.CellRendererText()
864 cell0.set_padding(5,2)
865 col0.pack_start(cell0, True)
866 col0.set_attributes(cell0, text=0)
867 layer_tv.append_column(col0)
868
869 scroll = gtk.ScrolledWindow()
870 scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
871 scroll.set_shadow_type(gtk.SHADOW_IN)
872 scroll.add(layer_tv)
873
874 table_layer = gtk.Table(2, 10, False)
875 hbox.pack_start(table_layer, expand=True, fill=True)
876
877 if split_model:
878 table_layer.attach(scroll, 0, 10, 0, 2)
879
880 layer_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN)
881 for layer in layers:
882 layer_store.set(layer_store.append(), 0, layer, 1, True)
883 for layer in layers_avail:
884 if layer not in layers:
885 layer_store.set(layer_store.append(), 0, layer, 1, False)
886
887 col1 = gtk.TreeViewColumn('Included')
888 layer_tv.append_column(col1)
889
890 cell1 = gtk.CellRendererToggle()
891 cell1.connect("toggled", self.layer_widget_toggled_cb, layer_store)
892 col1.pack_start(cell1, True)
893 col1.set_attributes(cell1, active=1)
894
895 else:
896 table_layer.attach(scroll, 0, 10, 0, 1)
897
898 layer_store = gtk.ListStore(gobject.TYPE_STRING)
899 for layer in layers:
900 layer_store.set(layer_store.append(), 0, layer)
901
902 image = gtk.Image()
903 image.set_from_stock(gtk.STOCK_ADD,gtk.ICON_SIZE_MENU)
904 add_button = gtk.Button()
905 add_button.set_image(image)
906 add_button.connect("clicked", self.layer_widget_add_clicked_cb, layer_store, window)
907 table_layer.attach(add_button, 0, 5, 1, 2, gtk.EXPAND | gtk.FILL, 0, 0, 0)
908 image = gtk.Image()
909 image.set_from_stock(gtk.STOCK_REMOVE,gtk.ICON_SIZE_MENU)
910 del_button = gtk.Button()
911 del_button.set_image(image)
912 del_button.connect("clicked", self.layer_widget_del_clicked_cb, tree_selection, layer_store)
913 table_layer.attach(del_button, 5, 10, 1, 2, gtk.EXPAND | gtk.FILL, 0, 0, 0)
914 layer_tv.set_model(layer_store)
915
916 hbox.show_all()
917
918 return hbox, layer_store
919
488 def __init__(self, title, layers, all_layers, split_model, 920 def __init__(self, title, layers, all_layers, split_model,
489 parent, flags, buttons): 921 parent, flags, buttons):
490 super(LayerSelectionDialog, self).__init__(title, parent, flags, buttons) 922 super(LayerSelectionDialog, self).__init__(title, parent, flags, buttons)
@@ -511,9 +943,9 @@ class LayerSelectionDialog (gtk.Dialog):
511 self.vbox.pack_start(hbox_top, expand=False, fill=False) 943 self.vbox.pack_start(hbox_top, expand=False, fill=False)
512 944
513 if self.split_model: 945 if self.split_model:
514 label = HobWidget.gen_label_widget("<span weight=\"bold\" font_desc='12'>Select Layers:</span>\n(Available layers under '${COREBASE}/layers/' directory)") 946 label = self.gen_label_widget("<span weight=\"bold\" font_desc='12'>Select Layers:</span>\n(Available layers under '${COREBASE}/layers/' directory)")
515 else: 947 else:
516 label = HobWidget.gen_label_widget("<span weight=\"bold\" font_desc='12'>Select Layers:</span>") 948 label = self.gen_label_widget("<span weight=\"bold\" font_desc='12'>Select Layers:</span>")
517 hbox_top.pack_start(label, expand=False, fill=False) 949 hbox_top.pack_start(label, expand=False, fill=False)
518 950
519 tooltip = "Layer is a collection of bb files and conf files" 951 tooltip = "Layer is a collection of bb files and conf files"
@@ -522,7 +954,7 @@ class LayerSelectionDialog (gtk.Dialog):
522 image.set_tooltip_text(tooltip) 954 image.set_tooltip_text(tooltip)
523 hbox_top.pack_end(image, expand=False, fill=False) 955 hbox_top.pack_end(image, expand=False, fill=False)
524 956
525 layer_widget, self.layer_store = HobWidget.gen_layer_widget(self.split_model, self.layers, self.all_layers, self, None) 957 layer_widget, self.layer_store = self.gen_layer_widget(self.split_model, self.layers, self.all_layers, self, None)
526 958
527 self.vbox.pack_start(layer_widget, expand=True, fill=True) 959 self.vbox.pack_start(layer_widget, expand=True, fill=True)
528 960
@@ -534,7 +966,7 @@ class LayerSelectionDialog (gtk.Dialog):
534 self.vbox.pack_end(hbox_button, expand=False, fill=False) 966 self.vbox.pack_end(hbox_button, expand=False, fill=False)
535 hbox_button.show() 967 hbox_button.show()
536 968
537 label = HobWidget.gen_label_widget("<i>'meta' is Core layer for Yocto images</i>\n" 969 label = self.gen_label_widget("<i>'meta' is Core layer for Yocto images</i>\n"
538 "<span weight=\"bold\">Please do not remove it</span>") 970 "<span weight=\"bold\">Please do not remove it</span>")
539 hbox_button.pack_start(label, expand=False, fill=False) 971 hbox_button.pack_start(label, expand=False, fill=False)
540 972