summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/crumbs/hobwidget.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/hobwidget.py')
-rw-r--r--bitbake/lib/bb/ui/crumbs/hobwidget.py465
1 files changed, 0 insertions, 465 deletions
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