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.py168
1 files changed, 55 insertions, 113 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py
index 890151ddd4..141c4efb1b 100644
--- a/bitbake/lib/bb/ui/crumbs/hobwidget.py
+++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py
@@ -423,104 +423,6 @@ class HobWidget:
423 return hbox, layer_store 423 return hbox, layer_store
424 424
425 @classmethod 425 @classmethod
426 def _toggle_single_cb(cls, cell, select_path, treeview, toggle_column):
427 model = treeview.get_model()
428 if not model:
429 return
430 iter = model.get_iter_first()
431 while iter:
432 path = model.get_path(iter)
433 model[path][toggle_column] = False
434 iter = model.iter_next(iter)
435
436 model[select_path][toggle_column] = True
437
438 @classmethod
439 def gen_imgtv_widget(cls, col0_width, col1_width):
440 vbox = gtk.VBox(False, 10)
441
442 imgsel_tv = gtk.TreeView()
443 imgsel_tv.set_rules_hint(True)
444 imgsel_tv.set_headers_visible(False)
445 tree_selection = imgsel_tv.get_selection()
446 tree_selection.set_mode(gtk.SELECTION_SINGLE)
447
448 col0= gtk.TreeViewColumn('Image name')
449 cell0 = gtk.CellRendererText()
450 cell0.set_padding(5,2)
451 col0.pack_start(cell0, True)
452 col0.set_attributes(cell0, text=0)
453 col0.set_max_width(col0_width)
454 col0.set_min_width(col0_width)
455 imgsel_tv.append_column(col0)
456
457 col1= gtk.TreeViewColumn('Select')
458 cell1 = gtk.CellRendererToggle()
459 cell1.set_padding(5,2)
460 cell1.connect("toggled", cls._toggle_single_cb, imgsel_tv, 1)
461 col1.pack_start(cell1, True)
462 col1.set_attributes(cell1, active=1)
463 col1.set_max_width(col1_width)
464 col1.set_min_width(col1_width)
465 imgsel_tv.append_column(col1)
466
467 scroll = gtk.ScrolledWindow()
468 scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
469 scroll.set_shadow_type(gtk.SHADOW_IN)
470 scroll.add(imgsel_tv)
471
472 vbox.pack_start(scroll, expand=True, fill=True)
473
474 return vbox, imgsel_tv
475
476 @classmethod
477 def gen_images_widget(cls, col0_width, col1_width, col2_width):
478 vbox = gtk.VBox(False, 10)
479
480 imgsel_tv = gtk.TreeView()
481 imgsel_tv.set_rules_hint(True)
482 imgsel_tv.set_headers_visible(False)
483 tree_selection = imgsel_tv.get_selection()
484 tree_selection.set_mode(gtk.SELECTION_SINGLE)
485
486 col0= gtk.TreeViewColumn('Image name')
487 cell0 = gtk.CellRendererText()
488 cell0.set_padding(5,2)
489 col0.pack_start(cell0, True)
490 col0.set_attributes(cell0, text=0)
491 col0.set_max_width(col0_width)
492 col0.set_min_width(col0_width)
493 imgsel_tv.append_column(col0)
494
495 col1= gtk.TreeViewColumn('Image size')
496 cell1 = gtk.CellRendererText()
497 cell1.set_padding(5,2)
498 col1.pack_start(cell1, True)
499 col1.set_attributes(cell1, text=1)
500 col1.set_max_width(col1_width)
501 col1.set_min_width(col1_width)
502 imgsel_tv.append_column(col1)
503
504 col2= gtk.TreeViewColumn('Select')
505 cell2 = gtk.CellRendererToggle()
506 cell2.set_padding(5,2)
507 cell2.connect("toggled", cls._toggle_single_cb, imgsel_tv, 2)
508 col2.pack_start(cell2, True)
509 col2.set_attributes(cell2, active=2)
510 col2.set_max_width(col2_width)
511 col2.set_min_width(col2_width)
512 imgsel_tv.append_column(col2)
513
514 scroll = gtk.ScrolledWindow()
515 scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
516 scroll.set_shadow_type(gtk.SHADOW_IN)
517 scroll.add(imgsel_tv)
518
519 vbox.pack_start(scroll, expand=True, fill=True)
520
521 return vbox, imgsel_tv
522
523 @classmethod
524 def _on_add_item_clicked(cls, button, model): 426 def _on_add_item_clicked(cls, button, model):
525 new_item = ["##KEY##", "##VALUE##"] 427 new_item = ["##KEY##", "##VALUE##"]
526 428
@@ -617,34 +519,59 @@ class HobViewTable (gtk.VBox):
617 """ 519 """
618 A VBox to contain the table for different recipe views and package view 520 A VBox to contain the table for different recipe views and package view
619 """ 521 """
620 def __init__(self, columns, reset_clicked_cb=None, toggled_cb=None): 522 __gsignals__ = {
523 "toggled" : (gobject.SIGNAL_RUN_LAST,
524 gobject.TYPE_NONE,
525 (gobject.TYPE_PYOBJECT,
526 gobject.TYPE_STRING,
527 gobject.TYPE_INT,
528 gobject.TYPE_PYOBJECT,)),
529 "changed" : (gobject.SIGNAL_RUN_LAST,
530 gobject.TYPE_NONE,
531 (gobject.TYPE_PYOBJECT,
532 gobject.TYPE_PYOBJECT,)),
533 }
534
535 def __init__(self, columns):
621 gtk.VBox.__init__(self, False, 6) 536 gtk.VBox.__init__(self, False, 6)
622 self.table_tree = gtk.TreeView() 537 self.table_tree = gtk.TreeView()
623 self.table_tree.set_headers_visible(True) 538 self.table_tree.set_headers_visible(True)
624 self.table_tree.set_headers_clickable(True) 539 self.table_tree.set_headers_clickable(True)
625 self.table_tree.set_enable_search(True) 540 self.table_tree.set_enable_search(True)
626 self.table_tree.set_search_column(0) 541 self.table_tree.set_rules_hint(True)
627 self.table_tree.get_selection().set_mode(gtk.SELECTION_SINGLE) 542 self.table_tree.get_selection().set_mode(gtk.SELECTION_SINGLE)
543 self.table_tree.get_selection().connect("changed", self.selection_changed_cb, self.table_tree)
628 544
629 for i in range(len(columns)): 545 for i in range(len(columns)):
630 col = gtk.TreeViewColumn(columns[i]['col_name']) 546 col = gtk.TreeViewColumn(columns[i]['col_name'])
631 col.set_clickable(True) 547 col.set_clickable(True)
632 col.set_resizable(True) 548 col.set_resizable(True)
633 col.set_sort_column_id(columns[i]['col_id']) 549 col.set_sort_column_id(columns[i]['col_id'])
634 col.set_min_width(columns[i]['col_min']) 550 if 'col_min' in columns[i].keys():
635 col.set_max_width(columns[i]['col_max']) 551 col.set_min_width(columns[i]['col_min'])
552 if 'col_max' in columns[i].keys():
553 col.set_max_width(columns[i]['col_max'])
636 self.table_tree.append_column(col) 554 self.table_tree.append_column(col)
637 555
638 if columns[i]['col_style'] == 'toggle': 556 if (not 'col_style' in columns[i].keys()) or columns[i]['col_style'] == 'text':
557 cell = gtk.CellRendererText()
558 col.pack_start(cell, True)
559 col.set_attributes(cell, text=columns[i]['col_id'])
560 elif columns[i]['col_style'] == 'check toggle':
639 cell = gtk.CellRendererToggle() 561 cell = gtk.CellRendererToggle()
640 cell.set_property('activatable', True) 562 cell.set_property('activatable', True)
641 cell.connect("toggled", toggled_cb, self.table_tree) 563 cell.connect("toggled", self.toggled_cb, i, self.table_tree)
564 self.toggle_id = i
565 col.pack_end(cell, True)
566 col.set_attributes(cell, active=columns[i]['col_id'])
567 elif columns[i]['col_style'] == 'radio toggle':
568 cell = gtk.CellRendererToggle()
569 cell.set_property('activatable', True)
570 cell.set_radio(True)
571 cell.connect("toggled", self.toggled_cb, i, self.table_tree)
572 self.toggle_id = i
642 col.pack_end(cell, True) 573 col.pack_end(cell, True)
643 col.set_attributes(cell, active=columns[i]['col_id']) 574 col.set_attributes(cell, active=columns[i]['col_id'])
644 elif columns[i]['col_style'] == 'text':
645 cell = gtk.CellRendererText()
646 col.pack_start(cell, True)
647 col.set_attributes(cell, text=columns[i]['col_id'])
648 575
649 scroll = gtk.ScrolledWindow() 576 scroll = gtk.ScrolledWindow()
650 scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) 577 scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
@@ -652,12 +579,27 @@ class HobViewTable (gtk.VBox):
652 scroll.add(self.table_tree) 579 scroll.add(self.table_tree)
653 self.pack_start(scroll, True, True, 0) 580 self.pack_start(scroll, True, True, 0)
654 581
655 hbox = gtk.HBox(False, 5) 582 def set_model(self, tree_model):
656 button = gtk.Button("Reset") 583 self.table_tree.set_model(tree_model)
657 button.connect('clicked', reset_clicked_cb) 584
658 hbox.pack_end(button, False, False, 0) 585 def set_search_entry(self, search_column_id, entry):
586 self.table_tree.set_search_column(search_column_id)
587 self.table_tree.set_search_entry(entry)
588
589 def toggle_default(self):
590 model = self.table_tree.get_model()
591 if not model:
592 return
593 iter = model.get_iter_first()
594 if iter:
595 rowpath = model.get_path(iter)
596 model[rowpath][self.toggle_id] = True
597
598 def toggled_cb(self, cell, path, columnid, tree):
599 self.emit("toggled", cell, path, columnid, tree)
659 600
660 self.pack_start(hbox, False, False, 0) 601 def selection_changed_cb(self, selection, tree):
602 self.emit("changed", selection, tree)
661 603
662class HobViewBar (gtk.EventBox): 604class HobViewBar (gtk.EventBox):
663 """ 605 """