summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
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
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')
-rw-r--r--bitbake/lib/bb/ui/crumbs/hig.py486
-rw-r--r--bitbake/lib/bb/ui/crumbs/hobwidget.py465
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/recipeselectionpage.py2
3 files changed, 460 insertions, 493 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
diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py
index 38bc573a26..664bf25560 100644
--- a/bitbake/lib/bb/ui/crumbs/hobwidget.py
+++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py
@@ -50,471 +50,6 @@ class hic:
50 ICON_INDI_CONFIRM_FILE = os.path.join(HOB_ICON_BASE_DIR, ('indicators/confirmation.png')) 50 ICON_INDI_CONFIRM_FILE = os.path.join(HOB_ICON_BASE_DIR, ('indicators/confirmation.png'))
51 ICON_INDI_ERROR_FILE = os.path.join(HOB_ICON_BASE_DIR, ('indicators/error.png')) 51 ICON_INDI_ERROR_FILE = os.path.join(HOB_ICON_BASE_DIR, ('indicators/error.png'))
52 52
53class HobWidget:
54 @classmethod
55 def resize_widget(cls, screen, widget, widget_width, widget_height):
56 screen_width, screen_height = screen.get_size_request()
57 ratio_height = screen_width * hwc.MAIN_WIN_HEIGHT/hwc.MAIN_WIN_WIDTH
58 if ratio_height < screen_height:
59 screen_height = ratio_height
60 widget_width = widget_width * screen_width/hwc.MAIN_WIN_WIDTH
61 widget_height = widget_height * screen_height/hwc.MAIN_WIN_HEIGHT
62 widget.set_size_request(widget_width, widget_height)
63
64 @classmethod
65 def _toggle_cb(cls, cell, path, model, column):
66 it = model.get_iter(path)
67 val = model.get_value(it, column)
68 val = not val
69 model.set(it, column, val)
70
71 @classmethod
72 def _pkgfmt_up_clicked_cb(cls, button, tree_selection):
73 (model, it) = tree_selection.get_selected()
74 if not it:
75 return
76 path = model.get_path(it)
77 if path[0] <= 0:
78 return
79
80 pre_it = model.get_iter_first()
81 if not pre_it:
82 return
83 else:
84 while model.iter_next(pre_it) :
85 if model.get_value(model.iter_next(pre_it), 1) != model.get_value(it, 1):
86 pre_it = model.iter_next(pre_it)
87 else:
88 break
89
90 cur_index = model.get_value(it, 0)
91 pre_index = cur_index
92 if pre_it:
93 model.set(pre_it, 0, pre_index)
94 cur_index = cur_index - 1
95 model.set(it, 0, cur_index)
96
97 @classmethod
98 def _pkgfmt_down_clicked_cb(cls, button, tree_selection):
99 (model, it) = tree_selection.get_selected()
100 if not it:
101 return
102 next_it = model.iter_next(it)
103 if not next_it:
104 return
105 cur_index = model.get_value(it, 0)
106 next_index = cur_index
107 model.set(next_it, 0, next_index)
108 cur_index = cur_index + 1
109 model.set(it, 0, cur_index)
110
111 @classmethod
112 def _tree_selection_changed_cb(cls, tree_selection, button1, button2):
113 (model, it) = tree_selection.get_selected()
114 inc = model.get_value(it, 2)
115 if inc:
116 button1.set_sensitive(True)
117 button2.set_sensitive(True)
118 else:
119 button1.set_sensitive(False)
120 button2.set_sensitive(False)
121
122 @classmethod
123 def _sort_func(cls, model, iter1, iter2, data):
124 val1 = model.get_value(iter1, 0)
125 val2 = model.get_value(iter2, 0)
126 inc1 = model.get_value(iter1, 2)
127 inc2 = model.get_value(iter2, 2)
128 if inc1 != inc2:
129 return inc2 - inc1
130 else:
131 return val1 - val2
132
133 @classmethod
134 def gen_pkgfmt_widget(cls, curr_package_format, all_package_format, tooltip=""):
135 pkgfmt_hbox = gtk.HBox(False, 15)
136
137 pkgfmt_store = gtk.ListStore(int, str, gobject.TYPE_BOOLEAN)
138 for format in curr_package_format.split():
139 pkgfmt_store.set(pkgfmt_store.append(), 1, format, 2, True)
140 for format in all_package_format:
141 if format not in curr_package_format:
142 pkgfmt_store.set(pkgfmt_store.append(), 1, format, 2, False)
143 pkgfmt_tree = gtk.TreeView(pkgfmt_store)
144 pkgfmt_tree.set_headers_clickable(True)
145 pkgfmt_tree.set_headers_visible(False)
146 tree_selection = pkgfmt_tree.get_selection()
147 tree_selection.set_mode(gtk.SELECTION_SINGLE)
148
149 col = gtk.TreeViewColumn('NO')
150 col.set_sort_column_id(0)
151 col.set_sort_order(gtk.SORT_ASCENDING)
152 col.set_clickable(False)
153 col1 = gtk.TreeViewColumn('TYPE')
154 col1.set_min_width(130)
155 col1.set_max_width(140)
156 col2 = gtk.TreeViewColumn('INCLUDED')
157 col2.set_min_width(60)
158 col2.set_max_width(70)
159 pkgfmt_tree.append_column(col1)
160 pkgfmt_tree.append_column(col2)
161 cell = gtk.CellRendererText()
162 cell1 = gtk.CellRendererText()
163 cell1.set_property('width-chars', 10)
164 cell2 = gtk.CellRendererToggle()
165 cell2.set_property('activatable', True)
166 cell2.connect("toggled", cls._toggle_cb, pkgfmt_store, 2)
167 col.pack_start(cell, True)
168 col1.pack_start(cell1, True)
169 col2.pack_end(cell2, True)
170 col.set_attributes(cell, text=0)
171 col1.set_attributes(cell1, text=1)
172 col2.set_attributes(cell2, active=2)
173
174 pkgfmt_store.set_sort_func(0, cls._sort_func, None)
175 pkgfmt_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
176
177 scroll = gtk.ScrolledWindow()
178 scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
179 scroll.set_shadow_type(gtk.SHADOW_IN)
180 scroll.add(pkgfmt_tree)
181 scroll.set_size_request(200,60)
182 pkgfmt_hbox.pack_start(scroll, False, False, 0)
183
184 vbox = gtk.VBox(False, 5)
185 pkgfmt_hbox.pack_start(vbox, False, False, 15)
186
187 up = gtk.Button()
188 image = gtk.Image()
189 image.set_from_stock(gtk.STOCK_GO_UP, gtk.ICON_SIZE_MENU)
190 up.set_image(image)
191 up.set_size_request(50,30)
192 up.connect("clicked", cls._pkgfmt_up_clicked_cb, tree_selection)
193 vbox.pack_start(up, False, False, 5)
194
195 down = gtk.Button()
196 image = gtk.Image()
197 image.set_from_stock(gtk.STOCK_GO_DOWN, gtk.ICON_SIZE_MENU)
198 down.set_image(image)
199 down.set_size_request(50,30)
200 down.connect("clicked", cls._pkgfmt_down_clicked_cb, tree_selection)
201 vbox.pack_start(down, False, False, 5)
202 tree_selection.connect("changed", cls._tree_selection_changed_cb, up, down)
203
204 image = gtk.Image()
205 image.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
206 image.set_tooltip_text(tooltip)
207 pkgfmt_hbox.pack_start(image, expand=False, fill=False)
208
209 pkgfmt_hbox.show_all()
210
211 return pkgfmt_hbox, pkgfmt_store
212
213 @classmethod
214 def gen_combo_widget(cls, curr_item, all_item, tooltip=""):
215 hbox = gtk.HBox(False, 10)
216 combo = gtk.combo_box_new_text()
217 hbox.pack_start(combo, expand=False, fill=False)
218
219 index = 0
220 for item in all_item or []:
221 combo.append_text(item)
222 if item == curr_item:
223 combo.set_active(index)
224 index += 1
225
226 image = gtk.Image()
227 image.show()
228 image.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
229 image.set_tooltip_text(tooltip)
230
231 hbox.pack_start(image, expand=False, fill=False)
232
233 hbox.show_all()
234
235 return hbox, combo
236
237 @classmethod
238 def gen_label_widget(cls, content):
239 label = gtk.Label()
240 label.set_alignment(0, 0)
241 label.set_markup(content)
242 label.show()
243 return label
244
245 @classmethod
246 def _select_path_cb(cls, action, parent, entry):
247 dialog = gtk.FileChooserDialog("", parent,
248 gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
249 (gtk.STOCK_OK, gtk.RESPONSE_YES,
250 gtk.STOCK_CANCEL, gtk.RESPONSE_NO))
251 response = dialog.run()
252 if response == gtk.RESPONSE_YES:
253 path = dialog.get_filename()
254 entry.set_text(path)
255
256 dialog.destroy()
257
258 @classmethod
259 def gen_entry_widget(cls, split_model, content, parent, tooltip=""):
260 hbox = gtk.HBox(False, 10)
261 entry = gtk.Entry()
262 entry.set_text(content)
263
264 if split_model:
265 hbox.pack_start(entry, expand=True, fill=True)
266 else:
267 table = gtk.Table(1, 10, True)
268 hbox.pack_start(table, expand=True, fill=True)
269 table.attach(entry, 0, 9, 0, 1)
270 image = gtk.Image()
271 image.set_from_stock(gtk.STOCK_OPEN,gtk.ICON_SIZE_BUTTON)
272 open_button = gtk.Button()
273 open_button.set_image(image)
274 open_button.connect("clicked", cls._select_path_cb, parent, entry)
275 table.attach(open_button, 9, 10, 0, 1)
276
277 image = gtk.Image()
278 image.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
279 image.set_tooltip_text(tooltip)
280 hbox.pack_start(image, expand=False, fill=False)
281
282 hbox.show_all()
283
284 return hbox, entry
285
286 @classmethod
287 def gen_spinner_widget(cls, content, lower, upper, tooltip=""):
288 hbox = gtk.HBox(False, 10)
289 adjust = gtk.Adjustment(value=content, lower=lower, upper=upper, step_incr=1)
290 spinner = gtk.SpinButton(adjustment=adjust, climb_rate=1, digits=0)
291
292 spinner.set_value(content)
293 hbox.pack_start(spinner, expand=False, fill=False)
294
295 image = gtk.Image()
296 image.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
297 image.set_tooltip_text(tooltip)
298 hbox.pack_start(image, expand=False, fill=False)
299
300 hbox.show_all()
301
302 return hbox, spinner
303
304 @classmethod
305 def conf_error(cls, parent, lbl):
306 dialog = CrumbsDialog(parent, lbl)
307 dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
308 response = dialog.run()
309 dialog.destroy()
310
311 @classmethod
312 def _add_layer_cb(cls, action, layer_store, parent):
313 dialog = gtk.FileChooserDialog("Add new layer", parent,
314 gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
315 (gtk.STOCK_OK, gtk.RESPONSE_YES,
316 gtk.STOCK_CANCEL, gtk.RESPONSE_NO))
317 label = gtk.Label("Select the layer you wish to add")
318 label.show()
319 dialog.set_extra_widget(label)
320 response = dialog.run()
321 path = dialog.get_filename()
322 dialog.destroy()
323
324 lbl = "<b>Error</b>\nUnable to load layer <i>%s</i> because " % path
325 if response == gtk.RESPONSE_YES:
326 import os
327 import os.path
328 layers = []
329 it = layer_store.get_iter_first()
330 while it:
331 layers.append(layer_store.get_value(it, 0))
332 it = layer_store.iter_next(it)
333
334 if not path:
335 lbl += "it is an invalid path."
336 elif not os.path.exists(path+"/conf/layer.conf"):
337 lbl += "there is no layer.conf inside the directory."
338 elif path in layers:
339 lbl += "it is already in loaded layers."
340 else:
341 layer_store.append([path])
342 return
343 cls.conf_error(parent, lbl)
344
345 @classmethod
346 def _del_layer_cb(cls, action, tree_selection, layer_store):
347 model, iter = tree_selection.get_selected()
348 if iter:
349 layer_store.remove(iter)
350
351 @classmethod
352 def _toggle_layer_cb(cls, cell, path, layer_store):
353 name = layer_store[path][0]
354 toggle = not layer_store[path][1]
355 layer_store[path][1] = toggle
356
357 @classmethod
358 def gen_layer_widget(cls, split_model, layers, layers_avail, window, tooltip=""):
359 hbox = gtk.HBox(False, 10)
360
361 layer_tv = gtk.TreeView()
362 layer_tv.set_rules_hint(True)
363 layer_tv.set_headers_visible(False)
364 tree_selection = layer_tv.get_selection()
365 tree_selection.set_mode(gtk.SELECTION_SINGLE)
366
367 col0= gtk.TreeViewColumn('Path')
368 cell0 = gtk.CellRendererText()
369 cell0.set_padding(5,2)
370 col0.pack_start(cell0, True)
371 col0.set_attributes(cell0, text=0)
372 layer_tv.append_column(col0)
373
374 scroll = gtk.ScrolledWindow()
375 scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
376 scroll.set_shadow_type(gtk.SHADOW_IN)
377 scroll.add(layer_tv)
378
379 table_layer = gtk.Table(2, 10, False)
380 hbox.pack_start(table_layer, expand=True, fill=True)
381
382 if split_model:
383 table_layer.attach(scroll, 0, 10, 0, 2)
384
385 layer_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN)
386 for layer in layers:
387 layer_store.set(layer_store.append(), 0, layer, 1, True)
388 for layer in layers_avail:
389 if layer not in layers:
390 layer_store.set(layer_store.append(), 0, layer, 1, False)
391
392 col1 = gtk.TreeViewColumn('Included')
393 layer_tv.append_column(col1)
394
395 cell1 = gtk.CellRendererToggle()
396 cell1.connect("toggled", cls._toggle_layer_cb, layer_store)
397 col1.pack_start(cell1, True)
398 col1.set_attributes(cell1, active=1)
399
400 else:
401 table_layer.attach(scroll, 0, 10, 0, 1)
402
403 layer_store = gtk.ListStore(gobject.TYPE_STRING)
404 for layer in layers:
405 layer_store.set(layer_store.append(), 0, layer)
406
407 image = gtk.Image()
408 image.set_from_stock(gtk.STOCK_ADD,gtk.ICON_SIZE_MENU)
409 add_button = gtk.Button()
410 add_button.set_image(image)
411 add_button.connect("clicked", cls._add_layer_cb, layer_store, window)
412 table_layer.attach(add_button, 0, 5, 1, 2, gtk.EXPAND | gtk.FILL, 0, 0, 0)
413 image = gtk.Image()
414 image.set_from_stock(gtk.STOCK_REMOVE,gtk.ICON_SIZE_MENU)
415 del_button = gtk.Button()
416 del_button.set_image(image)
417 del_button.connect("clicked", cls._del_layer_cb, tree_selection, layer_store)
418 table_layer.attach(del_button, 5, 10, 1, 2, gtk.EXPAND | gtk.FILL, 0, 0, 0)
419 layer_tv.set_model(layer_store)
420
421 hbox.show_all()
422
423 return hbox, layer_store
424
425 @classmethod
426 def _on_add_item_clicked(cls, button, model):
427 new_item = ["##KEY##", "##VALUE##"]
428
429 iter = model.append()
430 model.set (iter,
431 0, new_item[0],
432 1, new_item[1],
433 )
434
435
436 @classmethod
437 def _on_remove_item_clicked(cls, button, treeview):
438
439 selection = treeview.get_selection()
440 model, iter = selection.get_selected()
441
442 if iter:
443 path = model.get_path(iter)[0]
444 model.remove(iter)
445
446 @classmethod
447 def _on_cell_edited(cls, cell, path_string, new_text, model):
448 it = model.get_iter_from_string(path_string)
449 column = cell.get_data("column")
450 model.set(it, column, new_text)
451
452
453 @classmethod
454 def gen_editable_settings(cls, setting, tooltip=""):
455 setting_hbox = gtk.HBox(False, 10)
456
457 vbox = gtk.VBox(False, 10)
458 setting_hbox.pack_start(vbox, expand=True, fill=True)
459
460 setting_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
461 for key in setting.keys():
462 setting_store.set(setting_store.append(), 0, key, 1, setting[key])
463
464 setting_tree = gtk.TreeView(setting_store)
465 setting_tree.set_headers_visible(True)
466 setting_tree.set_size_request(300, 100)
467
468 col = gtk.TreeViewColumn('Key')
469 col.set_min_width(100)
470 col.set_max_width(150)
471 col.set_resizable(True)
472 col1 = gtk.TreeViewColumn('Value')
473 col1.set_min_width(100)
474 col1.set_max_width(150)
475 col1.set_resizable(True)
476 setting_tree.append_column(col)
477 setting_tree.append_column(col1)
478 cell = gtk.CellRendererText()
479 cell.set_property('width-chars', 10)
480 cell.set_property('editable', True)
481 cell.set_data("column", 0)
482 cell.connect("edited", cls._on_cell_edited, setting_store)
483 cell1 = gtk.CellRendererText()
484 cell1.set_property('width-chars', 10)
485 cell1.set_property('editable', True)
486 cell1.set_data("column", 1)
487 cell1.connect("edited", cls._on_cell_edited, setting_store)
488 col.pack_start(cell, True)
489 col1.pack_end(cell1, True)
490 col.set_attributes(cell, text=0)
491 col1.set_attributes(cell1, text=1)
492
493 scroll = gtk.ScrolledWindow()
494 scroll.set_shadow_type(gtk.SHADOW_IN)
495 scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
496 scroll.add(setting_tree)
497 vbox.pack_start(scroll, expand=True, fill=True)
498
499 # some buttons
500 hbox = gtk.HBox(True, 4)
501 vbox.pack_start(hbox, False, False)
502
503 button = gtk.Button(stock=gtk.STOCK_ADD)
504 button.connect("clicked", cls._on_add_item_clicked, setting_store)
505 hbox.pack_start(button)
506
507 button = gtk.Button(stock=gtk.STOCK_REMOVE)
508 button.connect("clicked", cls._on_remove_item_clicked, setting_tree)
509 hbox.pack_start(button)
510
511 image = gtk.Image()
512 image.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
513 image.set_tooltip_text(tooltip)
514 setting_hbox.pack_start(image, expand=False, fill=False)
515
516 return setting_hbox, setting_store
517
518class HobViewTable (gtk.VBox): 53class HobViewTable (gtk.VBox):
519 """ 54 """
520 A VBox to contain the table for different recipe views and package view 55 A VBox to contain the table for different recipe views and package view
diff --git a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
index 8a356935ac..ee36f8c8b1 100755
--- a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
+++ b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
@@ -23,7 +23,7 @@
23import gtk 23import gtk
24import glib 24import glib
25from bb.ui.crumbs.hobcolor import HobColors 25from bb.ui.crumbs.hobcolor import HobColors
26from bb.ui.crumbs.hobwidget import HobWidget, HobViewBar, HobViewTable 26from bb.ui.crumbs.hobwidget import HobViewBar, HobViewTable
27from bb.ui.crumbs.hoblistmodel import RecipeListModel 27from bb.ui.crumbs.hoblistmodel import RecipeListModel
28from bb.ui.crumbs.hobpages import HobPage 28from bb.ui.crumbs.hobpages import HobPage
29 29