From 656f9a07588cc00704825a78de9649ca4a1552b8 Mon Sep 17 00:00:00 2001 From: Dongxiao Xu Date: Mon, 28 Nov 2011 14:32:40 +0800 Subject: Hob: A new implemetation (v2) This commit implements a new design for hob Some of the new features: - Friendly new designed GUI. Quick response to user actions. - Two step builds support package generation and image generation. - Support running GUI seprarately from bitbake server. - Recipe/package selection and deselection. - Accurate customization for image contents and size. - Progress bars showing the parsing and build status. - Load/save user configurations from/into templates. (Bitbake rev: 4dacd29f9c957d20f4583330b51e5420f9c3338d) Signed-off-by: Dongxiao Xu Signed-off-by: Shane Wang Signed-off-by: Liming An Signed-off-by: Fengxia Hua Designed-by: Belen Barros Pena Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/crumbs/recipeselectionpage.py | 221 ++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100755 bitbake/lib/bb/ui/crumbs/recipeselectionpage.py (limited to 'bitbake/lib/bb/ui/crumbs/recipeselectionpage.py') diff --git a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py new file mode 100755 index 0000000000..73b8a1e4ef --- /dev/null +++ b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py @@ -0,0 +1,221 @@ +#!/usr/bin/env python +# +# BitBake Graphical GTK User Interface +# +# Copyright (C) 2012 Intel Corporation +# +# Authored by Dongxiao Xu +# Authored by Shane Wang +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import gtk +import glib +from bb.ui.crumbs.hobcolor import HobColors +from bb.ui.crumbs.hobwidget import HobWidget, HobViewBar, HobViewTable +from bb.ui.crumbs.hoblistmodel import RecipeListModel +from bb.ui.crumbs.hobpages import HobPage + +# +# RecipeSelectionPage +# +class RecipeSelectionPage (HobPage): + pages = [ + { + 'name' : 'Recipe', + 'filter' : { RecipeListModel.COL_TYPE : ['recipe'] }, + 'columns' : [{ + 'col_name' : 'Recipe', + 'col_id' : RecipeListModel.COL_NAME, + 'col_style': 'text', + 'col_min' : 100, + 'col_max' : 400 + }, { + 'col_name' : 'License', + 'col_id' : RecipeListModel.COL_LIC, + 'col_style': 'text', + 'col_min' : 100, + 'col_max' : 400 + }, { + 'col_name' : 'Group', + 'col_id' : RecipeListModel.COL_GROUP, + 'col_style': 'text', + 'col_min' : 100, + 'col_max' : 400 + }, { + 'col_name' : 'Included', + 'col_id' : RecipeListModel.COL_INC, + 'col_style': 'toggle', + 'col_min' : 50, + 'col_max' : 50 + }] + }, { + 'name' : 'Recipe Collection', + 'filter' : { RecipeListModel.COL_TYPE : ['task'] }, + 'columns' : [{ + 'col_name' : 'Recipe Collection', + 'col_id' : RecipeListModel.COL_NAME, + 'col_style': 'text', + 'col_min' : 100, + 'col_max' : 400 + }, { + 'col_name' : 'Description', + 'col_id' : RecipeListModel.COL_DESC, + 'col_style': 'text', + 'col_min' : 100, + 'col_max' : 400 + }, { + 'col_name' : 'Included', + 'col_id' : RecipeListModel.COL_INC, + 'col_style': 'toggle', + 'col_min' : 50, + 'col_max' : 50 + }] + }, { + 'name' : 'Included', + 'filter' : { RecipeListModel.COL_INC : [True], + RecipeListModel.COL_TYPE : ['recipe', 'task'] }, + 'columns' : [{ + 'col_name' : 'Recipe', + 'col_id' : RecipeListModel.COL_NAME, + 'col_style': 'text', + 'col_min' : 100, + 'col_max' : 400 + }, { + 'col_name' : 'Brought by', + 'col_id' : RecipeListModel.COL_BINB, + 'col_style': 'text', + 'col_min' : 100, + 'col_max' : 500 + }, { + 'col_name' : 'Included', + 'col_id' : RecipeListModel.COL_INC, + 'col_style': 'toggle', + 'col_min' : 50, + 'col_max' : 50 + }] + } + ] + + def __init__(self, builder = None): + super(RecipeSelectionPage, self).__init__(builder, "Recipe Selection") + + # set invisiable members + self.recipe_model = self.builder.recipe_model + + # create visual elements + self.create_visual_elements() + + def create_visual_elements(self): + self.label = gtk.Label("Recipes included: %s" % len(self.builder.configuration.selected_recipes)) + self.eventbox = self.add_onto_top_bar(self.label, 73) + self.pack_start(self.eventbox, expand=False, fill=False) + self.pack_start(self.group_align, expand=True, fill=True) + + # set visiable members + self.grid = gtk.Table(10, 1, True) + self.grid.set_col_spacings(3) + + # draw the left part of the window + # a notebook + self.ins = gtk.Notebook() + self.ins.set_show_tabs(False) + self.tables = [] # we need modify table when the dialog is shown + # append the tabs in order + for i in range(len(self.pages)): + columns = self.pages[i]['columns'] + tab = HobViewTable(columns, self.reset_clicked_cb, self.table_toggled_cb) + filter = self.pages[i]['filter'] + tab.table_tree.set_model(self.recipe_model.tree_model(filter)) + label = gtk.Label(self.pages[i]['name']) + self.ins.append_page(tab, label) + self.tables.append(tab) + + self.grid.attach(self.ins, 0, 1, 1, 10, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND) + # a black bar associated with the notebook + self.topbar = HobViewBar(self.ins) + self.grid.attach(self.topbar, 0, 1, 0, 1, gtk.FILL | gtk.EXPAND, gtk.FILL | gtk.EXPAND) + # set the search entry for each table + for tab in self.tables: + tab.table_tree.set_search_entry(self.topbar.search) + + inctab_tree_view = self.tables[len(self.pages)-1].table_tree + inctab_tree_selection = inctab_tree_view.get_selection() + inctab_tree_selection.connect("changed", self.tree_selection_cb, inctab_tree_view) + + # add all into the window + self.box_group_area.add(self.grid) + + button_box = gtk.HBox(False, 5) + self.box_group_area.pack_end(button_box, expand=False, fill=False) + + self.build_packages_button = gtk.Button() + label = gtk.Label() + mark = "Build packages" % self.span_tag('24px', 'bold') + label.set_markup(mark) + self.build_packages_button.set_image(label) + self.build_packages_button.set_size_request(205, 49) + self.build_packages_button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(HobColors.ORANGE)) + self.build_packages_button.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(HobColors.ORANGE)) + self.build_packages_button.modify_bg(gtk.STATE_SELECTED, gtk.gdk.Color(HobColors.ORANGE)) + self.build_packages_button.set_tooltip_text("Build packages for customization") + self.build_packages_button.set_flags(gtk.CAN_DEFAULT) + self.build_packages_button.grab_default() + self.build_packages_button.connect("clicked", self.build_packages_clicked_cb) + button_box.pack_end(self.build_packages_button, expand=False, fill=False) + + self.back_button = gtk.LinkButton("Go back to Image Configuration screen", "<< Back to image configuration") + self.back_button.connect("clicked", self.back_button_clicked_cb) + button_box.pack_start(self.back_button, expand=False, fill=False) + + def tree_selection_cb(self, tree_selection, tree_view): + tree_model = tree_view.get_model() + path, column = tree_view.get_cursor() + if not path or column == tree_view.get_column(2): + return + + it = tree_model.get_iter(path) + binb = tree_model.get_value(it, RecipeListModel.COL_BINB) + if binb: + self.builder.show_binb_dialog(binb) + + def build_packages_clicked_cb(self, button): + self.builder.build_packages() + + def back_button_clicked_cb(self, button): + self.builder.show_configuration() + + def refresh_selection(self): + self.builder.configuration.selected_image = self.recipe_model.get_selected_image() + _, self.builder.configuration.selected_recipes = self.recipe_model.get_selected_recipes() + self.label.set_text("Recipes included: %s" % len(self.builder.configuration.selected_recipes)) + + # Callback functions + def reset_clicked_cb(self, button): + self.builder.reset_recipe_model() + + def toggle_item_idle_cb(self, path): + if not self.recipe_model.path_included(path): + self.recipe_model.include_item(item_path=path, binb="User Selected", image_contents=False) + else: + self.recipe_model.exclude_item(item_path=path) + + self.builder.window_sensitive(True) + + def table_toggled_cb(self, cell, view_path, view_tree): + # Click to include a recipe + self.builder.window_sensitive(False) + view_model = view_tree.get_model() + path = self.recipe_model.convert_vpath_to_path(view_model, view_path) + glib.idle_add(self.toggle_item_idle_cb, path) -- cgit v1.2.3-54-g00ecf