summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2012-03-20 09:39:45 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-03-22 14:43:51 +0000
commit1f3a6379c5191e75117490e6a0df5eb23d85a7e9 (patch)
tree6d39a1c77ce3dc516f44b42d74f8a55666b23604 /bitbake
parentf9501768c8a3231cbd863b050d99bade1e71f7f1 (diff)
downloadpoky-1f3a6379c5191e75117490e6a0df5eb23d85a7e9.tar.gz
ui/crumbs/hig: make the layer selection dialogue more closely match design
The layer dialogue design includes in-line remove/delete widgets next to the layer path in the tree view for all layers other than the meta layer as well as an in-line notice that the meta layer cannot be removed. This is achieved in this patch through the use of custom cell_data_func's for the treeview to render the meta layer differently and a custom CellRenderer implementation, CellRendererPixbufActivatable, which renders a pixbuf and emits a clicked signal when the user clicks on it. Fixes [YOCTO #2083] (From Poky rev: 83c96b7a0ec4412716090098385a665045909a9a) (Bitbake rev: b2d8f28c0059992200457a15aef8be09e015a5dd) Signed-off-by: Joshua Lock <josh@linux.intel.com> Signed-off-by: Shane Wang <shane.wang@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/ui/crumbs/hig.py122
1 files changed, 93 insertions, 29 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py
index bc37d90a46..6b46a6212a 100644
--- a/bitbake/lib/bb/ui/crumbs/hig.py
+++ b/bitbake/lib/bb/ui/crumbs/hig.py
@@ -696,6 +696,27 @@ class DeployImageDialog (CrumbsDialog):
696 os.close(f_from) 696 os.close(f_from)
697 os.close(f_to) 697 os.close(f_to)
698 self.progress_bar.hide() 698 self.progress_bar.hide()
699
700class CellRendererPixbufActivatable(gtk.CellRendererPixbuf):
701 """
702 A custom CellRenderer implementation which is activatable
703 so that we can handle user clicks
704 """
705 __gsignals__ = { 'clicked' : (gobject.SIGNAL_RUN_LAST,
706 gobject.TYPE_NONE,
707 (gobject.TYPE_STRING,)), }
708
709 def __init__(self):
710 gtk.CellRendererPixbuf.__init__(self)
711 self.set_property('mode', gtk.CELL_RENDERER_MODE_ACTIVATABLE)
712 self.set_property('follow-state', True)
713
714 """
715 Respond to a user click on a cell
716 """
717 def do_activate(self, even, widget, path, background_area, cell_area, flags):
718 self.emit('clicked', path)
719
699# 720#
700# LayerSelectionDialog 721# LayerSelectionDialog
701# 722#
@@ -762,13 +783,13 @@ class LayerSelectionDialog (CrumbsDialog):
762 layer_tv.set_rules_hint(True) 783 layer_tv.set_rules_hint(True)
763 layer_tv.set_headers_visible(False) 784 layer_tv.set_headers_visible(False)
764 tree_selection = layer_tv.get_selection() 785 tree_selection = layer_tv.get_selection()
765 tree_selection.set_mode(gtk.SELECTION_SINGLE) 786 tree_selection.set_mode(gtk.SELECTION_NONE)
766 787
767 col0= gtk.TreeViewColumn('Path') 788 col0= gtk.TreeViewColumn('Path')
768 cell0 = gtk.CellRendererText() 789 cell0 = gtk.CellRendererText()
769 cell0.set_padding(5,2) 790 cell0.set_padding(5,2)
770 col0.pack_start(cell0, True) 791 col0.pack_start(cell0, True)
771 col0.set_attributes(cell0, text=0) 792 col0.set_cell_data_func(cell0, self.draw_layer_path_cb)
772 layer_tv.append_column(col0) 793 layer_tv.append_column(col0)
773 794
774 scroll = gtk.ScrolledWindow() 795 scroll = gtk.ScrolledWindow()
@@ -785,18 +806,33 @@ class LayerSelectionDialog (CrumbsDialog):
785 for layer in layers: 806 for layer in layers:
786 layer_store.set(layer_store.append(), 0, layer) 807 layer_store.set(layer_store.append(), 0, layer)
787 808
788 image = gtk.Image() 809 col1 = gtk.TreeViewColumn('Enabled')
789 image.set_from_stock(gtk.STOCK_ADD,gtk.ICON_SIZE_MENU) 810 layer_tv.append_column(col1)
790 add_button = gtk.Button() 811
791 add_button.set_image(image) 812 cell1 = CellRendererPixbufActivatable()
813 cell1.set_fixed_size(-1,35)
814 cell1.connect("clicked", self.del_cell_clicked_cb, layer_store)
815 col1.pack_start(cell1, True)
816 col1.set_cell_data_func(cell1, self.draw_delete_button_cb, layer_tv)
817
818 add_button = HobAltButton()
819 box = gtk.HBox(False, 6)
820 box.show()
821 add_button.add(box)
822 im = gtk.Image()
823 im.set_from_file(hic.ICON_INDI_ADD)
824 im.show()
825 box.pack_start(im, expand=False, fill=False, padding=6)
826 lbl = gtk.Label("Add layer")
827 lbl.set_alignment(0.0, 0.5)
828 lbl.show()
829 box.pack_start(lbl, expand=True, fill=True, padding=6)
792 add_button.connect("clicked", self.layer_widget_add_clicked_cb, layer_store, window) 830 add_button.connect("clicked", self.layer_widget_add_clicked_cb, layer_store, window)
793 table_layer.attach(add_button, 0, 5, 1, 2, gtk.EXPAND | gtk.FILL, 0, 0, 6) 831 add_button.set_can_default(True)
794 image = gtk.Image() 832 add_button.grab_default()
795 image.set_from_stock(gtk.STOCK_REMOVE,gtk.ICON_SIZE_MENU) 833 add_button.set_can_focus(True)
796 del_button = gtk.Button() 834 add_button.grab_focus()
797 del_button.set_image(image) 835 table_layer.attach(add_button, 0, 10, 1, 2, gtk.EXPAND | gtk.FILL, 0, 0, 6)
798 del_button.connect("clicked", self.layer_widget_del_clicked_cb, tree_selection, layer_store)
799 table_layer.attach(del_button, 5, 10, 1, 2, gtk.EXPAND | gtk.FILL, 0, 0, 6)
800 layer_tv.set_model(layer_store) 836 layer_tv.set_model(layer_store)
801 837
802 hbox.show_all() 838 hbox.show_all()
@@ -811,6 +847,11 @@ class LayerSelectionDialog (CrumbsDialog):
811 self.all_layers = all_layers 847 self.all_layers = all_layers
812 self.layers_changed = False 848 self.layers_changed = False
813 849
850 # icon for remove button in TreeView
851 im = gtk.Image()
852 im.set_from_file(hic.ICON_INDI_REMOVE)
853 self.rem_icon = im.get_pixbuf()
854
814 # class members for internal use 855 # class members for internal use
815 self.layer_store = None 856 self.layer_store = None
816 857
@@ -819,24 +860,9 @@ class LayerSelectionDialog (CrumbsDialog):
819 self.connect("response", self.response_cb) 860 self.connect("response", self.response_cb)
820 861
821 def create_visual_elements(self): 862 def create_visual_elements(self):
822 hbox_top = gtk.HBox()
823 self.vbox.pack_start(hbox_top, expand=False, fill=False)
824
825 label = self.gen_label_widget("<b>Select Layers:</b>")
826 hbox_top.pack_start(label, expand=False, fill=False)
827
828 tooltip = "Layer is a collection of bb files and conf files"
829 info = HobInfoButton(tooltip, self)
830 hbox_top.pack_end(info, expand=False, fill=False)
831
832 layer_widget, self.layer_store = self.gen_layer_widget(self.layers, self.all_layers, self, None) 863 layer_widget, self.layer_store = self.gen_layer_widget(self.layers, self.all_layers, self, None)
833 layer_widget.set_size_request(-1, 180) 864 layer_widget.set_size_request(450, 250)
834 self.vbox.pack_start(layer_widget, expand=True, fill=True) 865 self.vbox.pack_start(layer_widget, expand=True, fill=True)
835
836 label = self.gen_label_widget("<b>Note:</b> '<i>meta</i>' is the Core layer for Yocto images please do not remove it.")
837 label.show()
838 self.vbox.pack_end(label, expand=False, fill=False)
839
840 self.show_all() 866 self.show_all()
841 867
842 def response_cb(self, dialog, response_id): 868 def response_cb(self, dialog, response_id):
@@ -850,6 +876,44 @@ class LayerSelectionDialog (CrumbsDialog):
850 self.layers_changed = (self.layers != layers) 876 self.layers_changed = (self.layers != layers)
851 self.layers = layers 877 self.layers = layers
852 878
879 """
880 A custom cell_data_func to draw a delete 'button' in the TreeView for layers
881 other than the meta layer. The deletion of which is prevented so that the
882 user can't shoot themselves in the foot too badly.
883 """
884 def draw_delete_button_cb(self, col, cell, model, it, tv):
885 path = model.get_value(it, 0)
886 # Trailing slashes are uncommon in bblayers.conf but confuse os.path.basename
887 path.rstrip('/')
888 name = os.path.basename(path)
889 if name == "meta":
890 cell.set_sensitive(False)
891 cell.set_property('pixbuf', None)
892 cell.set_property('mode', gtk.CELL_RENDERER_MODE_INERT)
893 else:
894 cell.set_property('pixbuf', self.rem_icon)
895 cell.set_sensitive(True)
896 cell.set_property('mode', gtk.CELL_RENDERER_MODE_ACTIVATABLE)
897
898 return True
899
900 """
901 A custom cell_data_func to write an extra message into the layer path cell
902 for the meta layer. We should inform the user that they can't remove it for
903 their own safety.
904 """
905 def draw_layer_path_cb(self, col, cell, model, it):
906 path = model.get_value(it, 0)
907 name = os.path.basename(path)
908 if name == "meta":
909 cell.set_property('markup', "<b>Core layer for images: it cannot be removed</b>\n%s" % path)
910 else:
911 cell.set_property('text', path)
912
913 def del_cell_clicked_cb(self, cell, path, model):
914 it = model.get_iter_from_string(path)
915 model.remove(it)
916
853class ImageSelectionDialog (CrumbsDialog): 917class ImageSelectionDialog (CrumbsDialog):
854 918
855 __columns__ = [{ 919 __columns__ = [{